Merge pull request #4877 from ericrius1/hydra

added support for both right and left hydras for hydra scripts, and m…
This commit is contained in:
Philip Rosedale 2015-05-14 17:14:48 -07:00
commit 252631475f
2 changed files with 13 additions and 5 deletions

View file

@ -18,6 +18,7 @@
var entityProps, currentPosition, currentVelocity, currentRotation, distanceToTarget, velocityTowardTarget, desiredVelocity; var entityProps, currentPosition, currentVelocity, currentRotation, distanceToTarget, velocityTowardTarget, desiredVelocity;
var addedVelocity, newVelocity, angularVelocity, dT, cameraEntityDistance; var addedVelocity, newVelocity, angularVelocity, dT, cameraEntityDistance;
var LEFT = 0;
var RIGHT = 1; var RIGHT = 1;
var LASER_WIDTH = 3; var LASER_WIDTH = 3;
var LASER_COLOR = { var LASER_COLOR = {
@ -50,7 +51,7 @@ var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/s
var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav"); var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav");
function getRayIntersection(pickRay) { function getRayIntersection(pickRay) {
var intersection = Entities.findRayIntersection(pickRay); var intersection = Entities.findRayIntersection(pickRay, true);
return intersection; return intersection;
} }
@ -194,7 +195,7 @@ function controller(side) {
origin: this.palmPosition, origin: this.palmPosition,
direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition)) direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition))
}; };
var intersection = getRayIntersection(pickRay); var intersection = getRayIntersection(pickRay, true);
if (intersection.intersects && intersection.properties.collisionsWillMove) { if (intersection.intersects && intersection.properties.collisionsWillMove) {
this.laserWasHovered = true; this.laserWasHovered = true;
if (this.triggerHeld && !this.grabbing) { if (this.triggerHeld && !this.grabbing) {
@ -286,10 +287,12 @@ function controller(side) {
function update(deltaTime) { function update(deltaTime) {
rightController.update(deltaTime); rightController.update(deltaTime);
leftController.update(deltaTime);
} }
function scriptEnding() { function scriptEnding() {
rightController.cleanup(); rightController.cleanup();
leftController.cleanup();
} }
function vectorIsZero(v) { function vectorIsZero(v) {
@ -297,6 +300,7 @@ function vectorIsZero(v) {
} }
var rightController = new controller(RIGHT); var rightController = new controller(RIGHT);
var leftController = new controller(LEFT);
Script.update.connect(update); Script.update.connect(update);

View file

@ -16,8 +16,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
var addedVelocity, newVelocity, angularVelocity, dT, cameraEntityDistance; var addedVelocity, newVelocity, angularVelocity, dT, cameraEntityDistance;
var LEFT = 0;
var RIGHT = 1; var RIGHT = 1;
var LASER_WIDTH = 3; var LASER_WIDTH = 3;
var LASER_COLOR = { var LASER_COLOR = {
@ -50,10 +50,11 @@ var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/s
var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav"); var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav");
function getRayIntersection(pickRay) { function getRayIntersection(pickRay) {
var intersection = Entities.findRayIntersection(pickRay); var intersection = Entities.findRayIntersection(pickRay, true);
return intersection; return intersection;
} }
function controller(side) { function controller(side) {
this.triggerHeld = false; this.triggerHeld = false;
this.triggerThreshold = 0.9; this.triggerThreshold = 0.9;
@ -190,7 +191,7 @@ function controller(side) {
origin: this.palmPosition, origin: this.palmPosition,
direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition)) direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition))
}; };
var intersection = getRayIntersection(pickRay); var intersection = getRayIntersection(pickRay, true);
if (intersection.intersects && intersection.properties.collisionsWillMove) { if (intersection.intersects && intersection.properties.collisionsWillMove) {
this.laserWasHovered = true; this.laserWasHovered = true;
if (this.triggerHeld && !this.grabbing) { if (this.triggerHeld && !this.grabbing) {
@ -282,10 +283,12 @@ function controller(side) {
function update(deltaTime) { function update(deltaTime) {
rightController.update(deltaTime); rightController.update(deltaTime);
leftController.update(deltaTime);
} }
function scriptEnding() { function scriptEnding() {
rightController.cleanup(); rightController.cleanup();
leftController.cleanup();
} }
function vectorIsZero(v) { function vectorIsZero(v) {
@ -293,6 +296,7 @@ function vectorIsZero(v) {
} }
var rightController = new controller(RIGHT); var rightController = new controller(RIGHT);
var leftController = new controller(LEFT);
Script.update.connect(update); Script.update.connect(update);