mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 06:08:05 +02:00
allow more than one near-grab on an object
This commit is contained in:
parent
966945d08c
commit
d4f954a0e2
1 changed files with 12 additions and 12 deletions
|
@ -242,8 +242,7 @@ function MyController(hand, triggerAction) {
|
||||||
var intersection = Entities.findRayIntersection(pickRay, true);
|
var intersection = Entities.findRayIntersection(pickRay, true);
|
||||||
if (intersection.intersects &&
|
if (intersection.intersects &&
|
||||||
intersection.properties.collisionsWillMove === 1 &&
|
intersection.properties.collisionsWillMove === 1 &&
|
||||||
intersection.properties.locked === 0 &&
|
intersection.properties.locked === 0) {
|
||||||
!entityIsGrabbedByOther(intersection.entityID)) {
|
|
||||||
// the ray is intersecting something we can move.
|
// the ray is intersecting something we can move.
|
||||||
var handControllerPosition = Controller.getSpatialControlPosition(this.palm);
|
var handControllerPosition = Controller.getSpatialControlPosition(this.palm);
|
||||||
var intersectionDistance = Vec3.distance(handControllerPosition, intersection.intersection);
|
var intersectionDistance = Vec3.distance(handControllerPosition, intersection.intersection);
|
||||||
|
@ -258,6 +257,10 @@ function MyController(hand, triggerAction) {
|
||||||
this.state = STATE_NEAR_GRABBING;
|
this.state = STATE_NEAR_GRABBING;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (entityIsGrabbedByOther(intersection.entityID)) {
|
||||||
|
// don't allow two people to distance grab the same object
|
||||||
|
return;
|
||||||
|
}
|
||||||
// the hand is far from the intersected object. go into distance-holding mode
|
// the hand is far from the intersected object. go into distance-holding mode
|
||||||
this.state = STATE_DISTANCE_HOLDING;
|
this.state = STATE_DISTANCE_HOLDING;
|
||||||
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||||
|
@ -441,16 +444,13 @@ function MyController(hand, triggerAction) {
|
||||||
var offsetPosition = Vec3.multiplyQbyV(Quat.inverse(Quat.multiply(handRotation, offsetRotation)), offset);
|
var offsetPosition = Vec3.multiplyQbyV(Quat.inverse(Quat.multiply(handRotation, offsetRotation)), offset);
|
||||||
|
|
||||||
this.actionID = NULL_ACTION_ID;
|
this.actionID = NULL_ACTION_ID;
|
||||||
if (!entityIsGrabbedByOther(this.grabbedEntity)) {
|
this.actionID = Entities.addAction("hold", this.grabbedEntity, {
|
||||||
this.actionID = Entities.addAction("hold", this.grabbedEntity, {
|
hand: this.hand === RIGHT_HAND ? "right" : "left",
|
||||||
hand: this.hand === RIGHT_HAND ? "right" : "left",
|
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
||||||
timeScale: NEAR_GRABBING_ACTION_TIMEFRAME,
|
relativePosition: offsetPosition,
|
||||||
relativePosition: offsetPosition,
|
relativeRotation: offsetRotation,
|
||||||
relativeRotation: offsetRotation,
|
lifetime: ACTION_LIFETIME
|
||||||
tag: getTag(),
|
});
|
||||||
lifetime: ACTION_LIFETIME
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (this.actionID === NULL_ACTION_ID) {
|
if (this.actionID === NULL_ACTION_ID) {
|
||||||
this.actionID = null;
|
this.actionID = null;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue