Parcourir la source

Fix in Geometry.copy()

Without this fix, two geometries which have been copied share the same vertex data arrays. This leads to unexpected behaviour, e.g. infinite loop when trying to merge meshes.
jahow il y a 10 ans
Parent
commit
70ebd7287c
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 3 2
      Babylon/Mesh/babylon.geometry.ts

+ 3 - 2
Babylon/Mesh/babylon.geometry.ts

@@ -394,7 +394,8 @@
             var stopChecking = false;
 
             for (var kind in this._vertexBuffers) {
-                vertexData.set(this.getVerticesData(kind), kind);
+                // using slice() to make a copy of the array and not just reference it
+                vertexData.set(this.getVerticesData(kind).slice(0), kind);
 
                 if (!stopChecking) {
                     updatable = this.getVertexBuffer(kind).isUpdatable();
@@ -729,4 +730,4 @@
             }
         }
     }
-} 
+}