Ver Fonte

Fixed BufferGeometry example

Casey Grun há 10 anos atrás
pai
commit
447de7e62c
2 ficheiros alterados com 16 adições e 17 exclusões
  1. 1 5
      docs/api/core/BufferAttribute.html
  2. 15 12
      docs/api/core/BufferGeometry.html

+ 1 - 5
docs/api/core/BufferAttribute.html

@@ -10,13 +10,9 @@
 		<h1>[name]</h1>
 
 		<div class="desc">
-		This class stores data for an attribute associated with a [page:BufferGeometry]. See that page for details. This class is used to store builtin attributes such as vertex position, normals, color, etc., but can also be used in your code to store custom attributes in a [page:BufferGeometry].
+		This class stores data for an attribute associated with a [page:BufferGeometry]. See that page for details and a usage example. This class is used to store builtin attributes such as vertex position, normals, color, etc., but can also be used in your code to store custom attributes in a [page:BufferGeometry].
 		</div>
 
-		<h2>Example</h2>
-
-		<code>todo</code>
-
 		<h2>Constructor</h2>
 		<h3>[name]([page:Array array], [page:Integer itemSize])</h3>
 		<div>

+ 15 - 12
docs/api/core/BufferGeometry.html

@@ -24,30 +24,33 @@
 		<h3>Example</h3>
 		<code>
 		var geometry = new THREE.BufferGeometry();
-
 		// create a simple square shape. We duplicate the top left and bottom right
 		// vertices because each vertex needs to appear once per triangle. 
-		var vertexCount = 6;
-		var vertices = new Float32Array( vertexCount * 3 ); // three components per vertex
-		var vertexPositions = [ [-1, 1, 0], [1, 1, 0], [1, -1, 0], 
-								[-1, 1, 0], [1,-1, 0], [-1,-1, 0] ];
-		
+		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]
+		];
+		var vertices = new Float32Array( vertexPositions.length * 3 ); // three components per vertex
+
 		// components of the position vector for each vertex are stored
 		// contiguously in the buffer.
-		for ( var i = 0; i < vertexPosition.length; i++ )
+		for ( var i = 0; i < vertexPositions.length; i++ )
 		{
-			vertices[ i + 0 ] = vertexPositions[i][0];
-			vertices[ i + 1 ] = vertexPositions[i][1];
-			vertices[ i + 2 ] = vertexPositions[i][2];
+			vertices[ i*3 + 0 ] = vertexPositions[i][0];
+			vertices[ i*3 + 1 ] = vertexPositions[i][1];
+			vertices[ i*3 + 2 ] = vertexPositions[i][2];
 		}
 
 		// itemSize = 3 because there are 3 values (components) per vertex
 		geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
-
 		var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
 		var mesh = new THREE.Mesh( geometry, material );
 		</code>
-		View the source of the fromGeometry method for 
 
 		<h3>Accessing attributes</h3>
 		<p>