Explorar o código

Fix GC and retention point

sebastien %!s(int64=7) %!d(string=hai) anos
pai
achega
12cefda656

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 9000 - 8999
Playground/babylon.d.txt


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 5804 - 5803
dist/preview release/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 29 - 29
dist/preview release/babylon.js


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

@@ -24437,8 +24437,6 @@ var BABYLON;
             if (this._gamepadManager && this._gamepadManager._isMonitoring) {
                 this._gamepadManager._checkGamepadsStatus();
             }
-            // Before render
-            this.onBeforeRenderObservable.notifyObservers(this);
             // Update Cameras
             if (this.activeCameras.length > 0) {
                 for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
@@ -24461,6 +24459,8 @@ var BABYLON;
                     }
                 }
             }
+            // Before render
+            this.onBeforeRenderObservable.notifyObservers(this);
             // Customs render targets
             this.OnBeforeRenderTargetsRenderObservable.notifyObservers(this);
             var engine = this.getEngine();
@@ -44706,6 +44706,7 @@ var BABYLON;
             _this._previousPosition = BABYLON.Vector3.Zero();
             _this._collisionVelocity = BABYLON.Vector3.Zero();
             _this._newPosition = BABYLON.Vector3.Zero();
+            _this._computationVector = BABYLON.Vector3.Zero();
             _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
                 if (collidedMesh === void 0) { collidedMesh = null; }
                 if (_this.getScene().workerCollisions && _this.checkCollisions) {
@@ -44729,7 +44730,8 @@ var BABYLON;
                     sinb = 0.0001;
                 }
                 var target = _this._getTargetPosition();
-                target.addToRef(new BABYLON.Vector3(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb), _this._newPosition);
+                _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
+                target.addToRef(_this._computationVector, _this._newPosition);
                 _this.position.copyFrom(_this._newPosition);
                 var up = _this.upVector;
                 if (_this.allowUpsideDown && _this.beta < 0) {
@@ -45205,18 +45207,18 @@ var BABYLON;
             }
         };
         ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
-            var radiusv3 = this.position.subtract(this._getTargetPosition());
-            this.radius = radiusv3.length();
+            this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
+            this.radius = this._computationVector.length();
             if (this.radius === 0) {
                 this.radius = 0.0001; // Just to avoid division by zero
             }
             // Alpha
-            this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
-            if (radiusv3.z < 0) {
+            this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
+            if (this._computationVector.z < 0) {
                 this.alpha = 2 * Math.PI - this.alpha;
             }
             // Beta
-            this.beta = Math.acos(radiusv3.y / this.radius);
+            this.beta = Math.acos(this._computationVector.y / this.radius);
             this._checkLimits();
         };
         ArcRotateCamera.prototype.setPosition = function (position) {
@@ -45263,7 +45265,8 @@ var BABYLON;
                 sinb = 0.0001;
             }
             var target = this._getTargetPosition();
-            target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this._newPosition);
+            this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
+            target.addToRef(this._computationVector, this._newPosition);
             if (this.getScene().collisionsEnabled && this.checkCollisions) {
                 if (!this._collider) {
                     this._collider = new BABYLON.Collider();
@@ -60402,6 +60405,8 @@ var BABYLON;
             this._viewMatrix = BABYLON.Matrix.Zero();
             this._projectionMatrix = BABYLON.Matrix.Zero();
             this._transformMatrix = BABYLON.Matrix.Zero();
+            this._cachedPosition = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cachedDirection = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
             this._currentFaceIndex = 0;
             this._currentFaceIndexCache = 0;
             this._defaultTextureMatrix = BABYLON.Matrix.Identity();
@@ -60927,12 +60932,14 @@ var BABYLON;
                 }
             });
             // Clear according to the chosen filter.
+            var zero = new BABYLON.Color4(0, 0, 0, 0);
+            var one = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
             this._shadowMap.onClearObservable.add(function (engine) {
                 if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
-                    engine.clear(new BABYLON.Color4(0, 0, 0, 0), true, true, true);
+                    engine.clear(zero, true, true, true);
                 }
                 else {
-                    engine.clear(new BABYLON.Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
+                    engine.clear(one, true, true, true);
                 }
             });
         };
@@ -61277,8 +61284,8 @@ var BABYLON;
                 this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
             }
             if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
