From aaca0a8ad66260b8bc378322c36b829a4bc063e6 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Tue, 8 Apr 2014 15:25:31 -0600 Subject: [PATCH] Made Geometry2/IndexedGeometry2 more user friendly. Starting to consider implementing geometry.bufferGeometry... --- src/core/Geometry2.js | 16 ++++++++++------ src/core/IndexedGeometry2.js | 5 +++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/core/Geometry2.js b/src/core/Geometry2.js index 17da2404ad..bb496ae5d7 100644 --- a/src/core/Geometry2.js +++ b/src/core/Geometry2.js @@ -8,13 +8,13 @@ THREE.Geometry2 = function ( size ) { if ( size !== undefined ) { - var vertices = new Float32Array( size * 3 * 3 ); - var normals = new Float32Array( size * 3 * 3 ); - var uvs = new Float32Array( size * 3 * 2 ); + this.vertices = new Float32Array( size * 3 * 3 ); + this.normals = new Float32Array( size * 3 * 3 ); + this.uvs = new Float32Array( size * 3 * 2 ); - this.attributes[ 'position' ] = { array: vertices, itemSize: 3 }; - this.attributes[ 'normal' ] = { array: normals, itemSize: 3 }; - this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 }; + this.attributes[ 'position' ] = { array: this.vertices, itemSize: 3 }; + this.attributes[ 'normal' ] = { array: this.normals, itemSize: 3 }; + this.attributes[ 'uv' ] = { array: this.uvs, itemSize: 2 }; } @@ -24,6 +24,10 @@ THREE.Geometry2.prototype = Object.create( THREE.BufferGeometry.prototype ); THREE.Geometry2.prototype.setArrays = function ( vertices, normals, uvs ) { + this.vertices = vertices; + this.normals = normals; + this.uvs = uvs; + this.attributes[ 'position' ] = { array: vertices, itemSize: 3 }; this.attributes[ 'normal' ] = { array: normals, itemSize: 3 }; this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 }; diff --git a/src/core/IndexedGeometry2.js b/src/core/IndexedGeometry2.js index 9db02c5470..bb8f82e672 100644 --- a/src/core/IndexedGeometry2.js +++ b/src/core/IndexedGeometry2.js @@ -12,6 +12,11 @@ THREE.IndexedGeometry2.prototype = Object.create( THREE.BufferGeometry.prototype THREE.IndexedGeometry2.prototype.setArrays = function ( indices, vertices, normals, uvs ) { + this.indices = indices; + this.vertices = vertices; + this.normals = normals; + this.uvs = uvs; + this.attributes[ 'index' ] = { array: indices, itemSize: 1 }; this.attributes[ 'position' ] = { array: vertices, itemSize: 3 }; this.attributes[ 'normal' ] = { array: normals, itemSize: 3 }; -- GitLab