Browse Source

Merge branch 'master' into sceneAssetContainer

Trevor Baron 7 năm trước cách đây
mục cha
commit
2058e84fb3

+ 2 - 2
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -607,7 +607,7 @@ module BABYLON {
                 this._createGazeTracker();
 
                 this.raySelectionPredicate = (mesh) => {
-                    return true;
+                    return mesh.isVisible;
                 }
 
                 this.meshSelectionPredicate = (mesh) => {
@@ -615,7 +615,7 @@ module BABYLON {
                 }
 
                 this._raySelectionPredicate = (mesh) => {
-                    if (this._isTeleportationFloor(mesh) || (mesh.isVisible && mesh.name.indexOf("gazeTracker") === -1
+                    if (this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
                         && mesh.name.indexOf("teleportationTarget") === -1
                         && mesh.name.indexOf("torusTeleportation") === -1
                         && mesh.name.indexOf("laserPointer") === -1)) {

+ 6 - 1
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -428,6 +428,11 @@
         protected _forceNormalForward = false;
 
         /**
+         * Force metallic workflow.
+         */
+        protected _forceMetallicWorkflow = false;
+
+        /**
          * Default configuration related to image processing available in the PBR Material.
          */
         @serializeAsImageProcessingConfiguration()
@@ -862,7 +867,7 @@
 
                 defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
 
-                if ((this._metallic !== undefined && this._metallic !== null) || (this._roughness !== undefined && this._roughness !== null)) {
+                if (this._forceMetallicWorkflow || (this._metallic !== undefined && this._metallic !== null) || (this._roughness !== undefined && this._roughness !== null)) {
                     defines.METALLICWORKFLOW = true;
                 } else {
                     defines.METALLICWORKFLOW = false;

+ 1 - 0
src/Materials/PBR/babylon.pbrMetallicRoughnessMaterial.ts

@@ -60,6 +60,7 @@
             this._useRoughnessFromMetallicTextureAlpha = false;
             this._useRoughnessFromMetallicTextureGreen = true;
             this._useMetallnessFromMetallicTextureBlue = true;
+            this._forceMetallicWorkflow = true;
         }
 
         /**

+ 9 - 4
src/Mesh/babylon.mesh.ts

@@ -186,15 +186,20 @@
                 }
 
                 // Deep copy
-                Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source"], ["_poseMatrix", "_source"]);
-
+                Tools.DeepCopy(source, this, ["name", "material", "skeleton", "instances", "parent", "uniqueId", "source", "metadata"], ["_poseMatrix", "_source"]);
+
+                // Metadata
+                if (source.metadata && source.metadata.clone) {
+                    this.metadata = source.metadata.clone();
+                 } else {
+                    this.metadata = source.metadata;
+                 }                
+                
                 // Tags
                 if (Tags && Tags.HasTags(source)) {
                     Tags.AddTagsTo(this, Tags.GetTags(source, true));
                 }
 
-                this.metadata = source.metadata;
-
                 // Parent
                 this.parent = source.parent;
 

+ 28 - 1
src/babylon.scene.ts

@@ -1924,6 +1924,33 @@
             this.onAfterRenderObservable.removeCallback(func);
         }
 
+        private _executeOnceBeforeRender(func: () => void): void {
+            let execFunc = () => {
+                func();
+                setTimeout(() => {
+                    this.unregisterBeforeRender(execFunc);
+                });
+            }
+            this.registerBeforeRender(execFunc);
+        }
+
+        /**
+         * The provided function will run before render once and will be disposed afterwards.
+         * A timeout delay can be provided so that the function will be executed in N ms.
+         * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
+         * @param func The function to be executed.
+         * @param timeout optional delay in ms
+         */
+        public executeOnceBeforeRender(func: () => void, timeout?: number): void {
+            if (timeout !== undefined) {
+                setTimeout(() => {
+                    this._executeOnceBeforeRender(func);
+                }, timeout);
+            } else {
+                this._executeOnceBeforeRender(func);
+            }
+        }
+
         public _addPendingData(data: any): void {
             this._pendingData.push(data);
         }
@@ -2366,7 +2393,7 @@
 
             // Add light to all meshes (To support if the light is removed and then readded)
             for (var mesh of this.meshes) {
-                if(mesh._lightSources.indexOf(newLight) === -1){
+                if (mesh._lightSources.indexOf(newLight) === -1) {
                     mesh._lightSources.push(newLight);
                     mesh._resyncLightSources();
                 }