浏览代码

Better memory management for controllers

David Catuhe 8 年之前
父节点
当前提交
b126353b52
共有 27 个文件被更改,包括 29560 次插入29674 次删除
  1. 4334 4347
      dist/preview release/babylon.d.ts
  2. 13 13
      dist/preview release/babylon.js
  3. 57 110
      dist/preview release/babylon.max.js
  4. 4334 4347
      dist/preview release/babylon.module.d.ts
  5. 13 13
      dist/preview release/babylon.worker.js
  6. 10148 10159
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  7. 47 47
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  8. 87 115
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  9. 10148 10159
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
  10. 3 3
      dist/preview release/gui/babylon.gui.min.js
  11. 263 263
      dist/preview release/inspector/babylon.inspector.bundle.js
  12. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  13. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  14. 1 0
      dist/preview release/loaders/babylon.glTF2FileLoader.d.ts
  15. 9 5
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  16. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  17. 1 0
      dist/preview release/loaders/babylon.glTFFileLoader.d.ts
  18. 9 5
      dist/preview release/loaders/babylon.glTFFileLoader.js
  19. 3 3
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  20. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  21. 1 1
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  22. 1 1
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js
  23. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  24. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  25. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  26. 12 4
      src/Gamepad/Controllers/babylon.webVRController.ts
  27. 66 69
      src/Gamepad/Controllers/babylon.windowsMotionController.ts

文件差异内容过多而无法显示
+ 4334 - 4347
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 13 - 13
dist/preview release/babylon.js


+ 57 - 110
dist/preview release/babylon.max.js

@@ -52122,6 +52122,7 @@ var BABYLON;
         __extends(WebVRController, _super);
         __extends(WebVRController, _super);
         function WebVRController(vrGamepad) {
         function WebVRController(vrGamepad) {
             var _this = _super.call(this, vrGamepad) || this;
             var _this = _super.call(this, vrGamepad) || this;
+            // Observables
             _this.onTriggerStateChangedObservable = new BABYLON.Observable();
             _this.onTriggerStateChangedObservable = new BABYLON.Observable();
             _this.onMainButtonStateChangedObservable = new BABYLON.Observable();
             _this.onMainButtonStateChangedObservable = new BABYLON.Observable();
             _this.onSecondaryButtonStateChangedObservable = new BABYLON.Observable();
             _this.onSecondaryButtonStateChangedObservable = new BABYLON.Observable();
@@ -52194,6 +52195,14 @@ var BABYLON;
             this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
             this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
             return this._changes;
             return this._changes;
         };
         };
+        WebVRController.prototype.dispose = function () {
+            _super.prototype.dispose.call(this);
+            this.onTriggerStateChangedObservable.clear();
+            this.onMainButtonStateChangedObservable.clear();
+            this.onSecondaryButtonStateChangedObservable.clear();
+            this.onPadStateChangedObservable.clear();
+            this.onPadValuesChangedObservable.clear();
+        };
         return WebVRController;
         return WebVRController;
     }(BABYLON.PoseEnabledController));
     }(BABYLON.PoseEnabledController));
     BABYLON.WebVRController = WebVRController;
     BABYLON.WebVRController = WebVRController;
