Răsfoiți Sursa

UTF8Loader: Updated some of the addAttribute calls.
Need to think what to do when the array is already created, like index in this case...

Mr.doob 12 ani în urmă
părinte
comite
e5f0ec13e4
1 a modificat fișierele cu 18 adăugiri și 14 ștergeri
  1. 18 14
      examples/js/loaders/UTF8Loader.js

+ 18 - 14
examples/js/loaders/UTF8Loader.js

@@ -34,9 +34,13 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 
 	var geometry = new THREE.BufferGeometry();
 
-	var positionArray = new Float32Array( 3 * 3 * ntris );
-	var normalArray = new Float32Array( 3 * 3 * ntris );
-	var uvArray = new Float32Array( 2 * 3 * ntris );
+    var positions = new THREE.Float32Attribute( ntris * 3, 3 );
+    var normals = new THREE.Float32Attribute( ntris * 3, 3 );
+    var uvs = new THREE.Float32Attribute( ntris * 3, 2 );
+
+	var positionsArray = positions.array;
+	var normalsArray = normals.array;
+	var uvsArray = uvs.array;
 
 	var i, j, offset;
 	var x, y, z;
@@ -56,9 +60,9 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 		y = attribArray[ i + 1 ];
 		z = attribArray[ i + 2 ];
 
-		positionArray[ j++ ] = x;
-		positionArray[ j++ ] = y;
-		positionArray[ j++ ] = z;
+		positionsArray[ j++ ] = x;
+		positionsArray[ j++ ] = y;
+		positionsArray[ j++ ] = z;
 
 	}
 
@@ -72,8 +76,8 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 		u = attribArray[ i ];
 		v = attribArray[ i + 1 ];
 
-		uvArray[ j++ ] = u;
-		uvArray[ j++ ] = v;
+		uvsArray[ j++ ] = u;
+		uvsArray[ j++ ] = v;
 
 	}
 
@@ -88,16 +92,16 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
 		y = attribArray[ i + 1 ];
 		z = attribArray[ i + 2 ];
 
-		normalArray[ j++ ] = x;
-		normalArray[ j++ ] = y;
-		normalArray[ j++ ] = z;
+		normalsArray[ j++ ] = x;
+		normalsArray[ j++ ] = y;
+		normalsArray[ j++ ] = z;
 
 	}
 
     geometry.addAttribute( 'index', indexArray, 1 );
-    geometry.addAttribute( 'position', positionArray, 3 );
-    geometry.addAttribute( 'normal', normalArray, 3 );
-    geometry.addAttribute( 'uv', uvArray, 2 );
+    geometry.addAttribute( 'position', positions );
+    geometry.addAttribute( 'normal', normals );
+    geometry.addAttribute( 'uv', uvs );
 
     geometry.offsets.push( { start: 0, count: indexArray.length, index: 0 } );