Hide camera when clicking on it
This commit is contained in:
parent
b5d2822d00
commit
f4d28a6ee6
|
@ -58,3 +58,7 @@ CameraContainer.prototype.nextCamera = function() {
|
|||
this.current_camera%=this.cameras.length;
|
||||
}
|
||||
}
|
||||
|
||||
CameraContainer.prototype.map = function(callback) {
|
||||
this.cameras.map(callback);
|
||||
}
|
||||
|
|
|
@ -105,3 +105,8 @@ FixedCamera.prototype.addToScene = function(scene) {
|
|||
scene.add(this.mesh);
|
||||
scene.add(this.line);
|
||||
}
|
||||
|
||||
FixedCamera.prototype.traverse = function(callback) {
|
||||
callback(this.mesh);
|
||||
callback(this.line);
|
||||
}
|
||||
|
|
|
@ -204,6 +204,9 @@ function click(event) {
|
|||
|
||||
var intersects = raycaster.intersectObjects(scene.children, true);
|
||||
|
||||
// Re-show all cameras
|
||||
cameras.map(function(elt) { show(elt); });
|
||||
|
||||
if ( intersects.length > 0 ) {
|
||||
var minDistance;
|
||||
var bestIndex;
|
||||
|
@ -221,14 +224,18 @@ function click(event) {
|
|||
|
||||
if (bestIndex !== undefined) {
|
||||
if (cameras.getById(intersects[bestIndex].object.id) !== undefined) {
|
||||
cameras.get(0).move(cameras.getById(intersects[bestIndex].object.id));
|
||||
var new_camera = cameras.getById(intersects[bestIndex].object.id);
|
||||
hide(new_camera)
|
||||
cameras.get(0).move(new_camera);
|
||||
}
|
||||
}
|
||||
|
||||
// Looking for objects
|
||||
for (o in objects) {
|
||||
if ( intersects[bestIndex].object.id == objects[o].id && cameras.get(objects[o].seen_by[0]) !== undefined) {
|
||||
cameras.get(0).move(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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue