Refactor: Implement SmartCube renderer, improve UI styling, and fix gaps

This commit is contained in:
2026-02-22 04:35:59 +00:00
parent 57abfd6b80
commit b5ddc21662
4168 changed files with 763782 additions and 1008 deletions

View File

@@ -0,0 +1,46 @@
import { RubiksJSModel } from '../utils/RubiksJSModel.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);
postMessage({
type: 'STATE_UPDATE',
payload: {
cubies
}
});
} catch (e) {
console.error('[Worker] Error generating cubies:', e);
postMessage({ type: 'ERROR', payload: e.message });
}
};
self.onmessage = (e) => {
const { type, payload } = e.data;
switch (type) {
case 'INIT':
case 'RESET':
cube.reset();
sendUpdate();
break;
case 'ROTATE_LAYER':
const { axis, index, direction } = payload;
cube.rotateLayer(axis, index, direction);
sendUpdate();
break;
case 'VALIDATE':
const validation = cube.validate();
postMessage({
type: 'VALIDATION_RESULT',
payload: { valid: validation.valid, errors: validation.errors }
});
break;
}
};