Commit f386a9a7 authored by Amanda Ghassaei's avatar Amanda Ghassaei

ignore gui when intersecting mesh

parent e7a451b9
...@@ -29,6 +29,7 @@ function initViveInterface(globals){ ...@@ -29,6 +29,7 @@ function initViveInterface(globals){
}); });
var nodes = [null, null]; var nodes = [null, null];
var intersections = [false, false];
connect(); connect();
...@@ -44,7 +45,6 @@ function initViveInterface(globals){ ...@@ -44,7 +45,6 @@ function initViveInterface(globals){
position: new THREE.Vector3(0,1.6,0) position: new THREE.Vector3(0,1.6,0)
}; };
// dat.GUIVR.disableMouse();
var gui = dat.GUIVR.create( 'Settings' ); var gui = dat.GUIVR.create( 'Settings' );
gui.position.set( -0.033949220776551325, 2.2973055921574033, -1.0077168687920643 ); gui.position.set( -0.033949220776551325, 2.2973055921574033, -1.0077168687920643 );
gui.rotation.set( 0,0,0 ); gui.rotation.set( 0,0,0 );
...@@ -74,7 +74,7 @@ function initViveInterface(globals){ ...@@ -74,7 +74,7 @@ function initViveInterface(globals){
globals.materialHasChanged = true; globals.materialHasChanged = true;
globals.controls.setSliderInputVal("#percentDamping", val); globals.controls.setSliderInputVal("#percentDamping", val);
}); });
var numStepsSlider = gui.add(variables, "stepsPerFrame").min(1).max(200).step(1).name("Num Steps Per Frame").onChange( function(val) { gui.add(variables, "stepsPerFrame").min(1).max(200).step(1).name("Num Steps Per Frame").onChange( function(val) {
globals.numSteps = val; globals.numSteps = val;
$(".numStepsPerRender").val(val); $(".numStepsPerRender").val(val);
}).listen();; }).listen();;
...@@ -136,7 +136,9 @@ function initViveInterface(globals){ ...@@ -136,7 +136,9 @@ function initViveInterface(globals){
controller.addEventListener( 'primary press began', function( event ){ controller.addEventListener( 'primary press began', function( event ){
event.target.userData.mesh.material.color.setHex( meshColorOn ); event.target.userData.mesh.material.color.setHex( meshColorOn );
states[controllerIndex] = true; states[controllerIndex] = true;
guiInputHelper.pressed( true ); if (intersections[controllerIndex] || nodes[controllerIndex]) {
guiInputHelper.pressed( false );
} else guiInputHelper.pressed( true );
}); });
controller.addEventListener( 'primary press ended', function( event ){ controller.addEventListener( 'primary press ended', function( event ){
event.target.userData.mesh.material.color.setHex( meshColorOff ); event.target.userData.mesh.material.color.setHex( meshColorOff );
...@@ -255,13 +257,19 @@ function initViveInterface(globals){ ...@@ -255,13 +257,19 @@ function initViveInterface(globals){
continue; continue;
} }
var cast = new THREE.Raycaster(position, tDirection, 0, 0.1); var cast = new THREE.Raycaster(position, tDirection, 0, 1);
var intersects = cast.intersectObjects(globals.model.getMesh(), false); var intersects = cast.intersectObjects(globals.model.getMesh(), false);
if (intersects.length>0){ if (intersects.length>0){
intersections[i] = true;
var intersection = intersects[0]; var intersection = intersects[0];
var face = intersection.face; var face = intersection.face;
var point = intersection.point; var point = intersection.point;
if ((point.clone().sub(position)).lengthSq() > 0.01) {
nodes[i] = null;
continue;
}
var positionsArray = globals.model.getPositionsArray(); var positionsArray = globals.model.getPositionsArray();
var vertices = []; var vertices = [];
vertices.push(new THREE.Vector3(positionsArray[3*face.a], positionsArray[3*face.a+1], positionsArray[3*face.a+2])); vertices.push(new THREE.Vector3(positionsArray[3*face.a], positionsArray[3*face.a+1], positionsArray[3*face.a+2]));
...@@ -282,6 +290,7 @@ function initViveInterface(globals){ ...@@ -282,6 +290,7 @@ function initViveInterface(globals){
object3D.position.copy(transformToGlobalCoords(nodes[i].getPosition().clone())); object3D.position.copy(transformToGlobalCoords(nodes[i].getPosition().clone()));
object3D.visible = true; object3D.visible = true;
} else { } else {
intersections[i] = false;
nodes[i] = null; nodes[i] = null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment