瀏覽代碼

Made Geometry2/IndexedGeometry2 more user friendly.
Starting to consider implementing geometry.bufferGeometry...

Mr.doob 11 年之前
父節點
當前提交
aaca0a8ad6
共有 2 個文件被更改,包括 15 次插入6 次删除
  1. 10 6
      src/core/Geometry2.js
  2. 5 0
      src/core/IndexedGeometry2.js

+ 10 - 6
src/core/Geometry2.js

@@ -8,13 +8,13 @@ THREE.Geometry2 = function ( size ) {
 
 
 	if ( size !== undefined ) {
 	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 ) {
 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[ 'position' ] = { array: vertices, itemSize: 3 };
 	this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
 	this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
 	this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };
 	this.attributes[ 'uv' ] = { array: uvs, itemSize: 2 };

+ 5 - 0
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 ) {
 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[ 'index' ] = { array: indices, itemSize: 1 };
 	this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
 	this.attributes[ 'position' ] = { array: vertices, itemSize: 3 };
 	this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };
 	this.attributes[ 'normal' ] = { array: normals, itemSize: 3 };