@@ -52472,6 +52481,13 @@ var BABYLON;
 
 
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {
+    var LoadedMeshInfo = (function () {
+        function LoadedMeshInfo() {
+            this.buttonMeshes = {};
+            this.axisMeshes = {};
+        }
+        return LoadedMeshInfo;
+    }());
     var WindowsMotionController = (function (_super) {
     var WindowsMotionController = (function (_super) {
         __extends(WindowsMotionController, _super);
         __extends(WindowsMotionController, _super);
         function WindowsMotionController(vrGamepad) {
         function WindowsMotionController(vrGamepad) {
@@ -52509,7 +52525,6 @@ var BABYLON;
             };
             };
             _this.onTrackpadChangedObservable = new BABYLON.Observable();
             _this.onTrackpadChangedObservable = new BABYLON.Observable();
             _this.controllerType = BABYLON.PoseEnabledControllerType.WINDOWS;
             _this.controllerType = BABYLON.PoseEnabledControllerType.WINDOWS;
-            _this._parentMeshName = _this.id + " " + _this.hand;
             _this._loadedMeshInfo = null;
             _this._loadedMeshInfo = null;
             return _this;
             return _this;
         }
         }
@@ -52570,8 +52585,9 @@ var BABYLON;
          */
          */
         WindowsMotionController.prototype.handleButtonChange = function (buttonIdx, state, changes) {
         WindowsMotionController.prototype.handleButtonChange = function (buttonIdx, state, changes) {
             var buttonName = this._mapping.buttons[buttonIdx];
             var buttonName = this._mapping.buttons[buttonIdx];
-            if (!buttonName)
+            if (!buttonName) {
                 return;
                 return;
+            }
             // Only emit events for buttons that we know how to map from index to name
             // Only emit events for buttons that we know how to map from index to name
             var observable = this[this._mapping.buttonObservableNames[buttonName]];
             var observable = this[this._mapping.buttonObservableNames[buttonName]];
             if (observable) {
             if (observable) {
@@ -52581,16 +52597,18 @@ var BABYLON;
         };
         };
         WindowsMotionController.prototype.lerpButtonTransform = function (buttonName, buttonValue) {
         WindowsMotionController.prototype.lerpButtonTransform = function (buttonName, buttonValue) {
             // If there is no loaded mesh, there is nothing to transform.
             // If there is no loaded mesh, there is nothing to transform.
-            if (!this._loadedMeshInfo)
+            if (!this._loadedMeshInfo) {
                 return;
                 return;
+            }
             var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
             var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
             BABYLON.Quaternion.SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
             BABYLON.Quaternion.SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
             BABYLON.Vector3.LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
             BABYLON.Vector3.LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
         };
         };
         WindowsMotionController.prototype.lerpAxisTransform = function (axis, axisValue) {
         WindowsMotionController.prototype.lerpAxisTransform = function (axis, axisValue) {
             var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
             var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
-            if (!meshInfo)
+            if (!meshInfo) {
                 return;
                 return;
+            }
             // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
             // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
             var lerpValue = axisValue * 0.5 + 0.5;
             var lerpValue = axisValue * 0.5 + 0.5;
             BABYLON.Quaternion.SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
             BABYLON.Quaternion.SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
@@ -52603,73 +52621,35 @@ var BABYLON;
          */
          */
         WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded) {
         WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded) {
             var _this = this;
             var _this = this;
-            var parentMesh = scene.getMeshByName(this._parentMeshName);
-            if (parentMesh) {
-                // A mesh with the name we are expecting already exists in the scene, use that.
-                if (!this._loadedMeshInfo) {
-                    // Create our mesh info. Note that this method will always return non-null.
-                    this._loadedMeshInfo = this.createMeshInfo(parentMesh);
-                    this.attachToMesh(this._loadedMeshInfo.rootNode);
-                }
-                if (meshLoaded)
-                    meshLoaded(this._loadedMeshInfo.rootNode);
+            // Determine the device specific folder based on the ID suffix
+            var device = 'default';
+            if (this.id) {
+                var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
+                device = ((match && match[0]) || device);
+            }
+            // Hand
+            var filename;
+            if (this.hand === 'left') {
+                filename = WindowsMotionController.MODEL_LEFT_FILENAME;
             }
             }
             else {
             else {
-                // Make a call to load a mesh from CDN
-                this.loadModel(scene)
-                    .then(function (mesh) {
-                    _this.attachToMesh(mesh);
-                    if (meshLoaded)
-                        meshLoaded(mesh);
-                })
-                    .catch(function (message) {
-                    BABYLON.Tools.Warn(message);
-                    // We failed to load our custom models; fall back and attempt to the generic model.
-                    _super.prototype.initControllerMesh.call(_this, scene, meshLoaded);
-                });
+                filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
             }
             }
-        };
-        /**
-         * Starts a load request to get model data from the remote server, then parse it to ensure a valid format.
-         * If the first attempt fails, a second attempt will be made to retrieve a fallback model which is (non specific to the device ID suffix)
-         *
-         * @param scene in which to insert new Meshes
-         * @return A promise that resolves with the mesh that represents the loaded controller model, or rejects with an error message.
-         */
-        WindowsMotionController.prototype.loadModel = function (scene) {
-            var _this = this;
-            var self = this;
-            return new Promise(function (resolve, reject) {
-                // First attempt, use ID Suffix specific URL
-                attemptLoad(_this.createControllerModelUrl(false))
-                    .then(resolve)
-                    .catch(function (message) {
-                    BABYLON.Tools.Warn(message);
-                    // Second attempt, use fallback URL
-                    attemptLoad(_this.createControllerModelUrl(true))
-                        .then(resolve)
-                        .catch(reject);
-                });
+            var path = WindowsMotionController.MODEL_BASE_URL + device + '/';
+            BABYLON.SceneLoader.ImportMesh("", path, filename, scene, function (meshes) {
+                // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
+                _this._loadedMeshInfo = _this.processModel(scene, meshes);
+                if (!_this._loadedMeshInfo) {
+                    return;
+                }
+                _this.attachToMesh(_this._loadedMeshInfo.rootNode);
+                if (meshLoaded) {
+                    meshLoaded(_this._loadedMeshInfo.rootNode);
+                }
+            }, null, function (scene, message) {
+                BABYLON.Tools.Log(message);
+                BABYLON.Tools.Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
             });
             });
-            function attemptLoad(controllerSrc) {
-                var _this = this;
-                return new Promise(function (resolve, reject) {
-                    BABYLON.SceneLoader.ImportMesh("" /* all meshes */, controllerSrc.path, controllerSrc.name, scene, function (meshes) {
-                        // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
-                        _this._loadedMeshInfo = self.processModel(scene, meshes);
-                        if (_this._loadedMeshInfo) {
-                            // Mesh data processed successfully!
-                            resolve(_this._loadedMeshInfo.rootNode);
-                        }
-                        else {
-                            reject('Failed to parse controller model for device');
-                        }
-                    }, null, function (scene, message) {
-                        BABYLON.Tools.Log(message);
-                        reject('Failed to retrieve controller model from the remote server: ' + controllerSrc.path + controllerSrc.name);
-                    });
-                });
-            }
         };
         };
         /**
         /**
          * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
          * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
@@ -52682,7 +52662,7 @@ var BABYLON;
         WindowsMotionController.prototype.processModel = function (scene, meshes) {
         WindowsMotionController.prototype.processModel = function (scene, meshes) {
             var loadedMeshInfo = null;
             var loadedMeshInfo = null;
             // Create a new mesh to contain the glTF hierarchy
             // Create a new mesh to contain the glTF hierarchy
-            var parentMesh = new BABYLON.Mesh(this._parentMeshName, scene);
+            var parentMesh = new BABYLON.Mesh(this.id + " " + this.hand, scene);
             // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
             // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
             var childMesh = null;
             var childMesh = null;
             for (var i = 0; i < meshes.length; i++) {
             for (var i = 0; i < meshes.length; i++) {
@@ -52711,34 +52691,6 @@ var BABYLON;
             }
             }
             return loadedMeshInfo;
             return loadedMeshInfo;
         };
         };
-        /**
-         * Helper function that constructs a URL from the controller ID suffix, for future proofed
-         * art assets.
-         */
-        WindowsMotionController.prototype.createControllerModelUrl = function (forceDefault) {
-            // Determine the device specific folder based on the ID suffix
-            var device = 'default';
-            if (!forceDefault) {
-                if (this.id) {
-                    var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
-                    device = ((match && match[0]) || device);
-                }
-            }
-            // Hand
-            var filename;
-            if (this.hand === 'left')
-                filename = WindowsMotionController.MODEL_LEFT_FILENAME;
-            else if (this.hand === 'right')
-                filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
-            else
-                filename = WindowsMotionController.MODEL_UNIVERSAL_FILENAME;
-            // Final url
-            return {
-                //                path: WindowsMotionController.MODEL_BASE_URL + device + '/',
-                path: WindowsMotionController.MODEL_BASE_URL,
-                name: filename
-            };
-        };
         WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
         WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
             var loadedMeshInfo = new LoadedMeshInfo();
             var loadedMeshInfo = new LoadedMeshInfo();
             var i;
             var i;
@@ -52816,27 +52768,22 @@ var BABYLON;
                 return node.getChildMeshes(true, function (n) { return n.name == name; })[0];
                 return node.getChildMeshes(true, function (n) { return n.name == name; })[0];
             }
             }
         };
         };
-        // TODO: Update with final asset URL's
-        WindowsMotionController.MODEL_BASE_URL = 'http://yoda.blob.core.windows.net/models/';
-        WindowsMotionController.MODEL_LEFT_FILENAME = 'genericvrcontroller.babylon';
-        WindowsMotionController.MODEL_RIGHT_FILENAME = 'genericvrcontroller.babylon';
-        WindowsMotionController.MODEL_UNIVERSAL_FILENAME = 'genericvrcontroller.babylon';
+        WindowsMotionController.prototype.dispose = function () {
+            _super.prototype.dispose.call(this);
+            this.onTrackpadChangedObservable.clear();
+        };
+        WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/';
+        WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
+        WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
         WindowsMotionController.MODEL_ROOT_NODE_NAME = 'RootNode';
         WindowsMotionController.MODEL_ROOT_NODE_NAME = 'RootNode';
         WindowsMotionController.GLTF_ROOT_TRANSFORM_NAME = 'root';
         WindowsMotionController.GLTF_ROOT_TRANSFORM_NAME = 'root';
         WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
         WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
         WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
         WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
-        // TODO: Why do we need to flip the model around? Art asset or BabylonJS specific?
+        // Art assets is backward facing
         WindowsMotionController.ROTATE_OFFSET = [Math.PI, 0, 0]; // x, y, z.
         WindowsMotionController.ROTATE_OFFSET = [Math.PI, 0, 0]; // x, y, z.
         return WindowsMotionController;
         return WindowsMotionController;
-    }(BABYLON.GenericController));
+    }(BABYLON.WebVRController));
     BABYLON.WindowsMotionController = WindowsMotionController;
     BABYLON.WindowsMotionController = WindowsMotionController;
