소스 검색

Fix glTF loader bug where multiple sub meshes are being created

Gary Hsu 8 년 전
부모
커밋
fe6cb0f784
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      loaders/src/glTF/2.0/babylon.glTFLoader.ts

+ 3 - 2
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -271,7 +271,6 @@ module BABYLON.GLTF2 {
 
         private _loadMeshData(node: IGLTFNode, mesh: IGLTFMesh, babylonMesh: Mesh): void {
             babylonMesh.name = mesh.name || babylonMesh.name;
-            babylonMesh.subMeshes = [];
 
             var multiMaterial = new MultiMaterial(babylonMesh.name, this._babylonScene);
             babylonMesh.material = multiMaterial;
@@ -312,7 +311,9 @@ module BABYLON.GLTF2 {
                     if (++primitivesLoaded === numPrimitives) {
                         geometry.setAllVerticesData(vertexData, false);
 
-                        // Sub meshes must be created after setting vertex data because of mesh._createGlobalSubMesh.
+                        // TODO: optimize this so that sub meshes can be created without being overwritten after setting vertex data.
+                        // Sub meshes must be cleared and created after setting vertex data because of mesh._createGlobalSubMesh.
+                        babylonMesh.subMeshes = [];
                         for (var i = 0; i < subMeshInfos.length; i++) {
                             var info = subMeshInfos[i];
                             new SubMesh(info.materialIndex, info.verticesStart, info.verticesCount, info.indicesStart, info.indicesCount, babylonMesh);