mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Merge pull request #6318 from sethalves/non-colliding-to-trigger
grab changes
This commit is contained in:
commit
ce80b2d7e5
10 changed files with 66 additions and 54 deletions
|
@ -101,10 +101,10 @@ var STATE_DISTANCE_HOLDING = 2;
|
||||||
var STATE_CONTINUE_DISTANCE_HOLDING = 3;
|
var STATE_CONTINUE_DISTANCE_HOLDING = 3;
|
||||||
var STATE_NEAR_GRABBING = 4;
|
var STATE_NEAR_GRABBING = 4;
|
||||||
var STATE_CONTINUE_NEAR_GRABBING = 5;
|
var STATE_CONTINUE_NEAR_GRABBING = 5;
|
||||||
var STATE_NEAR_GRABBING_NON_COLLIDING = 6;
|
var STATE_NEAR_TRIGGER = 6;
|
||||||
var STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING = 7;
|
var STATE_CONTINUE_NEAR_TRIGGER = 7;
|
||||||
var STATE_FAR_GRABBING_NON_COLLIDING = 8;
|
var STATE_FAR_TRIGGER = 8;
|
||||||
var STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING = 9;
|
var STATE_CONTINUE_FAR_TRIGGER = 9;
|
||||||
var STATE_RELEASE = 10;
|
var STATE_RELEASE = 10;
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,14 +122,14 @@ function stateToName(state) {
|
||||||
return "near_grabbing";
|
return "near_grabbing";
|
||||||
case STATE_CONTINUE_NEAR_GRABBING:
|
case STATE_CONTINUE_NEAR_GRABBING:
|
||||||
return "continue_near_grabbing";
|
return "continue_near_grabbing";
|
||||||
case STATE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_NEAR_TRIGGER:
|
||||||
return "near_grabbing_non_colliding";
|
return "near_trigger";
|
||||||
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_NEAR_TRIGGER:
|
||||||
return "continue_near_grabbing_non_colliding";
|
return "continue_near_trigger";
|
||||||
case STATE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_FAR_TRIGGER:
|
||||||
return "far_grabbing_non_colliding";
|
return "far_trigger";
|
||||||
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_FAR_TRIGGER:
|
||||||
return "continue_far_grabbing_non_colliding";
|
return "continue_far_trigger";
|
||||||
case STATE_RELEASE:
|
case STATE_RELEASE:
|
||||||
return "release";
|
return "release";
|
||||||
}
|
}
|
||||||
|
@ -212,17 +212,17 @@ function MyController(hand) {
|
||||||
case STATE_CONTINUE_NEAR_GRABBING:
|
case STATE_CONTINUE_NEAR_GRABBING:
|
||||||
this.continueNearGrabbing();
|
this.continueNearGrabbing();
|
||||||
break;
|
break;
|
||||||
case STATE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_NEAR_TRIGGER:
|
||||||
this.nearGrabbingNonColliding();
|
this.nearTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_NEAR_TRIGGER:
|
||||||
this.continueNearGrabbingNonColliding();
|
this.continueNearTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_FAR_TRIGGER:
|
||||||
this.farGrabbingNonColliding();
|
this.farTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
|
case STATE_CONTINUE_FAR_TRIGGER:
|
||||||
this.continueFarGrabbingNonColliding();
|
this.continueFarTrigger();
|
||||||
break;
|
break;
|
||||||
case STATE_RELEASE:
|
case STATE_RELEASE:
|
||||||
this.release();
|
this.release();
|
||||||
|
@ -394,7 +394,7 @@ function MyController(hand) {
|
||||||
// the hand is very close to the intersected object. go into close-grabbing mode.
|
// the hand is very close to the intersected object. go into close-grabbing mode.
|
||||||
if (grabbableData.wantsTrigger) {
|
if (grabbableData.wantsTrigger) {
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_NEAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
} else if (!intersection.properties.locked) {
|
} else if (!intersection.properties.locked) {
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
|
@ -411,7 +411,7 @@ function MyController(hand) {
|
||||||
return;
|
return;
|
||||||
} else if (grabbableData.wantsTrigger) {
|
} else if (grabbableData.wantsTrigger) {
|
||||||
this.grabbedEntity = intersection.entityID;
|
this.grabbedEntity = intersection.entityID;
|
||||||
this.setState(STATE_FAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_FAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ function MyController(hand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (grabbableData.wantsTrigger) {
|
if (grabbableData.wantsTrigger) {
|
||||||
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_NEAR_TRIGGER);
|
||||||
return;
|
return;
|
||||||
} else if (!props.locked) {
|
} else if (!props.locked) {
|
||||||
this.setState(STATE_NEAR_GRABBING);
|
this.setState(STATE_NEAR_GRABBING);
|
||||||
|
@ -538,6 +538,7 @@ function MyController(hand) {
|
||||||
this.continueDistanceHolding = function() {
|
this.continueDistanceHolding = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,6 +632,7 @@ function MyController(hand) {
|
||||||
|
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,6 +700,7 @@ function MyController(hand) {
|
||||||
this.continueNearGrabbing = function() {
|
this.continueNearGrabbing = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,9 +736,10 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.nearGrabbingNonColliding = function() {
|
this.nearTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.hand === RIGHT_HAND) {
|
if (this.hand === RIGHT_HAND) {
|
||||||
|
@ -743,13 +747,14 @@ function MyController(hand) {
|
||||||
} else {
|
} else {
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||||
}
|
}
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "startNearGrabNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "startNearTrigger");
|
||||||
this.setState(STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_CONTINUE_NEAR_TRIGGER);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.farGrabbingNonColliding = function() {
|
this.farTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,22 +763,24 @@ function MyController(hand) {
|
||||||
} else {
|
} else {
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||||
}
|
}
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "startFarGrabNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "startFarTrigger");
|
||||||
this.setState(STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING);
|
this.setState(STATE_CONTINUE_FAR_TRIGGER);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.continueNearGrabbingNonColliding = function() {
|
this.continueNearTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrabbingNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "continueNearTrigger");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.continueFarGrabbingNonColliding = function() {
|
this.continueFarTrigger = function() {
|
||||||
if (this.triggerSmoothedReleased()) {
|
if (this.triggerSmoothedReleased()) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,12 +796,13 @@ function MyController(hand) {
|
||||||
this.lastPickTime = now;
|
this.lastPickTime = now;
|
||||||
if (intersection.entityID != this.grabbedEntity) {
|
if (intersection.entityID != this.grabbedEntity) {
|
||||||
this.setState(STATE_RELEASE);
|
this.setState(STATE_RELEASE);
|
||||||
|
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "continueFarGrabbingNonColliding");
|
Entities.callEntityMethod(this.grabbedEntity, "continueFarTrigger");
|
||||||
};
|
};
|
||||||
|
|
||||||
_this.allTouchedIDs = {};
|
_this.allTouchedIDs = {};
|
||||||
|
@ -876,7 +884,6 @@ function MyController(hand) {
|
||||||
if (this.actionID !== null) {
|
if (this.actionID !== null) {
|
||||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||||
}
|
}
|
||||||
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deactivateEntity(this.grabbedEntity);
|
this.deactivateEntity(this.grabbedEntity);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
ColorSelector.prototype = {
|
ColorSelector.prototype = {
|
||||||
|
|
||||||
startFarGrabNonColliding: function() {
|
startFarTrigger: function() {
|
||||||
this.selectColor();
|
this.selectColor();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -46,4 +46,4 @@
|
||||||
|
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new ColorSelector();
|
return new ColorSelector();
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
BoardEraser.prototype = {
|
BoardEraser.prototype = {
|
||||||
|
|
||||||
startFarGrabNonColliding: function() {
|
startFarTrigger: function() {
|
||||||
this.eraseBoard();
|
this.eraseBoard();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -42,4 +42,4 @@
|
||||||
|
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new BoardEraser();
|
return new BoardEraser();
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
this.hand = LEFT_HAND;
|
this.hand = LEFT_HAND;
|
||||||
},
|
},
|
||||||
|
|
||||||
startFarGrabNonColliding: function() {
|
startFarTrigger: function() {
|
||||||
if (this.painting) {
|
if (this.painting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
continueFarGrabbingNonColliding: function() {
|
continueFarTrigger: function() {
|
||||||
var handPosition = this.getHandPosition();
|
var handPosition = this.getHandPosition();
|
||||||
var pickRay = {
|
var pickRay = {
|
||||||
origin: handPosition,
|
origin: handPosition,
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseGrab: function() {
|
stopFarTrigger: function() {
|
||||||
if(this.hand !== this.whichHand) {
|
if(this.hand !== this.whichHand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -249,4 +249,4 @@
|
||||||
|
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new Whiteboard();
|
return new Whiteboard();
|
||||||
});
|
});
|
||||||
|
|
|
@ -74,6 +74,9 @@ var drawingSurface = Entities.addEntity({
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
color: {
|
color: {
|
||||||
currentColor: colors[0]
|
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
|
// Uncomment this line to delete whiteboard and all associated entity on script close
|
||||||
// Script.scriptEnding.connect(cleanup);
|
// Script.scriptEnding.connect(cleanup);
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
this.toggleLights();
|
this.toggleLights();
|
||||||
},
|
},
|
||||||
|
|
||||||
startNearGrabNonColliding: function () {
|
startNearTrigger: function () {
|
||||||
this.toggleLights();
|
this.toggleLights();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -61,7 +61,8 @@
|
||||||
setEntityCustomData(this.resetKey, this.entityID, {
|
setEntityCustomData(this.resetKey, this.entityID, {
|
||||||
on: on,
|
on: on,
|
||||||
type: lightType,
|
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
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new LightSwitch();
|
return new LightSwitch();
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,7 +17,7 @@ var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
|
||||||
Resetter.prototype = {
|
Resetter.prototype = {
|
||||||
|
|
||||||
startNearGrabNonColliding: function() {
|
startNearTrigger: function() {
|
||||||
this.resetObjects();
|
this.resetObjects();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -108,4 +108,4 @@ var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Resetter();
|
return new Resetter();
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
startNearGrabNonColliding: function() {
|
startNearTrigger: function() {
|
||||||
this.triggerReset();
|
this.triggerReset();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1259,4 +1259,4 @@
|
||||||
};
|
};
|
||||||
// entity scripts always need to return a newly constructed object of our type
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
return new ResetSwitch();
|
return new ResetSwitch();
|
||||||
});
|
});
|
||||||
|
|
|
@ -247,7 +247,8 @@ MasterReset = function() {
|
||||||
resetMe: true
|
resetMe: true
|
||||||
},
|
},
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
grabbable: false
|
grabbable: false,
|
||||||
|
wantsTrigger:true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -1237,4 +1238,4 @@ MasterReset = function() {
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
Resetter.prototype = {
|
Resetter.prototype = {
|
||||||
|
|
||||||
startNearGrabNonColliding: function() {
|
startNearTrigger: function() {
|
||||||
this.resetObjects();
|
this.resetObjects();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -125,4 +125,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Resetter();
|
return new Resetter();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue