Browse Source

Merge pull request #11674 from Mugen87/dev2

BabylonLoader: Clean up
Mr.doob 8 years ago
parent
commit
26ca35466f
1 changed files with 11 additions and 14 deletions
  1. 11 14
      examples/js/loaders/BabylonLoader.js

+ 11 - 14
examples/js/loaders/BabylonLoader.js

@@ -76,29 +76,28 @@ THREE.BabylonLoader.prototype = {
 
 		var geometry = new THREE.BufferGeometry();
 
-		// indices
+		var indices = json.indices;
+		var positions = json.positions;
+		var normals = json.normals;
+		var uvs = json.uvs;
 
-		var indices = new Uint16Array( json.indices );
+		// indices
 
-		geometry.setIndex( new THREE.BufferAttribute( indices, 1 ) );
+		geometry.setIndex( indices );
 
 		// positions
 
-		var positions = new Float32Array( json.positions );
-
 		for ( var j = 2, jl = positions.length; j < jl; j += 3 ) {
 
 			positions[ j ] = - positions[ j ];
 
 		}
 
-		geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
+		geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
 
 		// normals
 
-		if ( json.normals ) {
-
-			var normals = new Float32Array( json.normals );
+		if ( normals ) {
 
 			for ( var j = 2, jl = normals.length; j < jl; j += 3 ) {
 
@@ -106,17 +105,15 @@ THREE.BabylonLoader.prototype = {
 
 			}
 
-			geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
+			geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
 
 		}
 
 		// uvs
 
-		if ( json.uvs ) {
-
-			var uvs = new Float32Array( json.uvs );
+		if ( uvs ) {
 
-			geometry.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
+			geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
 
 		}