mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 14:12:50 +02:00
Add utility functions for adjusting target rotation and position.
This commit is contained in:
parent
58906d84eb
commit
c6a3496b25
1 changed files with 61 additions and 3 deletions
|
@ -146,7 +146,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
|
||||
var newTargetPosLocal = MyAvatar.worldToJointPoint(targetProps.position);
|
||||
MyAvatar.setJointTranslation(FAR_GRAB_JOINTS[this.hand], newTargetPosLocal);
|
||||
MyAvatar.setJointRotation(FAR_GRAB_JOINTS[this.hand], { x: 0, y: 0, z: 0, w: 1 });
|
||||
MyAvatar.setJointRotation(FAR_GRAB_JOINTS[this.hand], { x: 0, y: 0, z: 0, w: 1 }); // RKNOTE: This is where the rotation should be updated.
|
||||
|
||||
var args = [this.hand === RIGHT_HAND ? "right" : "left", MyAvatar.sessionUUID];
|
||||
Entities.callEntityMethod(targetProps.id, "startDistanceGrab", args);
|
||||
|
@ -235,7 +235,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
// var newTargetPosLocal = Mat4.transformPoint(MyAvatar.getSensorToWorldMatrix(), newTargetPosition);
|
||||
var newTargetPosLocal = MyAvatar.worldToJointPoint(newTargetPosition);
|
||||
MyAvatar.setJointTranslation(FAR_GRAB_JOINTS[this.hand], newTargetPosLocal);
|
||||
MyAvatar.setJointRotation(FAR_GRAB_JOINTS[this.hand], { x: 0, y: 0, z: 0, w: 1 });
|
||||
MyAvatar.setJointRotation(FAR_GRAB_JOINTS[this.hand], { x: 0, y: 0, z: 0, w: 1 }); // RKNOTE: This is where the rotation should be updated.
|
||||
|
||||
this.previousRoomControllerPosition = roomControllerPosition;
|
||||
};
|
||||
|
@ -259,7 +259,7 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
this.grabbing = false;
|
||||
this.targetEntityID = null;
|
||||
this.potentialEntityWithContextOverlay = false;
|
||||
MyAvatar.clearJointData(FAR_GRAB_JOINTS[this.hand]);
|
||||
MyAvatar.clearJointData(FAR_GRAB_JOINTS[this.hand]); // RKNOTE: Here, we should edit the entity's position and rotation data with the current joint rotation data.
|
||||
};
|
||||
|
||||
this.updateRecommendedArea = function () {
|
||||
|
@ -395,6 +395,64 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
return (_this.getOffHandTrigger() <= TRIGGER_OFF_VALUE) ? true : false;
|
||||
};
|
||||
|
||||
this.getTargetPosition = function () {
|
||||
if (this.targetIsNull()) {
|
||||
return null;
|
||||
} else {
|
||||
var props = Entities.getEntityProperties(this.targetEntityID, ["position"]);
|
||||
return props.position;
|
||||
}
|
||||
};
|
||||
|
||||
this.getTargetRotation = function () {
|
||||
if (this.targetIsNull()) {
|
||||
return null;
|
||||
} else {
|
||||
var props = Entities.getEntityProperties(this.targetEntityID, ["rotation"]);
|
||||
return props.rotation;
|
||||
}
|
||||
};
|
||||
|
||||
this.getTargetLocalPosition = function () {
|
||||
if (this.targetIsNull()) {
|
||||
return null;
|
||||
} else {
|
||||
var props = Entities.getEntityProperties(this.targetEntityID, ["localPosition"]);
|
||||
return props.localPosition;
|
||||
}
|
||||
};
|
||||
|
||||
this.getTargetLocalRotation = function () {
|
||||
if (this.targetIsNull()) {
|
||||
return null;
|
||||
} else {
|
||||
var props = Entities.getEntityProperties(this.targetEntityID, ["localRotation"]);
|
||||
return props.localRotation;
|
||||
}
|
||||
};
|
||||
|
||||
this.setTargetPosition = function (newPos) {
|
||||
if (this.targetIsNull()) {
|
||||
print("Fargrab Error: No target to edit position.");
|
||||
return;
|
||||
} else {
|
||||
var props;
|
||||
props.position = newPos;
|
||||
Entities.editEntity(this.targetEntityID, props);
|
||||
}
|
||||
};
|
||||
|
||||
this.setTargetRotation = function (newRot) {
|
||||
if (this.targetIsNull()) {
|
||||
print("Fargrab Error: No target to edit rotation.");
|
||||
return;
|
||||
} else {
|
||||
var props;
|
||||
props.rotation = newRot;
|
||||
Entitis.editEntity(this.targetEntityID, props);
|
||||
}
|
||||
}
|
||||
|
||||
this.isReady = function (controllerData) {
|
||||
if (HMD.active && this.hand === this.getOffHand()) {
|
||||
if (this.notPointingAtEntity(controllerData)) {
|
||||
|
|
Loading…
Reference in a new issue