瀏覽代碼

Fix clone/instancing issue

David Catuhe 5 年之前
父節點
當前提交
bcd8e8c416
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      src/Meshes/mesh.ts

+ 11 - 1
src/Meshes/mesh.ts

@@ -2814,7 +2814,17 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
      * @returns a new InstancedMesh
      */
     public createInstance(name: string): InstancedMesh {
-        this.makeGeometryUnique();
+        let geometry = this.geometry;
+
+        if (geometry && geometry.meshes.length > 1) {
+            let others = geometry.meshes.slice(0);
+            for (var other of others) {
+                if (other === this) {
+                    continue;
+                }
+                other.makeGeometryUnique();
+            }
+        }
 
         return Mesh._instancedMeshFactory(name, this);
     }