You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
6.1 KiB
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Mesh] &rarr;
<h1>实例化网格([name]</h1>
<p class="desc">
一种具有实例化渲染支持的特殊版本的[page:Mesh]。你可以使用 [name] 来渲染大量具有相同几何体与材质、但具有不同世界变换的物体。
使用 [name] 将帮助你减少 draw call 的数量,从而提升你应用程序的整体渲染性能。
</p>
<h2>示例</h2>
<p>
[example:webgl_instancing_dynamic WebGL / instancing / dynamic]<br />
[example:webgl_instancing_performance WebGL / instancing / performance]<br />
[example:webgl_instancing_scatter WebGL / instancing / scatter]<br />
[example:webgl_instancing_raycast WebGL / instancing / raycast]
</p>
<h2>构造函数</h2>
<h3>[name]( [param:BufferGeometry geometry], [param:Material material], [param:Integer count] )</h3>
<p>
[page:BufferGeometry geometry] - 一个 [page:BufferGeometry] 的实例。<br />
[page:Material material] - 一个 [page:Material] 的实例。默认为一个新的 [page:MeshBasicMaterial] 。<br />
[page:Integer count] - 实例的数量<br />
</p>
<h2>属性</h2>
<p>公共属性请查看基类 [page:Mesh]。</p>
<h3>[property:Box3 boundingBox]</h3>
<p>
当前 [name] 的外边界矩形。可以通过 [page:.computeBoundingBox]() 计算。默认值是 *null*。
</p>
<h3>[property:Sphere boundingSphere]</h3>
<p>
当前 [name] 的外边界球形。可以通过 [page:.computeBoundingSphere]() 计算。默认值是 *null*。
</p>
<h3>[property:Integer count]</h3>
<p>
实例的数量。被传入到构造函数中的*count*表示mesh实例数量的最大值。
你可以在运行时改变这个数值到 [0, count] 区间的一个整数。
</p>
<p>
如果你需要比原先的数量更多的实例数量,你需要创建一个新的[name]。
</p>
<h3>[property:InstancedBufferAttribute instanceColor]</h3>
<p>
代表所有实例的颜色。默认情况下*null*。
如果通过[page:.setColorAt]()修改实例化数据,则必须将它的[page:BufferAttribute.needsUpdate needsUpdate]标志设置为 true。
</p>
<h3>[property:InstancedBufferAttribute instanceMatrix]</h3>
<p>
表示所有实例的本地变换。
如果你要通过 [page:.setMatrixAt]() 来修改实例数据,你必须将它的 [page:BufferAttribute.needsUpdate needsUpdate] 标识为 true 。
</p>
<h3>[property:DataTexture morphTexture]</h3>
<p>
用于表示所有实例的变形权重。如果你通过 [page:.setMorphAt]() 修改了实例数据,你必须将 [page:Texture.needsUpdate needsUpdate] 标识设置为 true。
</p>
<h3>[property:Boolean isInstancedMesh]</h3>
<p>
用来检查对象是否属于 [name] 类型的只读标识。
</p>
<h2>方法</h2>
<p>公共方法请查看基类 [page:Mesh]。</p>
<h3>[method:undefined computeBoundingBox]()</h3>
<p>
计算当前几何体的的边界矩形,该操作会更新已有 [param:.boundingBox]。<br />
边界矩形不会默认计算,需要调用该接口指定计算边界矩形,否则保持默认值 *null*。
</p>
<h3>[method:undefined computeBoundingSphere]()</h3>
<p>
计算当前几何体的的边界球形,该操作会更新已有 [param:.boundingSphere]。<br />
边界球形不会默认计算,需要调用该接口指定计算边界球形,否则保持默认值 *null*。
</p>
<h3>[method:undefined dispose]()</h3>
<p>
释放实例的内部资源。
</p>
<h3>[method:undefined getColorAt]( [param:Integer index], [param:Color color] )</h3>
<p>
[page:Integer index]: 实例的索引。 值必须在 [0, count] 区间。
</p>
<p>
[page:Color color]: 传入的颜色对象将会被设置为指定的实例的颜色。
</p>
<p>
获取已定义实例的颜色。
</p>
<h3>[method:undefined getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
<p>
[page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
</p>
<p>
[page:Matrix4 matrix]: 该4x4矩阵将会被设为已定义实例的本地变换矩阵。
</p>
<p>
获得已定义实例的本地变换矩阵。
</p>
<h3>
[method:undefined getMorphAt]( [param:Integer index], [param:Mesh mesh] )
</h3>
<p>
[page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
</p>
<p>
[page:Mesh mesh]: 网格属性 [page:Mesh.morphTargetInfluences .morphTargetInfluences] 将会被填充为已定义实例的变形权重。
</p>
<p>获取已定义实例的变形权重</p>
<h3>[method:undefined setColorAt]( [param:Integer index], [param:Color color] )</h3>
<p>
[page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
</p>
<p>
[page:Color color]: 单个实例的颜色。
</p>
<p>
设置已定义实例的颜色。请确保在更新颜色后将 [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate] 标识设置为 true。
</p>
<h3>[method:undefined setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
<p>
[page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
</p>
<p>
[page:Matrix4 matrix]: 一个4x4矩阵表示单个实例本地变换。
</p>
<p>
设置给定的本地变换矩阵到已定义的实例。
请确保在更新所有矩阵后将 [page:.instanceMatrix][page:BufferAttribute.needsUpdate .needsUpdate] 设置为true。
</p>
<h3>
[method:undefined setMorphAt]( [param:Integer index], [param:Mesh mesh] )
</h3>
<p>
[page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
</p>
<p>
[page:Mesh mesh]: 网格属性 [page:Mesh.morphTargetInfluences .morphTargetInfluences] 包含了单个实例的变形权重。
</p>
<p>
设置已定义实例的变形权重。请确保在更新所有变形数据后将 [page:.morphTexture][page:Texture.needsUpdate .needsUpdate] 设置为 true。
</p>
<h2>源代码</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</p>
</body>
</html>