From a46bac5663dac42ca44f343f44c877007ae50e65 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Wed, 22 Apr 2015 16:24:45 +0200 Subject: [PATCH] Added option to hide arrows --- prototype/index.html | 2 ++ prototype/js/main.js | 32 +++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/prototype/index.html b/prototype/index.html index 6d2e0a8..c1ea646 100644 --- a/prototype/index.html +++ b/prototype/index.html @@ -20,6 +20,8 @@ + +
# diff --git a/prototype/js/main.js b/prototype/js/main.js index 8d08400..4978f64 100644 --- a/prototype/js/main.js +++ b/prototype/js/main.js @@ -12,6 +12,7 @@ var loader; var container_size = {width: 1067, height: 600}; var prev = {x:0, y:0, go:false}; +var showArrows = true; init(); animate(); @@ -36,6 +37,11 @@ function init() { cameras.mainCamera().collisions = collisions.checked; } + var showarrows = document.getElementById('showarrows'); + showarrows.onchange = function() { + showArrows = showarrows.checked; + } + // on initialise le moteur de rendu container = document.getElementById('container'); container.style.height = container_size.height + 'px'; @@ -218,7 +224,17 @@ function loadScene() { } function render() { - cameras.map(function(camera) { if (camera instanceof FixedCamera) show(camera); }); + var transform = showArrows ? show : hide; + cameras.map(function(camera) { + if (camera instanceof FixedCamera) { + transform(camera); + + camera.traverse(function(elt) { + elt.raycastable = showArrows; + }); + } + }); + cameras.updateMainCamera(); cameras.update(cameras.mainCamera()); cameras.look(); @@ -313,12 +329,14 @@ function pointedCamera(event) { // Looking for cameras for (i in intersects) { - if ((intersects[i].distance > 0.5 && minDistance === undefined) || (intersects[i].distance < minDistance )) { - // We will not consider a line as clickable - if (! (intersects[i].object instanceof THREE.Line)) { - if (!(intersects[i].object instanceof THREE.Mesh && intersects[i].object.material.opacity < 0.1)) { - minDistance = intersects[i].distance; - bestIndex = i; + if (intersects[i].object.raycastable) { + if ((intersects[i].distance > 0.5 && minDistance === undefined) || (intersects[i].distance < minDistance )) { + // We will not consider a line as clickable + if (! (intersects[i].object instanceof THREE.Line)) { + if (!(intersects[i].object instanceof THREE.Mesh && intersects[i].object.material.opacity < 0.1)) { + minDistance = intersects[i].distance; + bestIndex = i; + } } } }