diff --git a/src/core/Geometry2.js b/src/core/Geometry2.js new file mode 100644 index 0000000000000000000000000000000000000000..47d433e77c105d386e521630374572b38e21f780 --- /dev/null +++ b/src/core/Geometry2.js @@ -0,0 +1,28 @@ +/** + * @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; + +}; \ No newline at end of file diff --git a/src/extras/geometries/PlaneGeometry.js b/src/extras/geometries/PlaneGeometry.js index 869becbd68f8347f38b8b89574423b7c38ac6f22..da76183d8d632492bf9ade6b656a9cbb5e2a32b2 100644 --- a/src/extras/geometries/PlaneGeometry.js +++ b/src/extras/geometries/PlaneGeometry.js @@ -1,26 +1,9 @@ /** * @author mrdoob / http://mrdoob.com/ - * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as */ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) { - THREE.PlaneBufferGeometry.call( this, width, height, widthSegments, heightSegments ); - - var length = this.attributes.position.array.length; - - this.vertices = []; - this.normals = []; - this.uvs = []; - - for ( var i = 0, l = length / 3; i < l; i ++ ) { - - this.vertices.push( new THREE.TypedVector3( this.attributes.position.array, i * 3 ) ); - this.normals.push( new THREE.TypedVector3( this.attributes.normal.array, i * 3 ) ); - this.uvs.push( new THREE.TypedVector2( this.attributes.uv.array, i * 2 ) ); - - } + return new THREE.Geometry2( new THREE.PlaneBufferGeometry( width, height, widthSegments, heightSegments ) ); }; - -THREE.PlaneGeometry.prototype = Object.create( THREE.PlaneBufferGeometry.prototype ); diff --git a/utils/build/includes/common.json b/utils/build/includes/common.json index 6fba8af21f6b29669b462f9c306a1a707d2104fb..ea39e7f481c0f39bc697bb11f09865c3f95bbbbc 100644 --- a/utils/build/includes/common.json +++ b/utils/build/includes/common.json @@ -32,6 +32,7 @@ "src/core/BufferAttribute.js", "src/core/BufferGeometry.js", "src/core/Geometry.js", + "src/core/Geometry2.js", "src/cameras/Camera.js", "src/cameras/OrthographicCamera.js", "src/cameras/PerspectiveCamera.js",