content/hifi-content/lincoln/mirror-box/mirror_box/RFtoLF.js
2022-02-14 02:04:11 +01:00

63 lines
No EOL
1.5 KiB
JavaScript

var handlerId = 0;
var propList = ["rightHandType","leftHandType", "leftFootType", "leftFootPosition", "leftFootRotation", "rightFootType", "rightFootPosition", "rightFootRotation"];
var ikTypes = {
RotationAndPosition: 0,
RotationOnly: 1,
HmdHead: 2,
HipsRelativeRotationAndPosition: 3,
Off: 4
};
function disableStateHandler(props) {
return { leftFootType: ikTypes["Off"],
rightFootType: ikTypes["Off"] };
}
function mirrorPos(pos) {
return {x: pos.x, y: (pos.y - 0.85)/2.4, z: -pos.z}
}
// function mirrorRot() {
// return {x: q.x, y: -q.y, z: -q.z, w: q.w};
// }
function offsetRot(q) {
return {x: q.x, y: -q.y, z: -q.z, w: q.w};
}
function offsetPos(p) {
return {x: -p.x, y: (p.y - 0.85)/2.4, z: -p.z}
}
function update() {
MyAvatar.clearIKJointLimitHistory();
}
function init() {
Script.update.connect(update);
handlerId = MyAvatar.addAnimationStateHandler(function(props) {
var pose = Controller.getPoseValue(Controller.Standard.LeftHand);
return {
rightHandType: ikTypes["Off"],
leftHandType: ikTypes["Off"],
leftFootPosition: offsetPos(pose.translation),
leftFootRotation: offsetRot(pose.rotation),
leftFootType: ikTypes["RotationAndPosition"],
rightFootType: ikTypes["RotationAndPosition"],
rightFootPosition: mirrorPos(pose.translation),
//rightFootRotation: pose.rotation
}
}, propList);
}
function shutdown() {
MyAvatar.removeAnimationStateHandler(handlerId);
}
init();
Script.scriptEnding.connect(shutdown);