-                this._cachedPosition = lightPosition.clone();
-                this._cachedDirection = this._lightDirection.clone();
+                this._cachedPosition.copyFrom(lightPosition);
+                this._cachedDirection.copyFrom(this._lightDirection);
                 BABYLON.Matrix.LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), BABYLON.Vector3.Up(), this._viewMatrix);
                 var shadowMap = this.getShadowMap();
                 if (shadowMap) {
@@ -81868,6 +81875,7 @@ var BABYLON;
             };
             makeNotPick(mesh);
             var childMeshes = mesh.getChildMeshes();
+            this.webVRController._pointingPoseNode = null;
             for (var i = 0; i < childMeshes.length; i++) {
                 if (childMeshes[i].name && childMeshes[i].name.indexOf(BABYLON.PoseEnabledController.POINTING_POSE) >= 0) {
                     mesh = childMeshes[i];
@@ -88567,6 +88575,7 @@ var BABYLON;
                 this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
             }
             animatable = BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
+                _this.stopAllAnimations();
                 if (onAnimationEnd) {
                     onAnimationEnd();
                 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 29 - 29
dist/preview release/babylon.worker.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 6572 - 6571
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 17 - 17
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 22 - 13
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -24437,8 +24437,6 @@ var BABYLON;
             if (this._gamepadManager && this._gamepadManager._isMonitoring) {
                 this._gamepadManager._checkGamepadsStatus();
             }
-            // Before render
-            this.onBeforeRenderObservable.notifyObservers(this);
             // Update Cameras
             if (this.activeCameras.length > 0) {
                 for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
@@ -24461,6 +24459,8 @@ var BABYLON;
                     }
                 }
             }
+            // Before render
+            this.onBeforeRenderObservable.notifyObservers(this);
             // Customs render targets
             this.OnBeforeRenderTargetsRenderObservable.notifyObservers(this);
             var engine = this.getEngine();
@@ -44706,6 +44706,7 @@ var BABYLON;
             _this._previousPosition = BABYLON.Vector3.Zero();
             _this._collisionVelocity = BABYLON.Vector3.Zero();
             _this._newPosition = BABYLON.Vector3.Zero();
+            _this._computationVector = BABYLON.Vector3.Zero();
             _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
                 if (collidedMesh === void 0) { collidedMesh = null; }
                 if (_this.getScene().workerCollisions && _this.checkCollisions) {
@@ -44729,7 +44730,8 @@ var BABYLON;
                     sinb = 0.0001;
                 }
                 var target = _this._getTargetPosition();
-                target.addToRef(new BABYLON.Vector3(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb), _this._newPosition);
+                _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
+                target.addToRef(_this._computationVector, _this._newPosition);
                 _this.position.copyFrom(_this._newPosition);
                 var up = _this.upVector;
                 if (_this.allowUpsideDown && _this.beta < 0) {
@@ -45205,18 +45207,18 @@ var BABYLON;
             }
         };
         ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
-            var radiusv3 = this.position.subtract(this._getTargetPosition());
-            this.radius = radiusv3.length();
+            this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
+            this.radius = this._computationVector.length();
             if (this.radius === 0) {
                 this.radius = 0.0001; // Just to avoid division by zero
             }
             // Alpha
-            this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
-            if (radiusv3.z < 0) {
+            this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
+            if (this._computationVector.z < 0) {
                 this.alpha = 2 * Math.PI - this.alpha;
             }
             // Beta
-            this.beta = Math.acos(radiusv3.y / this.radius);
+            this.beta = Math.acos(this._computationVector.y / this.radius);
             this._checkLimits();
         };
         ArcRotateCamera.prototype.setPosition = function (position) {
@@ -45263,7 +45265,8 @@ var BABYLON;
                 sinb = 0.0001;
             }
             var target = this._getTargetPosition();
-            target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this._newPosition);
+            this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
+            target.addToRef(this._computationVector, this._newPosition);
             if (this.getScene().collisionsEnabled && this.checkCollisions) {
                 if (!this._collider) {
                     this._collider = new BABYLON.Collider();
@@ -59702,6 +59705,8 @@ var BABYLON;
             this._viewMatrix = BABYLON.Matrix.Zero();
             this._projectionMatrix = BABYLON.Matrix.Zero();
             this._transformMatrix = BABYLON.Matrix.Zero();
+            this._cachedPosition = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cachedDirection = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
             this._currentFaceIndex = 0;
             this._currentFaceIndexCache = 0;
             this._defaultTextureMatrix = BABYLON.Matrix.Identity();
@@ -60227,12 +60232,14 @@ var BABYLON;
                 }
             });
             // Clear according to the chosen filter.
+            var zero = new BABYLON.Color4(0, 0, 0, 0);
+            var one = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
             this._shadowMap.onClearObservable.add(function (engine) {
                 if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
-                    engine.clear(new BABYLON.Color4(0, 0, 0, 0), true, true, true);
+                    engine.clear(zero, true, true, true);
                 }
                 else {
-                    engine.clear(new BABYLON.Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
+                    engine.clear(one, true, true, true);
                 }
             });
         };
@@ -60577,8 +60584,8 @@ var BABYLON;
                 this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
             }
             if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
-                this._cachedPosition = lightPosition.clone();
-                this._cachedDirection = this._lightDirection.clone();
+                this._cachedPosition.copyFrom(lightPosition);
+                this._cachedDirection.copyFrom(this._lightDirection);
                 BABYLON.Matrix.LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), BABYLON.Vector3.Up(), this._viewMatrix);
                 var shadowMap = this.getShadowMap();
                 if (shadowMap) {
@@ -81168,6 +81175,7 @@ var BABYLON;
             };
             makeNotPick(mesh);
             var childMeshes = mesh.getChildMeshes();
+            this.webVRController._pointingPoseNode = null;
             for (var i = 0; i < childMeshes.length; i++) {
                 if (childMeshes[i].name && childMeshes[i].name.indexOf(BABYLON.PoseEnabledController.POINTING_POSE) >= 0) {
                     mesh = childMeshes[i];
@@ -87867,6 +87875,7 @@ var BABYLON;
                 this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
             }
             animatable = BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
+                _this.stopAllAnimations();
                 if (onAnimationEnd) {
                     onAnimationEnd();
                 }

+ 22 - 13
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -24410,8 +24410,6 @@ var BABYLON;
             if (this._gamepadManager && this._gamepadManager._isMonitoring) {
                 this._gamepadManager._checkGamepadsStatus();
             }
-            // Before render
-            this.onBeforeRenderObservable.notifyObservers(this);
             // Update Cameras
             if (this.activeCameras.length > 0) {
                 for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
@@ -24434,6 +24432,8 @@ var BABYLON;
                     }
                 }
             }
+            // Before render
+            this.onBeforeRenderObservable.notifyObservers(this);
             // Customs render targets
             this.OnBeforeRenderTargetsRenderObservable.notifyObservers(this);
             var engine = this.getEngine();
@@ -44679,6 +44679,7 @@ var BABYLON;
             _this._previousPosition = BABYLON.Vector3.Zero();
             _this._collisionVelocity = BABYLON.Vector3.Zero();
             _this._newPosition = BABYLON.Vector3.Zero();
+            _this._computationVector = BABYLON.Vector3.Zero();
             _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
                 if (collidedMesh === void 0) { collidedMesh = null; }
                 if (_this.getScene().workerCollisions && _this.checkCollisions) {
@@ -44702,7 +44703,8 @@ var BABYLON;
                     sinb = 0.0001;
                 }
                 var target = _this._getTargetPosition();
-                target.addToRef(new BABYLON.Vector3(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb), _this._newPosition);
+                _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
+                target.addToRef(_this._computationVector, _this._newPosition);
                 _this.position.copyFrom(_this._newPosition);
                 var up = _this.upVector;
                 if (_this.allowUpsideDown && _this.beta < 0) {
@@ -45178,18 +45180,18 @@ var BABYLON;
             }
         };
         ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
-            var radiusv3 = this.position.subtract(this._getTargetPosition());
-            this.radius = radiusv3.length();
+            this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
+            this.radius = this._computationVector.length();
             if (this.radius === 0) {
                 this.radius = 0.0001; // Just to avoid division by zero
             }
             // Alpha
-            this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
-            if (radiusv3.z < 0) {
+            this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
+            if (this._computationVector.z < 0) {
                 this.alpha = 2 * Math.PI - this.alpha;
             }
             // Beta
-            this.beta = Math.acos(radiusv3.y / this.radius);
+            this.beta = Math.acos(this._computationVector.y / this.radius);
             this._checkLimits();
         };
         ArcRotateCamera.prototype.setPosition = function (position) {
@@ -45236,7 +45238,8 @@ var BABYLON;
                 sinb = 0.0001;
             }
             var target = this._getTargetPosition();
