change grabbing-non-colliding to trigger. fix whiteboard and some other scripts

This commit is contained in:
Seth Alves 2015-11-05 10:35:02 -08:00
parent dba6031703
commit 4a3b434fd4
10 changed files with 66 additions and 54 deletions

View file

@ -101,10 +101,10 @@ var STATE_DISTANCE_HOLDING = 2;
var STATE_CONTINUE_DISTANCE_HOLDING = 3;
var STATE_NEAR_GRABBING = 4;
var STATE_CONTINUE_NEAR_GRABBING = 5;
var STATE_NEAR_GRABBING_NON_COLLIDING = 6;
var STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING = 7;
var STATE_FAR_GRABBING_NON_COLLIDING = 8;
var STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING = 9;
var STATE_NEAR_TRIGGER = 6;
var STATE_CONTINUE_NEAR_TRIGGER = 7;
var STATE_FAR_TRIGGER = 8;
var STATE_CONTINUE_FAR_TRIGGER = 9;
var STATE_RELEASE = 10;
@ -122,14 +122,14 @@ function stateToName(state) {
return "near_grabbing";
case STATE_CONTINUE_NEAR_GRABBING:
return "continue_near_grabbing";
case STATE_NEAR_GRABBING_NON_COLLIDING:
return "near_grabbing_non_colliding";
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
return "continue_near_grabbing_non_colliding";
case STATE_FAR_GRABBING_NON_COLLIDING:
return "far_grabbing_non_colliding";
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
return "continue_far_grabbing_non_colliding";
case STATE_NEAR_TRIGGER:
return "near_trigger";
case STATE_CONTINUE_NEAR_TRIGGER:
return "continue_near_trigger";
case STATE_FAR_TRIGGER:
return "far_trigger";
case STATE_CONTINUE_FAR_TRIGGER:
return "continue_far_trigger";
case STATE_RELEASE:
return "release";
}
@ -212,17 +212,17 @@ function MyController(hand) {
case STATE_CONTINUE_NEAR_GRABBING:
this.continueNearGrabbing();
break;
case STATE_NEAR_GRABBING_NON_COLLIDING:
this.nearGrabbingNonColliding();
case STATE_NEAR_TRIGGER:
this.nearTrigger();
break;
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
this.continueNearGrabbingNonColliding();
case STATE_CONTINUE_NEAR_TRIGGER:
this.continueNearTrigger();
break;
case STATE_FAR_GRABBING_NON_COLLIDING:
this.farGrabbingNonColliding();
case STATE_FAR_TRIGGER:
this.farTrigger();
break;
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
this.continueFarGrabbingNonColliding();
case STATE_CONTINUE_FAR_TRIGGER:
this.continueFarTrigger();
break;
case STATE_RELEASE:
this.release();
@ -394,7 +394,7 @@ function MyController(hand) {
// the hand is very close to the intersected object. go into close-grabbing mode.
if (grabbableData.wantsTrigger) {
this.grabbedEntity = intersection.entityID;
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
this.setState(STATE_NEAR_TRIGGER);
return;
} else if (!intersection.properties.locked) {
this.grabbedEntity = intersection.entityID;
@ -411,7 +411,7 @@ function MyController(hand) {
return;
} else if (grabbableData.wantsTrigger) {
this.grabbedEntity = intersection.entityID;
this.setState(STATE_FAR_GRABBING_NON_COLLIDING);
this.setState(STATE_FAR_TRIGGER);
return;
}
}
@ -483,7 +483,7 @@ function MyController(hand) {
return;
}
if (grabbableData.wantsTrigger) {
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
this.setState(STATE_NEAR_TRIGGER);
return;
} else if (!props.locked) {
this.setState(STATE_NEAR_GRABBING);
@ -538,6 +538,7 @@ function MyController(hand) {
this.continueDistanceHolding = function() {
if (this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
return;
}
@ -631,6 +632,7 @@ function MyController(hand) {
if (this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
return;
}
@ -698,6 +700,7 @@ function MyController(hand) {
this.continueNearGrabbing = function() {
if (this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
return;
}
@ -733,9 +736,10 @@ function MyController(hand) {
}
};
this.nearGrabbingNonColliding = function() {
this.nearTrigger = function() {
if (this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
return;
}
if (this.hand === RIGHT_HAND) {
@ -743,13 +747,14 @@ function MyController(hand) {
} else {
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
}
Entities.callEntityMethod(this.grabbedEntity, "startNearGrabNonColliding");
this.setState(STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING);
Entities.callEntityMethod(this.grabbedEntity, "startNearTrigger");
this.setState(STATE_CONTINUE_NEAR_TRIGGER);
};
this.farGrabbingNonColliding = function() {
this.farTrigger = function() {
if (this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
return;
}
@ -758,22 +763,24 @@ function MyController(hand) {
} else {
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
}
Entities.callEntityMethod(this.grabbedEntity, "startFarGrabNonColliding");
this.setState(STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING);
Entities.callEntityMethod(this.grabbedEntity, "startFarTrigger");
this.setState(STATE_CONTINUE_FAR_TRIGGER);
};
this.continueNearGrabbingNonColliding = function() {
this.continueNearTrigger = function() {
if (this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
return;
}
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrabbingNonColliding");
Entities.callEntityMethod(this.grabbedEntity, "continueNearTrigger");
};
this.continueFarGrabbingNonColliding = function() {
this.continueFarTrigger = function() {
if (this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
return;
}
@ -789,12 +796,13 @@ function MyController(hand) {
this.lastPickTime = now;
if (intersection.entityID != this.grabbedEntity) {
this.setState(STATE_RELEASE);
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
return;
}
}
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
Entities.callEntityMethod(this.grabbedEntity, "continueFarGrabbingNonColliding");
Entities.callEntityMethod(this.grabbedEntity, "continueFarTrigger");
};
_this.allTouchedIDs = {};
@ -876,7 +884,6 @@ function MyController(hand) {
if (this.actionID !== null) {
Entities.deleteAction(this.grabbedEntity, this.actionID);
}
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
}
this.deactivateEntity(this.grabbedEntity);

View file

@ -20,7 +20,7 @@
ColorSelector.prototype = {
startFarGrabNonColliding: function() {
startFarTrigger: function() {
this.selectColor();
},
@ -46,4 +46,4 @@
// entity scripts always need to return a newly constructed object of our type
return new ColorSelector();
});
});

View file

@ -20,7 +20,7 @@
BoardEraser.prototype = {
startFarGrabNonColliding: function() {
startFarTrigger: function() {
this.eraseBoard();
},
@ -42,4 +42,4 @@
// entity scripts always need to return a newly constructed object of our type
return new BoardEraser();
});
});

View file

@ -43,7 +43,7 @@
this.hand = LEFT_HAND;
},
startFarGrabNonColliding: function() {
startFarTrigger: function() {
if (this.painting) {
return;
}
@ -62,7 +62,7 @@
});
},
continueFarGrabbingNonColliding: function() {
continueFarTrigger: function() {
var handPosition = this.getHandPosition();
var pickRay = {
origin: handPosition,
@ -183,7 +183,7 @@
},
releaseGrab: function() {
stopFarTrigger: function() {
if(this.hand !== this.whichHand) {
return;
}
@ -249,4 +249,4 @@
// entity scripts always need to return a newly constructed object of our type
return new Whiteboard();
});
});

View file

@ -74,6 +74,9 @@ var drawingSurface = Entities.addEntity({
userData: JSON.stringify({
color: {
currentColor: colors[0]
},
"grabbableKey": {
wantsTrigger:true
}
})
@ -211,4 +214,4 @@ function cleanup() {
// Uncomment this line to delete whiteboard and all associated entity on script close
// Script.scriptEnding.connect(cleanup);
// Script.scriptEnding.connect(cleanup);

View file

@ -33,7 +33,7 @@
this.toggleLights();
},
startNearGrabNonColliding: function () {
startNearTrigger: function () {
this.toggleLights();
},
@ -61,7 +61,8 @@
setEntityCustomData(this.resetKey, this.entityID, {
on: on,
type: lightType,
resetMe: true
resetMe: true,
grabbableKey: {wantsTrigger:true}
});
},
@ -89,4 +90,4 @@
// entity scripts always need to return a newly constructed object of our type
return new LightSwitch();
});
});

View file

@ -17,7 +17,7 @@ var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
Resetter.prototype = {
startNearGrabNonColliding: function() {
startNearTrigger: function() {
this.resetObjects();
},
@ -108,4 +108,4 @@ var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
};
return new Resetter();
});
});

View file

@ -39,7 +39,7 @@
},
startNearGrabNonColliding: function() {
startNearTrigger: function() {
this.triggerReset();
},
@ -1259,4 +1259,4 @@
};
// entity scripts always need to return a newly constructed object of our type
return new ResetSwitch();
});
});

View file

@ -247,7 +247,8 @@ MasterReset = function() {
resetMe: true
},
grabbableKey: {
grabbable: false
grabbable: false,
wantsTrigger:true
}
})
});
@ -1237,4 +1238,4 @@ MasterReset = function() {
Script.scriptEnding.connect(cleanup);
}
};
};

View file

@ -17,7 +17,7 @@
Resetter.prototype = {
startNearGrabNonColliding: function() {
startNearTrigger: function() {
this.resetObjects();
},
@ -125,4 +125,4 @@
};
return new Resetter();
});
});