mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:29:01 +02:00
teleport.js should still function on avatars with no feet.
This commit is contained in:
parent
3fdad14ca4
commit
7da73d0ff1
1 changed files with 16 additions and 36 deletions
|
@ -366,45 +366,25 @@ function Teleporter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// related to repositioning the avatar after you teleport
|
// related to repositioning the avatar after you teleport
|
||||||
|
var FOOT_JOINT_NAMES = ["RightToe_End", "RightToeBase", "RightFoot"];
|
||||||
|
var DEFAULT_ROOT_TO_FOOT_OFFSET = 0.5;
|
||||||
function getAvatarFootOffset() {
|
function getAvatarFootOffset() {
|
||||||
var data = getJointData();
|
|
||||||
var upperLeg, lowerLeg, foot, toe, toeTop;
|
|
||||||
data.forEach(function(d) {
|
|
||||||
|
|
||||||
var jointName = d.joint;
|
// find a valid foot jointIndex
|
||||||
if (jointName === "RightUpLeg") {
|
var footJointIndex = -1;
|
||||||
upperLeg = d.translation.y;
|
var i, l = FOOT_JOINT_NAMES.length;
|
||||||
} else if (jointName === "RightLeg") {
|
for (i = 0; i < l; i++) {
|
||||||
lowerLeg = d.translation.y;
|
footJointIndex = MyAvatar.getJointIndex(FOOT_JOINT_NAMES[i]);
|
||||||
} else if (jointName === "RightFoot") {
|
if (footJointIndex != -1) {
|
||||||
foot = d.translation.y;
|
break;
|
||||||
} else if (jointName === "RightToeBase") {
|
|
||||||
toe = d.translation.y;
|
|
||||||
} else if (jointName === "RightToe_End") {
|
|
||||||
toeTop = d.translation.y;
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
if (footJointIndex != -1) {
|
||||||
var offset = upperLeg + lowerLeg + foot + toe + toeTop;
|
// default vertical offset from foot to avatar root.
|
||||||
offset = offset / 100;
|
return -MyAvatar.getAbsoluteDefaultJointTranslationInObjectFrame(footJointIndex).y;
|
||||||
return offset;
|
} else {
|
||||||
}
|
return DEFAULT_ROOT_TO_FOOT_OFFSET;
|
||||||
|
}
|
||||||
function getJointData() {
|
|
||||||
var allJointData = [];
|
|
||||||
var jointNames = MyAvatar.jointNames;
|
|
||||||
jointNames.forEach(function(joint, index) {
|
|
||||||
var translation = MyAvatar.getJointTranslation(index);
|
|
||||||
var rotation = MyAvatar.getJointRotation(index);
|
|
||||||
allJointData.push({
|
|
||||||
joint: joint,
|
|
||||||
index: index,
|
|
||||||
translation: translation,
|
|
||||||
rotation: rotation
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return allJointData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var leftPad = new ThumbPad('left');
|
var leftPad = new ThumbPad('left');
|
||||||
|
|
Loading…
Reference in a new issue