-            target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this._newPosition);
+            this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
+            target.addToRef(this._computationVector, this._newPosition);
             if (this.getScene().collisionsEnabled && this.checkCollisions) {
                 if (!this._collider) {
                     this._collider = new BABYLON.Collider();
@@ -59675,6 +59678,8 @@ var BABYLON;
             this._viewMatrix = BABYLON.Matrix.Zero();
             this._projectionMatrix = BABYLON.Matrix.Zero();
             this._transformMatrix = BABYLON.Matrix.Zero();
+            this._cachedPosition = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cachedDirection = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
             this._currentFaceIndex = 0;
             this._currentFaceIndexCache = 0;
             this._defaultTextureMatrix = BABYLON.Matrix.Identity();
@@ -60200,12 +60205,14 @@ var BABYLON;
                 }
             });
             // Clear according to the chosen filter.
+            var zero = new BABYLON.Color4(0, 0, 0, 0);
+            var one = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
             this._shadowMap.onClearObservable.add(function (engine) {
                 if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
-                    engine.clear(new BABYLON.Color4(0, 0, 0, 0), true, true, true);
+                    engine.clear(zero, true, true, true);
                 }
                 else {
-                    engine.clear(new BABYLON.Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
+                    engine.clear(one, true, true, true);
                 }
             });
         };
@@ -60550,8 +60557,8 @@ var BABYLON;
                 this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
             }
             if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
-                this._cachedPosition = lightPosition.clone();
-                this._cachedDirection = this._lightDirection.clone();
+                this._cachedPosition.copyFrom(lightPosition);
+                this._cachedDirection.copyFrom(this._lightDirection);
                 BABYLON.Matrix.LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), BABYLON.Vector3.Up(), this._viewMatrix);
                 var shadowMap = this.getShadowMap();
                 if (shadowMap) {
@@ -81141,6 +81148,7 @@ var BABYLON;
             };
             makeNotPick(mesh);
             var childMeshes = mesh.getChildMeshes();
+            this.webVRController._pointingPoseNode = null;
             for (var i = 0; i < childMeshes.length; i++) {
                 if (childMeshes[i].name && childMeshes[i].name.indexOf(BABYLON.PoseEnabledController.POINTING_POSE) >= 0) {
                     mesh = childMeshes[i];
@@ -87840,6 +87848,7 @@ var BABYLON;
                 this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
             }
             animatable = BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
+                _this.stopAllAnimations();
                 if (onAnimationEnd) {
                     onAnimationEnd();
                 }

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

@@ -24410,8 +24410,6 @@ var BABYLON;
             if (this._gamepadManager && this._gamepadManager._isMonitoring) {
                 this._gamepadManager._checkGamepadsStatus();
             }
-            // Before render
-            this.onBeforeRenderObservable.notifyObservers(this);
             // Update Cameras
             if (this.activeCameras.length > 0) {
                 for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
@@ -24434,6 +24432,8 @@ var BABYLON;
                     }
                 }
             }
+            // Before render
+            this.onBeforeRenderObservable.notifyObservers(this);
             // Customs render targets
             this.OnBeforeRenderTargetsRenderObservable.notifyObservers(this);
             var engine = this.getEngine();
@@ -44679,6 +44679,7 @@ var BABYLON;
             _this._previousPosition = BABYLON.Vector3.Zero();
             _this._collisionVelocity = BABYLON.Vector3.Zero();
             _this._newPosition = BABYLON.Vector3.Zero();
+            _this._computationVector = BABYLON.Vector3.Zero();
             _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
                 if (collidedMesh === void 0) { collidedMesh = null; }
                 if (_this.getScene().workerCollisions && _this.checkCollisions) {
@@ -44702,7 +44703,8 @@ var BABYLON;
                     sinb = 0.0001;
                 }
                 var target = _this._getTargetPosition();
-                target.addToRef(new BABYLON.Vector3(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb), _this._newPosition);
+                _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
+                target.addToRef(_this._computationVector, _this._newPosition);
                 _this.position.copyFrom(_this._newPosition);
                 var up = _this.upVector;
                 if (_this.allowUpsideDown && _this.beta < 0) {
@@ -45178,18 +45180,18 @@ var BABYLON;
             }
         };
         ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
