trying to fix interaction with grab script...

This commit is contained in:
James B. Pollack 2016-07-07 19:22:42 -07:00
parent 7fa1dc7053
commit f8ff0da901
3 changed files with 55 additions and 8 deletions

View file

@ -0,0 +1,17 @@
function mousePressEvent(event) {
var overlay = Overlays.getOverlayAtPoint({x:event.x,y:event.y});
print('overlay is: ' + overlay)
// var pickRay = Camera.computePickRay(event.x, event.y);
// var intersection = Overlays.findRayIntersection(pickRay);
// print('intersection is: ' + intersection)
};
Controller.mouseMoveEvent.connect(function(event){
print('mouse press')
mousePressEvent(event)
});
Script.scriptEnding.connect(function(){
Controller.mousePressEvent.disconnect(mousePressEvent);
})

View file

@ -367,7 +367,6 @@ function MyController(hand) {
// for lights
this.spotlight = null;
this.pointlight = null;
this.overlayLine = null;
this.searchSphere = null;
this.waitForTriggerRelease = false;
@ -400,6 +399,7 @@ function MyController(hand) {
this.updateSmoothedTrigger();
if (this.ignoreInput()) {
// print('in ignore input turn off')
this.turnOffVisualizations();
return;
}
@ -531,6 +531,7 @@ function MyController(hand) {
};
this.overlayLineOn = function(closePoint, farPoint, color) {
if (this.overlayLine === null) {
var lineProperties = {
lineWidth: 5,
@ -543,6 +544,7 @@ function MyController(hand) {
alpha: 1
};
this.overlayLine = Overlays.addOverlay("line3d", lineProperties);
print('CREATED OVERLAY IT IS ' + this.overlayLine )
} else {
Overlays.editOverlay(this.overlayLine, {
@ -555,7 +557,9 @@ function MyController(hand) {
drawInFront: true, // Even when burried inside of something, show it.
alpha: 1
});
print('edited overlay line ' + this.overlayLine )
}
};
this.searchIndicatorOn = function(distantPickRay) {
@ -758,14 +762,20 @@ function MyController(hand) {
};
this.overlayLineOff = function() {
return;
if (this.overlayLine !== null) {
Overlays.deleteOverlay(this.overlayLine);
Overlays.deleteOverlay(this.overlayLine);
print('REMOVING OVERLAY LINE' + this.overlayLine)
this.overlayLine = null;
}
this.overlayLine = null;
// print('overlay shoudl be null and is line is ' + this.overlayLine)
};
this.searchSphereOff = function() {
if (this.searchSphere !== null) {
print('removing search sphere' + this.searchSphere)
Overlays.deleteOverlay(this.searchSphere);
this.searchSphere = null;
this.searchSphereDistance = DEFAULT_SEARCH_SPHERE_DISTANCE;
@ -792,21 +802,28 @@ function MyController(hand) {
}
};
this.turnOffVisualizations = function() {
this.turnOffVisualizations = function(hand) {
// print('TURN OFF VISUALIZATIONS: ' + hand)
if (USE_ENTITY_LINES_FOR_SEARCHING === true || USE_ENTITY_LINES_FOR_MOVING === true) {
this.lineOff();
// print('after line off')
}
if (USE_OVERLAY_LINES_FOR_SEARCHING === true || USE_OVERLAY_LINES_FOR_MOVING === true) {
this.overlayLineOff();
// print('after overlay line off')
}
if (USE_PARTICLE_BEAM_FOR_MOVING === true) {
this.particleBeamOff();
// print('after particle beam off')
}
this.searchSphereOff();
restore2DMode();
// print('after all turn off calls')
};
this.triggerPress = function(value) {
@ -2232,11 +2249,18 @@ var handleHandMessages = function(channel, message, sender) {
if (sender === MyAvatar.sessionUUID) {
if (channel === 'Hifi-Hand-Disabler') {
if (message === 'left') {
leftController.turnOffVisualizations('left');
handToDisable = LEFT_HAND;
}
if (message === 'right') {
rightController.turnOffVisualizations('right');
handToDisable = RIGHT_HAND;
}
if (message === "both") {
print('disable both')
leftController.turnOffVisualizations('left');
rightController.turnOffVisualizations('right');
}
if (message === 'both' || message === 'none') {
handToDisable = message;
}

View file

@ -102,6 +102,7 @@ function Teleporter() {
this.updateConnected = null;
this.smoothArrivalInterval = null;
this.fadeSphere = null;
this.teleportHand = null;
this.initialize = function() {
this.createMappings();
@ -265,7 +266,7 @@ function Teleporter() {
} else {
Script.update.disconnect(this.update);
}
this.teleportHand = null;
this.updateConnected = null;
this.disableMappings();
this.turnOffOverlayBeams();
@ -301,6 +302,7 @@ function Teleporter() {
teleporter.leftRay();
if ((leftPad.buttonValue === 0 || leftTrigger.buttonValue === 0) && inTeleportMode === true) {
print('TELEPORTING LEFT')
_this.teleport();
return;
}
@ -309,6 +311,8 @@ function Teleporter() {
teleporter.rightRay();
if ((rightPad.buttonValue === 0 || rightTrigger.buttonValue === 0) && inTeleportMode === true) {
print('TELEPORTING RIGHT')
_this.teleport();
return;
}
@ -429,6 +433,7 @@ function Teleporter() {
visible: true,
alpha: 1,
solid: true,
drawInFront: true,
glow: 1.0
};
@ -457,7 +462,8 @@ function Teleporter() {
visible: true,
alpha: 1,
solid: true,
glow: 1.0
glow: 1.0,
drawInFront: true
};
this.leftOverlayLine = Overlays.addOverlay("line3d", lineProperties);
@ -506,7 +512,7 @@ function Teleporter() {
};
this.disableGrab = function() {
Messages.sendLocalMessage('Hifi-Hand-Disabler', 'both');
Messages.sendLocalMessage('Hifi-Hand-Disabler', this.teleportHand);
};
this.enableGrab = function() {
@ -514,7 +520,7 @@ function Teleporter() {
};
this.triggerHaptics = function() {
var hand = this.hand === 'left' ? 0 : 1;
var hand = this.teleportHand === 'left' ? 0 : 1;
var haptic = Controller.triggerShortHapticPulse(0.2, hand);
};