瀏覽代碼

Nightly + new booleans to turn off cache wipe

David Catuhe 8 年之前
父節點
當前提交
df4ec91db3

文件差異過大導致無法顯示
+ 22 - 22
dist/preview release/babylon.core.js


文件差異過大導致無法顯示
+ 4065 - 4063
dist/preview release/babylon.d.ts


文件差異過大導致無法顯示
+ 32 - 32
dist/preview release/babylon.js


+ 52 - 25
dist/preview release/babylon.max.js

@@ -7121,6 +7121,9 @@ var BABYLON;
          * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
          */
         PerfCounter.prototype.addCount = function (newCount, fetchResult) {
+            if (!PerfCounter.Enabled) {
+                return;
+            }
             this._current += newCount;
             if (fetchResult) {
                 this._fetchResult();
@@ -7130,6 +7133,9 @@ var BABYLON;
          * Start monitoring this performance counter
          */
         PerfCounter.prototype.beginMonitoring = function () {
+            if (!PerfCounter.Enabled) {
+                return;
+            }
             this._startMonitoringTime = Tools.Now;
         };
         /**
@@ -7138,6 +7144,9 @@ var BABYLON;
          */
         PerfCounter.prototype.endMonitoring = function (newFrame) {
             if (newFrame === void 0) { newFrame = true; }
+            if (!PerfCounter.Enabled) {
+                return;
+            }
             if (newFrame) {
                 this.fetchNewFrame();
             }
@@ -7165,6 +7174,7 @@ var BABYLON;
         };
         return PerfCounter;
     }());
