mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Fixed a potential bug with puck-attach parenting
This commit is contained in:
parent
620f1a65c0
commit
961f748d87
1 changed files with 12 additions and 5 deletions
|
@ -140,18 +140,25 @@ function finalizePuck() {
|
||||||
}
|
}
|
||||||
function updatePucks() {
|
function updatePucks() {
|
||||||
// for each puck, update its position and orientation
|
// for each puck, update its position and orientation
|
||||||
for (var puck in trackedPucks) {
|
for (var puckName in trackedPucks) {
|
||||||
var action = indexToTrackedObjectName(puck);
|
var action = indexToTrackedObjectName(puckName);
|
||||||
var pose = Controller.getPoseValue(Controller.Standard[action]);
|
var pose = Controller.getPoseValue(Controller.Standard[action]);
|
||||||
if (pose && pose.valid) {
|
if (pose && pose.valid) {
|
||||||
if (trackedPucks[puck].trackedEntityID) {
|
var puck = trackedPucks[puckName];
|
||||||
|
if (puck.trackedEntityID) {
|
||||||
var avatarXform = new Xform(MyAvatar.orientation, MyAvatar.position);
|
var avatarXform = new Xform(MyAvatar.orientation, MyAvatar.position);
|
||||||
var puckXform = new Xform(pose.rotation, pose.translation);
|
var puckXform = new Xform(pose.rotation, pose.translation);
|
||||||
var finalXform = Xform.mul(avatarXform, Xform.mul(puckXform, Vec3.ZERO));
|
var finalXform = Xform.mul(avatarXform, Xform.mul(puckXform, Vec3.ZERO));
|
||||||
|
|
||||||
Entities.editEntity(trackedPucks[puck].puckEntityID, {
|
Entities.editEntity(puck.puckEntityID, {
|
||||||
position: finalXform.pos,
|
position: finalXform.pos,
|
||||||
rotation: finalXform.rot
|
rotation: finalXform.rot,
|
||||||
|
});
|
||||||
|
|
||||||
|
// in case someone grabbed both entities and destroyed the
|
||||||
|
// child/parent relationship
|
||||||
|
Entities.editEntity(puck.trackedEntityID, {
|
||||||
|
parentID: puck.puckEntityID
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue