mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 22:47:49 +02:00
when one hand adjusts something equippd in the other, print out the new local position and rotation in case a content-creator wants to update userData
This commit is contained in:
parent
630d5cfc82
commit
b782ae667c
1 changed files with 15 additions and 7 deletions
|
@ -1970,10 +1970,24 @@ function MyController(hand) {
|
||||||
|
|
||||||
var noVelocity = false;
|
var noVelocity = false;
|
||||||
if (this.grabbedEntity !== null) {
|
if (this.grabbedEntity !== null) {
|
||||||
|
|
||||||
|
// If this looks like the release after adjusting something still held in the other hand, print the position
|
||||||
|
// and rotation of the held thing to help content creators set the userData.
|
||||||
|
var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, this.grabbedEntity, {});
|
||||||
|
if (grabData.refCount > 1) {
|
||||||
|
grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "localRotation"]);
|
||||||
|
if (grabbedProperties && grabbedProperties.localPosition && grabbedProperties.localRotation) {
|
||||||
|
print((this.hand === RIGHT_HAND ? '"LeftHand"' : '"RightHand"') + ":" +
|
||||||
|
'[{"x":' + grabbedProperties.localPosition.x + ', "y":' + grabbedProperties.localPosition.y +
|
||||||
|
', "z":' + grabbedProperties.localPosition.z + '}, {"x":' + grabbedProperties.localRotation.x +
|
||||||
|
', "y":' + grabbedProperties.localRotation.y + ', "z":' + grabbedProperties.localRotation.z +
|
||||||
|
', "w":' + grabbedProperties.localRotation.w + '}]');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (this.actionID !== null) {
|
if (this.actionID !== null) {
|
||||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||||
// sometimes we want things to stay right where they are when we let go.
|
// sometimes we want things to stay right where they are when we let go.
|
||||||
var grabData = getEntityCustomData(GRAB_USER_DATA_KEY, this.grabbedEntity, {});
|
|
||||||
var releaseVelocityData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
|
var releaseVelocityData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
|
||||||
if (releaseVelocityData.disableReleaseVelocity === true ||
|
if (releaseVelocityData.disableReleaseVelocity === true ||
|
||||||
// this next line allowed both:
|
// this next line allowed both:
|
||||||
|
@ -1994,12 +2008,6 @@ function MyController(hand) {
|
||||||
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
joint: this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, ["localPosition", "localRotation"]);
|
|
||||||
print("adjusted position: " + vec3toStr(grabbedProperties.localPosition));
|
|
||||||
print("adjusted rotation: " + quatToStr(grabbedProperties.localRotation));
|
|
||||||
|
|
||||||
|
|
||||||
this.grabbedEntity = null;
|
this.grabbedEntity = null;
|
||||||
|
|
||||||
if (this.triggerSmoothedGrab()) {
|
if (this.triggerSmoothedGrab()) {
|
||||||
|
|
Loading…
Reference in a new issue