David Catuhe 7 jaren geleden
bovenliggende
commit
8a95fca573

File diff suppressed because it is too large
+ 12513 - 12514
Playground/babylon.d.txt


File diff suppressed because it is too large
+ 2172 - 2173
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.js


+ 13 - 29
dist/preview release/babylon.max.js

@@ -12576,7 +12576,7 @@ var BABYLON;
             }
             // Create Audio Engine if needed.
             if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
-                Engine.audioEngine = Engine.AudioEngineFactory(this);
+                Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
             }
             // Prepare buffer pointers
             for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
@@ -55732,7 +55732,7 @@ var BABYLON;
                     else {
                         var parameter = {};
                         BABYLON.Tools.DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
-                        if (triggerOptions.parameter.mesh) {
+                        if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
                             parameter._meshId = triggerOptions.parameter.mesh.id;
                         }
                         triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
@@ -69518,7 +69518,7 @@ var BABYLON;
 var BABYLON;
 (function (BABYLON) {
     // Sets the default audio engine to Babylon JS.
-    BABYLON.Engine.AudioEngineFactory = function (engine) { return new AudioEngine(engine); };
+    BABYLON.Engine.AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
     /**
      * This represents the default audio engine used in babylon.
      * It is responsible to play, synchronize and analyse sounds throughout the  application.
@@ -69530,10 +69530,10 @@ var BABYLON;
          *
          * There should be only one per page as some browsers restrict the number
          * of audio contexts you can create.
-         * @param engine defines the hosting engine
+         * @param hostElement defines the host element where to display the mute icon if necessary
          */
-        function AudioEngine(engine) {
-            if (engine === void 0) { engine = BABYLON.Engine.LastCreatedEngine; }
+        function AudioEngine(hostElement) {
+            if (hostElement === void 0) { hostElement = null; }
             var _this = this;
             this._audioContext = null;
             this._audioContextInitialized = false;
@@ -69583,7 +69583,7 @@ var BABYLON;
                 this.canUseWebAudio = true;
             }
             var audioElem = document.createElement('audio');
-            this._engine = engine;
+            this._hostElement = hostElement;
             try {
                 if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
                     this.isMP3supported = true;
@@ -69641,7 +69641,6 @@ var BABYLON;
             return result || Promise.resolve();
         };
         AudioEngine.prototype._initializeAudioContext = function () {
-            var _this = this;
             try {
                 if (this.canUseWebAudio) {
                     this._audioContext = new AudioContext();
@@ -69654,17 +69653,6 @@ var BABYLON;
                         // Do not wait for the promise to unlock.
                         this._triggerRunningState();
                     }
-                    else {
-                        if (this._audioContext && this._audioContext.resume) {
-                            this._resumeAudioContext().then(function () {
-                                _this._triggerRunningState();
-                            }).catch(function () {
-                                // Can not resume automatically
-                                // Needs user action
-                                _this.lock();
-                            });
-                        }
-                    }
                 }
             }
             catch (e) {
@@ -69681,16 +69669,16 @@ var BABYLON;
             this._resumeAudioContext()
                 .then(function () {
                 _this._tryToRun = false;
-                _this.unlocked = true;
                 if (_this._muteButton) {
                     _this._hideMuteButton();
                 }
-                // Notify users that the audio stack is unlocked/unmuted
-                _this.onAudioUnlockedObservable.notifyObservers(_this);
             }).catch(function () {
                 _this._tryToRun = false;
                 _this.unlocked = false;
             });
+            // Notify users that the audio stack is unlocked/unmuted
+            this.unlocked = true;
+            this.onAudioUnlockedObservable.notifyObservers(this);
         };
         AudioEngine.prototype._triggerSuspendedState = function () {
             this.unlocked = false;
@@ -69702,7 +69690,6 @@ var BABYLON;
             if (this.useCustomUnlockedButton) {
                 return;
             }
-            this._canvas = this._engine.getRenderingCanvas();
             this._muteButton = document.createElement("BUTTON");
             this._muteButton.className = "babylonUnmuteIcon";
             this._muteButton.id = "babylonUnmuteIconBtn";
@@ -69713,9 +69700,6 @@ var BABYLON;
             document.getElementsByTagName('head')[0].appendChild(style);
             document.body.appendChild(this._muteButton);
             this._moveButtonToTopLeft();
-            this._muteButton.addEventListener('mousedown', function () {
-                _this._triggerRunningState();
-            }, true);
             this._muteButton.addEventListener('touchend', function () {
                 _this._triggerRunningState();
             }, true);
@@ -69725,9 +69709,9 @@ var BABYLON;
             window.addEventListener("resize", this._onResize);
         };
         AudioEngine.prototype._moveButtonToTopLeft = function () {
-            if (this._canvas && this._muteButton) {
-                this._muteButton.style.top = this._canvas.offsetTop + 20 + "px";
-                this._muteButton.style.left = this._canvas.offsetLeft + 20 + "px";
+            if (this._hostElement && this._muteButton) {
+                this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
+                this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
             }
         };
         AudioEngine.prototype._hideMuteButton = function () {

+ 13 - 29
dist/preview release/babylon.no-module.max.js

@@ -12543,7 +12543,7 @@ var BABYLON;
             }
             // Create Audio Engine if needed.
             if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
-                Engine.audioEngine = Engine.AudioEngineFactory(this);
+                Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
             }
             // Prepare buffer pointers
             for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
@@ -55699,7 +55699,7 @@ var BABYLON;
                     else {
                         var parameter = {};
                         BABYLON.Tools.DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
-                        if (triggerOptions.parameter.mesh) {
+                        if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
                             parameter._meshId = triggerOptions.parameter.mesh.id;
                         }
                         triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
@@ -69485,7 +69485,7 @@ var BABYLON;
 var BABYLON;
 (function (BABYLON) {
     // Sets the default audio engine to Babylon JS.
-    BABYLON.Engine.AudioEngineFactory = function (engine) { return new AudioEngine(engine); };
+    BABYLON.Engine.AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
     /**
      * This represents the default audio engine used in babylon.
      * It is responsible to play, synchronize and analyse sounds throughout the  application.
@@ -69497,10 +69497,10 @@ var BABYLON;
          *
          * There should be only one per page as some browsers restrict the number
          * of audio contexts you can create.
-         * @param engine defines the hosting engine
+         * @param hostElement defines the host element where to display the mute icon if necessary
          */
-        function AudioEngine(engine) {
-            if (engine === void 0) { engine = BABYLON.Engine.LastCreatedEngine; }
+        function AudioEngine(hostElement) {
+            if (hostElement === void 0) { hostElement = null; }
             var _this = this;
             this._audioContext = null;
             this._audioContextInitialized = false;
@@ -69550,7 +69550,7 @@ var BABYLON;
                 this.canUseWebAudio = true;
             }
             var audioElem = document.createElement('audio');
-            this._engine = engine;
+            this._hostElement = hostElement;
             try {
                 if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
                     this.isMP3supported = true;
@@ -69608,7 +69608,6 @@ var BABYLON;
             return result || Promise.resolve();
         };
         AudioEngine.prototype._initializeAudioContext = function () {
-            var _this = this;
             try {
                 if (this.canUseWebAudio) {
                     this._audioContext = new AudioContext();
@@ -69621,17 +69620,6 @@ var BABYLON;
                         // Do not wait for the promise to unlock.
                         this._triggerRunningState();
                     }
-                    else {
-                        if (this._audioContext && this._audioContext.resume) {
-                            this._resumeAudioContext().then(function () {
-                                _this._triggerRunningState();
-                            }).catch(function () {
-                                // Can not resume automatically
-                                // Needs user action
-                                _this.lock();
-                            });
-                        }
-                    }
                 }
             }
             catch (e) {
@@ -69648,16 +69636,16 @@ var BABYLON;
             this._resumeAudioContext()
                 .then(function () {
                 _this._tryToRun = false;
-                _this.unlocked = true;
                 if (_this._muteButton) {
                     _this._hideMuteButton();
                 }
-                // Notify users that the audio stack is unlocked/unmuted
-                _this.onAudioUnlockedObservable.notifyObservers(_this);
             }).catch(function () {
                 _this._tryToRun = false;
                 _this.unlocked = false;
             });
+            // Notify users that the audio stack is unlocked/unmuted
+            this.unlocked = true;
+            this.onAudioUnlockedObservable.notifyObservers(this);
         };
         AudioEngine.prototype._triggerSuspendedState = function () {
             this.unlocked = false;
@@ -69669,7 +69657,6 @@ var BABYLON;
             if (this.useCustomUnlockedButton) {
                 return;
             }
-            this._canvas = this._engine.getRenderingCanvas();
             this._muteButton = document.createElement("BUTTON");
             this._muteButton.className = "babylonUnmuteIcon";
             this._muteButton.id = "babylonUnmuteIconBtn";
@@ -69680,9 +69667,6 @@ var BABYLON;
             document.getElementsByTagName('head')[0].appendChild(style);
             document.body.appendChild(this._muteButton);
             this._moveButtonToTopLeft();
-            this._muteButton.addEventListener('mousedown', function () {
-                _this._triggerRunningState();
-            }, true);
             this._muteButton.addEventListener('touchend', function () {
                 _this._triggerRunningState();
             }, true);
@@ -69692,9 +69676,9 @@ var BABYLON;
             window.addEventListener("resize", this._onResize);
         };
         AudioEngine.prototype._moveButtonToTopLeft = function () {
-            if (this._canvas && this._muteButton) {
-                this._muteButton.style.top = this._canvas.offsetTop + 20 + "px";
-                this._muteButton.style.left = this._canvas.offsetLeft + 20 + "px";
+            if (this._hostElement && this._muteButton) {
+                this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
+                this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
             }
         };
         AudioEngine.prototype._hideMuteButton = function () {

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.worker.js


+ 13 - 29
dist/preview release/es6.js

@@ -12543,7 +12543,7 @@ var BABYLON;
             }
             // Create Audio Engine if needed.
             if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
-                Engine.audioEngine = Engine.AudioEngineFactory(this);
+                Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
             }
             // Prepare buffer pointers
             for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
@@ -55699,7 +55699,7 @@ var BABYLON;
                     else {
                         var parameter = {};
                         BABYLON.Tools.DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
-                        if (triggerOptions.parameter.mesh) {
+                        if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
                             parameter._meshId = triggerOptions.parameter.mesh.id;
                         }
                         triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
@@ -69485,7 +69485,7 @@ var BABYLON;
 var BABYLON;
 (function (BABYLON) {
     // Sets the default audio engine to Babylon JS.
-    BABYLON.Engine.AudioEngineFactory = function (engine) { return new AudioEngine(engine); };
+    BABYLON.Engine.AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
     /**
      * This represents the default audio engine used in babylon.
      * It is responsible to play, synchronize and analyse sounds throughout the  application.
@@ -69497,10 +69497,10 @@ var BABYLON;
          *
          * There should be only one per page as some browsers restrict the number
          * of audio contexts you can create.
-         * @param engine defines the hosting engine
+         * @param hostElement defines the host element where to display the mute icon if necessary
          */
-        function AudioEngine(engine) {
-            if (engine === void 0) { engine = BABYLON.Engine.LastCreatedEngine; }
+        function AudioEngine(hostElement) {
+            if (hostElement === void 0) { hostElement = null; }
             var _this = this;
             this._audioContext = null;
             this._audioContextInitialized = false;
@@ -69550,7 +69550,7 @@ var BABYLON;
                 this.canUseWebAudio = true;
             }
             var audioElem = document.createElement('audio');
-            this._engine = engine;
+            this._hostElement = hostElement;
             try {
                 if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
                     this.isMP3supported = true;
@@ -69608,7 +69608,6 @@ var BABYLON;
             return result || Promise.resolve();
         };
         AudioEngine.prototype._initializeAudioContext = function () {
-            var _this = this;
             try {
                 if (this.canUseWebAudio) {
                     this._audioContext = new AudioContext();
@@ -69621,17 +69620,6 @@ var BABYLON;
                         // Do not wait for the promise to unlock.
                         this._triggerRunningState();
                     }
-                    else {
-                        if (this._audioContext && this._audioContext.resume) {
-                            this._resumeAudioContext().then(function () {
-                                _this._triggerRunningState();
-                            }).catch(function () {
-                                // Can not resume automatically
-                                // Needs user action
-                                _this.lock();
-                            });
-                        }
-                    }
                 }
             }
             catch (e) {
@@ -69648,16 +69636,16 @@ var BABYLON;
             this._resumeAudioContext()
                 .then(function () {
                 _this._tryToRun = false;
-                _this.unlocked = true;
                 if (_this._muteButton) {
                     _this._hideMuteButton();
                 }
-                // Notify users that the audio stack is unlocked/unmuted
-                _this.onAudioUnlockedObservable.notifyObservers(_this);
             }).catch(function () {
                 _this._tryToRun = false;
                 _this.unlocked = false;
             });
+            // Notify users that the audio stack is unlocked/unmuted
+            this.unlocked = true;
+            this.onAudioUnlockedObservable.notifyObservers(this);
         };
         AudioEngine.prototype._triggerSuspendedState = function () {
             this.unlocked = false;
@@ -69669,7 +69657,6 @@ var BABYLON;
             if (this.useCustomUnlockedButton) {
                 return;
             }
-            this._canvas = this._engine.getRenderingCanvas();
             this._muteButton = document.createElement("BUTTON");
             this._muteButton.className = "babylonUnmuteIcon";
             this._muteButton.id = "babylonUnmuteIconBtn";
@@ -69680,9 +69667,6 @@ var BABYLON;
             document.getElementsByTagName('head')[0].appendChild(style);
             document.body.appendChild(this._muteButton);
             this._moveButtonToTopLeft();
-            this._muteButton.addEventListener('mousedown', function () {
-                _this._triggerRunningState();
-            }, true);
             this._muteButton.addEventListener('touchend', function () {
                 _this._triggerRunningState();
             }, true);
@@ -69692,9 +69676,9 @@ var BABYLON;
             window.addEventListener("resize", this._onResize);
         };
         AudioEngine.prototype._moveButtonToTopLeft = function () {
-            if (this._canvas && this._muteButton) {
-                this._muteButton.style.top = this._canvas.offsetTop + 20 + "px";
-                this._muteButton.style.left = this._canvas.offsetLeft + 20 + "px";
+            if (this._hostElement && this._muteButton) {
+                this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
+                this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
             }
         };
         AudioEngine.prototype._hideMuteButton = function () {

+ 20 - 14
dist/preview release/serializers/babylon.glTF2Serializer.js

@@ -1887,20 +1887,26 @@ var BABYLON;
                             // Read data from WebGL
                             var canvas = engine.getRenderingCanvas();
                             if (canvas) {
-                                BABYLON.Tools.ToBlob(canvas, function (blob) {
-                                    if (blob) {
-                                        var fileReader = new FileReader();
-                                        fileReader.onload = function (event) {
-                                            var base64String = event.target.result;
-                                            hostingScene.dispose();
-                                            resolve(base64String);
-                                        };
-                                        fileReader.readAsDataURL(blob);
-                                    }
-                                    else {
-                                        reject("gltfMaterialExporter: Failed to get blob from image canvas!");
-                                    }
-                                });
+                                if (!canvas.toBlob) { // fallback for browsers without "canvas.toBlob"
+                                    var dataURL = canvas.toDataURL();
+                                    resolve(dataURL);
+                                }
+                                else {
+                                    BABYLON.Tools.ToBlob(canvas, function (blob) {
+                                        if (blob) {
+                                            var fileReader = new FileReader();
+                                            fileReader.onload = function (event) {
+                                                var base64String = event.target.result;
+                                                hostingScene.dispose();
+                                                resolve(base64String);
+                                            };
+                                            fileReader.readAsDataURL(blob);
+                                        }
+                                        else {
+                                            reject("gltfMaterialExporter: Failed to get blob from image canvas!");
+                                        }
+                                    });
+                                }
                             }
                             else {
                                 reject("Engine is missing a canvas!");

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/serializers/babylon.glTF2Serializer.min.js


+ 20 - 14
dist/preview release/serializers/babylonjs.serializers.js

@@ -2048,20 +2048,26 @@ var BABYLON;
                             // Read data from WebGL
                             var canvas = engine.getRenderingCanvas();
                             if (canvas) {
-                                BABYLON.Tools.ToBlob(canvas, function (blob) {
-                                    if (blob) {
-                                        var fileReader = new FileReader();
-                                        fileReader.onload = function (event) {
-                                            var base64String = event.target.result;
-                                            hostingScene.dispose();
-                                            resolve(base64String);
-                                        };
-                                        fileReader.readAsDataURL(blob);
-                                    }
-                                    else {
-                                        reject("gltfMaterialExporter: Failed to get blob from image canvas!");
-                                    }
-                                });
+                                if (!canvas.toBlob) { // fallback for browsers without "canvas.toBlob"
+                                    var dataURL = canvas.toDataURL();
+                                    resolve(dataURL);
+                                }
+                                else {
+                                    BABYLON.Tools.ToBlob(canvas, function (blob) {
+                                        if (blob) {
+                                            var fileReader = new FileReader();
+                                            fileReader.onload = function (event) {
+                                                var base64String = event.target.result;
+                                                hostingScene.dispose();
+                                                resolve(base64String);
+                                            };
+                                            fileReader.readAsDataURL(blob);
+                                        }
+                                        else {
+                                            reject("gltfMaterialExporter: Failed to get blob from image canvas!");
+                                        }
+                                    });
+                                }
                             }
                             else {
                                 reject("Engine is missing a canvas!");

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/serializers/babylonjs.serializers.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 1
tests/validation/config.json

@@ -2,7 +2,7 @@
   "root": "https://rawgit.com/BabylonJS/Website/master",
   "tests": [
     {
-      "title": "Simulat pointer",
+      "title": "Simulate pointer",
       "playgroundId": "#8MGKWK#66",
       "referenceImage": "simulatePointer.png"
     },

+ 1 - 1
tests/validation/validation.js

@@ -304,7 +304,7 @@ function runTest(index, done) {
         var request = new XMLHttpRequest();
         request.open('GET', config.root + test.scriptToRun, true);
 
-        request.onreadystatechange = () => {
+        request.onreadystatechange = function() {
             if (request.readyState === 4) {
                 try {
                     request.onreadystatechange = null;