David Catuhe 12 years ago
parent
commit
124d4279c2

+ 21 - 24
Babylon/Cameras/babylon.deviceOrientationCamera.js

@@ -12,8 +12,8 @@
         this.cameraRotation = new BABYLON.Vector2(0, 0);
         this.rotation = new BABYLON.Vector3(0, 0, 0);
         this.ellipsoid = new BABYLON.Vector3(0.5, 1, 0.5);
-        this.angularSensibility = 200000.0;
-        this.moveSensibility = 500.0;
+        this.angularSensibility = 10000.0;
+        this.moveSensibility = 50.0;
 
         if (!scene.activeCamera) {
             scene.activeCamera = this;
@@ -21,7 +21,7 @@
         // Collisions
         this._collider = new BABYLON.Collider();
         this._needMoveForGravity = true;
-        
+
         // Offset
         this._offsetX = null;
         this._offsetY = null;
@@ -29,10 +29,10 @@
         this._orientationBeta = 0;
         this._initialOrientationGamma = 0;
         this._initialOrientationBeta = 0;
-        
+
         // Animations
         this.animations = [];
-        
+
         // Internals
         this._cameraRotationMatrix = new BABYLON.Matrix();
         this._referencePoint = BABYLON.Vector3.Zero();
@@ -54,19 +54,20 @@
         }
         this._attachedCanvas = canvas;
 
+        var that = this;
         if (!this._orientationChanged) {
             this._orientationChanged = function (evt) {
-                
-                if (!this._initialOrientationGamma) {
-                    this._initialOrientationGamma = evt.gamma;
-                    this._initialOrientationBeta = evt.beta;
+
+                if (!that._initialOrientationGamma) {
+                    that._initialOrientationGamma = evt.gamma;
+                    that._initialOrientationBeta = evt.beta;
                 }
 
-                this._orientationGamma = evt.gamma;
-                this._orientationBeta = evt.beta;
+                that._orientationGamma = evt.gamma;
+                that._orientationBeta = evt.beta;
 
-                this._offsetY = (this._initialOrientationBeta - this._orientationBeta) * 0.05;
-                this._offsetX = (this._initialOrientationGamma - this._orientationGamma) * -0.05;
+                that._offsetY = (that._initialOrientationBeta - that._orientationBeta);
+                that._offsetX = (that._initialOrientationGamma - that._orientationGamma);
             };
         }
 
@@ -79,28 +80,24 @@
         }
 
         window.removeEventListener("deviceorientation", this._orientationChanged);
-        
+
         this._attachedCanvas = null;
         this._orientationGamma = 0;
         this._orientationBeta = 0;
         this._initialOrientationGamma = 0;
         this._initialOrientationBeta = 0;
     };
-    
+
     BABYLON.DeviceOrientationCamera.prototype._checkInputs = function () {
         if (!this._offsetX) {
             return;
         }
-        this.cameraRotation.y += this._offsetX / this.angularSensibility;
+        this.cameraRotation.y -= this._offsetX / this.angularSensibility;
 
-        if (this._pointerPressed.length > 1) {
-            this.cameraRotation.x += -this._offsetY / this.angularSensibility;
-        } else {
-            var speed = this._computeLocalCameraSpeed();
-            var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
+        var speed = this._computeLocalCameraSpeed();
+        var direction = new BABYLON.Vector3(0, 0, speed * this._offsetY / this.moveSensibility);
 
-            BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
-            this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
-        }
+        BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, 0, this._cameraRotationMatrix);
+        this.cameraDirection.addInPlace(BABYLON.Vector3.TransformCoordinates(direction, this._cameraRotationMatrix));
     };
 })();

+ 2 - 0
Babylon/Culling/babylon.boundingBox.js

@@ -41,6 +41,8 @@
         }
         this.minimumWorld = BABYLON.Vector3.Zero();
         this.maximumWorld = BABYLON.Vector3.Zero();
+
+        this._update(BABYLON.Matrix.Identity());
     };
 
     // Methods

+ 1 - 0
Babylon/Culling/babylon.boundingSphere.js

@@ -11,6 +11,7 @@
         this.radius = distance * 0.5;
 
         this.centerWorld = BABYLON.Vector3.Zero();
+        this._update(BABYLON.Matrix.Identity());
     };
     
     // Methods

+ 2 - 1
Babylon/Materials/textures/babylon.renderTargetTexture.js

@@ -20,6 +20,7 @@
 
     // Members        
     BABYLON.RenderTargetTexture.prototype.renderParticles = true;
+    BABYLON.RenderTargetTexture.prototype.renderSprites = false;
     BABYLON.RenderTargetTexture.prototype.isRenderTarget = true;
     BABYLON.RenderTargetTexture.prototype.coordinatesMode = BABYLON.Texture.PROJECTION_MODE;
 
@@ -75,7 +76,7 @@
         }
 
         // Render
-        this._renderingManager.render(this.customRenderFunction, null, this.renderList, this.renderParticles);
+        this._renderingManager.render(this.customRenderFunction, this.renderList, this.renderParticles, this.renderSprites);
 
         // Unbind
         engine.unBindFramebuffer(this._texture);

+ 46 - 8
Babylon/Rendering/babylon.renderingManager.js

