Skip to content

Commit

Permalink
v1.5.2
Browse files Browse the repository at this point in the history
Former-commit-id: 124d427
  • Loading branch information
deltakosh committed Oct 11, 2013
1 parent 39bc82d commit cd25ff2
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 63 deletions.
45 changes: 21 additions & 24 deletions Babylon/Cameras/babylon.deviceOrientationCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,27 @@
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;
}
// Collisions
this._collider = new BABYLON.Collider();
this._needMoveForGravity = true;

// Offset
this._offsetX = null;
this._offsetY = null;
this._orientationGamma = 0;
this._orientationBeta = 0;
this._initialOrientationGamma = 0;
this._initialOrientationBeta = 0;

// Animations
this.animations = [];

// Internals
this._cameraRotationMatrix = new BABYLON.Matrix();
this._referencePoint = BABYLON.Vector3.Zero();
Expand All @@ -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);
};
}

Expand All @@ -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 changes: 2 additions & 0 deletions Babylon/Culling/babylon.boundingBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
}
this.minimumWorld = BABYLON.Vector3.Zero();
this.maximumWorld = BABYLON.Vector3.Zero();

this._update(BABYLON.Matrix.Identity());
};

// Methods
Expand Down
1 change: 1 addition & 0 deletions Babylon/Culling/babylon.boundingSphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
this.radius = distance * 0.5;

this.centerWorld = BABYLON.Vector3.Zero();
this._update(BABYLON.Matrix.Identity());
};

// Methods
Expand Down
3 changes: 2 additions & 1 deletion Babylon/Materials/textures/babylon.renderTargetTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
54 changes: 46 additions & 8 deletions Babylon/Rendering/babylon.renderingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -17,26 +21,60 @@
continue;
}

this._clearDepthBuffer();

if (!particleSystem.emitter.position || !activeMeshes || activeMeshes.indexOf(particleSystem.emitter) !== -1) {
this._scene._activeParticles += particleSystem.render();
}
}
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) {
Expand All @@ -62,7 +100,7 @@

this._renderingGroups[renderingGroupId].dispatch(subMesh);
};

// Statics
BABYLON.RenderingManager.MAX_RENDERINGGROUPS = 4;
})();
2 changes: 1 addition & 1 deletion Babylon/Shaders/iedefault.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions Babylon/Sprites/babylon.spriteManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
};

// Members
BABYLON.SpriteManager.prototype.renderingGroupId = 0;
BABYLON.SpriteManager.prototype.onDispose = null;

// Methods
Expand Down
2 changes: 1 addition & 1 deletion Babylon/babylon.engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 2 additions & 12 deletions Babylon/babylon.scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions Samples/babylon.js

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions babylon.1.5.1.js

This file was deleted.

13 changes: 13 additions & 0 deletions babylon.1.5.2.js

Large diffs are not rendered by default.

0 comments on commit cd25ff2

Please sign in to comment.