Преглед изворни кода

add scene gemetry based on uniqueId in case multiple geometry share the same id

Trevor Baron пре 6 година
родитељ
комит
de449d4629
2 измењених фајлова са 17 додато и 2 уклоњено
  1. 6 1
      src/Mesh/babylon.geometry.ts
  2. 11 1
      src/babylon.scene.ts

+ 6 - 1
src/Mesh/babylon.geometry.ts

@@ -5,10 +5,14 @@ module BABYLON {
     export class Geometry implements IGetSetVerticesData {
         // Members
         /**
-         * Gets or sets the unique ID of the geometry
+         * Gets or sets the ID of the geometry
          */
         public id: string;
         /**
+         * Gets or sets the unique ID of the geometry
+         */
+        public uniqueId: number;
+        /**
          * Gets the delay loading state of the geometry (none by default which means not delayed)
          */
         public delayLoadState = Engine.DELAYLOADSTATE_NONE;
@@ -94,6 +98,7 @@ module BABYLON {
          */
         constructor(id: string, scene: Scene, vertexData?: VertexData, updatable: boolean = false, mesh: Nullable<Mesh> = null) {
             this.id = id;
+            this.uniqueId = scene.getUniqueId();
             this._engine = scene.getEngine();
             this._meshes = [];
             this._scene = scene;

+ 11 - 1
src/babylon.scene.ts

@@ -3613,6 +3613,16 @@ module BABYLON {
             return null;
         }
 
+        private _getGeometryByUniqueID(id: number): Nullable<Geometry> {
+            for (var index = 0; index < this.geometries.length; index++) {
+                if (this.geometries[index].uniqueId === id) {
+                    return this.geometries[index];
+                }
+            }
+
+            return null;
+        }
+
         /**
          * Add a new geometry to this scene
          * @param geometry defines the geometry to be added to the scene.
@@ -3620,7 +3630,7 @@ module BABYLON {
          * @return a boolean defining if the geometry was added or not
          */
         public pushGeometry(geometry: Geometry, force?: boolean): boolean {
-            if (!force && this.getGeometryByID(geometry.id)) {
+            if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
                 return false;
             }