mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 10:43:21 +02:00
scale offsets to avatar height
This commit is contained in:
parent
2949560e90
commit
c95e880677
1 changed files with 13 additions and 6 deletions
|
@ -24,7 +24,7 @@ function ExtendedOverlay(key, type, properties, selected, hasSphere) { // A wrap
|
||||||
overlays[key] = this;
|
overlays[key] = this;
|
||||||
if (hasSphere) {
|
if (hasSphere) {
|
||||||
var sphereKey = key + "-s";
|
var sphereKey = key + "-s";
|
||||||
this.sphere = new ExtendedOverlay(sphereKey, "sphere", {drawInFront: true, solid: true, alpha: 0.6, color: color(selected)}, false, false);
|
this.sphere = new ExtendedOverlay(sphereKey, "sphere", {drawInFront: true, solid: true, alpha: 0.8, color: color(selected)}, false, false);
|
||||||
} else {
|
} else {
|
||||||
this.sphere = undefined;
|
this.sphere = undefined;
|
||||||
}
|
}
|
||||||
|
@ -263,15 +263,22 @@ function updateOverlays() {
|
||||||
var avatar = AvatarList.getAvatar(id);
|
var avatar = AvatarList.getAvatar(id);
|
||||||
var target = avatar.position;
|
var target = avatar.position;
|
||||||
var distance = Vec3.distance(target, eye);
|
var distance = Vec3.distance(target, eye);
|
||||||
|
var offset = 0.2;
|
||||||
|
|
||||||
|
// base offset on 1/2 distance from hips to head if we can
|
||||||
|
var headIndex = avatar.getJointIndex("Head");
|
||||||
|
if (headIndex > 0) {
|
||||||
|
offset = avatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y / 2;
|
||||||
|
}
|
||||||
|
|
||||||
// get diff between target and eye (a vector pointing to the eye from avatar position)
|
// get diff between target and eye (a vector pointing to the eye from avatar position)
|
||||||
var diff = Vec3.subtract(target, eye);
|
var diff = Vec3.subtract(target, eye);
|
||||||
|
|
||||||
// now, add a small bit of that difference to target
|
// move a bit in front, towards the camera (TODO: scale this based on height?)
|
||||||
target = Vec3.sum(target, Vec3.multiply(Vec3.normalize(diff), 0.2));
|
target = Vec3.sum(target, Vec3.multiply(Vec3.normalize(diff), offset));
|
||||||
|
|
||||||
// now bump it up a bit (TODO: scale this to the avatar height)
|
// now bump it up a bit
|
||||||
target.y = target.y + 0.2;
|
target.y = target.y + offset;
|
||||||
|
|
||||||
overlay.ping = pingPong;
|
overlay.ping = pingPong;
|
||||||
overlay.editOverlay({
|
overlay.editOverlay({
|
||||||
|
|
Loading…
Reference in a new issue