diff --git a/src/lib/controls/gesture-math.js b/src/lib/controls/gesture-math.js index 1c679c7..115d3d9 100644 --- a/src/lib/controls/gesture-math.js +++ b/src/lib/controls/gesture-math.js @@ -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, diff --git a/src/lib/controls/pointer-gesture.js b/src/lib/controls/pointer-gesture.js index 6b2cae1..50402d7 100644 --- a/src/lib/controls/pointer-gesture.js +++ b/src/lib/controls/pointer-gesture.js @@ -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