Explorar o código

Merge pull request #4308 from TrevorDev/developmentFrictionFixes

Development friction fixes
David Catuhe %!s(int64=7) %!d(string=hai) anos
pai
achega
8150606082

+ 1 - 0
dist/preview release/what's new.md

@@ -13,6 +13,7 @@
 - Added ability to not generate polynomials harmonics upon prefiltered texture creation ([sebavan](http://www.github.com/sebavan))
 - Added predicate function to customize the list of mesh included in the computation of bounding vectors in the ```getHierarchyBoundingVectors``` method ([sebavan](http://www.github.com/sebavan))
 - Added webVR constructor options: disable laser pointer toggle, teleportation floor meshes ([TrevorDev](https://github.com/TrevorDev))
+- Get a root mesh from an asset container, load a mesh from a file with a single string url ([TrevorDev](https://github.com/TrevorDev))
 
 ### glTF Loader
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 57 - 26
src/Loading/babylon.sceneLoader.ts


+ 15 - 0
src/babylon.assetContainer.ts

@@ -332,5 +332,20 @@ module BABYLON {
 
             this.removeAllFromScene();
         }
+
+        /**
+         * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
+         * @returns the root mesh
+         */
+        public createRootMesh(){
+            var rootMesh = new BABYLON.Mesh("assetContainerRootMesh", this.scene);
+            this.meshes.forEach((m)=>{
+                if(!m.parent){
+                    rootMesh.addChild(m);
+                }
+            })
+            this.meshes.unshift(rootMesh);
+            return rootMesh;
+        }
     }
 }

+ 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);
+                })
+            }
         }
 
       /**