Camera disappears progressively (classy :D)
This commit is contained in:
parent
d33e91f899
commit
bdb975e2f0
|
@ -23,8 +23,8 @@ CameraContainer.prototype.look = function() {
|
||||||
this.cameras[this.current_camera].look();
|
this.cameras[this.current_camera].look();
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraContainer.prototype.update = function() {
|
CameraContainer.prototype.update = function(position) {
|
||||||
this.cameras[this.current_camera].update();
|
this.cameras.map(function (elt) { elt.update(position); });
|
||||||
}
|
}
|
||||||
|
|
||||||
CameraContainer.prototype.push = function(camera) {
|
CameraContainer.prototype.push = function(camera) {
|
||||||
|
|
|
@ -91,8 +91,19 @@ FixedCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
|
||||||
FixedCamera.prototype.constructor = FixedCamera;
|
FixedCamera.prototype.constructor = FixedCamera;
|
||||||
|
|
||||||
// Update function
|
// 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
|
// Look function
|
||||||
|
|
|
@ -167,7 +167,7 @@ function animate() {
|
||||||
requestAnimationFrame(animate);
|
requestAnimationFrame(animate);
|
||||||
|
|
||||||
stats.begin();
|
stats.begin();
|
||||||
cameras.update();
|
cameras.update(cameras.mainCamera().position);
|
||||||
cameras.look();
|
cameras.look();
|
||||||
|
|
||||||
renderer.render(scene, cameras.mainCamera());
|
renderer.render(scene, cameras.mainCamera());
|
||||||
|
@ -204,9 +204,6 @@ function click(event) {
|
||||||
|
|
||||||
var intersects = raycaster.intersectObjects(scene.children, true);
|
var intersects = raycaster.intersectObjects(scene.children, true);
|
||||||
|
|
||||||
// Re-show all cameras
|
|
||||||
cameras.map(function(elt) { show(elt); });
|
|
||||||
|
|
||||||
if ( intersects.length > 0 ) {
|
if ( intersects.length > 0 ) {
|
||||||
var minDistance;
|
var minDistance;
|
||||||
var bestIndex;
|
var bestIndex;
|
||||||
|
@ -225,7 +222,6 @@ function click(event) {
|
||||||
if (bestIndex !== undefined) {
|
if (bestIndex !== undefined) {
|
||||||
if (cameras.getById(intersects[bestIndex].object.id) !== undefined) {
|
if (cameras.getById(intersects[bestIndex].object.id) !== undefined) {
|
||||||
var new_camera = cameras.getById(intersects[bestIndex].object.id);
|
var new_camera = cameras.getById(intersects[bestIndex].object.id);
|
||||||
hide(new_camera)
|
|
||||||
cameras.get(0).move(new_camera);
|
cameras.get(0).move(new_camera);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +230,6 @@ function click(event) {
|
||||||
for (o in objects) {
|
for (o in objects) {
|
||||||
if ( intersects[bestIndex].object.id == objects[o].id && cameras.get(objects[o].seen_by[0]) !== undefined) {
|
if ( intersects[bestIndex].object.id == objects[o].id && cameras.get(objects[o].seen_by[0]) !== undefined) {
|
||||||
var new_camera = cameras.get(objects[o].seen_by[0]);
|
var new_camera = cameras.get(objects[o].seen_by[0]);
|
||||||
hide(new_camera);
|
|
||||||
cameras.get(0).move(new_camera);
|
cameras.get(0).move(new_camera);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue