mirror of
https://github.com/tiennm99/rubik.git
synced 2026-06-05 04:14:07 +00:00
debug: add gesture diagnostic logs gated behind globalThis.RUBIK_DEBUG
Temporary instrumentation to diagnose residual edge-rotation reversal that survives the face-anchor fix. Logs hit context, gesture math, and the committed move spec so we can trace any remaining sign mismatch. Disabled by default — set `RUBIK_DEBUG = true` in the browser console to enable. Will be removed once the residual bug is localized.
This commit is contained in:
@@ -65,6 +65,21 @@ export function chooseRotationAxis({ hitFaceAxis, hitWorldPos, dx, dy, projectFn
|
||||
const motionScreen = projectFn(hitWorldPos.clone().add(motionWorld)).sub(screenOrigin);
|
||||
const signMul = motionScreen.dot(drag) >= 0 ? 1 : -1;
|
||||
|
||||
if (typeof globalThis !== 'undefined' && globalThis.RUBIK_DEBUG) {
|
||||
console.log('[GESTURE]', {
|
||||
hitFaceAxis,
|
||||
hitWorldPos: [hitWorldPos.x.toFixed(3), hitWorldPos.y.toFixed(3), hitWorldPos.z.toFixed(3)],
|
||||
drag: [dx, dy],
|
||||
projs: projs.map((p) => p.toFixed(3)),
|
||||
dragAxis,
|
||||
rotAxis,
|
||||
faceAnchor: [faceAnchor.x, faceAnchor.y, faceAnchor.z],
|
||||
motionWorld: [motionWorld.x.toFixed(3), motionWorld.y.toFixed(3), motionWorld.z.toFixed(3)],
|
||||
motionScreen: [motionScreen.x.toFixed(3), motionScreen.y.toFixed(3)],
|
||||
signMul
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
rotAxis,
|
||||
dragAxis,
|
||||
|
||||
@@ -80,6 +80,15 @@ export function setupPointerGesture({ canvas, camera, controls, parentGroup, mes
|
||||
return;
|
||||
}
|
||||
const hitWorldPos = hitMesh.getWorldPosition(new Vector3());
|
||||
if (typeof globalThis !== 'undefined' && globalThis.RUBIK_DEBUG) {
|
||||
const cubie = hitMesh.userData.cubie;
|
||||
console.log('[HIT]', {
|
||||
hitFaceAxis,
|
||||
hitWorldPos: [hitWorldPos.x.toFixed(3), hitWorldPos.y.toFixed(3), hitWorldPos.z.toFixed(3)],
|
||||
cubieHome: cubie.home,
|
||||
cubiePosition: cubie.position
|
||||
});
|
||||
}
|
||||
const decision = chooseRotationAxis({
|
||||
hitFaceAxis,
|
||||
hitWorldPos,
|
||||
@@ -143,6 +152,9 @@ export function setupPointerGesture({ canvas, camera, controls, parentGroup, mes
|
||||
const sign = turns > 0 ? 1 : -1;
|
||||
const count = Math.abs(turns) === 2 ? 2 : 1;
|
||||
const spec = { axis: pivotAxis, layer: layerIndex, sign, count, name: '' };
|
||||
if (typeof globalThis !== 'undefined' && globalThis.RUBIK_DEBUG) {
|
||||
console.log('[COMMIT]', { curAngle: curAngle.toFixed(3), turns, spec, name: specToName(spec) });
|
||||
}
|
||||
snapAndAnimate({
|
||||
parentGroup, pivot, meshes, cubies, spec,
|
||||
fromAngle: curAngle, toAngle: targetAngle, durationMs: 120
|
||||
|
||||
Reference in New Issue
Block a user