-    var LoadedMeshInfo = (function () {
-        function LoadedMeshInfo() {
-            this.buttonMeshes = {};
-            this.axisMeshes = {};
-        }
-        return LoadedMeshInfo;
-    }());
 })(BABYLON || (BABYLON = {}));
 })(BABYLON || (BABYLON = {}));
 
 
 //# sourceMappingURL=babylon.windowsMotionController.js.map
 //# sourceMappingURL=babylon.windowsMotionController.js.map

文件差异内容过多而无法显示
+ 4334 - 4347
dist/preview release/babylon.module.d.ts


文件差异内容过多而无法显示
+ 13 - 13
dist/preview release/babylon.worker.js


文件差异内容过多而无法显示
+ 10148 - 10159
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


文件差异内容过多而无法显示
+ 47 - 47
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 87 - 115
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -7629,6 +7629,7 @@ var BABYLON;
              * Observable event triggered each time the canvas receives pointerout event
              * Observable event triggered each time the canvas receives pointerout event
              */
              */
             this.onCanvasPointerOutObservable = new BABYLON.Observable();
             this.onCanvasPointerOutObservable = new BABYLON.Observable();
+            this._vrExclusivePointerMode = false;
             // Uniform buffers list
             // Uniform buffers list
             this.disableUniformBuffers = false;
             this.disableUniformBuffers = false;
             this._uniformBuffers = new Array();
             this._uniformBuffers = new Array();
@@ -7859,9 +7860,13 @@ var BABYLON;
                 document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
                 document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
                 document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
                 document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
                 this._onVRDisplayPointerRestricted = function () {
                 this._onVRDisplayPointerRestricted = function () {
+                    _this._vrExclusivePointerMode = true;
+                    console.log("enter");
                     canvas.requestPointerLock();
                     canvas.requestPointerLock();
                 };
                 };
                 this._onVRDisplayPointerUnrestricted = function () {
                 this._onVRDisplayPointerUnrestricted = function () {
+                    _this._vrExclusivePointerMode = false;
+                    console.log("exit");
                     document.exitPointerLock();
                     document.exitPointerLock();
                 };
                 };
                 window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
                 window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
