cubing.js
cubing.js copied to clipboard
Calculate the default orbit coordinates for custom geometries.
To Reproduce Steps to reproduce the behavior:
- Go to https://experiments.cubing.net/cubing.js/twisty/puzzle-description.html
Relevant source:
<twisty-player
experimental-puzzle-description="c f 0.333333333333333 v 0"
alg="F2 UFL R B' R UBR' L' D' UBL L U2 B' UBR U2 L2 UFL F B UBL R2 B UFL' D2 DBL R2 UFL U2 F' DBL' U UFL F'"
experimental-sprite="../twisty/world.png"
></twisty-player>
This uses centeredCameraOrbitCoordinates, which centers us between the L and R faces instead of showing us more of R.
https://github.com/cubing/cubing.js/blob/b8e175a87fe6e549e3a6114271267e17cc38ca28/src/cubing/twisty/old/dom/TwistyPlayerConfig.ts#L64-L65
Expected behavior
The camera takes into account the puzzle shape and shows us more of R.
Steps:
- Update PuzzleLoader to have a
baseSolid?: "t"| "c"| "o"| "d"| "i"field.
- Even better, add an enum in
PuzzleGeometryfor the 5 values.
- Change
OrbitCoordinatesPropto listen to the puzzle loader prop instead of a puzzle ID. - Pass the puzzle loader to
defaultCameraOrbitCoordinates(...)instead of the puzzle ID and calculate the orbit coordinates depending on the Platonic solid.
- In the default case, still return
centeredCameraOrbitCoordinatesbut add:
console.warn("Tried to calculate default orbit coordinates for a puzzle loader that is missing a `baseSolid` field:", puzzleLoader);