Camera disappears progressively (classy :D)

This commit is contained in:
Thomas FORGIONE
2015-04-13 10:11:42 +02:00
parent d33e91f899
commit bdb975e2f0
3 changed files with 15 additions and 9 deletions

View File

@@ -23,8 +23,8 @@ CameraContainer.prototype.look = function() {
this.cameras[this.current_camera].look();
}
CameraContainer.prototype.update = function() {
this.cameras[this.current_camera].update();
CameraContainer.prototype.update = function(position) {
this.cameras.map(function (elt) { elt.update(position); });
}
CameraContainer.prototype.push = function(camera) {

View File

@@ -91,8 +91,19 @@ FixedCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
FixedCamera.prototype.constructor = FixedCamera;
// Update function
FixedCamera.prototype.update = function() {
FixedCamera.prototype.update = function(position) {
// Compute distance between center of camera and position
dist = Tools.norm2(Tools.diff(position, this.position));
var low_bound = 500;
var high_bound = 500000;
if (dist < 500)
this.mesh.material.opacity = 0;
else if (dist > 500000)
this.mesh.material.opacity = 0.5;
else
this.mesh.material.opacity = (dist - 50)*0.5/(high_bound - low_bound);
}
// Look function