@@ -8214,6 +8219,13 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
+        Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
+            get: function () {
+                return this._vrExclusivePointerMode;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
         Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
             get: function () {
             get: function () {
                 return this.webGLVersion > 1 && !this.disableUniformBuffers;
                 return this.webGLVersion > 1 && !this.disableUniformBuffers;
@@ -34375,6 +34387,9 @@ var BABYLON;
             if (!this._pointerInput) {
             if (!this._pointerInput) {
                 this._pointerInput = function (p, s) {
                 this._pointerInput = function (p, s) {
                     var evt = p.event;
                     var evt = p.event;
+                    if (engine.isInVRExclusivePointerMode) {
+                        return;
+                    }
                     if (!_this.touchEnabled && evt.pointerType === "touch") {
                     if (!_this.touchEnabled && evt.pointerType === "touch") {
                         return;
                         return;
                     }
                     }
@@ -34436,6 +34451,9 @@ var BABYLON;
                 if (!engine.isPointerLock) {
                 if (!engine.isPointerLock) {
                     return;
                     return;
                 }
                 }
+                if (engine.isInVRExclusivePointerMode) {
+                    return;
+                }
                 var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
                 var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
                 var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
                 var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
                 if (_this.camera.getScene().useRightHandedSystem) {
                 if (_this.camera.getScene().useRightHandedSystem) {
@@ -35381,6 +35399,9 @@ var BABYLON;
             var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false };
             var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false };
             this._pointerInput = function (p, s) {
             this._pointerInput = function (p, s) {
                 var evt = p.event;
                 var evt = p.event;
+                if (engine.isInVRExclusivePointerMode) {
+                    return;
+                }
                 if (p.type !== BABYLON.PointerEventTypes.POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
                 if (p.type !== BABYLON.PointerEventTypes.POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
                     return;
                     return;
                 }
                 }
@@ -52101,6 +52122,7 @@ var BABYLON;
         __extends(WebVRController, _super);
         __extends(WebVRController, _super);
         function WebVRController(vrGamepad) {
         function WebVRController(vrGamepad) {
             var _this = _super.call(this, vrGamepad) || this;
             var _this = _super.call(this, vrGamepad) || this;
+            // Observables
             _this.onTriggerStateChangedObservable = new BABYLON.Observable();
             _this.onTriggerStateChangedObservable = new BABYLON.Observable();
             _this.onMainButtonStateChangedObservable = new BABYLON.Observable();
             _this.onMainButtonStateChangedObservable = new BABYLON.Observable();
             _this.onSecondaryButtonStateChangedObservable = new BABYLON.Observable();
             _this.onSecondaryButtonStateChangedObservable = new BABYLON.Observable();
@@ -52173,6 +52195,14 @@ var BABYLON;
             this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
             this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
             return this._changes;
             return this._changes;
         };
         };
+        WebVRController.prototype.dispose = function () {
+            _super.prototype.dispose.call(this);
+            this.onTriggerStateChangedObservable.clear();
+            this.onMainButtonStateChangedObservable.clear();
+            this.onSecondaryButtonStateChangedObservable.clear();
+            this.onPadStateChangedObservable.clear();
+            this.onPadValuesChangedObservable.clear();
+        };
         return WebVRController;
         return WebVRController;
     }(BABYLON.PoseEnabledController));
     }(BABYLON.PoseEnabledController));
     BABYLON.WebVRController = WebVRController;
     BABYLON.WebVRController = WebVRController;
@@ -52451,6 +52481,13 @@ var BABYLON;
 
 
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {
+    var LoadedMeshInfo = (function () {
+        function LoadedMeshInfo() {
+            this.buttonMeshes = {};
+            this.axisMeshes = {};
+        }
+        return LoadedMeshInfo;
+    }());
     var WindowsMotionController = (function (_super) {
     var WindowsMotionController = (function (_super) {
         __extends(WindowsMotionController, _super);
         __extends(WindowsMotionController, _super);
         function WindowsMotionController(vrGamepad) {
         function WindowsMotionController(vrGamepad) {
@@ -52488,7 +52525,6 @@ var BABYLON;
             };
             };
             _this.onTrackpadChangedObservable = new BABYLON.Observable();
             _this.onTrackpadChangedObservable = new BABYLON.Observable();
             _this.controllerType = BABYLON.PoseEnabledControllerType.WINDOWS;
             _this.controllerType = BABYLON.PoseEnabledControllerType.WINDOWS;
-            _this._parentMeshName = _this.id + " " + _this.hand;
             _this._loadedMeshInfo = null;
             _this._loadedMeshInfo = null;
             return _this;
             return _this;
         }
         }
@@ -52549,8 +52585,9 @@ var BABYLON;
          */
          */
         WindowsMotionController.prototype.handleButtonChange = function (buttonIdx, state, changes) {
         WindowsMotionController.prototype.handleButtonChange = function (buttonIdx, state, changes) {
             var buttonName = this._mapping.buttons[buttonIdx];
             var buttonName = this._mapping.buttons[buttonIdx];
-            if (!buttonName)
+            if (!buttonName) {
                 return;
                 return;
+            }
             // Only emit events for buttons that we know how to map from index to name
             // Only emit events for buttons that we know how to map from index to name
             var observable = this[this._mapping.buttonObservableNames[buttonName]];
             var observable = this[this._mapping.buttonObservableNames[buttonName]];
             if (observable) {
             if (observable) {
@@ -52560,16 +52597,18 @@ var BABYLON;
         };
         };
         WindowsMotionController.prototype.lerpButtonTransform = function (buttonName, buttonValue) {
         WindowsMotionController.prototype.lerpButtonTransform = function (buttonName, buttonValue) {
             // If there is no loaded mesh, there is nothing to transform.
             // If there is no loaded mesh, there is nothing to transform.
-            if (!this._loadedMeshInfo)
+            if (!this._loadedMeshInfo) {
                 return;
                 return;
+            }
             var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
             var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
             BABYLON.Quaternion.SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
             BABYLON.Quaternion.SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
             BABYLON.Vector3.LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
             BABYLON.Vector3.LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
         };
         };
         WindowsMotionController.prototype.lerpAxisTransform = function (axis, axisValue) {
         WindowsMotionController.prototype.lerpAxisTransform = function (axis, axisValue) {
             var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
             var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
-            if (!meshInfo)
+            if (!meshInfo) {
                 return;
                 return;
+            }
             // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
             // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
             var lerpValue = axisValue * 0.5 + 0.5;
             var lerpValue = axisValue * 0.5 + 0.5;
             BABYLON.Quaternion.SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
             BABYLON.Quaternion.SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
@@ -52582,73 +52621,35 @@ var BABYLON;
          */
          */
         WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded) {
         WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded) {
             var _this = this;
             var _this = this;
-            var parentMesh = scene.getMeshByName(this._parentMeshName);
-            if (parentMesh) {
-                // A mesh with the name we are expecting already exists in the scene, use that.
-                if (!this._loadedMeshInfo) {
-                    // Create our mesh info. Note that this method will always return non-null.
-                    this._loadedMeshInfo = this.createMeshInfo(parentMesh);
-                    this.attachToMesh(this._loadedMeshInfo.rootNode);
-                }
-                if (meshLoaded)
-                    meshLoaded(this._loadedMeshInfo.rootNode);
+            // Determine the device specific folder based on the ID suffix
+            var device = 'default';
+            if (this.id) {
+                var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
+                device = ((match && match[0]) || device);
+            }
+            // Hand
+            var filename;
+            if (this.hand === 'left') {
+                filename = WindowsMotionController.MODEL_LEFT_FILENAME;
             }
             }
             else {
             else {
-                // Make a call to load a mesh from CDN
-                this.loadModel(scene)
-                    .then(function (mesh) {
-                    _this.attachToMesh(mesh);
-                    if (meshLoaded)
-                        meshLoaded(mesh);
-                })
-                    .catch(function (message) {
-                    BABYLON.Tools.Warn(message);
-                    // We failed to load our custom models; fall back and attempt to the generic model.
-                    _super.prototype.initControllerMesh.call(_this, scene, meshLoaded);
-                });
+                filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
             }
             }
-        };
-        /**
-         * Starts a load request to get model data from the remote server, then parse it to ensure a valid format.
-         * If the first attempt fails, a second attempt will be made to retrieve a fallback model which is (non specific to the device ID suffix)
-         *
-         * @param scene in which to insert new Meshes
-         * @return A promise that resolves with the mesh that represents the loaded controller model, or rejects with an error message.
-         */
-        WindowsMotionController.prototype.loadModel = function (scene) {
-            var _this = this;
-            var self = this;
-            return new Promise(function (resolve, reject) {
-                // First attempt, use ID Suffix specific URL
-                attemptLoad(_this.createControllerModelUrl(false))
-                    .then(resolve)
-                    .catch(function (message) {
-                    BABYLON.Tools.Warn(message);
-                    // Second attempt, use fallback URL
-                    attemptLoad(_this.createControllerModelUrl(true))
-                        .then(resolve)
-                        .catch(reject);
-                });
+            var path = WindowsMotionController.MODEL_BASE_URL + device + '/';
+            BABYLON.SceneLoader.ImportMesh("", path, filename, scene, function (meshes) {
+                // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
+                _this._loadedMeshInfo = _this.processModel(scene, meshes);
+                if (!_this._loadedMeshInfo) {
+                    return;
+                }
+                _this.attachToMesh(_this._loadedMeshInfo.rootNode);
+                if (meshLoaded) {
+                    meshLoaded(_this._loadedMeshInfo.rootNode);
+                }
+            }, null, function (scene, message) {
+                BABYLON.Tools.Log(message);
+                BABYLON.Tools.Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
             });
             });
-            function attemptLoad(controllerSrc) {
-                var _this = this;
-                return new Promise(function (resolve, reject) {
-                    BABYLON.SceneLoader.ImportMesh("" /* all meshes */, controllerSrc.path, controllerSrc.name, scene, function (meshes) {
-                        // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
-                        _this._loadedMeshInfo = self.processModel(scene, meshes);
-                        if (_this._loadedMeshInfo) {
-                            // Mesh data processed successfully!
-                            resolve(_this._loadedMeshInfo.rootNode);
-                        }
-                        else {
-                            reject('Failed to parse controller model for device');
-                        }
-                    }, null, function (scene, message) {
-                        BABYLON.Tools.Log(message);
-                        reject('Failed to retrieve controller model from the remote server: ' + controllerSrc.path + controllerSrc.name);
-                    });
-                });
-            }
         };
         };
         /**
         /**
          * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
          * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
@@ -52661,7 +52662,7 @@ var BABYLON;
         WindowsMotionController.prototype.processModel = function (scene, meshes) {
         WindowsMotionController.prototype.processModel = function (scene, meshes) {
             var loadedMeshInfo = null;
             var loadedMeshInfo = null;
             // Create a new mesh to contain the glTF hierarchy
             // Create a new mesh to contain the glTF hierarchy
-            var parentMesh = new BABYLON.Mesh(this._parentMeshName, scene);
+            var parentMesh = new BABYLON.Mesh(this.id + " " + this.hand, scene);
             // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
             // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
             var childMesh = null;
             var childMesh = null;
             for (var i = 0; i < meshes.length; i++) {
             for (var i = 0; i < meshes.length; i++) {
@@ -52690,34 +52691,6 @@ var BABYLON;
             }
             }
             return loadedMeshInfo;
             return loadedMeshInfo;
         };
         };
-        /**
-         * Helper function that constructs a URL from the controller ID suffix, for future proofed
-         * art assets.
-         */
-        WindowsMotionController.prototype.createControllerModelUrl = function (forceDefault) {
-            // Determine the device specific folder based on the ID suffix
-            var device = 'default';
-            if (!forceDefault) {
-                if (this.id) {
-                    var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
-                    device = ((match && match[0]) || device);
-                }
-            }
-            // Hand
-            var filename;
-            if (this.hand === 'left')
-                filename = WindowsMotionController.MODEL_LEFT_FILENAME;
-            else if (this.hand === 'right')
-                filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
-            else
-                filename = WindowsMotionController.MODEL_UNIVERSAL_FILENAME;
-            // Final url
-            return {
-                //                path: WindowsMotionController.MODEL_BASE_URL + device + '/',
-                path: WindowsMotionController.MODEL_BASE_URL,
-                name: filename
-            };
-        };
         WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
         WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
             var loadedMeshInfo = new LoadedMeshInfo();
             var loadedMeshInfo = new LoadedMeshInfo();
             var i;
             var i;
@@ -52795,27 +52768,22 @@ var BABYLON;
                 return node.getChildMeshes(true, function (n) { return n.name == name; })[0];
                 return node.getChildMeshes(true, function (n) { return n.name == name; })[0];
             }
             }
         };
         };
-        // TODO: Update with final asset URL's
-        WindowsMotionController.MODEL_BASE_URL = 'http://yoda.blob.core.windows.net/models/';
-        WindowsMotionController.MODEL_LEFT_FILENAME = 'genericvrcontroller.babylon';
-        WindowsMotionController.MODEL_RIGHT_FILENAME = 'genericvrcontroller.babylon';
-        WindowsMotionController.MODEL_UNIVERSAL_FILENAME = 'genericvrcontroller.babylon';
+        WindowsMotionController.prototype.dispose = function () {
+            _super.prototype.dispose.call(this);
+            this.onTrackpadChangedObservable.clear();
+        };
+        WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/';
+        WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
+        WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
         WindowsMotionController.MODEL_ROOT_NODE_NAME = 'RootNode';
         WindowsMotionController.MODEL_ROOT_NODE_NAME = 'RootNode';
         WindowsMotionController.GLTF_ROOT_TRANSFORM_NAME = 'root';
         WindowsMotionController.GLTF_ROOT_TRANSFORM_NAME = 'root';
         WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
         WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
         WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
         WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
-        // TODO: Why do we need to flip the model around? Art asset or BabylonJS specific?
+        // Art assets is backward facing
         WindowsMotionController.ROTATE_OFFSET = [Math.PI, 0, 0]; // x, y, z.
         WindowsMotionController.ROTATE_OFFSET = [Math.PI, 0, 0]; // x, y, z.
         return WindowsMotionController;
         return WindowsMotionController;
-    }(BABYLON.GenericController));
+    }(BABYLON.WebVRController));
     BABYLON.WindowsMotionController = WindowsMotionController;
     BABYLON.WindowsMotionController = WindowsMotionController;
-    var LoadedMeshInfo = (function () {
-        function LoadedMeshInfo() {
-            this.buttonMeshes = {};
-            this.axisMeshes = {};
-        }
-        return LoadedMeshInfo;
-    }());
 })(BABYLON || (BABYLON = {}));
 })(BABYLON || (BABYLON = {}));
 
 
 //# sourceMappingURL=babylon.windowsMotionController.js.map
 //# sourceMappingURL=babylon.windowsMotionController.js.map
