fix: resolve middle slice state sync and zero-step drag freeze
All checks were successful
Deploy to Production / deploy (push) Successful in 6s

This commit is contained in:
2026-02-24 11:37:37 +00:00
parent 8a20531fa0
commit fccc43d0eb
8 changed files with 258 additions and 65 deletions

View File

@@ -3,15 +3,22 @@ import { RubiksJSModel } from "../utils/CubeLogicAdapter.js";
const cube = new RubiksJSModel();
// Helper to send state update
const sendUpdate = () => {
try {
const cubies = cube.toCubies();
// console.log('[Worker] Sending update with cubies:', cubies.length);
const { cp, co, ep, eo } = cube.state;
postMessage({
type: "STATE_UPDATE",
payload: {
cubies,
deepCubeState: {
cp: [...cp],
co: [...co],
ep: [...ep],
eo: [...eo],
},
},
});
} catch (e) {
@@ -37,6 +44,13 @@ self.onmessage = (e) => {
break;
}
case "ROTATE_SLICE": {
const { axis, direction, steps = 1 } = payload;
cube.rotateSlice(axis, direction, steps);
sendUpdate();
break;
}
case "TURN": {
const { move } = payload;
cube.applyTurn(move);
@@ -52,5 +66,6 @@ self.onmessage = (e) => {
});
break;
}
};