+    PerfCounter.Enabled = true;
     BABYLON.PerfCounter = PerfCounter;
     /**
      * Use this className as a decorator on a given class definition to add it a name and optionally its module.
@@ -7849,6 +7859,7 @@ var BABYLON;
             this.isPointerLock = false;
             this.cullBackFaces = true;
             this.renderEvenInBackground = true;
+            this.preventCacheWipeBetweenFrames = false;
             // To enable/disable IDB support and avoid XHR on .manifest
             this.enableOfflineSupport = true;
             this.scenes = new Array();
@@ -8710,9 +8721,12 @@ var BABYLON;
          *   });
          */
         Engine.prototype.resize = function () {
-            var width = navigator.isCocoonJS ? window.innerWidth : this._renderingCanvas.clientWidth;
-            var height = navigator.isCocoonJS ? window.innerHeight : this._renderingCanvas.clientHeight;
-            this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
+            // We're not resizing the size of the canvas while in VR mode & presenting
+            if (!(this._vrDisplayEnabled && this._vrDisplayEnabled.isPresenting)) {
+                var width = navigator.isCocoonJS ? window.innerWidth : this._renderingCanvas.clientWidth;
+                var height = navigator.isCocoonJS ? window.innerHeight : this._renderingCanvas.clientHeight;
+                this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
+            }
         };
         /**
          * force a specific size of the canvas
@@ -9457,6 +9471,9 @@ var BABYLON;
         };
         // Textures
         Engine.prototype.wipeCaches = function () {
+            if (this.preventCacheWipeBetweenFrames) {
+                return;
+            }
             this.resetTextureCache();
             this._currentEffect = null;
             this._stencilState.reset();
@@ -16128,14 +16145,14 @@ var BABYLON;
                     break;
                 case Camera.RIG_MODE_WEBVR:
                     if (rigParams.vrDisplay) {
-                        //var leftEye = rigParams.vrDisplay.getEyeParameters('left');
-                        //var rightEye = rigParams.vrDisplay.getEyeParameters('right');
+                        var leftEye = rigParams.vrDisplay.getEyeParameters('left');
+                        var rightEye = rigParams.vrDisplay.getEyeParameters('right');
                         //Left eye
                         this._rigCameras[0].viewport = new BABYLON.Viewport(0, 0, 0.5, 1.0);
                         this._rigCameras[0].setCameraRigParameter("left", true);
+                        this._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
                         this._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
                         this._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
-                        //this._rigCameras[0].setCameraRigParameter('eyeParameters', leftEye);
                         this._rigCameras[0]._cameraRigParams.vrWorkMatrix = new BABYLON.Matrix();
                         this._rigCameras[0].getProjectionMatrix = this._getWebVRProjectionMatrix;
                         this._rigCameras[0]._getViewMatrix = this._getWebVRViewMatrix;
@@ -16143,7 +16160,7 @@ var BABYLON;
                         this._rigCameras[0]._updateCameraRotationMatrix = this._updateCameraRotationMatrix;
                         //Right eye
                         this._rigCameras[1].viewport = new BABYLON.Viewport(0.5, 0, 0.5, 1.0);
-                        //this._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
+                        this._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
                         this._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
                         this._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
                         this._rigCameras[1]._cameraRigParams.vrWorkMatrix = new BABYLON.Matrix();
@@ -17690,6 +17707,13 @@ var BABYLON;
             if (needToRotate) {
                 this.rotation.x += this.cameraRotation.x;
                 this.rotation.y += this.cameraRotation.y;
+                //rotate, if quaternion is set and rotation was used
+                if (this.rotationQuaternion) {
+                    var len = this.rotation.length();
+                    if (len) {
+                        BABYLON.Quaternion.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
+                    }
+                }
                 if (!this.noRotationConstraint) {
                     var limit = (Math.PI / 2) * 0.95;
                     if (this.rotation.x > limit)
@@ -49320,13 +49344,14 @@ var BABYLON;
                 this._webvrViewMatrix.m[12] += parentCamera.position.x;
                 this._webvrViewMatrix.m[13] += parentCamera.position.y;
                 this._webvrViewMatrix.m[14] += parentCamera.position.z;
+                // is rotation offset set? 
+                if (!BABYLON.Quaternion.IsIdentity(this.rotationQuaternion)) {
+                    this._webvrViewMatrix.decompose(BABYLON.Tmp.Vector3[0], BABYLON.Tmp.Quaternion[0], BABYLON.Tmp.Vector3[1]);
+                    this.rotationQuaternion.multiplyToRef(BABYLON.Tmp.Quaternion[0], BABYLON.Tmp.Quaternion[0]);
+                    BABYLON.Matrix.ComposeToRef(BABYLON.Tmp.Vector3[0], BABYLON.Tmp.Quaternion[0], BABYLON.Tmp.Vector3[1], this._webvrViewMatrix);
+                }
                 this._webvrViewMatrix.invert();
             }
-            // is rotation offset set? 
-            if (!BABYLON.Quaternion.IsIdentity(this.rotationQuaternion)) {
-                this.rotationQuaternion.toRotationMatrix(this._tempMatrix);
-                this._tempMatrix.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
-            }
             this._updateCameraRotationMatrix();
             BABYLON.Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
             // Computing target for getTarget()
@@ -51505,11 +51530,11 @@ var BABYLON;
         PoseEnabledController.prototype.update = function () {
             _super.prototype.update.call(this);
             // update this device's offset position from the attached camera, if provided
-            if (this._poseControlledCamera && this._poseControlledCamera.deviceScaleFactor) {
-                //this.position.copyFrom(this._poseControlledCamera.position);
-                //this.rotationQuaternion.copyFrom(this._poseControlledCamera.rotationQuaternion);
-                this.deviceScaleFactor = this._poseControlledCamera.deviceScaleFactor;
-            }
+            //if (this._poseControlledCamera && this._poseControlledCamera.deviceScaleFactor) {
+            //this.position.copyFrom(this._poseControlledCamera.position);
+            //this.rotationQuaternion.copyFrom(this._poseControlledCamera.rotationQuaternion);
+            //this.deviceScaleFactor = this._poseControlledCamera.deviceScaleFactor;
+            //}
             var pose = this.vrGamepad.pose;
             this.updateFromDevice(pose);
             if (this._mesh) {
@@ -51527,11 +51552,6 @@ var BABYLON;
                     }
                     this.devicePosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
                     this._calculatedPosition.addInPlace(this.position);
-                    // scale the position using the scale factor, add the device's position
-                    if (this._poseControlledCamera) {
-                        // this allows total positioning freedom - the device, the camera and the mesh can be individually controlled.
-                        this._calculatedPosition.addInPlace(this._poseControlledCamera.position);
-                    }
                 }
                 if (poseData.orientation) {
                     this.deviceRotationQuaternion.copyFromFloats(this.rawPose.orientation[0], this.rawPose.orientation[1], -this.rawPose.orientation[2], -this.rawPose.orientation[3]);
@@ -51542,20 +51562,27 @@ var BABYLON;
                     // if the camera is set, rotate to the camera's rotation
                     this.rotationQuaternion.multiplyToRef(this.deviceRotationQuaternion, this._calculatedRotation);
                     if (this._poseControlledCamera) {
-                        this._calculatedRotation.multiplyToRef(this._poseControlledCamera.rotationQuaternion, this._calculatedRotation);
+                        BABYLON.Matrix.ScalingToRef(1, 1, 1, BABYLON.Tmp.Matrix[1]);
+                        this._calculatedRotation.toRotationMatrix(BABYLON.Tmp.Matrix[0]);
+                        BABYLON.Matrix.TranslationToRef(this._calculatedPosition.x, this._calculatedPosition.y, this._calculatedPosition.z, BABYLON.Tmp.Matrix[2]);
+                        //Matrix.Identity().multiplyToRef(Tmp.Matrix[1], Tmp.Matrix[4]);
+                        BABYLON.Tmp.Matrix[1].multiplyToRef(BABYLON.Tmp.Matrix[0], BABYLON.Tmp.Matrix[5]);
+                        this._poseControlledCamera.getWorldMatrix().getTranslationToRef(BABYLON.Tmp.Vector3[0]);
+                        BABYLON.Matrix.ComposeToRef(new BABYLON.Vector3(this.deviceScaleFactor, this.deviceScaleFactor, this.deviceScaleFactor), this._poseControlledCamera.rotationQuaternion, BABYLON.Tmp.Vector3[0], BABYLON.Tmp.Matrix[4]);
+                        BABYLON.Tmp.Matrix[5].multiplyToRef(BABYLON.Tmp.Matrix[2], BABYLON.Tmp.Matrix[1]);
+                        BABYLON.Tmp.Matrix[1].multiplyToRef(BABYLON.Tmp.Matrix[4], BABYLON.Tmp.Matrix[2]);
+                        BABYLON.Tmp.Matrix[2].decompose(BABYLON.Tmp.Vector3[0], this._calculatedRotation, this._calculatedPosition);
                     }
                 }
             }
         };
         PoseEnabledController.prototype.attachToMesh = function (mesh) {
-            this._mesh = mesh;
             if (!this._mesh.rotationQuaternion) {
                 this._mesh.rotationQuaternion = new BABYLON.Quaternion();
             }
         };
         PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
             this._poseControlledCamera = camera;
-            this.deviceScaleFactor = camera.deviceScaleFactor;
         };
         PoseEnabledController.prototype.detachMesh = function () {
             this._mesh = undefined;

文件差異過大導致無法顯示
+ 4065 - 4063
dist/preview release/babylon.module.d.ts


文件差異過大導致無法顯示
+ 32 - 32
dist/preview release/babylon.noworker.js


文件差異過大導致無法顯示
+ 38 - 38
dist/preview release/canvas2D/babylon.canvas2d.js


文件差異過大導致無法顯示
+ 12 - 12
dist/preview release/canvas2D/babylon.canvas2d.min.js


文件差異過大導致無法顯示
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js


文件差異過大導致無法顯示
+ 1 - 1
dist/preview release/inspector/babylon.inspector.min.js


+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -856,7 +856,7 @@ var BABYLON;
                 var translation = node.translation || [0, 0, 0];
                 var rotation = node.rotation || [0, 0, 0, 1];
                 var scale = node.scale || [1, 1, 1];
-                configureNode(lastNode, BABYLON.Vector3.FromArray(translation), BABYLON.Quaternion.RotationAxis(BABYLON.Vector3.FromArray(rotation).normalize(), rotation[3]), BABYLON.Vector3.FromArray(scale));
+                configureNode(lastNode, BABYLON.Vector3.FromArray(translation), BABYLON.Quaternion.FromArray(rotation), BABYLON.Vector3.FromArray(scale));
             }
             lastNode.updateCache(true);
             node.babylonNode = lastNode;

文件差異過大導致無法顯示
+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 77 - 79
localDev/index.html

@@ -1,89 +1,87 @@
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-	<title>Local Development</title>
-	
-    <script src="https://babylonjs.azurewebsites.net/cannon.js"></script>
-    <script src="https://babylonjs.azurewebsites.net/Oimo.js"></script>
-	<script src="../assets/refs/dat.gui.min.js"></script>
-	<script src="../tools/DevLoader/BabylonLoader.js"></script>
-
-	<style>
-		html, body {
-			width: 100%;
-			height: 100%;
-			padding: 0;
-			margin: 0;
-			overflow: hidden;
-		}
-
-		#renderCanvas {
-			width: 100%;
-			height: 100%;
-		}
-
-		#fps {
-			position: absolute;
-			background-color: black;
-			border: 2px solid red;
-			text-align: center;
-			font-size: 16px;
-			color: white;
-			top: 15px;
-			left: 10px;
-			width: 60px;
-			height: 20px;
-		}
-	</style>
+    <title>Local Development</title>
+    
+    <script src="https://babylonjs.azurewebsites.net/babylon.js"></script>
+    <style>
+        html, body {
+            width: 100%;
+            height: 100%;
+            padding: 0;
+            margin: 0;
+            overflow: hidden;
+        }
+ 
+        #renderCanvas {
+            width: 100%;
+            height: 100%;
+        }
+    </style>
 </head>
 <body>
-	<div id="fps">0</div>
-	<canvas id="renderCanvas"></canvas>
-	
-	<script>
-		var canvas = document.getElementById("renderCanvas");
-		var divFps = document.getElementById("fps");
-
-		// Global to simulate PG.
-		var engine = null;
-
-		// Allow querystring to navigate easily in debug in local samples.
-		var indexjs = 'src/index';
-		var sampleSearch = /sample=([0-9]+)/i;
-		var matches = null;
-		if ((matches = sampleSearch.exec(window.location)) !== null) {			
-			indexjs += '.';
-			indexjs += matches[1];
-		}
-		indexjs += '.js';
-
-		// Load the scripts + map file to allow vscode debug.
-		BABYLONDEVTOOLS.Loader
-			.require(indexjs)
-			.load(function() {
-				if (BABYLON.Engine.isSupported()) {
-					engine = new BABYLON.Engine(canvas, true, { stencil: true });					
-					BABYLONDEVTOOLS.Loader.debugShortcut(engine);			
+    <canvas id="renderCanvas"></canvas>
+    
+    <script>
+        var canvas = document.getElementById("renderCanvas");
+        var engine = new BABYLON.Engine(canvas, true, { stencil: false, audioEngine: false });   
+		engine.preventCacheWipeBetweenFrames = true;
+		BABYLON.PerfCounter.Enabled = false;
+ 
+        BABYLON.SceneLoader.ShowLoadingScreen = false;              
+ 
+        BABYLON.SceneLoader.Load("./", "cortana.babylon", engine, function(scene) {
+ 
+            // Replace camera by a arcRotate to be able to rotate around Cortana
+            var newCamera = new BABYLON.ArcRotateCamera("camera1", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
+        //    newCamera.attachControl(canvas, false); // Attach mouse control to be able to move around
+            newCamera.setPosition(new BABYLON.Vector3(0, 2, -4));
+ 
+            scene.activeCamera = newCamera;
+            
+            // Update materials (they are pretty good actually only alpha is missing)
+            for (var index = 0; index < scene.materials.length; index++) {
+                scene.materials[index].diffuseTexture.hasAlpha = true;
+                scene.materials[index].useAlphaFromDiffuseTexture = true;
+                scene.materials[index].alpha = 0.5;
 
-					// call the scene creation from the js.
-					var scene = createScene();
+                // Freezing materials
+                scene.materials[index].freeze();
+            }
+ 
+            var mesh = scene.getMeshByName("Inner1");
+            mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
+            mesh = scene.getMeshByName("Inner2");
+            mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
+            mesh = scene.getMeshByName("Inner3");
+            mesh.scaling = new BABYLON.Vector3(0.6, 0.6, 0.6);
 
-					// Register a render loop to repeatedly render the scene
-					engine.runRenderLoop(function () {
-						scene.render();
-						divFps.innerHTML = engine.getFps().toFixed() + " fps";
-					});
+            for (var index = 0; index < scene.meshes.length; index++) {
+                // Avoid frustum clipping. No needed here as objects are always visible
+                scene.meshes[index].alwaysSelectAsActiveMesh = true;
+            }
+ 
+            // Find root object
+            var innerSphere = scene.getMeshByName("InnerSphereHolder");
+            var outerSphere = scene.getMeshByName("OuterSphereHolder");
 
-					// Resize
-					window.addEventListener("resize", function () {
-						engine.resize();
-					});
-					
-				}
-				else {
-					alert('BabylonJS is not supported.')
-				}
-			});
-	</script>
+            // Set clear color to black (it is white by default)
+            scene.clearColor = BABYLON.Color3.Black();
+        
+            // Register a render loop to repeatedly render the scene
+            engine.runRenderLoop(function () {
+                scene.render();
+ 
+                // Do a bit of self-rotation
+                innerSphere.rotation.y += 0.01;
+                outerSphere.rotation.y -= 0.01;
+            });
+        });
+ 
+        // Resize
+        window.addEventListener("resize", function () {
+            engine.resize();
+        });                 
+    </script>
 </body>
 </html>

+ 12 - 0
src/Tools/babylon.tools.ts

@@ -1184,6 +1184,8 @@
      * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
      */
     export class PerfCounter {
+        public static Enabled = true;
+
         /**
          * Returns the smallest value ever
          */
@@ -1253,6 +1255,9 @@
          * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
          */
         public addCount(newCount: number, fetchResult: boolean) {
+            if (!PerfCounter.Enabled) {
+                return;
+            }
             this._current += newCount;
             if (fetchResult) {
                 this._fetchResult();
@@ -1263,6 +1268,9 @@
          * Start monitoring this performance counter
          */
         public beginMonitoring() {
+            if (!PerfCounter.Enabled) {
+                return;
+            }
             this._startMonitoringTime = Tools.Now;
         }
 
@@ -1271,6 +1279,10 @@
          * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
          */
         public endMonitoring(newFrame: boolean = true) {
+            if (!PerfCounter.Enabled) {
+                return;
+            }
+                        
             if (newFrame) {
                 this.fetchNewFrame();
             }

+ 4 - 0
src/babylon.engine.ts

@@ -422,6 +422,7 @@
         public isPointerLock = false;
         public cullBackFaces = true;
         public renderEvenInBackground = true;
+        public preventCacheWipeBetweenFrames = false;
         // To enable/disable IDB support and avoid XHR on .manifest
         public enableOfflineSupport = true;
         public scenes = new Array<Scene>();
@@ -2065,6 +2066,9 @@
 
         // Textures
         public wipeCaches(): void {
+            if (this.preventCacheWipeBetweenFrames) {
+                return;
+            }
             this.resetTextureCache();
             this._currentEffect = null;