{"id":16321502,"url":"https://github.com/doodlewind/freecube","last_synced_at":"2025-03-16T14:31:00.393Z","repository":{"id":80192992,"uuid":"145788348","full_name":"doodlewind/freecube","owner":"doodlewind","description":"⚛ Solve Rubik's Cube with WebGL in 10KB.","archived":false,"fork":false,"pushed_at":"2019-05-02T08:07:23.000Z","size":369,"stargazers_count":131,"open_issues_count":2,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-27T10:36:48.166Z","etag":null,"topics":["animation","cfop","cube-face-rotation","javascript","rubik-cube","webgl"],"latest_commit_sha":null,"homepage":"https://ewind.us/h5/freecube","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doodlewind.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-23T02:21:02.000Z","updated_at":"2025-01-27T15:36:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"d9cdff41-1085-494f-aa9d-0f30cce6ddbf","html_url":"https://github.com/doodlewind/freecube","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodlewind%2Ffreecube","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodlewind%2Ffreecube/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodlewind%2Ffreecube/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doodlewind%2Ffreecube/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doodlewind","download_url":"https://codeload.github.com/doodlewind/freecube/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243818195,"owners_count":20352629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["animation","cfop","cube-face-rotation","javascript","rubik-cube","webgl"],"created_at":"2024-10-10T22:47:57.365Z","updated_at":"2025-03-16T14:31:00.385Z","avatar_url":"https://github.com/doodlewind.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Freecube\n⚛ Solve Rubik's Cube with WebGL in 10KB.\n\n![banner](./resources/banner.png)\n\nFreecube renders and animates Rubik's Cube with raw WebGL, plus a tiny rule-based solver showing how CFOP works.\n\n![animate-demo](./resources/animate-demo.gif)\n\n\n## Usage\n\n```\nnpm install freecube\n```\n\n``` js\nimport { Cube, Solver } from 'freecube'\n\nconst canvas = document.querySelector('#gl')\nconst cube = new Cube(canvas)\nconst solver = new Solver(cube)\n\ncube.render(30, -45) // Render the cube with X and Y rotation.\ncube.shuffle(20, true) // Shuffle it with animation.\nsolver.solve() // Generate solution with CFOP algorithm.\n```\n\n\n## API\n\n### `Cube`\n`new Cube(canvas: CanvasElement, moves: Moves)`\n\nMain class emulating Rubik's Cube, it maintains cube state in `this.blocks` and optional WebGL instance in `this.gl`.\n\n* `canvas` - DOM canvas element for rendering, can be null for \"headless\" case.\n* `moves` - Array of cube moves, .e.g., `['R', 'U', 'F']`.\n\n#### `animate`\n`(move: String|Moves, duration: number) =\u003e Promise`\n\nAnimate the cube moves with single or multi `move`, uses `cube.move` under the hood. you can set move speed with optional `durataion` args. The promise returned will be resolved on animation ends.\n\n#### `getBlock`\n`(coord: Coord) =\u003e Block`\n\nGet block data in the cube. `coord` shapes as `[0, 1, -1]` and the block returns in `{ positions: Array, colors: Array }` format. `block.positions` is the vertex positions of the block, and `block.colors` represents block colors in `[F, B, U, D, R, L]` sequence.\n\n#### `move`\n`(move: String|Moves) =\u003e Cube`\n\nUpdate cube state with moves passed in, uses `cube.rotate` under the hood. Just use it as `animate` without animation. Chain calling like `cube.move('U').move('R')` is supported.\n\n\u003e Only `F / B / L / R / U / D` and their counter moves can be used for now. \"Advanced\" turns like `M / r / x / R2` are not supported.\n\n#### `rotate`\n`(center: Coord, clockwise: boolean) =\u003e Cube`\n\nRotate cube face in 90 degree. `center` coord is the center block of the face, `clockwise` for rotate direction.\n\n#### `render`\n`(rX: number, rY: number, moveFace: String, moveAngle: number)`\n\nRenders the cube with `rX` and `rY` as overall rotation, and `moveFace` and `moveAngle` for a cube face rotation.\n\n#### `shuffle`\n`(n: number, animate: false) =\u003e Cube|Promise`\n\nShuffles the cube. Returns cube instance if animation not used, and promise on shuffle animation ends.\n\n### `Solver`\nRule-based module solving Rubik's Cube with CFOP algorithm.\n\n#### `solve`\n`() =\u003e Array\u003cMoves\u003e`\n\nSolve the cube state with all CFOP steps. Returns array of 4 series of moves.\n\n#### `solveCross`\n`() =\u003e Moves`\n\nReturns the moves to build a cross.\n\n#### `solveF2L`\n`() =\u003e Moves`\n\nReturns the moves to build first two layers.\n\n#### `solveOLL`\n`() =\u003e Moves`\n\nReturns the moves to pass OLL.\n\n#### `solvePLL`\n`() =\u003e Moves`\n\nReturns the moves to pass PLL.\n\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoodlewind%2Ffreecube","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoodlewind%2Ffreecube","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoodlewind%2Ffreecube/lists"}