-            var radiusv3 = this.position.subtract(this._getTargetPosition());
-            this.radius = radiusv3.length();
+            this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
+            this.radius = this._computationVector.length();
             if (this.radius === 0) {
                 this.radius = 0.0001; // Just to avoid division by zero
             }
             // Alpha
-            this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
-            if (radiusv3.z < 0) {
+            this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
+            if (this._computationVector.z < 0) {
                 this.alpha = 2 * Math.PI - this.alpha;
             }
             // Beta
-            this.beta = Math.acos(radiusv3.y / this.radius);
+            this.beta = Math.acos(this._computationVector.y / this.radius);
             this._checkLimits();
         };
         ArcRotateCamera.prototype.setPosition = function (position) {
@@ -45236,7 +45238,8 @@ var BABYLON;
                 sinb = 0.0001;
             }
             var target = this._getTargetPosition();
-            target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this._newPosition);
+            this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
+            target.addToRef(this._computationVector, this._newPosition);
             if (this.getScene().collisionsEnabled && this.checkCollisions) {
                 if (!this._collider) {
                     this._collider = new BABYLON.Collider();
@@ -60375,6 +60378,8 @@ var BABYLON;
             this._viewMatrix = BABYLON.Matrix.Zero();
             this._projectionMatrix = BABYLON.Matrix.Zero();
             this._transformMatrix = BABYLON.Matrix.Zero();
+            this._cachedPosition = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cachedDirection = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
             this._currentFaceIndex = 0;
             this._currentFaceIndexCache = 0;
             this._defaultTextureMatrix = BABYLON.Matrix.Identity();
@@ -60900,12 +60905,14 @@ var BABYLON;
                 }
             });
             // Clear according to the chosen filter.
+            var zero = new BABYLON.Color4(0, 0, 0, 0);
+            var one = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
             this._shadowMap.onClearObservable.add(function (engine) {
                 if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
-                    engine.clear(new BABYLON.Color4(0, 0, 0, 0), true, true, true);
+                    engine.clear(zero, true, true, true);
                 }
                 else {
-                    engine.clear(new BABYLON.Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
+                    engine.clear(one, true, true, true);
                 }
             });
         };
@@ -61250,8 +61257,8 @@ var BABYLON;
                 this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
             }
             if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
-                this._cachedPosition = lightPosition.clone();
-                this._cachedDirection = this._lightDirection.clone();
+                this._cachedPosition.copyFrom(lightPosition);
+                this._cachedDirection.copyFrom(this._lightDirection);
                 BABYLON.Matrix.LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), BABYLON.Vector3.Up(), this._viewMatrix);
                 var shadowMap = this.getShadowMap();
                 if (shadowMap) {
@@ -81841,6 +81848,7 @@ var BABYLON;
             };
             makeNotPick(mesh);
             var childMeshes = mesh.getChildMeshes();
+            this.webVRController._pointingPoseNode = null;
             for (var i = 0; i < childMeshes.length; i++) {
                 if (childMeshes[i].name && childMeshes[i].name.indexOf(BABYLON.PoseEnabledController.POINTING_POSE) >= 0) {
                     mesh = childMeshes[i];
@@ -88540,6 +88548,7 @@ var BABYLON;
                 this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
             }
             animatable = BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
+                _this.stopAllAnimations();
                 if (onAnimationEnd) {
                     onAnimationEnd();
                 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 42 - 42
dist/preview release/viewer/babylon.viewer.js


+ 29 - 30
dist/preview release/viewer/babylon.viewer.max.js

@@ -24520,8 +24520,6 @@ var BABYLON;
             if (this._gamepadManager && this._gamepadManager._isMonitoring) {
                 this._gamepadManager._checkGamepadsStatus();
             }
-            // Before render
-            this.onBeforeRenderObservable.notifyObservers(this);
             // Update Cameras
             if (this.activeCameras.length > 0) {
                 for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
@@ -24544,6 +24542,8 @@ var BABYLON;
                     }
                 }
             }
+            // Before render
+            this.onBeforeRenderObservable.notifyObservers(this);
             // Customs render targets
             this.OnBeforeRenderTargetsRenderObservable.notifyObservers(this);
             var engine = this.getEngine();
@@ -44789,6 +44789,7 @@ var BABYLON;
             _this._previousPosition = BABYLON.Vector3.Zero();
             _this._collisionVelocity = BABYLON.Vector3.Zero();
             _this._newPosition = BABYLON.Vector3.Zero();
