cubing.js icon indicating copy to clipboard operation
cubing.js copied to clipboard

Calculate the default orbit coordinates for custom geometries.

Open lgarron opened this issue 4 years ago • 0 comments

To Reproduce Steps to reproduce the behavior:

  1. 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:

  1. Update PuzzleLoader to have a baseSolid?: "t"| "c"| "o"| "d"| "i" field.
  • Even better, add an enum in PuzzleGeometry for the 5 values.
  1. Change OrbitCoordinatesProp to listen to the puzzle loader prop instead of a puzzle ID.
  2. 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 centeredCameraOrbitCoordinates but add:
console.warn("Tried to calculate default orbit coordinates for a puzzle loader that is missing a `baseSolid` field:", puzzleLoader);

lgarron avatar Sep 14 '21 09:09 lgarron