Parcourir la source

Fix clone/instancing issue

David Catuhe il y a 5 ans
Parent
commit
bcd8e8c416
1 fichiers modifiés avec 11 ajouts et 1 suppressions
  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);
     }