@@ -8,6 +8,10 @@
 
     // Methods
     BABYLON.RenderingManager.prototype._renderParticles = function (index, activeMeshes) {
+        if (this._scene._activeParticleSystems.length === 0) {
+            return;
+        }
+
         // Particles
         var beforeParticlesDate = new Date();
         for (var particleIndex = 0; particleIndex < this._scene._activeParticleSystems.length; particleIndex++) {
@@ -17,6 +21,8 @@
                 continue;
             }
 
+            this._clearDepthBuffer();
+
             if (!particleSystem.emitter.position || !activeMeshes || activeMeshes.indexOf(particleSystem.emitter) !== -1) {
                 this._scene._activeParticles += particleSystem.render();
             }
@@ -24,19 +30,51 @@
         this._scene._particlesDuration += new Date() - beforeParticlesDate;
     };
 
-    BABYLON.RenderingManager.prototype.render = function (customRenderFunction, beforeTransparents, activeMeshes, renderParticles) {
+    BABYLON.RenderingManager.prototype._renderSprites = function (index) {
+        if (this._scene.spriteManagers.length === 0) {
+            return;
+        }
+
+        // Sprites       
+        var beforeSpritessDate = new Date();
+        for (var id = 0; id < this._scene.spriteManagers.length; id++) {
+            var spriteManager = this._scene.spriteManagers[id];
+
+            if (spriteManager.renderingGroupId === index) {
+                this._clearDepthBuffer();
+                spriteManager.render();
+            }
+        }
+        this._scene._spritesDuration = new Date() - beforeSpritessDate;
+    };
+
+    BABYLON.RenderingManager.prototype._clearDepthBuffer = function () {
+        if (this._depthBufferAlreadyCleaned) {
+            return;
+        }
+
+        this._scene.getEngine().clear(0, false, true);
+        this._depthBufferAlreadyCleaned = true;
+    };
+
+    BABYLON.RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
+        var that = this;
+
         for (var index = 0 ; index < BABYLON.RenderingManager.MAX_RENDERINGGROUPS; index++) {
+            this._depthBufferAlreadyCleaned = index == 0;
             var renderingGroup = this._renderingGroups[index];
-            if (index > 0) {
-                this._scene.getEngine().clear(0, false, true);
-            }
 
             if (renderingGroup) {
-                if (!renderingGroup.render(customRenderFunction, index == 0 ? beforeTransparents : null)) {
+                this._clearDepthBuffer();
+                if (!renderingGroup.render(customRenderFunction, function () {
+                    if (renderSprites) {
+                        that._renderSprites(index);
+                }
+                })) {
                     this._renderingGroups.splice(index, 1);
                 }
-            } else if (beforeTransparents && index == 0) {
-                beforeTransparents();
+            } else if (renderSprites) {
+                this._renderSprites(index);
             }
 
             if (renderParticles) {
@@ -62,7 +100,7 @@
 
         this._renderingGroups[renderingGroupId].dispatch(subMesh);
     };
-    
+
     // Statics
     BABYLON.RenderingManager.MAX_RENDERINGGROUPS = 4;
 })();

+ 1 - 1
Babylon/Shaders/iedefault.fragment.fx

@@ -103,7 +103,7 @@ float ChebychevInequality(vec2 moments, float t)
 	}
 
 	float variance = moments.y - (moments.x * moments.x);
-	variance = max(variance, 0);
+	variance = max(variance, 0.);
 
 	float d = t - moments.x;
 	return variance / (variance + d * d);

+ 1 - 0
Babylon/Sprites/babylon.spriteManager.js

@@ -49,6 +49,7 @@
     };
     
     // Members
+    BABYLON.SpriteManager.prototype.renderingGroupId = 0;
     BABYLON.SpriteManager.prototype.onDispose = null;
 
     // Methods

+ 1 - 1
Babylon/babylon.engine.js

@@ -189,7 +189,7 @@
         this._gl.clearDepth(1.0);
         var mode = 0;
 
-        if (backBuffer || this.forceWireframe)
+        if (backBuffer)
             mode |= this._gl.COLOR_BUFFER_BIT;
 
         if (depthStencil)

+ 2 - 12
Babylon/babylon.scene.js

@@ -586,7 +586,7 @@
 
         // Clear
         var beforeRenderDate = new Date();
-        engine.clear(this.clearColor, this.autoClear, true);
+        engine.clear(this.clearColor, this.autoClear || this.forceWireframe, true);
 
         // Backgrounds
         if (this.layers.length) {
@@ -603,17 +603,7 @@
         }
 
         // Render
-        var that = this;
-        this._renderingManager.render(null, function() {
-            // Sprites
-            var beforeSpritessDate = new Date();
-            for (var index = 0; index < that.spriteManagers.length; index++) {
-                var spriteManager = that.spriteManagers[index];
-
-                spriteManager.render();
-            }
-            that._spritesDuration = new Date() - beforeSpritessDate;
-        }, null, true);
+        this._renderingManager.render(null, null, true, true);
 
         // Foregrounds
         if (this.layers.length) {

File diff suppressed because it is too large
+ 3 - 3
Samples/babylon.js


File diff suppressed because it is too large
+ 0 - 13
babylon.1.5.1.js


File diff suppressed because it is too large
+ 13 - 0
babylon.1.5.2.js