Skip to content

Commit 22d20b6

Browse files
gkjohnsonMugen87
andauthored
BatchedMesh: Add documentation (#27175)
* Add docs * Add more docs * Add page to docs * Add more docs * Update * Add note for extension requirement * Update list.json Ensure alphabetical order in side menu. --------- Co-authored-by: Michael Herzog <[email protected]>
1 parent d5678cd commit 22d20b6

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<base href="../../../" />
6+
<script src="page.js"></script>
7+
<link type="text/css" rel="stylesheet" href="page.css" />
8+
</head>
9+
<body>
10+
[page:Mesh] &rarr;
11+
12+
<h1>[name]</h1>
13+
14+
<p class="desc">
15+
A special version of [page:Mesh] with multi draw batch rendering support. Use
16+
[name] if you have to render a large number of objects with the same
17+
material but with different world transformations and geometry. The usage
18+
of [name] will help you to reduce the number of draw calls and thus
19+
improve the overall rendering performance in your application.
20+
21+
<br/>
22+
<br/>
23+
24+
Requires platform support for the [link:https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_multi_draw WEBGL_multi_draw extension].
25+
</p>
26+
27+
<h2>Examples</h2>
28+
<p>
29+
[example:webgl_mesh_batch WebGL / mesh / batch]<br />
30+
</p>
31+
32+
<h2>Constructor</h2>
33+
<h3>
34+
[name](
35+
[param:Integer maxGeometryCount], [param:Integer maxVertexCount],
36+
[param:Integer maxIndexCount], [param:Material material],
37+
)
38+
</h3>
39+
<p>
40+
[page:Integer maxGeometryCount] - the max number of individual geometries planned to be added.<br />
41+
[page:Integer maxVertexCount] - the max number of vertices to be used by all geometries.<br />
42+
[page:Integer maxIndexCount] - the max number of indices to be used by all geometries.<br />
43+
[page:Material material] - an instance of [page:Material]. Default is a
44+
new [page:MeshBasicMaterial].<br />
45+
[page:Integer count] - the number of instances.<br />
46+
</p>
47+
48+
<h2>Properties</h2>
49+
<p>See the base [page:Mesh] class for common properties.</p>
50+
51+
<h3>[property:Box3 boundingBox]</h3>
52+
<p>
53+
This bounding box encloses all instances of the [name]. Can be calculated
54+
with [page:.computeBoundingBox](). Default is `null`.
55+
</p>
56+
57+
<h3>[property:Sphere boundingSphere]</h3>
58+
<p>
59+
This bounding sphere encloses all instances of the [name]. Can be
60+
calculated with [page:.computeBoundingSphere](). Default is `null`.
61+
</p>
62+
63+
<h3>[property:Boolean perObjectFrustumCulled]</h3>
64+
<p>
65+
If true then the individual objects within the [name] are frustum culled. Default is `true`.
66+
</p>
67+
68+
<h3>[property:Boolean sortObjects]</h3>
69+
<p>
70+
If true then the individual objects within the [name] are sorted to improve overdraw-related artifacts.
71+
If the material is marked as "transparent" objects are rendered back to front and if not then they are
72+
rendered front to back. Default is `true`.
73+
</p>
74+
75+
<h3>[property:Boolean isBatchedMesh]</h3>
76+
<p>Read-only flag to check if a given object is of type [name].</p>
77+
78+
<h2>Methods</h2>
79+
<p>See the base [page:Mesh] class for common methods.</p>
80+
81+
<h3>[method:undefined computeBoundingBox]()</h3>
82+
<p>
83+
Computes the bounding box, updating [page:.boundingBox] attribute.<br />
84+
Bounding boxes aren't computed by default. They need to be explicitly
85+
computed, otherwise they are `null`.
86+
</p>
87+
88+
<h3>[method:undefined computeBoundingSphere]()</h3>
89+
<p>
90+
Computes the bounding sphere, updating [page:.boundingSphere]
91+
attribute.<br />
92+
Bounding spheres aren't computed by default. They need to be explicitly
93+
computed, otherwise they are `null`.
94+
</p>
95+
96+
<h3>[method:undefined dispose]()</h3>
97+
<p>
98+
Frees the GPU-related resources allocated by this instance. Call this
99+
method whenever this instance is no longer used in your app.
100+
</p>
101+
102+
<h3>
103+
[method:Matrix4 getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
104+
</h3>
105+
<p>
106+
[page:Integer index]: The index of an instance. Values have to be in the
107+
range [0, count].
108+
</p>
109+
<p>
110+
[page:Matrix4 matrix]: This 4x4 matrix will be set to the local
111+
transformation matrix of the defined instance.
112+
</p>
113+
<p>Get the local transformation matrix of the defined instance.</p>
114+
115+
<h3>
116+
[method:Boolean getVisibleAt]( [param:Integer index] )
117+
</h3>
118+
<p>
119+
[page:Integer index]: The index of an instance. Values have to be in the
120+
range [0, count].
121+
</p>
122+
<p>Get whether the given instance is marked as "visible" or not.</p>
123+
124+
<h3>
125+
[method:this setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
126+
</h3>
127+
<p>
128+
[page:Integer index]: The index of an instance. Values have to be in the
129+
range [0, count].
130+
</p>
131+
<p>
132+
[page:Matrix4 matrix]: A 4x4 matrix representing the local transformation
133+
of a single instance.
134+
</p>
135+
<p>
136+
Sets the given local transformation matrix to the defined instance. Make
137+
sure you set [page:.instanceMatrix][page:BufferAttribute.needsUpdate .needsUpdate]
138+
to true after updating all the matrices.
139+
</p>
140+
141+
<h3>
142+
[method:this setVisibleAt]( [param:Integer index], [param:Boolean visible] )
143+
</h3>
144+
<p>
145+
[page:Integer index]: The index of an instance. Values have to be in the
146+
range [0, count].
147+
</p>
148+
<p>
149+
[page:Boolean visible]: A boolean value indicating the visibility state.
150+
</p>
151+
<p>
152+
Sets the visibility of the object at the given index.
153+
</p>
154+
155+
<h3>
156+
[method:Integer addGeometry]( [param:BufferGeometry geometry], [param:Integer reservedVertexRange], [param:Integer reservedIndexRange] )
157+
</h3>
158+
<p>
159+
[page:BufferGeometry index]: The geometry to add into the [name].
160+
</p>
161+
<p>
162+
[page:Integer reservedVertexRange]: Optional parameter specifying the amount of vertex buffer space to reserve for the added geometry. This
163+
is necessary if it is planned to set a new geometry at this index at a later time that is larger than the original geometry. Defaults to
164+
the length of the given geometry vertex buffer.
165+
</p>
166+
<p>
167+
[page:Integer reservedIndexRange]: Optional parameter specifying the amount of index buffer space to reserve for the added geometry. This
168+
is necessary if it is planned to set a new geometry at this index at a later time that is larger than the original geometry. Defaults to
169+
the length of the given geometry index buffer.
170+
</p>
171+
<p>
172+
Adds the given geometry to the [name] and returns the associated index referring to it.
173+
</p>
174+
175+
<h3>
176+
[method:Integer setGeometryAt]( [param:Integer index], [param:BufferGeometry geometry] )
177+
</h3>
178+
<p>
179+
[page:Integer index]: Which geometry index to replace with this geometry.
180+
</p>
181+
<p>
182+
[page:BufferGeometry geometry]: The geometry to substitute at the given geometry index.
183+
</p>
184+
<p>
185+
Replaces the geometry at `index` with the provided geometry. Throws an error if there is not enough space reserved for geometry at the index.
186+
</p>
187+
188+
<h3>
189+
[method:this deleteGeometry]( [param:Integer index] )
190+
</h3>
191+
<p>
192+
Marks the geometry at the given index as deleted and to not be rendered anymore.
193+
</p>
194+
195+
<h2>Source</h2>
196+
197+
<p>
198+
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
199+
</p>
200+
</body>
201+
</html>

docs/list.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@
262262
},
263263

264264
"Objects": {
265+
"BatchedMesh": "api/en/objects/BatchedMesh",
265266
"Bone": "api/en/objects/Bone",
266267
"Group": "api/en/objects/Group",
267268
"InstancedMesh": "api/en/objects/InstancedMesh",

0 commit comments

Comments
 (0)