+            _this._computationVector = BABYLON.Vector3.Zero();
             _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
                 if (collidedMesh === void 0) { collidedMesh = null; }
                 if (_this.getScene().workerCollisions && _this.checkCollisions) {
@@ -44812,7 +44813,8 @@ var BABYLON;
                     sinb = 0.0001;
                 }
                 var target = _this._getTargetPosition();
-                target.addToRef(new BABYLON.Vector3(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb), _this._newPosition);
+                _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
+                target.addToRef(_this._computationVector, _this._newPosition);
                 _this.position.copyFrom(_this._newPosition);
                 var up = _this.upVector;
                 if (_this.allowUpsideDown && _this.beta < 0) {
@@ -45288,18 +45290,18 @@ var BABYLON;
             }
         };
         ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
-            var radiusv3 = this.position.subtract(this._getTargetPosition());
-            this.radius = radiusv3.length();
+            this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
+            this.radius = this._computationVector.length();
             if (this.radius === 0) {
                 this.radius = 0.0001; // Just to avoid division by zero
             }
             // Alpha
-            this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2)));
-            if (radiusv3.z < 0) {
+            this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
+            if (this._computationVector.z < 0) {
                 this.alpha = 2 * Math.PI - this.alpha;
             }
             // Beta
-            this.beta = Math.acos(radiusv3.y / this.radius);
+            this.beta = Math.acos(this._computationVector.y / this.radius);
             this._checkLimits();
         };
         ArcRotateCamera.prototype.setPosition = function (position) {
@@ -45346,7 +45348,8 @@ var BABYLON;
                 sinb = 0.0001;
             }
             var target = this._getTargetPosition();
-            target.addToRef(new BABYLON.Vector3(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb), this._newPosition);
+            this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
+            target.addToRef(this._computationVector, this._newPosition);
             if (this.getScene().collisionsEnabled && this.checkCollisions) {
                 if (!this._collider) {
                     this._collider = new BABYLON.Collider();
@@ -60485,6 +60488,8 @@ var BABYLON;
             this._viewMatrix = BABYLON.Matrix.Zero();
             this._projectionMatrix = BABYLON.Matrix.Zero();
             this._transformMatrix = BABYLON.Matrix.Zero();
+            this._cachedPosition = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+            this._cachedDirection = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
             this._currentFaceIndex = 0;
             this._currentFaceIndexCache = 0;
             this._defaultTextureMatrix = BABYLON.Matrix.Identity();
@@ -61010,12 +61015,14 @@ var BABYLON;
                 }
             });
             // Clear according to the chosen filter.
+            var zero = new BABYLON.Color4(0, 0, 0, 0);
+            var one = new BABYLON.Color4(1.0, 1.0, 1.0, 1.0);
             this._shadowMap.onClearObservable.add(function (engine) {
                 if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
-                    engine.clear(new BABYLON.Color4(0, 0, 0, 0), true, true, true);
+                    engine.clear(zero, true, true, true);
                 }
                 else {
-                    engine.clear(new BABYLON.Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
+                    engine.clear(one, true, true, true);
                 }
             });
         };
@@ -61360,8 +61367,8 @@ var BABYLON;
                 this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
             }
             if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
-                this._cachedPosition = lightPosition.clone();
-                this._cachedDirection = this._lightDirection.clone();
+                this._cachedPosition.copyFrom(lightPosition);
+                this._cachedDirection.copyFrom(this._lightDirection);
                 BABYLON.Matrix.LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), BABYLON.Vector3.Up(), this._viewMatrix);
                 var shadowMap = this.getShadowMap();
                 if (shadowMap) {
@@ -81951,6 +81958,7 @@ var BABYLON;
             };
             makeNotPick(mesh);
             var childMeshes = mesh.getChildMeshes();
+            this.webVRController._pointingPoseNode = null;
             for (var i = 0; i < childMeshes.length; i++) {
                 if (childMeshes[i].name && childMeshes[i].name.indexOf(BABYLON.PoseEnabledController.POINTING_POSE) >= 0) {
                     mesh = childMeshes[i];
@@ -88650,6 +88658,7 @@ var BABYLON;
                 this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
             }
             animatable = BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
+                _this.stopAllAnimations();
                 if (onAnimationEnd) {
                     onAnimationEnd();
                 }
@@ -92177,7 +92186,7 @@ var DefaultViewer = (function (_super) {
             console.log(error);
             _this.hideLoadingScreen();
             _this.showOverlayScreen('error');
-            return _this.scene;
+            return Promise.reject(error);
         });
     };
     DefaultViewer.prototype.showOverlayScreen = function (subScreen) {
@@ -92836,7 +92845,7 @@ var AbstractViewer = (function () {
                 return _this.onEngineInitObservable.notifyObserversWithPromise(engine);
             }).then(function () {
                 if (autoLoadModel) {
-                    return _this.loadModel();
+                    return _this.loadModel().then(function () { return _this.scene; });
                 }
                 else {
                     return _this.scene || _this.initScene();
@@ -92845,8 +92854,6 @@ var AbstractViewer = (function () {
                 return _this.onSceneInitObservable.notifyObserversWithPromise(scene);
             }).then(function () {
                 return _this.onInitDoneObservable.notifyObserversWithPromise(_this);
-            }).then(function () {
-                return _this;
             });
         });
     };
@@ -92890,14 +92897,10 @@ var AbstractViewer = (function () {
         if (clearScene === void 0) { clearScene = true; }
         var modelUrl = (typeof modelConfig === 'string') ? modelConfig : modelConfig.url;
         if (!modelUrl) {
-            return Promise.resolve(this.scene);
+            return Promise.reject("no model configuration found");
         }
         if (this.isLoading) {
-            this.nextLoading = function () {
-                delete _this.nextLoading;
-                _this.loadModel(modelConfig, clearScene);
-            };
-            return Promise.resolve(this.scene);
+            return Promise.reject("sanother model is curently being loaded.");
         }
         this.isLoading = true;
         if ((typeof modelConfig === 'string')) {
@@ -92947,18 +92950,14 @@ var AbstractViewer = (function () {
                 if (_this.configuration.camera) {
                     _this.configureCamera(_this.configuration.camera, model);
                 }
-                return _this.initEnvironment(model.meshes);
+                return _this.initEnvironment(model);
             }).then(function () {
                 _this.isLoading = false;
-                if (_this.nextLoading) {
-                    return _this.nextLoading();
-                }
-                return _this.scene;
+                return model;
             });
         });
     };
-    AbstractViewer.prototype.initEnvironment = function (focusMeshes) {
-        if (focusMeshes === void 0) { focusMeshes = this.scene.meshes; }
+    AbstractViewer.prototype.initEnvironment = function (model) {
         this.configureEnvironment(this.configuration.skybox, this.configuration.ground);
         return Promise.resolve(this.scene);
     };

+ 1 - 0
src/Behaviors/Cameras/babylon.framingBehavior.ts

@@ -328,6 +328,7 @@ module BABYLON {
 
             animatable = Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(),
                 60, this._radiusTransition, this._framingTime, () => {
+                    this.stopAllAnimations();
                     if (onAnimationEnd) {
                         onAnimationEnd();
                     }

+ 8 - 6
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -540,8 +540,8 @@
         private _viewMatrix = Matrix.Zero();
         private _projectionMatrix = Matrix.Zero();
         private _transformMatrix = Matrix.Zero();
-        private _cachedPosition: Vector3;
-        private _cachedDirection: Vector3;
+        private _cachedPosition: Vector3 = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+        private _cachedDirection: Vector3 = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
         private _cachedDefines: string;
         private _currentRenderID: number;
         private _boxBlurPostprocess: Nullable<PostProcess>;
@@ -633,12 +633,14 @@
             });
 
             // Clear according to the chosen filter.
+            let zero = new Color4(0, 0, 0, 0);
+            let one = new Color4(1.0, 1.0, 1.0, 1.0);
             this._shadowMap.onClearObservable.add((engine: Engine) => {
                 if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
-                    engine.clear(new Color4(0, 0, 0, 0), true, true, true);
+                    engine.clear(zero, true, true, true);
                 }
                 else {
-                    engine.clear(new Color4(1.0, 1.0, 1.0, 1.0), true, true, true);
+                    engine.clear(one, true, true, true);
                 }
             });
         }
@@ -1050,8 +1052,8 @@
 
             if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
 
-                this._cachedPosition = lightPosition.clone();
-                this._cachedDirection = this._lightDirection.clone();
+                this._cachedPosition.copyFrom(lightPosition);
+                this._cachedDirection.copyFrom(this._lightDirection);
 
                 Matrix.LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), Vector3.Up(), this._viewMatrix);