fix(pose_3d): ghost fallback alla posa dell'arm quando /state e' offline
This commit is contained in:
1 parent
fd506dff9b
commit
d4cd82551e
1 file changed
+14
-4
+14
-4
@@ -241,12 +241,17 @@ function syncGhostsToTargetOrReal() {
|
||||
// ghost segue il target locale (mosso dal gizmo)
|
||||
ghost.visible = true;
|
||||
} else if (side === state.active_side) {
|
||||
// ghost allineato al reale (preparato per drag)
|
||||
// ghost allineato al reale (preparato per drag).
|
||||
// Fallback se /state e' offline: copia dall'arm visibile.
|
||||
const real = state.current[side];
|
||||
const arm = state.arms[side];
|
||||
if (real) {
|
||||
ghost.position.set(real.position[0], real.position[1], real.position[2]);
|
||||
ghost.quaternion.set(real.quaternion[0], real.quaternion[1],
|
||||
real.quaternion[2], real.quaternion[3]);
|
||||
} else if (arm) {
|
||||
ghost.position.copy(arm.position);
|
||||
ghost.quaternion.copy(arm.quaternion);
|
||||
}
|
||||
} else {
|
||||
ghost.visible = false;
|
||||
@@ -350,14 +355,19 @@ function activateSide(side) {
|
||||
}
|
||||
|
||||
function ensureGhostInit(side) {
|
||||
// Se non c'è target locale, allinea ghost al reale (preparato per drag)
|
||||
if (!state.target[side]) {
|
||||
// Se non c'è target locale, allinea ghost al reale (preparato per drag).
|
||||
// Se /state non e' disponibile (G1 offline), fallback alla posizione
|
||||
// dell'arm visibile (che usa SHOULDER come default).
|
||||
if (state.target[side]) return;
|
||||
const real = state.current[side];
|
||||
const arm = state.arms[side];
|
||||
if (real) {
|
||||
state.ghosts[side].position.set(real.position[0], real.position[1], real.position[2]);
|
||||
state.ghosts[side].quaternion.set(real.quaternion[0], real.quaternion[1],
|
||||
real.quaternion[2], real.quaternion[3]);
|
||||
}
|
||||
} else if (arm) {
|
||||
state.ghosts[side].position.copy(arm.position);
|
||||
state.ghosts[side].quaternion.copy(arm.quaternion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user