Ver código fonte

Fixing oculus collision system

David Catuhe 11 anos atrás
pai
commit
92c1f93548

+ 1 - 1
Babylon/Cameras/Controllers/babylon.gravityInputController.js

@@ -7,7 +7,7 @@ var BABYLON = BABYLON || {};
         BABYLON.InputController.call(this, scene, target);
         this._moveVectorGlobal = new BABYLON.Vector3(0, 0, 0);
         this._moveVectorLocal = new BABYLON.Vector3(0, 0, 0);
-        this._fallSpeed = .6;
+        this._fallSpeed = 2;
     };
     BABYLON.GravityInputController.prototype = Object.create(BABYLON.InputController.prototype);
     BABYLON.GravityInputController.prototype.update = function () {

+ 3 - 0
Babylon/Cameras/babylon.oculusOrientedCamera.js

@@ -4,6 +4,9 @@ var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.OculusOrientedCamera = function (name, position, scene, isLeftEye, ovrSettings, neutralOrientation) {
+        // OculusOrientedCamera is usually built 2 times using the same position
+        // So I duplicate the position to avoid errors from physics system (which could manipulate it twice per frame)
+        position = position ? new BABYLON.Vector3(position.x, position.y, position.z) : null;
         BABYLON.Camera.call(this, name, position, scene);
         this._referenceDirection = new BABYLON.Vector3(0, 0, 1);
         this._referenceUp = new BABYLON.Vector3(0, 1, 0);

+ 22 - 1
Babylon/babylon.engine.js

@@ -4,6 +4,7 @@ var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Engine = function (canvas, antialias, options) {
+        var that = this;
         this._renderingCanvas = canvas;
 
         options = options || {};
@@ -20,9 +21,26 @@ var BABYLON = BABYLON || {};
             throw new Error("WebGL not supported");
         }
 
+        this._windowIsBackground = false;
+        window.addEventListener("blur", function () {
+            that._windowIsBackground = true;
+        });
+
+        window.addEventListener("focus", function () {
+            that._windowIsBackground = false;
+
+            if (that._runningLoop) {
+                // Register new frame
+                BABYLON.Tools.QueueNewFrame(function () {
+                    that._renderLoop();
+                });
+            }
+        });
+
         // Options
         this.forceWireframe = false;
         this.cullBackFaces = true;
+        this.renderEvenInBackground = true;
 
         // Scenes
         this.scenes = [];
@@ -64,7 +82,6 @@ var BABYLON = BABYLON || {};
 
         // Fullscreen
         this.isFullscreen = false;
-        var that = this;
 
         var onFullscreenChange = function () {
             if (document.fullscreen !== undefined) {
@@ -154,6 +171,10 @@ var BABYLON = BABYLON || {};
     };
 
     BABYLON.Engine.prototype._renderLoop = function () {
+        if (!this.renderEvenInBackground && this._windowIsBackground) {
+            return;
+        }
+
         // Start new frame
         this.beginFrame();
 

Diferenças do arquivo suprimidas por serem muito extensas
+ 2 - 2
babylon.1.10.0.js