|
@@ -1,10 +1,11 @@
|
|
<!DOCTYPE html>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<html lang="en">
|
|
<head>
|
|
<head>
|
|
- <meta charset="utf-8" />
|
|
|
|
- <script src="../../list.js"></script>
|
|
|
|
- <script src="../../page.js"></script>
|
|
|
|
- <link type="text/css" rel="stylesheet" href="../../page.css" />
|
|
|
|
|
|
+ <meta charset="utf-8" />
|
|
|
|
+ <base href="../../" />
|
|
|
|
+ <script src="list.js"></script>
|
|
|
|
+ <script src="page.js"></script>
|
|
|
|
+ <link type="text/css" rel="stylesheet" href="page.css" />
|
|
</head>
|
|
</head>
|
|
<body>
|
|
<body>
|
|
<h1>[name]</h1>
|
|
<h1>[name]</h1>
|
|
@@ -13,10 +14,10 @@
|
|
<p>
|
|
<p>
|
|
This class is an efficient alternative to [page:Geometry], because it stores all data, including
|
|
This class is an efficient alternative to [page:Geometry], because it stores all data, including
|
|
vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers; this
|
|
vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers; this
|
|
- reduces the cost of passing all this data to the GPU.
|
|
|
|
- This also makes BufferGeometry harder to work with than [page:Geometry]; rather than accessing
|
|
|
|
- position data as [page:Vector3] objects, color data as [page:Color] objects, and so on, you have to
|
|
|
|
- access the raw data from the appropriate [page:BufferAttribute attribute] buffer. This makes
|
|
|
|
|
|
+ reduces the cost of passing all this data to the GPU.
|
|
|
|
+ This also makes BufferGeometry harder to work with than [page:Geometry]; rather than accessing
|
|
|
|
+ position data as [page:Vector3] objects, color data as [page:Color] objects, and so on, you have to
|
|
|
|
+ access the raw data from the appropriate [page:BufferAttribute attribute] buffer. This makes
|
|
BufferGeometry best-suited for static objects where you don't need to manipulate the geometry much
|
|
BufferGeometry best-suited for static objects where you don't need to manipulate the geometry much
|
|
after instantiating it.
|
|
after instantiating it.
|
|
</p>
|
|
</p>
|
|
@@ -25,8 +26,8 @@
|
|
<code>
|
|
<code>
|
|
var geometry = new THREE.BufferGeometry();
|
|
var geometry = new THREE.BufferGeometry();
|
|
// create a simple square shape. We duplicate the top left and bottom right
|
|
// create a simple square shape. We duplicate the top left and bottom right
|
|
- // vertices because each vertex needs to appear once per triangle.
|
|
|
|
- var vertexPositions = [
|
|
|
|
|
|
+ // vertices because each vertex needs to appear once per triangle.
|
|
|
|
+ var vertexPositions = [
|
|
[-1.0, -1.0, 1.0],
|
|
[-1.0, -1.0, 1.0],
|
|
[ 1.0, -1.0, 1.0],
|
|
[ 1.0, -1.0, 1.0],
|
|
[ 1.0, 1.0, 1.0],
|
|
[ 1.0, 1.0, 1.0],
|
|
@@ -53,17 +54,17 @@
|
|
</code>
|
|
</code>
|
|
<p>More examples: [example:webgl_buffergeometry Complex mesh with non-indexed faces], [example:webgl_buffergeometry_uint Complex mesh with indexed faces], [example:webgl_buffergeometry_lines Lines], [example:webgl_buffergeometry_lines_indexed Indexed Lines], [example:webgl_buffergeometry_particles Particles], and [example:webgl_buffergeometry_rawshader Raw Shaders].</p>
|
|
<p>More examples: [example:webgl_buffergeometry Complex mesh with non-indexed faces], [example:webgl_buffergeometry_uint Complex mesh with indexed faces], [example:webgl_buffergeometry_lines Lines], [example:webgl_buffergeometry_lines_indexed Indexed Lines], [example:webgl_buffergeometry_particles Particles], and [example:webgl_buffergeometry_rawshader Raw Shaders].</p>
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
<h3>Accessing attributes</h3>
|
|
<h3>Accessing attributes</h3>
|
|
<p>
|
|
<p>
|
|
- WebGL stores data associated with individual vertices of a geometry in <emph>attributes</emph>.
|
|
|
|
|
|
+ WebGL stores data associated with individual vertices of a geometry in <emph>attributes</emph>.
|
|
Examples include the position of the vertex, the normal vector for the vertex, the vertex color,
|
|
Examples include the position of the vertex, the normal vector for the vertex, the vertex color,
|
|
and so on. When using [page:Geometry], the [page:WebGLRenderer renderer] takes care of wrapping
|
|
and so on. When using [page:Geometry], the [page:WebGLRenderer renderer] takes care of wrapping
|
|
- up this information into typed array buffers and sending this data to the shader. With
|
|
|
|
|
|
+ up this information into typed array buffers and sending this data to the shader. With
|
|
BufferGeometry, all of this data is stored in buffers associated with an individual attributes.
|
|
BufferGeometry, all of this data is stored in buffers associated with an individual attributes.
|
|
This means that to get the position data associated with a vertex (for instance), you must call
|
|
This means that to get the position data associated with a vertex (for instance), you must call
|
|
- [page:.getAttribute] to access the 'position' [page:BufferAttribute attribute], then access the individual
|
|
|
|
- x, y, and z coordinates of the position.
|
|
|
|
|
|
+ [page:.getAttribute] to access the 'position' [page:BufferAttribute attribute], then access the individual
|
|
|
|
+ x, y, and z coordinates of the position.
|
|
</p>
|
|
</p>
|
|
<p>
|
|
<p>
|
|
The following attributes are set by various members of this class:
|
|
The following attributes are set by various members of this class:
|
|
@@ -96,7 +97,7 @@
|
|
If this attribute is not set, the [page:WebGLRenderer renderer] assumes that each three contiguous positions represent a single triangle.
|
|
If this attribute is not set, the [page:WebGLRenderer renderer] assumes that each three contiguous positions represent a single triangle.
|
|
</div>
|
|
</div>
|
|
<p>
|
|
<p>
|
|
- In addition to the the built-in attributes, you can set your own custom attributes using the addAttribute method. With [page:Geometry], these attributes are set and stored on the [page:Material]. In BufferGeometry, the attributes are stored with the geometry itself. Note that you still need to set the attributes information on the material as well, but the value of each attribute is stored in the BufferGeometry.
|
|
|
|
|
|
+ In addition to the the built-in attributes, you can set your own custom attributes using the addAttribute method. With [page:Geometry], these attributes are set and stored on the [page:Material]. In BufferGeometry, the attributes are stored with the geometry itself. Note that you still need to set the attributes information on the material as well, but the value of each attribute is stored in the BufferGeometry.
|
|
</p>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
@@ -115,22 +116,22 @@
|
|
<div>
|
|
<div>
|
|
Unique number for this buffergeometry instance.
|
|
Unique number for this buffergeometry instance.
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
|
|
+
|
|
<h3>[property:Hashmap attributes]</h3>
|
|
<h3>[property:Hashmap attributes]</h3>
|
|
<div>
|
|
<div>
|
|
This hashmap has as id the name of the attribute to be set and as value the [page:BufferAttribute buffer] to set it to.
|
|
This hashmap has as id the name of the attribute to be set and as value the [page:BufferAttribute buffer] to set it to.
|
|
Rather than accessing this property directly, use addAttribute and getAttribute to access attributes of this geometry.
|
|
Rather than accessing this property directly, use addAttribute and getAttribute to access attributes of this geometry.
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
|
|
+
|
|
<!--
|
|
<!--
|
|
<h3>[property:Boolean dynamic]</h3>
|
|
<h3>[property:Boolean dynamic]</h3>
|
|
<div>
|
|
<div>
|
|
When set, it holds certain buffers in memory to have faster updates for this object. When unset, it deletes those buffers and saves memory.
|
|
When set, it holds certain buffers in memory to have faster updates for this object. When unset, it deletes those buffers and saves memory.
|
|
</div> -->
|
|
</div> -->
|
|
-
|
|
|
|
|
|
+
|
|
<h3>[property:Array drawCalls] (previously [property:Array offsets])</h3>
|
|
<h3>[property:Array drawCalls] (previously [property:Array offsets])</h3>
|
|
<div>
|
|
<div>
|
|
- For geometries that use indexed triangles, this Array can be used to split the object into multiple WebGL draw calls. Each draw call will draw some subset of the vertices in this geometry using the configured [page:Material shader]. This may be necessary if, for instance, you have more than 65535 vertices in your object.
|
|
|
|
|
|
+ For geometries that use indexed triangles, this Array can be used to split the object into multiple WebGL draw calls. Each draw call will draw some subset of the vertices in this geometry using the configured [page:Material shader]. This may be necessary if, for instance, you have more than 65535 vertices in your object.
|
|
Each element is an object of the form:
|
|
Each element is an object of the form:
|
|
<code>{ start: Integer, count: Integer, index: Integer }</code>
|
|
<code>{ start: Integer, count: Integer, index: Integer }</code>
|
|
where start specifies the index of the first vertex in this draw call, count specifies how many vertices are included, and index specifies an optional offset.
|
|
where start specifies the index of the first vertex in this draw call, count specifies how many vertices are included, and index specifies an optional offset.
|
|
@@ -149,7 +150,7 @@
|
|
Bounding sphere.
|
|
Bounding sphere.
|
|
<code>{ radius: float }</code>
|
|
<code>{ radius: float }</code>
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
|
|
+
|
|
<h3>[property:Array morphTargets]</h3>
|
|
<h3>[property:Array morphTargets]</h3>
|
|
<div>
|
|
<div>
|
|
Array of morph targets. Each morph target is a Javascript object:
|
|
Array of morph targets. Each morph target is a Javascript object:
|
|
@@ -160,15 +161,15 @@
|
|
<h3>[property:boolean hasTangents]</h3>
|
|
<h3>[property:boolean hasTangents]</h3>
|
|
<div>
|
|
<div>
|
|
True if BufferGeometry has tangents. Set in [page:.computeTangents].
|
|
True if BufferGeometry has tangents. Set in [page:.computeTangents].
|
|
- </div>
|
|
|
|
|
|
+ </div>
|
|
|
|
|
|
<h2>Methods</h2>
|
|
<h2>Methods</h2>
|
|
|
|
|
|
<h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
|
|
<h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
|
|
-
|
|
|
|
|
|
+
|
|
<h3>[property:null addAttribute]( [page:String name], [page:BufferAttribute attribute] )</h3>
|
|
<h3>[property:null addAttribute]( [page:String name], [page:BufferAttribute attribute] )</h3>
|
|
<div>
|
|
<div>
|
|
- Adds an attribute to this geometry. Use this rather than the attributes property,
|
|
|
|
|
|
+ Adds an attribute to this geometry. Use this rather than the attributes property,
|
|
because an internal array of attributes is maintained to speed up iterating over
|
|
because an internal array of attributes is maintained to speed up iterating over
|
|
attributes.
|
|
attributes.
|
|
</div>
|
|
</div>
|
|
@@ -207,7 +208,7 @@
|
|
Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.<br />
|
|
Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.<br />
|
|
Bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are *null*.
|
|
Bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are *null*.
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
|
|
+
|
|
<h3>[method:null dispose]()</h3>
|
|
<h3>[method:null dispose]()</h3>
|
|
<div>
|
|
<div>
|
|
Disposes the object from memory. <br />
|
|
Disposes the object from memory. <br />
|