浏览代码

Merge pull request #10259 from Virtulous/dev

A few fixes
Mr.doob 8 年之前
父节点
当前提交
fb1b800f51
共有 1 个文件被更改,包括 27 次插入3 次删除
  1. 27 3
      examples/js/loaders/AssimpLoader.js

+ 27 - 3
examples/js/loaders/AssimpLoader.js

@@ -650,7 +650,7 @@
 				mat = new THREE.MeshLambertMaterial();
 				mat = new THREE.MeshLambertMaterial();
 			geometry.setIndex( new THREE.BufferAttribute( new Uint32Array( this.mIndexArray ), 1 ) );
 			geometry.setIndex( new THREE.BufferAttribute( new Uint32Array( this.mIndexArray ), 1 ) );
 			geometry.addAttribute( 'position', new THREE.BufferAttribute( this.mVertexBuffer, 3 ) );
 			geometry.addAttribute( 'position', new THREE.BufferAttribute( this.mVertexBuffer, 3 ) );
-			if ( this.mNormalBuffer.length > 0 )
+			if ( this.mNormalBuffer && this.mNormalBuffer.length > 0 )
 				geometry.addAttribute( 'normal', new THREE.BufferAttribute( this.mNormalBuffer, 3 ) );
 				geometry.addAttribute( 'normal', new THREE.BufferAttribute( this.mNormalBuffer, 3 ) );
 			if ( this.mColorBuffer && this.mColorBuffer.length > 0 )
 			if ( this.mColorBuffer && this.mColorBuffer.length > 0 )
 				geometry.addAttribute( 'color', new THREE.BufferAttribute( this.mColorBuffer, 4 ) );
 				geometry.addAttribute( 'color', new THREE.BufferAttribute( this.mColorBuffer, 4 ) );
@@ -1850,10 +1850,34 @@
 
 
 					}
 					}
 
 
-					mesh.mIndexArray.push( f.mIndices[ a ] );
+					
 
 
 				}
 				}
 
 
+				if(f.mNumIndices === 3) {
+
+					mesh.mIndexArray.push( f.mIndices[ 0 ] );
+					mesh.mIndexArray.push( f.mIndices[ 1 ] );
+					mesh.mIndexArray.push( f.mIndices[ 2 ] );
+
+				}
+				else if(f.mNumIndices === 4) {
+
+					mesh.mIndexArray.push( f.mIndices[ 0 ] );
+					mesh.mIndexArray.push( f.mIndices[ 1 ] );
+					mesh.mIndexArray.push( f.mIndices[ 2 ] );
+					mesh.mIndexArray.push( f.mIndices[ 2 ] );
+					mesh.mIndexArray.push( f.mIndices[ 3 ] );
+					mesh.mIndexArray.push( f.mIndices[ 0 ] );
+
+				} else {
+
+					throw ( new Error( "Sorry, can't currently triangulate polys. Use the triangulate preprocessor in Assimp." ))
+					
+				}
+
+
+
 			}
 			}
 
 
 		}
 		}
@@ -2326,4 +2350,4 @@
 
 
 	THREE.AssimpLoader = AssimpLoader;
 	THREE.AssimpLoader = AssimpLoader;
 
 
-} )();
+} )();