@@ -75132,21 +75100,25 @@ var BABYLON;
                 }
                 }
             };
             };
             GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
             GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
-                var rootMesh = new BABYLON.Mesh("root", this._babylonScene);
-                rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
-                rootMesh.rotation.y = Math.PI;
+                this._rootMesh = new BABYLON.Mesh("root", this._babylonScene);
+                this._rootMesh.isVisible = false;
+                this._rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
+                this._rootMesh.rotation.y = Math.PI;
                 var nodes = this._gltf.nodes;
                 var nodes = this._gltf.nodes;
                 if (nodes) {
                 if (nodes) {
                     for (var i = 0; i < nodes.length; i++) {
                     for (var i = 0; i < nodes.length; i++) {
                         var mesh = nodes[i].babylonMesh;
                         var mesh = nodes[i].babylonMesh;
                         if (mesh && !mesh.parent) {
                         if (mesh && !mesh.parent) {
-                            mesh.parent = rootMesh;
+                            mesh.parent = this._rootMesh;
                         }
                         }
                     }
                     }
                 }
                 }
             };
             };
             GLTFLoader.prototype._getMeshes = function () {
             GLTFLoader.prototype._getMeshes = function () {
                 var meshes = [];
                 var meshes = [];
+                if (this._rootMesh) {
+                    meshes.push(this._rootMesh);
+                }
                 var nodes = this._gltf.nodes;
                 var nodes = this._gltf.nodes;
                 if (nodes) {
                 if (nodes) {
                     nodes.forEach(function (node) {
                     nodes.forEach(function (node) {
@@ -76090,7 +76062,7 @@ var BABYLON;
             GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
             GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
                 // Set defaults if undefined
                 // Set defaults if undefined
                 magFilter = magFilter === undefined ? GLTF2.ETextureMagFilter.LINEAR : magFilter;
                 magFilter = magFilter === undefined ? GLTF2.ETextureMagFilter.LINEAR : magFilter;
-                minFilter = minFilter === undefined ? GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST : minFilter;
+                minFilter = minFilter === undefined ? GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR : minFilter;
                 if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
                 if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
                     switch (minFilter) {
                     switch (minFilter) {
                         case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;
                         case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;

文件差异内容过多而无法显示
+ 10148 - 10159
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/gui/babylon.gui.min.js


文件差异内容过多而无法显示
+ 263 - 263
dist/preview release/inspector/babylon.inspector.bundle.js


文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


+ 1 - 0
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -301,6 +301,7 @@ declare module BABYLON.GLTF2 {
         private _disposed;
         private _disposed;
         private _blockPendingTracking;
         private _blockPendingTracking;
         private _nonBlockingData;
         private _nonBlockingData;
+        private _rootMesh;
         private _renderReadyObservable;
         private _renderReadyObservable;
         private _renderPendingCount;
         private _renderPendingCount;
         private _loaderPendingCount;
         private _loaderPendingCount;

+ 9 - 5
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -462,21 +462,25 @@ var BABYLON;
                 }
                 }
             };
             };
             GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
             GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
-                var rootMesh = new BABYLON.Mesh("root", this._babylonScene);
-                rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
-                rootMesh.rotation.y = Math.PI;
+                this._rootMesh = new BABYLON.Mesh("root", this._babylonScene);
+                this._rootMesh.isVisible = false;
+                this._rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
+                this._rootMesh.rotation.y = Math.PI;
                 var nodes = this._gltf.nodes;
                 var nodes = this._gltf.nodes;
                 if (nodes) {
                 if (nodes) {
                     for (var i = 0; i < nodes.length; i++) {
                     for (var i = 0; i < nodes.length; i++) {
                         var mesh = nodes[i].babylonMesh;
                         var mesh = nodes[i].babylonMesh;
                         if (mesh && !mesh.parent) {
                         if (mesh && !mesh.parent) {
-                            mesh.parent = rootMesh;
+                            mesh.parent = this._rootMesh;
                         }
                         }
                     }
                     }
                 }
                 }
             };
             };
             GLTFLoader.prototype._getMeshes = function () {
             GLTFLoader.prototype._getMeshes = function () {
                 var meshes = [];
                 var meshes = [];
+                if (this._rootMesh) {
+                    meshes.push(this._rootMesh);
+                }
                 var nodes = this._gltf.nodes;
                 var nodes = this._gltf.nodes;
                 if (nodes) {
                 if (nodes) {
                     nodes.forEach(function (node) {
                     nodes.forEach(function (node) {
@@ -1420,7 +1424,7 @@ var BABYLON;
             GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
             GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
                 // Set defaults if undefined
                 // Set defaults if undefined
                 magFilter = magFilter === undefined ? GLTF2.ETextureMagFilter.LINEAR : magFilter;
                 magFilter = magFilter === undefined ? GLTF2.ETextureMagFilter.LINEAR : magFilter;
-                minFilter = minFilter === undefined ? GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST : minFilter;
+                minFilter = minFilter === undefined ? GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR : minFilter;
                 if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
                 if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
                     switch (minFilter) {
                     switch (minFilter) {
                         case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;
                         case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 1 - 0
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -797,6 +797,7 @@ declare module BABYLON.GLTF2 {
         private _disposed;
         private _disposed;
         private _blockPendingTracking;
         private _blockPendingTracking;
         private _nonBlockingData;
         private _nonBlockingData;
+        private _rootMesh;
         private _renderReadyObservable;
         private _renderReadyObservable;
         private _renderPendingCount;
         private _renderPendingCount;
         private _loaderPendingCount;
         private _loaderPendingCount;

+ 9 - 5
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2620,21 +2620,25 @@ var BABYLON;
                 }
                 }
             };
             };
             GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
             GLTFLoader.prototype._addRightHandToLeftHandRootTransform = function () {
-                var rootMesh = new BABYLON.Mesh("root", this._babylonScene);
-                rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
-                rootMesh.rotation.y = Math.PI;
+                this._rootMesh = new BABYLON.Mesh("root", this._babylonScene);
+                this._rootMesh.isVisible = false;
+                this._rootMesh.scaling = new BABYLON.Vector3(1, 1, -1);
+                this._rootMesh.rotation.y = Math.PI;
                 var nodes = this._gltf.nodes;
                 var nodes = this._gltf.nodes;
                 if (nodes) {
                 if (nodes) {
                     for (var i = 0; i < nodes.length; i++) {
                     for (var i = 0; i < nodes.length; i++) {
                         var mesh = nodes[i].babylonMesh;
                         var mesh = nodes[i].babylonMesh;
                         if (mesh && !mesh.parent) {
                         if (mesh && !mesh.parent) {
-                            mesh.parent = rootMesh;
+                            mesh.parent = this._rootMesh;
                         }
                         }
                     }
                     }
                 }
                 }
             };
             };
             GLTFLoader.prototype._getMeshes = function () {
             GLTFLoader.prototype._getMeshes = function () {
                 var meshes = [];
                 var meshes = [];
+                if (this._rootMesh) {
+                    meshes.push(this._rootMesh);
+                }
                 var nodes = this._gltf.nodes;
                 var nodes = this._gltf.nodes;
                 if (nodes) {
                 if (nodes) {
                     nodes.forEach(function (node) {
                     nodes.forEach(function (node) {
@@ -3578,7 +3582,7 @@ var BABYLON;
             GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
             GLTFUtils.GetTextureSamplingMode = function (magFilter, minFilter) {
                 // Set defaults if undefined
                 // Set defaults if undefined
                 magFilter = magFilter === undefined ? GLTF2.ETextureMagFilter.LINEAR : magFilter;
                 magFilter = magFilter === undefined ? GLTF2.ETextureMagFilter.LINEAR : magFilter;
-                minFilter = minFilter === undefined ? GLTF2.ETextureMinFilter.LINEAR_MIPMAP_NEAREST : minFilter;
+                minFilter = minFilter === undefined ? GLTF2.ETextureMinFilter.LINEAR_MIPMAP_LINEAR : minFilter;
                 if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
                 if (magFilter === GLTF2.ETextureMagFilter.LINEAR) {
                     switch (minFilter) {
                     switch (minFilter) {
                         case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;
                         case GLTF2.ETextureMinFilter.NEAREST: return BABYLON.Texture.LINEAR_NEAREST;

文件差异内容过多而无法显示
+ 3 - 3
dist/preview release/loaders/babylon.glTFFileLoader.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


+ 12 - 4
src/Gamepad/Controllers/babylon.webVRController.ts

@@ -4,12 +4,10 @@ module BABYLON {
 
 
         protected _defaultModel: AbstractMesh;
         protected _defaultModel: AbstractMesh;
 
 
+        // Observables
         public onTriggerStateChangedObservable = new Observable<ExtendedGamepadButton>();
         public onTriggerStateChangedObservable = new Observable<ExtendedGamepadButton>();
-
         public onMainButtonStateChangedObservable = new Observable<ExtendedGamepadButton>();
         public onMainButtonStateChangedObservable = new Observable<ExtendedGamepadButton>();
-
         public onSecondaryButtonStateChangedObservable = new Observable<ExtendedGamepadButton>();
         public onSecondaryButtonStateChangedObservable = new Observable<ExtendedGamepadButton>();
-
         public onPadStateChangedObservable = new Observable<ExtendedGamepadButton>();
         public onPadStateChangedObservable = new Observable<ExtendedGamepadButton>();
         public onPadValuesChangedObservable = new Observable<StickValues>();
         public onPadValuesChangedObservable = new Observable<StickValues>();
 
 
@@ -94,6 +92,16 @@ module BABYLON {
             this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
             this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
             return this._changes;
             return this._changes;
         }
         }
+
+        public dispose(): void {
+            super.dispose();
+
+            this.onTriggerStateChangedObservable.clear();
+            this.onMainButtonStateChangedObservable.clear();
+            this.onSecondaryButtonStateChangedObservable.clear();
+            this.onPadStateChangedObservable.clear();
+            this.onPadValuesChangedObservable.clear();
+        }
     }
     }
         
         
-}
+}

+ 66 - 69
src/Gamepad/Controllers/babylon.windowsMotionController.ts

@@ -1,22 +1,43 @@
 module BABYLON {
 module BABYLON {
-    export class WindowsMotionController extends GenericController {
 
 
-        // TODO: Update with final asset URL's
-        private static readonly MODEL_BASE_URL:string = 'http://yoda.blob.core.windows.net/models/';
-        private static readonly MODEL_LEFT_FILENAME:string = 'genericvrcontroller.babylon';
-        private static readonly MODEL_RIGHT_FILENAME:string = 'genericvrcontroller.babylon';
-        private static readonly MODEL_UNIVERSAL_FILENAME:string = 'genericvrcontroller.babylon';
+    class LoadedMeshInfo {
+        public rootNode: AbstractMesh;
+        public pointingPoseNode: AbstractMesh;
+        public holdingPoseNode: AbstractMesh;
+        public buttonMeshes: { [id: string] : IButtonMeshInfo; } = {};
+        public axisMeshes: { [id: number] : IAxisMeshInfo; } = {};
+    }
+
+    interface IMeshInfo {
+        index: number;
+        value: AbstractMesh;
+    }
+
+    interface IButtonMeshInfo extends IMeshInfo {
+        pressed: AbstractMesh;
+        unpressed: AbstractMesh;
+    }
+
+    interface IAxisMeshInfo extends IMeshInfo {
+        min: AbstractMesh;
+        max: AbstractMesh;
+    }
+
+    export class WindowsMotionController extends WebVRController {
+        private static readonly MODEL_BASE_URL:string = 'https://controllers.babylonjs.com/';
+        private static readonly MODEL_LEFT_FILENAME:string = 'left.glb';
+        private static readonly MODEL_RIGHT_FILENAME:string = 'right.glb';
         private static readonly MODEL_ROOT_NODE_NAME:string = 'RootNode';
         private static readonly MODEL_ROOT_NODE_NAME:string = 'RootNode';
         private static readonly GLTF_ROOT_TRANSFORM_NAME:string = 'root';
         private static readonly GLTF_ROOT_TRANSFORM_NAME:string = 'root';
 
 
         public static readonly GAMEPAD_ID_PREFIX:string = 'Spatial Controller (Spatial Interaction Source) ';
         public static readonly GAMEPAD_ID_PREFIX:string = 'Spatial Controller (Spatial Interaction Source) ';
         private static readonly GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
         private static readonly GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
 
 
-        // TODO: Why do we need to flip the model around? Art asset or BabylonJS specific?
+        // Art assets is backward facing
         private static readonly ROTATE_OFFSET:number[] = [Math.PI, 0, 0]; // x, y, z.
         private static readonly ROTATE_OFFSET:number[] = [Math.PI, 0, 0]; // x, y, z.
 
 
         private _loadedMeshInfo: LoadedMeshInfo;
         private _loadedMeshInfo: LoadedMeshInfo;
-        private readonly _mapping : IControllerMappingInfo = {
+        private readonly _mapping = {
             // Semantic button names
             // Semantic button names
             buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
             buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
             // A mapping of the button name to glTF model node name
             // A mapping of the button name to glTF model node name
@@ -56,23 +77,23 @@ module BABYLON {
             this._loadedMeshInfo = null;
             this._loadedMeshInfo = null;
         }
         }
         
         
-        public get onTriggerButtonStateChangedObservable() {
+        public get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onTriggerStateChangedObservable;
             return this.onTriggerStateChangedObservable;
         }
         }
 
 
-        public get onMenuButtonStateChangedObservable() {
+        public get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onSecondaryButtonStateChangedObservable;
             return this.onSecondaryButtonStateChangedObservable;
         }
         }
 
 
-        public get onGripButtonStateChangedObservable() {
+        public get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onMainButtonStateChangedObservable;
             return this.onMainButtonStateChangedObservable;
         }
         }
 
 
-        public get onThumbstickButtonStateChangedObservable() {
+        public get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onPadStateChangedObservable;
             return this.onPadStateChangedObservable;
         }    
         }    
 
 
-        public get onTouchpadButtonStateChangedObservable() {
+        public get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton> {
             return this.onTrackpadChangedObservable;
             return this.onTrackpadChangedObservable;
         }
         }
         
         
@@ -100,7 +121,9 @@ module BABYLON {
          */
          */
         protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges) {
         protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges) {
             let buttonName = this._mapping.buttons[buttonIdx];
             let buttonName = this._mapping.buttons[buttonIdx];
-            if (!buttonName) return; 
+            if (!buttonName) {
+                return; 
+            }
 
 
             // Only emit events for buttons that we know how to map from index to name
             // Only emit events for buttons that we know how to map from index to name
             let observable = this[this._mapping.buttonObservableNames[buttonName]];
             let observable = this[this._mapping.buttonObservableNames[buttonName]];
@@ -114,7 +137,9 @@ module BABYLON {
         protected lerpButtonTransform(buttonName: string, buttonValue: number) {
         protected lerpButtonTransform(buttonName: string, buttonValue: number) {
             
             
             // If there is no loaded mesh, there is nothing to transform.
             // If there is no loaded mesh, there is nothing to transform.
-            if (!this._loadedMeshInfo) return;
+            if (!this._loadedMeshInfo) {
+                return;
+            }
 
 
             var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
             var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
             BABYLON.Quaternion.SlerpToRef(
             BABYLON.Quaternion.SlerpToRef(
@@ -131,7 +156,9 @@ module BABYLON {
         
         
         protected lerpAxisTransform(axis:number, axisValue: number) {
         protected lerpAxisTransform(axis:number, axisValue: number) {
             let meshInfo = this._loadedMeshInfo.axisMeshes[axis];
             let meshInfo = this._loadedMeshInfo.axisMeshes[axis];
-            if (!meshInfo) return;
+            if (!meshInfo) {
+                return;
+            }
 
 
             // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
             // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
             let lerpValue = axisValue * 0.5 + 0.5;
             let lerpValue = axisValue * 0.5 + 0.5;
@@ -154,39 +181,40 @@ module BABYLON {
          */
          */
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {
         public initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void) {
             // Determine the device specific folder based on the ID suffix
             // Determine the device specific folder based on the ID suffix
-            var device = 'default';
+            let device = 'default';
             if (this.id) {
             if (this.id) {
-                var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
+                let match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
                 device = ((match && match[0]) || device);
                 device = ((match && match[0]) || device);
             }
             }
 
 
             // Hand
             // Hand
-            var filename;
+            let filename: string;
             if (this.hand === 'left') {
             if (this.hand === 'left') {
                 filename = WindowsMotionController.MODEL_LEFT_FILENAME;
                 filename = WindowsMotionController.MODEL_LEFT_FILENAME;
             }
             }
-            else if (this.hand === 'right') {
+            else { // Right is the default if no hand is specified
                 filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
                 filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
             }
             }
-            else {
-                filename = WindowsMotionController.MODEL_UNIVERSAL_FILENAME;
-            }
 
 
             let path = WindowsMotionController.MODEL_BASE_URL + device + '/';
             let path = WindowsMotionController.MODEL_BASE_URL + device + '/';
 
 
             SceneLoader.ImportMesh("", path, filename, scene, (meshes: AbstractMesh[]) => {
             SceneLoader.ImportMesh("", path, filename, scene, (meshes: AbstractMesh[]) => {
-                    // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
-                    this._loadedMeshInfo = this.processModel(scene, meshes);
+                // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
+                this._loadedMeshInfo = this.processModel(scene, meshes);
 
 
-                    this.attachToMesh(this._loadedMeshInfo.rootNode);
-                    if (meshLoaded) {
-                        meshLoaded(this._loadedMeshInfo.rootNode);
-                    }
-                }, 
-                null, 
-                (scene: Scene, message: string) => {
-                    Tools.Log(message);
-                    Tools.Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
+                if (!this._loadedMeshInfo) {
+                    return;
+                }
+
+                this._defaultModel = this._loadedMeshInfo.rootNode;
+                this.attachToMesh(this._defaultModel);
+                
+                if (meshLoaded) {
+                    meshLoaded(this._defaultModel);
+                }
+            }, null, (scene: Scene, message: string) => {
+                Tools.Log(message);
+                Tools.Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
             });
             });
         }
         }
 
 
@@ -199,7 +227,6 @@ module BABYLON {
          * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
          * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
          */
          */
         private processModel(scene: Scene, meshes: AbstractMesh[]) : LoadedMeshInfo {
         private processModel(scene: Scene, meshes: AbstractMesh[]) : LoadedMeshInfo {
-
             let loadedMeshInfo = null;
             let loadedMeshInfo = null;
 
 
             // Create a new mesh to contain the glTF hierarchy
             // Create a new mesh to contain the glTF hierarchy
@@ -240,7 +267,6 @@ module BABYLON {
         }
         }
         
         
         private createMeshInfo(rootNode: AbstractMesh) : LoadedMeshInfo {
         private createMeshInfo(rootNode: AbstractMesh) : LoadedMeshInfo {
-
             let loadedMeshInfo = new LoadedMeshInfo();
             let loadedMeshInfo = new LoadedMeshInfo();
             var i;
             var i;
             loadedMeshInfo.rootNode = rootNode;
             loadedMeshInfo.rootNode = rootNode;
@@ -324,40 +350,11 @@ module BABYLON {
                 return node.getChildMeshes(true, n => n.name == name)[0];
                 return node.getChildMeshes(true, n => n.name == name)[0];
             }
             }
         }
         }
-    }
 
 
-    class LoadedMeshInfo {
-        public rootNode: AbstractMesh;
-        public pointingPoseNode: AbstractMesh;
-        public holdingPoseNode: AbstractMesh;
-        public buttonMeshes: { [id: string] : IButtonMeshInfo; } = {};
-        public axisMeshes: { [id: number] : IAxisMeshInfo; } = {};
-    }
+        public dispose(): void {
+            super.dispose();
 
 
-    interface IMeshInfo {
-        index: number;
-        value: AbstractMesh;
-    }
-
-    interface IButtonMeshInfo extends IMeshInfo {
-        pressed: AbstractMesh;
-        unpressed: AbstractMesh;
-    }
-
-    interface IAxisMeshInfo extends IMeshInfo {
-        min: AbstractMesh;
-        max: AbstractMesh;
-    }
-
-    interface IControllerMappingInfo {
-        buttons: string[];
-        buttonMeshNames: { [id: string ] : string };
-        buttonObservableNames: { [id: string ] : string };
-        axisMeshNames: string[];
-    }
-
-    interface IControllerUrl {
-        path: string;
-        name: string;
+            this.onTrackpadChangedObservable.clear();
+        }
     }
     }
 }
 }