소스 검색

BufferGeometryManipulator maybe? See #4386.

Mr.doob 11 년 전
부모
커밋
9858c27eaf
4개의 변경된 파일27개의 추가작업 그리고 31개의 파일을 삭제
  1. 4 2
      examples/canvas_geometry_terrain.html
  2. 22 0
      src/core/BufferGeometryManipulator.js
  3. 0 28
      src/core/Geometry2.js
  4. 1 1
      utils/build/includes/common.json

+ 4 - 2
examples/canvas_geometry_terrain.html

@@ -75,10 +75,12 @@
 				var plane = new THREE.PlaneGeometry( 2000, 2000, quality - 1, quality - 1 );
 				plane.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) );
 
-				for ( var i = 0, l = plane.vertices.length; i < l; i ++ ) {
+				var manipulator = new THREE.BufferGeometryManipulator( plane );
+
+				for ( var i = 0, l = manipulator.vertices.length; i < l; i ++ ) {
 
 					var x = i % quality, y = Math.floor( i / quality );
-					plane.vertices[ i ].y = data[ ( x * step ) + ( y * step ) * 1024 ] * 2 - 128;
+					manipulator.vertices[ i ].y = data[ ( x * step ) + ( y * step ) * 1024 ] * 2 - 128;
 
 				}
 

+ 22 - 0
src/core/BufferGeometryManipulator.js

@@ -0,0 +1,22 @@
+/**
+ * @author mrdoob / http://mrdoob.com/
+ */
+
+THREE.BufferGeometryManipulator = function ( bufferGeometry ) {
+
+	this.vertices = [];
+	this.normals = [];
+	this.uvs = [];
+
+	var attributes = bufferGeometry.attributes;
+	var length = attributes.position.array.length;
+
+	for ( var i = 0, l = length / 3; i < l; i ++ ) {
+
+		this.vertices.push( new THREE.TypedVector3( attributes.position.array, i * 3 ) );
+		this.normals.push( new THREE.TypedVector3( attributes.normal.array, i * 3 ) );
+		this.uvs.push( new THREE.TypedVector2( attributes.uv.array, i * 2 ) );
+
+	}
+
+};

+ 0 - 28
src/core/Geometry2.js

@@ -1,28 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.Geometry2 = function ( bufferGeometry ) {
-
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
-
-	var attributes = bufferGeometry.attributes;
-	var length = attributes.position.array.length;
-
-	for ( var i = 0, l = length / 3; i < l; i ++ ) {
-
-		vertices.push( new THREE.TypedVector3( attributes.position.array, i * 3 ) );
-		normals.push( new THREE.TypedVector3( attributes.normal.array, i * 3 ) );
-		uvs.push( new THREE.TypedVector2( attributes.uv.array, i * 2 ) );
-
-	}
-
-	bufferGeometry.vertices = vertices;
-	bufferGeometry.normals = normals;
-	bufferGeometry.uvs = uvs;
-
-	return bufferGeometry;
-
-};

+ 1 - 1
utils/build/includes/common.json

@@ -31,8 +31,8 @@
 	"src/core/Face4.js",
 	"src/core/BufferAttribute.js",
 	"src/core/BufferGeometry.js",
+	"src/core/BufferGeometryManipulator.js",
 	"src/core/Geometry.js",
-	"src/core/Geometry2.js",
 	"src/cameras/Camera.js",
 	"src/cameras/OrthographicCamera.js",
 	"src/cameras/PerspectiveCamera.js",