Bläddra i källkod

BufferGeometry.fromDirectGeometry: Always create position. (WebGLRenderer requires it)

Mr.doob 10 år sedan
förälder
incheckning
7d45778e1e
1 ändrade filer med 9 tillägg och 13 borttagningar
  1. 9 13
      src/core/BufferGeometry.js

+ 9 - 13
src/core/BufferGeometry.js

@@ -303,19 +303,8 @@ THREE.BufferGeometry.prototype = {
 
 	fromDirectGeometry: function ( geometry ) {
 
-		if ( geometry.indices.length > 0 ) {
-
-			var indices = new Uint16Array( geometry.indices.length * 3 );
-			this.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
-
-		}
-
-		if ( geometry.vertices.length > 0 ) {
-
-			var positions = new Float32Array( geometry.vertices.length * 3 );
-			this.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );
-
-		}
+		var positions = new Float32Array( geometry.vertices.length * 3 );
+		this.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );
 
 		if ( geometry.normals.length > 0 ) {
 
@@ -352,6 +341,13 @@ THREE.BufferGeometry.prototype = {
 
 		}
 
+		if ( geometry.indices.length > 0 ) {
+
+			var indices = new Uint16Array( geometry.indices.length * 3 );
+			this.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
+
+		}
+
 		// morphs
 
 		if ( geometry.morphTargets.length > 0 ) {