Commit ca9c0d2c authored by Amanda Ghassaei's avatar Amanda Ghassaei

debugging

parent f386a9a7
...@@ -1461,6 +1461,7 @@ var GUIVR = function DATGUIVR() { ...@@ -1461,6 +1461,7 @@ var GUIVR = function DATGUIVR() {
pressed: false, pressed: false,
gripped: false, gripped: false,
events: new _events2.default(), events: new _events2.default(),
enabled: true,
interaction: { interaction: {
grip: undefined, grip: undefined,
press: undefined, press: undefined,
...@@ -1556,7 +1557,7 @@ var GUIVR = function DATGUIVR() { ...@@ -1556,7 +1557,7 @@ var GUIVR = function DATGUIVR() {
inputObjects.push(input); inputObjects.push(input);
return input.laser; return input;
} }
/* /*
...@@ -1741,8 +1742,9 @@ var GUIVR = function DATGUIVR() { ...@@ -1741,8 +1742,9 @@ var GUIVR = function DATGUIVR() {
} }
inputObjects.forEach(function () { inputObjects.forEach(function () {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
box = _ref.box, if (!_ref.enabled) return;
var box = _ref.box,
object = _ref.object, object = _ref.object,
raycast = _ref.raycast, raycast = _ref.raycast,
laser = _ref.laser, laser = _ref.laser,
......
...@@ -30,6 +30,7 @@ function initViveInterface(globals){ ...@@ -30,6 +30,7 @@ function initViveInterface(globals){
var nodes = [null, null]; var nodes = [null, null];
var intersections = [false, false]; var intersections = [false, false];
var guiHelpers = [null, null];
connect(); connect();
...@@ -42,7 +43,7 @@ function initViveInterface(globals){ ...@@ -42,7 +43,7 @@ function initViveInterface(globals){
stepsPerFrame: globals.numSteps, stepsPerFrame: globals.numSteps,
damping: globals.percentDamping, damping: globals.percentDamping,
strainMap: false, strainMap: false,
position: new THREE.Vector3(0,1.6,0) position: new THREE.Vector3(0,1.3,0)
}; };
var gui = dat.GUIVR.create( 'Settings' ); var gui = dat.GUIVR.create( 'Settings' );
...@@ -108,8 +109,8 @@ function initViveInterface(globals){ ...@@ -108,8 +109,8 @@ function initViveInterface(globals){
controller.head = camera; controller.head = camera;
var var
meshColorOff = 0x555555, meshColorOff = 0x888888,
meshColorOn = 0x888888, meshColorOn = 0xcccccc,
controllerMaterial = new THREE.MeshStandardMaterial({ controllerMaterial = new THREE.MeshStandardMaterial({
color: meshColorOff color: meshColorOff
}), }),
...@@ -130,15 +131,16 @@ function initViveInterface(globals){ ...@@ -130,15 +131,16 @@ function initViveInterface(globals){
controller.add( controllerMesh ); controller.add( controllerMesh );
var guiInputHelper = dat.GUIVR.addInputObject( controller ); var guiInputHelper = dat.GUIVR.addInputObject( controller );
scene.add( guiInputHelper ); scene.add( guiInputHelper.laser );
guiHelpers[controllerIndex] = guiInputHelper;
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;
if (intersections[controllerIndex] || nodes[controllerIndex]) { if (intersections[controllerIndex] || nodes[controllerIndex]) {
guiInputHelper.pressed( false ); guiInputHelper.laser.pressed( false );
} else guiInputHelper.pressed( true ); } else guiInputHelper.laser.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 );
...@@ -147,7 +149,7 @@ function initViveInterface(globals){ ...@@ -147,7 +149,7 @@ function initViveInterface(globals){
nodes[controllerIndex].setFixed(false); nodes[controllerIndex].setFixed(false);
globals.fixedHasChanged = true; globals.fixedHasChanged = true;
} }
guiInputHelper.pressed( false ); guiInputHelper.laser.pressed( false );
}); });
controller.addEventListener( 'disconnected', function( event ){ controller.addEventListener( 'disconnected', function( event ){
...@@ -222,6 +224,12 @@ function initViveInterface(globals){ ...@@ -222,6 +224,12 @@ function initViveInterface(globals){
var tMatrix = new THREE.Matrix4(); var tMatrix = new THREE.Matrix4();
var tDirection = new THREE.Vector3(0,0,-1); var tDirection = new THREE.Vector3(0,0,-1);
function disableLaserPointer(helper){
helper.enabled = false;
helper.laser.visible = false;
helper.cursor.visible = false;
}
function checkForIntersections(){ function checkForIntersections(){
var numControllers = controllers.length; var numControllers = controllers.length;
if (numControllers>2){ if (numControllers>2){
...@@ -245,6 +253,7 @@ function initViveInterface(globals){ ...@@ -245,6 +253,7 @@ function initViveInterface(globals){
if (states[i] && nodes[i]){ if (states[i] && nodes[i]){
//drag node //drag node
disableLaserPointer(guiHelpers[i]);
if (!nodes[i].isFixed()) { if (!nodes[i].isFixed()) {
nodes[i].setFixed(true); nodes[i].setFixed(true);
globals.fixedHasChanged = true; globals.fixedHasChanged = true;
...@@ -260,6 +269,7 @@ function initViveInterface(globals){ ...@@ -260,6 +269,7 @@ function initViveInterface(globals){
var cast = new THREE.Raycaster(position, tDirection, 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){
disableLaserPointer(guiHelpers[i]);
intersections[i] = true; intersections[i] = true;
var intersection = intersects[0]; var intersection = intersects[0];
var face = intersection.face; var face = intersection.face;
...@@ -292,6 +302,7 @@ function initViveInterface(globals){ ...@@ -292,6 +302,7 @@ function initViveInterface(globals){
} else { } else {
intersections[i] = false; intersections[i] = false;
nodes[i] = null; nodes[i] = null;
guiHelpers[i].enabled = true;
} }
} else { } else {
......
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