Merge pull request #6515 from imgntn/personal_lasers

Personal lasers in handControllerGrab.js
This commit is contained in:
Seth Alves 2015-12-01 13:29:05 -08:00
commit e0eae23dd3

View file

@ -200,6 +200,7 @@ function entityIsGrabbedByOther(entityID) {
return false; return false;
} }
function MyController(hand) { function MyController(hand) {
this.hand = hand; this.hand = hand;
if (this.hand === RIGHT_HAND) { if (this.hand === RIGHT_HAND) {
@ -223,6 +224,8 @@ function MyController(hand) {
this.rawTriggerValue = 0; this.rawTriggerValue = 0;
this.rawBumperValue = 0; this.rawBumperValue = 0;
this.overlayLine = null;
this.offsetPosition = { this.offsetPosition = {
x: 0.0, x: 0.0,
y: 0.0, y: 0.0,
@ -318,6 +321,33 @@ function MyController(hand) {
}); });
} }
this.overlayLineOn = function(closePoint, farPoint, color) {
if (this.overlayLine === null) {
var lineProperties = {
lineWidth: 5,
start: closePoint,
end: farPoint,
color: color,
ignoreRayIntersection: true, // always ignore this
visible: true,
alpha: 1
};
this.overlayLine = Overlays.addOverlay("line3d", lineProperties);
} else {
var success = Overlays.editOverlay(this.overlayLine, {
lineWidth: 5,
start: closePoint,
end: farPoint,
color: color,
visible: true,
ignoreRayIntersection: true, // always ignore this
alpha: 1
});
}
}
this.lineOn = function(closePoint, farPoint, color) { this.lineOn = function(closePoint, farPoint, color) {
// draw a line // draw a line
if (this.pointer === null) { if (this.pointer === null) {
@ -356,6 +386,13 @@ function MyController(hand) {
this.pointer = null; this.pointer = null;
}; };
this.overlayLineOff = function() {
if (this.overlayLine !== null) {
Overlays.deleteOverlay(this.overlayLine);
}
this.overlayLine = null;
};
this.triggerPress = function(value) { this.triggerPress = function(value) {
_this.rawTriggerValue = value; _this.rawTriggerValue = value;
}; };
@ -604,7 +641,8 @@ function MyController(hand) {
} }
} }
this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR); //this.lineOn(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
this.overlayLineOn(distantPickRay.origin, Vec3.sum(distantPickRay.origin, Vec3.multiply(distantPickRay.direction, LINE_LENGTH)), NO_INTERSECT_COLOR);
}; };
this.distanceHolding = function() { this.distanceHolding = function() {
@ -650,6 +688,9 @@ function MyController(hand) {
this.currentAvatarPosition = MyAvatar.position; this.currentAvatarPosition = MyAvatar.position;
this.currentAvatarOrientation = MyAvatar.orientation; this.currentAvatarOrientation = MyAvatar.orientation;
this.overlayLineOff();
}; };
this.continueDistanceHolding = function() { this.continueDistanceHolding = function() {
@ -757,6 +798,7 @@ function MyController(hand) {
} }
this.lineOff(); this.lineOff();
this.overlayLineOff();
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES); var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
this.activateEntity(this.grabbedEntity, grabbedProperties); this.activateEntity(this.grabbedEntity, grabbedProperties);
@ -898,6 +940,7 @@ function MyController(hand) {
this.pullTowardEquipPosition = function() { this.pullTowardEquipPosition = function() {
this.lineOff(); this.lineOff();
this.overlayLineOff();
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES); var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA); var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
@ -1101,7 +1144,7 @@ function MyController(hand) {
this.release = function() { this.release = function() {
this.lineOff(); this.lineOff();
this.overlayLineOff();
if (this.grabbedEntity !== null) { if (this.grabbedEntity !== null) {
if (this.actionID !== null) { if (this.actionID !== null) {
Entities.deleteAction(this.grabbedEntity, this.actionID); Entities.deleteAction(this.grabbedEntity, this.actionID);