feat(pose_3d): Editor mode Apply + Cancel
This commit is contained in:
1 parent
64500944d6
commit
5b2239e307
1 file changed
+52
@@ -373,6 +373,57 @@ function bindSideControls() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----- Editor mode actions -----
|
||||||
|
async function onApplyClick() {
|
||||||
|
if (state.mode !== 'editor') return; // in Jog non c'è Apply
|
||||||
|
const side = state.active_side;
|
||||||
|
const tgt = state.target[side];
|
||||||
|
if (!tgt) return;
|
||||||
|
try {
|
||||||
|
await jsonFetch('/api/pose_3d/apply', {
|
||||||
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
side, position: tgt.position, quaternion: tgt.quaternion,
|
||||||
|
dry_run: true, precise: state.precise,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
// commit locale: il target diventa il nuovo current (simulato)
|
||||||
|
state.current[side] = { position: tgt.position, quaternion: tgt.quaternion };
|
||||||
|
state.target[side] = null;
|
||||||
|
updateRealWrists();
|
||||||
|
syncGhostsToTargetOrReal();
|
||||||
|
updateReadout();
|
||||||
|
$('p3Status').textContent = '✓ Editor: target committato (simulato)';
|
||||||
|
$('p3Status').className = 'p3-status ok';
|
||||||
|
} catch (e) {
|
||||||
|
showError(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCancelClick() {
|
||||||
|
const side = state.active_side;
|
||||||
|
state.target[side] = null;
|
||||||
|
syncGhostsToTargetOrReal();
|
||||||
|
updateReadout();
|
||||||
|
}
|
||||||
|
|
||||||
|
function showError(msg) {
|
||||||
|
$('p3ErrorBox').style.display = 'block';
|
||||||
|
$('p3ErrorText').textContent = msg;
|
||||||
|
$('p3Status').textContent = '✗ errore';
|
||||||
|
$('p3Status').className = 'p3-status error';
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearError() {
|
||||||
|
$('p3ErrorBox').style.display = 'none';
|
||||||
|
$('p3ErrorText').textContent = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEditorButtons() {
|
||||||
|
$('p3ApplyBtn').addEventListener('click', onApplyClick);
|
||||||
|
$('p3CancelBtn').addEventListener('click', onCancelClick);
|
||||||
|
}
|
||||||
|
|
||||||
// ----- init triggered on first activation -----
|
// ----- init triggered on first activation -----
|
||||||
let inited = false;
|
let inited = false;
|
||||||
function ensureInit() {
|
function ensureInit() {
|
||||||
@@ -384,6 +435,7 @@ function ensureInit() {
|
|||||||
bindSideControls();
|
bindSideControls();
|
||||||
bindGizmoControls();
|
bindGizmoControls();
|
||||||
bindGizmoEvents();
|
bindGizmoEvents();
|
||||||
|
bindEditorButtons();
|
||||||
pollState();
|
pollState();
|
||||||
pollTimer = setInterval(pollState, POLL_MS);
|
pollTimer = setInterval(pollState, POLL_MS);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user