Pārlūkot izejas kodu

recursive add mesh to scene

Trevor Baron 7 gadi atpakaļ
vecāks
revīzija
0e2683326f
1 mainītis faili ar 8 papildinājumiem un 1 dzēšanām
  1. 8 1
      src/babylon.scene.ts

+ 8 - 1
src/babylon.scene.ts

@@ -3011,8 +3011,9 @@
         /**
          * Add a mesh to the list of scene's meshes
          * @param newMesh defines the mesh to add
+         * @param recursive if all child meshes should also be added to the scene
          */
-        public addMesh(newMesh: AbstractMesh) {
+        public addMesh(newMesh: AbstractMesh, recursive = false) {
             this.meshes.push(newMesh);
 
             //notify the collision coordinator
@@ -3022,6 +3023,12 @@
             newMesh._resyncLightSources();
 
             this.onNewMeshAddedObservable.notifyObservers(newMesh);
+
+            if(recursive){
+                newMesh.getChildMeshes().forEach((m)=>{
+                    this.addMesh(m);
+                })
+            }
         }
 
       /**