cubing 0.21.3 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.DS_Store +0 -0
- package/dist/bin/puzzle-geometry-bin.js +9 -5
- package/dist/bin/puzzle-geometry-bin.js.map +2 -2
- package/dist/bundle-global/cubing.bundle-global.js +284 -303
- package/dist/esm/.DS_Store +0 -0
- package/dist/esm/3d-3WQVOHX5.js +21 -0
- package/dist/esm/3d-3WQVOHX5.js.map +7 -0
- package/dist/esm/alg/index.js +1 -1
- package/dist/esm/bluetooth/index.js +3 -3
- package/dist/esm/bluetooth/index.js.map +1 -1
- package/dist/esm/{chunk-RE7MIN5R.js → chunk-4IUYLRHT.js} +2 -2
- package/dist/esm/{chunk-RE7MIN5R.js.map → chunk-4IUYLRHT.js.map} +0 -0
- package/dist/esm/{chunk-CSVAFZSB.js → chunk-7KI3I3Y7.js} +5 -5
- package/dist/esm/{chunk-CSVAFZSB.js.map → chunk-7KI3I3Y7.js.map} +0 -0
- package/dist/esm/{chunk-APIIMJG6.js → chunk-DLN5QS4V.js} +448 -1052
- package/dist/esm/chunk-DLN5QS4V.js.map +7 -0
- package/dist/esm/{chunk-BU5PUJK3.js → chunk-EWRBHQFX.js} +1 -1
- package/dist/esm/{chunk-BU5PUJK3.js.map → chunk-EWRBHQFX.js.map} +1 -1
- package/dist/esm/{chunk-MUQMBH2S.js → chunk-HXKINJ7U.js} +3 -3
- package/dist/esm/{chunk-MUQMBH2S.js.map → chunk-HXKINJ7U.js.map} +1 -1
- package/dist/esm/{chunk-YV3RT5PX.js → chunk-X6JHXPDX.js} +2 -2
- package/dist/esm/{chunk-YV3RT5PX.js.map → chunk-X6JHXPDX.js.map} +0 -0
- package/dist/esm/kpuzzle/index.js +2 -2
- package/dist/esm/notation/index.js +2 -2
- package/dist/esm/protocol/index.js +2 -2
- package/dist/esm/puzzle-geometry/index.js +10 -6
- package/dist/esm/puzzle-geometry/index.js.map +2 -2
- package/dist/esm/puzzles/index.js +3 -3
- package/dist/esm/scramble/index.js +4 -4
- package/dist/esm/search/index.js +4 -4
- package/dist/esm/stream/index.js +1 -1
- package/dist/esm/twisty/index.js +715 -2341
- package/dist/esm/twisty/index.js.map +3 -3
- package/dist/esm/{worker-inside-generated-string-KDZOUGJF.js → worker-inside-generated-string-ZA6E6672.js} +21 -21
- package/dist/esm/worker-inside-generated-string-ZA6E6672.js.map +7 -0
- package/dist/types/alg/index.d.ts +1 -0
- package/dist/types/alg/index.d.ts.map +1 -1
- package/dist/types/alg/units/leaves/Move.d.ts +1 -1
- package/dist/types/alg/units/leaves/Move.d.ts.map +1 -1
- package/dist/types/puzzle-geometry/PGPuzzles.spec.d.ts +3 -0
- package/dist/types/puzzle-geometry/PGPuzzles.spec.d.ts.map +1 -1
- package/dist/types/puzzle-geometry/PuzzleGeometry.d.ts +5 -1
- package/dist/types/puzzle-geometry/PuzzleGeometry.d.ts.map +1 -1
- package/dist/types/puzzles/index.d.ts +1 -1
- package/dist/types/puzzles/index.d.ts.map +1 -1
- package/dist/types/search/worker-inside-generated-string.d.ts +1 -1
- package/dist/types/search/worker-inside-generated-string.d.ts.map +1 -1
- package/dist/types/twisty/{old/animation/cursor/CursorTypes.d.ts → controllers/AnimationTypes.d.ts} +10 -3
- package/dist/types/twisty/controllers/AnimationTypes.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/RenderScheduler.d.ts +0 -0
- package/dist/types/twisty/controllers/RenderScheduler.d.ts.map +1 -0
- package/dist/types/twisty/controllers/TwistyAnimationController.d.ts +1 -1
- package/dist/types/twisty/controllers/TwistyAnimationController.d.ts.map +1 -1
- package/dist/types/twisty/{old/animation → controllers}/easing.d.ts +0 -0
- package/dist/types/twisty/controllers/easing.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/AlgDuration.d.ts +2 -2
- package/dist/types/twisty/controllers/indexer/AlgDuration.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/AlgIndexer.d.ts +3 -3
- package/dist/types/twisty/controllers/indexer/AlgIndexer.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/SimpleAlgIndexer.d.ts +3 -3
- package/dist/types/twisty/controllers/indexer/SimpleAlgIndexer.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexer.d.ts +3 -3
- package/dist/types/twisty/controllers/indexer/simultaneous-moves/SimultaneousMoveIndexer.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.d.ts +3 -3
- package/dist/types/twisty/controllers/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/simultaneous-moves/simul-moves.d.ts +2 -2
- package/dist/types/twisty/controllers/indexer/simultaneous-moves/simul-moves.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/tree/AlgWalker.d.ts +2 -2
- package/dist/types/twisty/controllers/indexer/tree/AlgWalker.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/indexer/tree/TreeAlgIndexer.d.ts +3 -3
- package/dist/types/twisty/controllers/indexer/tree/TreeAlgIndexer.d.ts.map +1 -0
- package/dist/types/twisty/controllers/indexer/tree/chunkAlgs.d.ts +3 -0
- package/dist/types/twisty/controllers/indexer/tree/chunkAlgs.d.ts.map +1 -0
- package/dist/types/twisty/{old/animation → controllers}/stream/timeline-move-calculation-draft.d.ts +2 -2
- package/dist/types/twisty/controllers/stream/timeline-move-calculation-draft.d.ts.map +1 -0
- package/dist/types/twisty/heavy-code-imports/dynamic-entries/3d.d.ts +1 -2
- package/dist/types/twisty/heavy-code-imports/dynamic-entries/3d.d.ts.map +1 -1
- package/dist/types/twisty/index.d.ts +8 -11
- package/dist/types/twisty/index.d.ts.map +1 -1
- package/dist/types/twisty/model/TwistyPlayerModel.d.ts +11 -0
- package/dist/types/twisty/model/TwistyPlayerModel.d.ts.map +1 -1
- package/dist/types/twisty/model/props/TwistyPropDebugger.d.ts +1 -1
- package/dist/types/twisty/model/props/TwistyPropDebugger.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/display/FoundationDisplayProp.d.ts +6 -0
- package/dist/types/twisty/model/props/puzzle/display/FoundationDisplayProp.d.ts.map +1 -0
- package/dist/types/twisty/model/props/puzzle/display/HintFaceletProp.d.ts +5 -1
- package/dist/types/twisty/model/props/puzzle/display/HintFaceletProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/display/StickeringProp.d.ts +44 -1
- package/dist/types/twisty/model/props/puzzle/display/StickeringProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/AnchoredStartProp.d.ts +2 -2
- package/dist/types/twisty/model/props/puzzle/state/AnchoredStartProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesProp.d.ts +1 -1
- package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesSimplified.d.ts +1 -1
- package/dist/types/twisty/model/props/puzzle/state/CurrentLeavesSimplified.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/CurrentTransformationProp.d.ts +1 -1
- package/dist/types/twisty/model/props/puzzle/state/CurrentTransformationProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/IndexerConstructorProp.d.ts +5 -2
- package/dist/types/twisty/model/props/puzzle/state/IndexerConstructorProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/IndexerProp.d.ts +2 -2
- package/dist/types/twisty/model/props/puzzle/state/IndexerProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/LegacyPositionProp.d.ts +2 -2
- package/dist/types/twisty/model/props/puzzle/state/LegacyPositionProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/state/MovePressInputProp.d.ts +6 -0
- package/dist/types/twisty/model/props/puzzle/state/MovePressInputProp.d.ts.map +1 -0
- package/dist/types/twisty/model/props/puzzle/state/NaiveMoveCountProp.d.ts +10 -0
- package/dist/types/twisty/model/props/puzzle/state/NaiveMoveCountProp.d.ts.map +1 -0
- package/dist/types/twisty/model/props/puzzle/state/SetupAnchorProp.d.ts +5 -1
- package/dist/types/twisty/model/props/puzzle/state/SetupAnchorProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDProp.d.ts +1 -1
- package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDRequestProp.d.ts +19 -1
- package/dist/types/twisty/model/props/puzzle/structure/PuzzleIDRequestProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/puzzle/structure/PuzzleLoaderProp.d.ts +1 -1
- package/dist/types/twisty/model/props/puzzle/structure/PuzzleLoaderProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/timeline/DetailedTimelineInfoProp.d.ts +2 -3
- package/dist/types/twisty/model/props/timeline/DetailedTimelineInfoProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/timeline/PlayingInfoProp.d.ts +1 -1
- package/dist/types/twisty/model/props/timeline/PlayingInfoProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/timeline/TimestampRequestProp.d.ts +1 -1
- package/dist/types/twisty/model/props/timeline/TimestampRequestProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/BackViewProp.d.ts +6 -1
- package/dist/types/twisty/model/props/viewer/BackViewProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/BackgroundProp.d.ts +5 -1
- package/dist/types/twisty/model/props/viewer/BackgroundProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/ControlPanelProp.d.ts +5 -1
- package/dist/types/twisty/model/props/viewer/ControlPanelProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/OrbitCoordinatesProp.d.ts +18 -5
- package/dist/types/twisty/model/props/viewer/OrbitCoordinatesProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/OrbitCoordinatesRequestProp.d.ts +6 -6
- package/dist/types/twisty/model/props/viewer/OrbitCoordinatesRequestProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/TimeRangeProp.d.ts +2 -2
- package/dist/types/twisty/model/props/viewer/TimeRangeProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/ViewerLinkProp.d.ts +5 -1
- package/dist/types/twisty/model/props/viewer/ViewerLinkProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/VisualizationProp.d.ts +7 -1
- package/dist/types/twisty/model/props/viewer/VisualizationProp.d.ts.map +1 -1
- package/dist/types/twisty/model/props/viewer/VisualizationStrategyProp.d.ts +1 -1
- package/dist/types/twisty/model/props/viewer/VisualizationStrategyProp.d.ts.map +1 -1
- package/dist/types/twisty/views/2D/Twisty2DPuzzle.css.d.ts +3 -0
- package/dist/types/twisty/views/2D/Twisty2DPuzzle.css.d.ts.map +1 -0
- package/dist/types/twisty/views/2D/Twisty2DPuzzle.d.ts +4 -6
- package/dist/types/twisty/views/2D/Twisty2DPuzzle.d.ts.map +1 -1
- package/dist/types/twisty/views/2D/Twisty2DPuzzleWrapper.d.ts +1 -1
- package/dist/types/twisty/views/2D/Twisty2DPuzzleWrapper.d.ts.map +1 -1
- package/dist/types/twisty/views/2D/Twisty2DSceneWrapper.d.ts +2 -2
- package/dist/types/twisty/views/2D/Twisty2DSceneWrapper.d.ts.map +1 -1
- package/dist/types/twisty/views/3D/DragTracker.d.ts +28 -0
- package/dist/types/twisty/views/3D/DragTracker.d.ts.map +1 -0
- package/dist/types/twisty/views/3D/RendererPool.d.ts.map +1 -1
- package/dist/types/twisty/views/3D/Twisty3DPuzzleWrapper.d.ts +6 -1
- package/dist/types/twisty/views/3D/Twisty3DPuzzleWrapper.d.ts.map +1 -1
- package/dist/types/twisty/views/3D/Twisty3DSceneWrapper.d.ts +9 -4
- package/dist/types/twisty/views/3D/Twisty3DSceneWrapper.d.ts.map +1 -1
- package/dist/types/twisty/views/3D/Twisty3DVantage.css.d.ts +3 -0
- package/dist/types/twisty/views/3D/Twisty3DVantage.css.d.ts.map +1 -0
- package/dist/types/twisty/views/3D/Twisty3DVantage.d.ts +11 -7
- package/dist/types/twisty/views/3D/Twisty3DVantage.d.ts.map +1 -1
- package/dist/types/twisty/views/3D/TwistyOrbitControls.d.ts +24 -0
- package/dist/types/twisty/views/3D/TwistyOrbitControls.d.ts.map +1 -0
- package/dist/types/twisty/views/3D/TwistyOrbitControls.spec.d.ts +5 -0
- package/dist/types/twisty/views/3D/TwistyOrbitControls.spec.d.ts.map +1 -0
- package/dist/types/twisty/views/3D/puzzles/Cube3D.d.ts +4 -4
- package/dist/types/twisty/views/3D/puzzles/Cube3D.d.ts.map +1 -1
- package/dist/types/twisty/views/3D/puzzles/PG3D.d.ts +17 -10
- package/dist/types/twisty/views/3D/puzzles/PG3D.d.ts.map +1 -1
- package/dist/types/twisty/views/3D/puzzles/Twisty3DPuzzle.d.ts +1 -1
- package/dist/types/twisty/views/3D/puzzles/Twisty3DPuzzle.d.ts.map +1 -1
- package/dist/types/twisty/{old/dom/element → views}/ClassListManager.d.ts +0 -0
- package/dist/types/twisty/views/ClassListManager.d.ts.map +1 -0
- package/dist/types/twisty/{old/dom/element → views}/ManagedCustomElement.d.ts +0 -0
- package/dist/types/twisty/views/ManagedCustomElement.d.ts.map +1 -0
- package/dist/types/twisty/views/TwistyAlgEditor/LeafTokens.d.ts +1 -1
- package/dist/types/twisty/views/TwistyAlgEditor/LeafTokens.d.ts.map +1 -1
- package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.css.d.ts +1 -1
- package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.css.d.ts.map +1 -1
- package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.d.ts +2 -1
- package/dist/types/twisty/views/TwistyAlgEditor/TwistyAlgEditor.d.ts.map +1 -1
- package/dist/types/twisty/views/TwistyAlgViewer.css.d.ts +1 -1
- package/dist/types/twisty/views/TwistyAlgViewer.css.d.ts.map +1 -1
- package/dist/types/twisty/views/TwistyAlgViewer.d.ts +2 -2
- package/dist/types/twisty/views/TwistyAlgViewer.d.ts.map +1 -1
- package/dist/types/twisty/views/TwistyPlayer.css.d.ts +3 -0
- package/dist/types/twisty/views/TwistyPlayer.css.d.ts.map +1 -0
- package/dist/types/twisty/views/TwistyPlayer.d.ts +7 -3
- package/dist/types/twisty/views/TwistyPlayer.d.ts.map +1 -1
- package/dist/types/twisty/views/TwistyPlayerSettable.d.ts +7 -4
- package/dist/types/twisty/views/TwistyPlayerSettable.d.ts.map +1 -1
- package/dist/types/twisty/views/TwistyViewerWrapper.css.d.ts +3 -0
- package/dist/types/twisty/views/TwistyViewerWrapper.css.d.ts.map +1 -0
- package/dist/types/twisty/{old/dom/viewers → views}/canvas.d.ts +0 -0
- package/dist/types/twisty/views/canvas.d.ts.map +1 -0
- package/dist/types/twisty/views/control-panel/TwistyButtonsV2.css.d.ts +4 -0
- package/dist/types/twisty/views/control-panel/TwistyButtonsV2.css.d.ts.map +1 -0
- package/dist/types/twisty/views/control-panel/TwistyButtonsV2.d.ts +1 -1
- package/dist/types/twisty/views/control-panel/TwistyButtonsV2.d.ts.map +1 -1
- package/dist/types/twisty/views/control-panel/TwistyScrubber.css.d.ts +3 -0
- package/dist/types/twisty/{old/dom/controls → views/control-panel}/TwistyScrubber.css.d.ts.map +1 -1
- package/dist/types/twisty/views/control-panel/TwistyScrubberV2.d.ts +1 -1
- package/dist/types/twisty/views/control-panel/TwistyScrubberV2.d.ts.map +1 -1
- package/dist/types/twisty/{old/dom/element → views}/node-custom-element-shims.d.ts +0 -0
- package/dist/types/twisty/views/node-custom-element-shims.d.ts.map +1 -0
- package/dist/types/twisty/views/stream/TwistyStreamSource.css.d.ts +3 -0
- package/dist/types/twisty/views/stream/TwistyStreamSource.css.d.ts.map +1 -0
- package/dist/types/twisty/{old/dom → views}/stream/TwistyStreamSource.d.ts +1 -1
- package/dist/types/twisty/views/stream/TwistyStreamSource.d.ts.map +1 -0
- package/docs/.DS_Store +0 -0
- package/docs/cubing/.DS_Store +0 -0
- package/docs/cubing/api/index.html +11 -52
- package/package.json +1 -1
- package/src/cubing/.DS_Store +0 -0
- package/src/cubing/alg/index.ts +1 -0
- package/src/cubing/alg/units/leaves/Move.ts +1 -1
- package/src/cubing/bluetooth/smart-timer/GanTimer.ts +1 -1
- package/src/cubing/puzzle-geometry/PGPuzzles.spec.ts +4 -0
- package/src/cubing/puzzle-geometry/PuzzleGeometry.ts +14 -6
- package/src/cubing/puzzles/index.ts +1 -1
- package/src/cubing/search/worker-inside-generated-string.js +1 -1
- package/src/cubing/twisty/.DS_Store +0 -0
- package/{dist/types → src/cubing/twisty/controllers}/.DS_Store +0 -0
- package/src/cubing/twisty/{old/animation/cursor/CursorTypes.ts → controllers/AnimationTypes.ts} +11 -2
- package/src/cubing/twisty/{old/animation → controllers}/RenderScheduler.ts +0 -0
- package/src/cubing/twisty/controllers/TwistyAnimationController.ts +4 -4
- package/src/cubing/twisty/controllers/animation/.DS_Store +0 -0
- package/src/cubing/twisty/{old/animation → controllers}/easing.ts +0 -0
- package/src/cubing/twisty/controllers/indexer/.DS_Store +0 -0
- package/src/cubing/twisty/{old/animation → controllers}/indexer/AlgDuration.ts +2 -2
- package/src/cubing/twisty/{old/animation → controllers}/indexer/AlgIndexer.ts +4 -4
- package/src/cubing/twisty/{old/animation → controllers}/indexer/SimpleAlgIndexer.ts +4 -4
- package/src/cubing/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexer.ts +3 -3
- package/src/cubing/twisty/{old/animation → controllers}/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.ts +3 -3
- package/src/cubing/twisty/{old/animation → controllers}/indexer/simultaneous-moves/simul-moves.ts +2 -2
- package/src/cubing/twisty/{old/animation → controllers}/indexer/tree/AlgWalker.ts +4 -4
- package/src/cubing/twisty/{old/animation → controllers}/indexer/tree/TreeAlgIndexer.ts +3 -3
- package/src/cubing/twisty/{old/animation → controllers}/indexer/tree/chunkAlgs.ts +2 -2
- package/src/cubing/twisty/{old/animation → controllers}/stream/timeline-move-calculation-draft.spec.ts.TODO +0 -0
- package/src/cubing/twisty/{old/animation → controllers}/stream/timeline-move-calculation-draft.ts +2 -2
- package/src/cubing/twisty/heavy-code-imports/.DS_Store +0 -0
- package/src/cubing/twisty/heavy-code-imports/dynamic-entries/3d.ts +2 -12
- package/src/cubing/twisty/index.ts +11 -18
- package/src/cubing/twisty/model/.DS_Store +0 -0
- package/src/cubing/twisty/model/TwistyPlayerModel.ts +30 -1
- package/src/cubing/twisty/model/props/.DS_Store +0 -0
- package/src/cubing/twisty/model/props/TwistyPropDebugger.ts +3 -3
- package/src/cubing/twisty/model/props/puzzle/.DS_Store +0 -0
- package/src/cubing/twisty/model/props/puzzle/display/FoundationDisplayProp.ts +9 -0
- package/src/cubing/twisty/model/props/puzzle/display/HintFaceletProp.ts +6 -1
- package/src/cubing/twisty/model/props/puzzle/display/StickeringProp.ts +47 -1
- package/src/cubing/twisty/model/props/puzzle/state/AlgTransformationProp.ts +1 -1
- package/src/cubing/twisty/model/props/puzzle/state/AnchoredStartProp.ts +2 -2
- package/src/cubing/twisty/model/props/puzzle/state/CurrentLeavesProp.ts +2 -2
- package/src/cubing/twisty/model/props/puzzle/state/CurrentLeavesSimplified.ts +1 -1
- package/src/cubing/twisty/model/props/puzzle/state/CurrentTransformationProp.ts +1 -1
- package/src/cubing/twisty/model/props/puzzle/state/IndexerConstructorProp.ts +12 -5
- package/src/cubing/twisty/model/props/puzzle/state/IndexerProp.ts +2 -2
- package/src/cubing/twisty/model/props/puzzle/state/LegacyPositionProp.ts +2 -2
- package/src/cubing/twisty/model/props/puzzle/state/MovePressInputProp.ts +9 -0
- package/src/cubing/twisty/model/props/puzzle/state/NaiveMoveCountProp.ts +20 -0
- package/src/cubing/twisty/model/props/puzzle/state/SetupAnchorProp.ts +7 -1
- package/src/cubing/twisty/model/props/puzzle/structure/PuzzleIDProp.ts +1 -1
- package/src/cubing/twisty/model/props/puzzle/structure/PuzzleIDRequestProp.ts +20 -1
- package/src/cubing/twisty/model/props/puzzle/structure/PuzzleLoaderProp.ts +1 -1
- package/src/cubing/twisty/model/props/timeline/DetailedTimelineInfoProp.ts +5 -3
- package/src/cubing/twisty/model/props/timeline/PlayingInfoProp.ts +1 -4
- package/src/cubing/twisty/model/props/timeline/TimestampRequestProp.ts +1 -1
- package/src/cubing/twisty/model/props/viewer/BackViewProp.ts +7 -1
- package/src/cubing/twisty/model/props/viewer/BackgroundProp.ts +6 -1
- package/src/cubing/twisty/model/props/viewer/ControlPanelProp.ts +5 -1
- package/src/cubing/twisty/model/props/viewer/OrbitCoordinatesProp.ts +83 -12
- package/src/cubing/twisty/model/props/viewer/OrbitCoordinatesRequestProp.ts +8 -8
- package/src/cubing/twisty/model/props/viewer/TimeRangeProp.ts +2 -2
- package/src/cubing/twisty/model/props/viewer/ViewerLinkProp.ts +5 -1
- package/src/cubing/twisty/model/props/viewer/VisualizationProp.ts +8 -1
- package/src/cubing/twisty/model/props/viewer/VisualizationStrategyProp.ts +1 -1
- package/src/cubing/twisty/old/.DS_Store +0 -0
- package/src/cubing/twisty/old/animation/.DS_Store +0 -0
- package/src/cubing/twisty/old/dom/.DS_Store +0 -0
- package/src/cubing/twisty/views/.DS_Store +0 -0
- package/src/cubing/twisty/{old/dom/viewers/Twisty2DSVGView.css.ts → views/2D/Twisty2DPuzzle.css.ts} +1 -1
- package/src/cubing/twisty/views/2D/Twisty2DPuzzle.ts +8 -12
- package/src/cubing/twisty/views/2D/Twisty2DPuzzleWrapper.ts +1 -1
- package/src/cubing/twisty/views/2D/Twisty2DSceneWrapper.ts +4 -4
- package/src/cubing/twisty/views/3D/.DS_Store +0 -0
- package/src/cubing/twisty/views/3D/DragTracker.ts +184 -0
- package/src/cubing/twisty/views/3D/RendererPool.ts +2 -1
- package/src/cubing/twisty/views/3D/Twisty3DPuzzleWrapper.ts +51 -5
- package/src/cubing/twisty/views/3D/Twisty3DSceneWrapper.ts +51 -10
- package/src/cubing/twisty/{old/dom/viewers/Twisty3DCanvas.css.ts → views/3D/Twisty3DVantage.css.ts} +2 -2
- package/src/cubing/twisty/views/3D/Twisty3DVantage.ts +88 -30
- package/src/cubing/twisty/views/3D/TwistyOrbitControls.spec.ts +213 -0
- package/src/cubing/twisty/views/3D/TwistyOrbitControls.ts +176 -0
- package/src/cubing/twisty/views/3D/puzzles/Cube3D.ts +5 -9
- package/src/cubing/twisty/views/3D/puzzles/PG3D.ts +127 -37
- package/src/cubing/twisty/views/3D/puzzles/Twisty3DPuzzle.ts +1 -1
- package/src/cubing/twisty/{old/dom/element → views}/ClassListManager.ts +0 -0
- package/src/cubing/twisty/{old/dom/element → views}/ManagedCustomElement.ts +0 -0
- package/src/cubing/twisty/views/TwistyAlgEditor/LeafTokens.ts +1 -1
- package/src/cubing/twisty/views/TwistyAlgEditor/TwistyAlgEditor.css.ts +1 -1
- package/src/cubing/twisty/views/TwistyAlgEditor/TwistyAlgEditor.ts +11 -4
- package/src/cubing/twisty/views/TwistyAlgViewer.css.ts +1 -1
- package/src/cubing/twisty/views/TwistyAlgViewer.ts +4 -4
- package/src/cubing/twisty/{old/dom → views}/TwistyPlayer.css.ts +4 -1
- package/src/cubing/twisty/views/TwistyPlayer.ts +16 -25
- package/src/cubing/twisty/views/TwistyPlayerSettable.ts +14 -10
- package/src/cubing/twisty/{old/dom/viewers → views}/TwistyViewerWrapper.css.ts +1 -1
- package/src/cubing/twisty/{old/dom/viewers → views}/canvas.ts +0 -0
- package/src/cubing/twisty/{old/dom/controls/buttons.css.ts → views/control-panel/TwistyButtonsV2.css.ts} +1 -1
- package/src/cubing/twisty/views/control-panel/TwistyButtonsV2.ts +5 -8
- package/src/cubing/twisty/{old/dom/controls → views/control-panel}/TwistyScrubber.css.ts +1 -1
- package/src/cubing/twisty/views/control-panel/TwistyScrubberV2.ts +3 -3
- package/src/cubing/twisty/{old/dom/element → views}/node-custom-element-shims.ts +0 -0
- package/src/cubing/twisty/{old/dom → views}/stream/TwistyStreamSource.css.ts +1 -1
- package/src/cubing/twisty/{old/dom → views}/stream/TwistyStreamSource.ts +9 -9
- package/dist/esm/3d-B25DP5PE.js +0 -39
- package/dist/esm/3d-B25DP5PE.js.map +0 -7
- package/dist/esm/chunk-APIIMJG6.js.map +0 -7
- package/dist/esm/worker-inside-generated-string-KDZOUGJF.js.map +0 -7
- package/dist/types/twisty/old/animation/RenderScheduler.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/Timeline.d.ts +0 -72
- package/dist/types/twisty/old/animation/Timeline.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/cursor/AlgCursor.d.ts +0 -53
- package/dist/types/twisty/old/animation/cursor/AlgCursor.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/cursor/CursorTypes.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/easing.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/AlgDuration.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/AlgIndexer.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/SimpleAlgIndexer.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/simultaneous-moves/SimultaneousMoveIndexer.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/simultaneous-moves/simul-moves.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/tree/AlgWalker.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/tree/TreeAlgIndexer.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/indexer/tree/chunkAlgs.d.ts +0 -3
- package/dist/types/twisty/old/animation/indexer/tree/chunkAlgs.d.ts.map +0 -1
- package/dist/types/twisty/old/animation/stream/timeline-move-calculation-draft.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/TwistyAlgViewerV1.css.d.ts +0 -3
- package/dist/types/twisty/old/dom/TwistyAlgViewerV1.css.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/TwistyAlgViewerV1.d.ts +0 -52
- package/dist/types/twisty/old/dom/TwistyAlgViewerV1.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/TwistyPlayer.css.d.ts +0 -3
- package/dist/types/twisty/old/dom/TwistyPlayer.css.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/TwistyPlayer.d.ts +0 -92
- package/dist/types/twisty/old/dom/TwistyPlayer.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/TwistyPlayer.spec.d.ts +0 -5
- package/dist/types/twisty/old/dom/TwistyPlayer.spec.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/TwistyPlayerConfig.d.ts +0 -165
- package/dist/types/twisty/old/dom/TwistyPlayerConfig.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/controls/TwistyControlElement.d.ts +0 -2
- package/dist/types/twisty/old/dom/controls/TwistyControlElement.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/controls/TwistyScrubber.css.d.ts +0 -3
- package/dist/types/twisty/old/dom/controls/TwistyScrubber.d.ts +0 -14
- package/dist/types/twisty/old/dom/controls/TwistyScrubber.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/controls/buttons.css.d.ts +0 -4
- package/dist/types/twisty/old/dom/controls/buttons.css.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/controls/buttons.d.ts +0 -40
- package/dist/types/twisty/old/dom/controls/buttons.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/controls/buttons.spec.d.ts +0 -5
- package/dist/types/twisty/old/dom/controls/buttons.spec.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/element/ClassListManager.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/element/ElementConfig.d.ts +0 -49
- package/dist/types/twisty/old/dom/element/ElementConfig.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/element/ManagedCustomElement.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/element/node-custom-element-shims.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/stream/TwistyStreamSource.css.d.ts +0 -3
- package/dist/types/twisty/old/dom/stream/TwistyStreamSource.css.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/stream/TwistyStreamSource.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/Twisty2DSVG.d.ts +0 -26
- package/dist/types/twisty/old/dom/viewers/Twisty2DSVG.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/Twisty2DSVGView.css.d.ts +0 -3
- package/dist/types/twisty/old/dom/viewers/Twisty2DSVGView.css.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.css.d.ts +0 -3
- package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.css.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.d.ts +0 -41
- package/dist/types/twisty/old/dom/viewers/Twisty3DCanvas.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/TwistyOrbitControls.d.ts +0 -59
- package/dist/types/twisty/old/dom/viewers/TwistyOrbitControls.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/TwistyViewerElement.d.ts +0 -4
- package/dist/types/twisty/old/dom/viewers/TwistyViewerElement.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.css.d.ts +0 -3
- package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.css.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.d.ts +0 -18
- package/dist/types/twisty/old/dom/viewers/TwistyViewerWrapper.d.ts.map +0 -1
- package/dist/types/twisty/old/dom/viewers/canvas.d.ts.map +0 -1
- package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.d.ts +0 -41
- package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.d.ts.map +0 -1
- package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.spec.d.ts +0 -5
- package/dist/types/twisty/views/3D/TwistyOrbitControlsV2.spec.d.ts.map +0 -1
- package/src/cubing/twisty/old/animation/Timeline.ts +0 -378
- package/src/cubing/twisty/old/animation/cursor/AlgCursor.ts +0 -252
- package/src/cubing/twisty/old/dom/TwistyAlgViewerV1.css.ts +0 -25
- package/src/cubing/twisty/old/dom/TwistyAlgViewerV1.ts +0 -516
- package/src/cubing/twisty/old/dom/TwistyPlayer.spec.ts +0 -25
- package/src/cubing/twisty/old/dom/TwistyPlayer.ts +0 -927
- package/src/cubing/twisty/old/dom/TwistyPlayerConfig.ts +0 -378
- package/src/cubing/twisty/old/dom/controls/TwistyControlElement.ts +0 -1
- package/src/cubing/twisty/old/dom/controls/TwistyScrubber.ts +0 -53
- package/src/cubing/twisty/old/dom/controls/buttons.spec.ts +0 -37
- package/src/cubing/twisty/old/dom/controls/buttons.ts +0 -326
- package/src/cubing/twisty/old/dom/element/ElementConfig.ts +0 -180
- package/src/cubing/twisty/old/dom/viewers/Twisty2DSVG.ts +0 -118
- package/src/cubing/twisty/old/dom/viewers/Twisty3DCanvas.ts +0 -256
- package/src/cubing/twisty/old/dom/viewers/TwistyOrbitControls.ts +0 -420
- package/src/cubing/twisty/old/dom/viewers/TwistyViewerElement.ts +0 -5
- package/src/cubing/twisty/old/dom/viewers/TwistyViewerWrapper.ts +0 -45
- package/src/cubing/twisty/views/3D/TwistyOrbitControlsV2.spec.ts +0 -209
- package/src/cubing/twisty/views/3D/TwistyOrbitControlsV2.ts +0 -270
package/dist/esm/twisty/index.js
CHANGED
|
@@ -1,36 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CSSSource,
|
|
3
|
-
ClassListManager,
|
|
4
2
|
Cube3D,
|
|
5
3
|
DEGREES_PER_RADIAN,
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
FreshListenerManager,
|
|
5
|
+
HintFaceletProp,
|
|
6
|
+
NO_VALUE,
|
|
8
7
|
PG3D,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
customElementsShim,
|
|
17
|
-
defaultCameraOrbitCoordinates,
|
|
18
|
-
experimentalShowRenderStats,
|
|
19
|
-
pixelRatio,
|
|
20
|
-
pyraminxLookAt,
|
|
21
|
-
twisty3DCanvasCSS,
|
|
22
|
-
twistyViewerWrapperCSS
|
|
23
|
-
} from "../chunk-APIIMJG6.js";
|
|
8
|
+
SimpleTwistyPropSource,
|
|
9
|
+
StaleDropper,
|
|
10
|
+
StickeringProp,
|
|
11
|
+
TwistyPropDerived,
|
|
12
|
+
TwistyPropSource,
|
|
13
|
+
from
|
|
14
|
+
} from "../chunk-DLN5QS4V.js";
|
|
24
15
|
import {
|
|
25
16
|
countAnimatedLeaves,
|
|
26
17
|
countMoves
|
|
27
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-4IUYLRHT.js";
|
|
28
19
|
import {
|
|
29
20
|
cube3x3x3,
|
|
30
21
|
cubeAppearance,
|
|
31
22
|
customPGPuzzleLoader,
|
|
32
23
|
puzzles
|
|
33
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-HXKINJ7U.js";
|
|
34
25
|
import {
|
|
35
26
|
KPuzzle,
|
|
36
27
|
KPuzzleSVGWrapper,
|
|
@@ -39,7 +30,7 @@ import {
|
|
|
39
30
|
identityTransformation,
|
|
40
31
|
invertTransformation,
|
|
41
32
|
transformationForMove
|
|
42
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-X6JHXPDX.js";
|
|
43
34
|
import {
|
|
44
35
|
Alg,
|
|
45
36
|
AlgBuilder,
|
|
@@ -52,16 +43,15 @@ import {
|
|
|
52
43
|
direct,
|
|
53
44
|
directedGenerator,
|
|
54
45
|
experimentalAppendMove
|
|
55
|
-
} from "../chunk-
|
|
46
|
+
} from "../chunk-EWRBHQFX.js";
|
|
56
47
|
import {
|
|
57
48
|
__privateAdd,
|
|
58
49
|
__privateGet,
|
|
59
50
|
__privateMethod,
|
|
60
|
-
__privateSet
|
|
61
|
-
__privateWrapper
|
|
51
|
+
__privateSet
|
|
62
52
|
} from "../chunk-WO2AXYFE.js";
|
|
63
53
|
|
|
64
|
-
// src/cubing/twisty/
|
|
54
|
+
// src/cubing/twisty/controllers/AnimationTypes.ts
|
|
65
55
|
var Direction;
|
|
66
56
|
(function(Direction2) {
|
|
67
57
|
Direction2[Direction2["Forwards"] = 1] = "Forwards";
|
|
@@ -77,52 +67,29 @@ var BoundaryType;
|
|
|
77
67
|
BoundaryType2["EntireTimeline"] = "entire-timeline";
|
|
78
68
|
})(BoundaryType || (BoundaryType = {}));
|
|
79
69
|
|
|
80
|
-
// src/cubing/twisty/
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (idx > __privateGet(this, _latestResolvedIdx)) {
|
|
91
|
-
__privateSet(this, _latestResolvedIdx, idx);
|
|
92
|
-
return {
|
|
93
|
-
fresh: true,
|
|
94
|
-
result
|
|
95
|
-
};
|
|
96
|
-
} else {
|
|
97
|
-
return { fresh: false };
|
|
70
|
+
// src/cubing/twisty/controllers/RenderScheduler.ts
|
|
71
|
+
var RenderScheduler = class {
|
|
72
|
+
constructor(callback) {
|
|
73
|
+
this.callback = callback;
|
|
74
|
+
this.animFrameID = null;
|
|
75
|
+
this.animFrame = this.animFrameWrapper.bind(this);
|
|
76
|
+
}
|
|
77
|
+
requestAnimFrame() {
|
|
78
|
+
if (!this.animFrameID) {
|
|
79
|
+
this.animFrameID = requestAnimationFrame(this.animFrame);
|
|
98
80
|
}
|
|
99
81
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
constructor() {
|
|
106
|
-
__privateAdd(this, _latestAssignedIdx2, 0);
|
|
107
|
-
__privateAdd(this, _latestResolvedIdx2, 0);
|
|
82
|
+
cancelAnimFrame() {
|
|
83
|
+
if (this.animFrameID) {
|
|
84
|
+
cancelAnimationFrame(this.animFrameID);
|
|
85
|
+
this.animFrameID = 0;
|
|
86
|
+
}
|
|
108
87
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const idx = ++__privateWrapper(this, _latestAssignedIdx2)._;
|
|
113
|
-
const result = await p;
|
|
114
|
-
if (idx > __privateGet(this, _latestResolvedIdx2)) {
|
|
115
|
-
__privateSet(this, _latestResolvedIdx2, idx);
|
|
116
|
-
resolve(result);
|
|
117
|
-
}
|
|
118
|
-
} catch (e) {
|
|
119
|
-
reject(e);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
88
|
+
animFrameWrapper(timestamp) {
|
|
89
|
+
this.animFrameID = 0;
|
|
90
|
+
this.callback(timestamp);
|
|
122
91
|
}
|
|
123
92
|
};
|
|
124
|
-
_latestAssignedIdx2 = new WeakMap();
|
|
125
|
-
_latestResolvedIdx2 = new WeakMap();
|
|
126
93
|
|
|
127
94
|
// src/cubing/twisty/model/helpers.ts
|
|
128
95
|
function arrayEquals(a, b) {
|
|
@@ -386,12 +353,126 @@ var TwistyPlayerController = class {
|
|
|
386
353
|
}
|
|
387
354
|
};
|
|
388
355
|
|
|
389
|
-
// src/cubing/twisty/
|
|
356
|
+
// src/cubing/twisty/model/props/viewer/ControlPanelProp.ts
|
|
357
|
+
var controlsLocations = {
|
|
358
|
+
"bottom-row": true,
|
|
359
|
+
"none": true
|
|
360
|
+
};
|
|
361
|
+
var ControlPanelProp = class extends SimpleTwistyPropSource {
|
|
362
|
+
getDefaultValue() {
|
|
363
|
+
return "auto";
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// src/cubing/twisty/views/ClassListManager.ts
|
|
368
|
+
var _currentClassName;
|
|
369
|
+
var ClassListManager = class {
|
|
370
|
+
constructor(elem, prefix, validSuffixes) {
|
|
371
|
+
this.elem = elem;
|
|
372
|
+
this.prefix = prefix;
|
|
373
|
+
this.validSuffixes = validSuffixes;
|
|
374
|
+
__privateAdd(this, _currentClassName, null);
|
|
375
|
+
}
|
|
376
|
+
clearValue() {
|
|
377
|
+
if (__privateGet(this, _currentClassName)) {
|
|
378
|
+
this.elem.contentWrapper.classList.remove(__privateGet(this, _currentClassName));
|
|
379
|
+
}
|
|
380
|
+
__privateSet(this, _currentClassName, null);
|
|
381
|
+
}
|
|
382
|
+
setValue(suffix) {
|
|
383
|
+
if (!this.validSuffixes.includes(suffix)) {
|
|
384
|
+
throw new Error(`Invalid suffix: ${suffix}`);
|
|
385
|
+
}
|
|
386
|
+
const newClassName = `${this.prefix}${suffix}`;
|
|
387
|
+
const changed = __privateGet(this, _currentClassName) !== newClassName;
|
|
388
|
+
if (changed) {
|
|
389
|
+
this.clearValue();
|
|
390
|
+
this.elem.contentWrapper.classList.add(newClassName);
|
|
391
|
+
__privateSet(this, _currentClassName, newClassName);
|
|
392
|
+
}
|
|
393
|
+
return changed;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
_currentClassName = new WeakMap();
|
|
397
|
+
|
|
398
|
+
// src/cubing/twisty/views/node-custom-element-shims.ts
|
|
399
|
+
var HTMLElementStub = class {
|
|
400
|
+
};
|
|
401
|
+
var HTMLElementShim;
|
|
402
|
+
if (typeof HTMLElement !== "undefined") {
|
|
403
|
+
HTMLElementShim = HTMLElement;
|
|
404
|
+
} else {
|
|
405
|
+
HTMLElementShim = HTMLElementStub;
|
|
406
|
+
}
|
|
407
|
+
var CustomElementsStub = class {
|
|
408
|
+
define() {
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
var customElementsShim;
|
|
412
|
+
if (typeof customElements !== "undefined") {
|
|
413
|
+
customElementsShim = customElements;
|
|
414
|
+
} else {
|
|
415
|
+
customElementsShim = new CustomElementsStub();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// src/cubing/twisty/views/ManagedCustomElement.ts
|
|
419
|
+
var CSSSource = class {
|
|
420
|
+
constructor(sourceText) {
|
|
421
|
+
this.sourceText = sourceText;
|
|
422
|
+
}
|
|
423
|
+
getAsString() {
|
|
424
|
+
return this.sourceText;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var _cssSourceMap;
|
|
428
|
+
var ManagedCustomElement = class extends HTMLElementShim {
|
|
429
|
+
constructor(options) {
|
|
430
|
+
super();
|
|
431
|
+
__privateAdd(this, _cssSourceMap, new Map());
|
|
432
|
+
this.shadow = this.attachShadow({ mode: options?.mode ?? "closed" });
|
|
433
|
+
this.contentWrapper = document.createElement("div");
|
|
434
|
+
this.contentWrapper.classList.add("wrapper");
|
|
435
|
+
this.shadow.appendChild(this.contentWrapper);
|
|
436
|
+
}
|
|
437
|
+
addCSS(cssSource) {
|
|
438
|
+
if (__privateGet(this, _cssSourceMap).get(cssSource)) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const cssElem = document.createElement("style");
|
|
442
|
+
cssElem.textContent = cssSource.getAsString();
|
|
443
|
+
__privateGet(this, _cssSourceMap).set(cssSource, cssElem);
|
|
444
|
+
this.shadow.appendChild(cssElem);
|
|
445
|
+
}
|
|
446
|
+
removeCSS(cssSource) {
|
|
447
|
+
const cssElem = __privateGet(this, _cssSourceMap).get(cssSource);
|
|
448
|
+
if (!cssElem) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
this.shadow.removeChild(cssElem);
|
|
452
|
+
__privateGet(this, _cssSourceMap).delete(cssSource);
|
|
453
|
+
}
|
|
454
|
+
addElement(element) {
|
|
455
|
+
return this.contentWrapper.appendChild(element);
|
|
456
|
+
}
|
|
457
|
+
prependElement(element) {
|
|
458
|
+
this.contentWrapper.prepend(element);
|
|
459
|
+
}
|
|
460
|
+
removeElement(element) {
|
|
461
|
+
return this.contentWrapper.removeChild(element);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
_cssSourceMap = new WeakMap();
|
|
465
|
+
customElementsShim.define("twisty-managed-custom-element", ManagedCustomElement);
|
|
466
|
+
|
|
467
|
+
// src/cubing/twisty/views/TwistyPlayer.css.ts
|
|
390
468
|
var twistyPlayerCSS = new CSSSource(`
|
|
391
469
|
:host {
|
|
392
470
|
width: 384px;
|
|
393
471
|
height: 256px;
|
|
394
472
|
display: grid;
|
|
473
|
+
|
|
474
|
+
-webkit-user-select: none;
|
|
475
|
+
user-select: none;
|
|
395
476
|
}
|
|
396
477
|
|
|
397
478
|
.wrapper {
|
|
@@ -455,291 +536,55 @@ twisty-scrubber {
|
|
|
455
536
|
}
|
|
456
537
|
`);
|
|
457
538
|
|
|
458
|
-
// src/cubing/vendor/p-lazy/p-lazy.ts
|
|
459
|
-
var PLazy = class extends Promise {
|
|
460
|
-
constructor(executor) {
|
|
461
|
-
super((resolve) => {
|
|
462
|
-
resolve();
|
|
463
|
-
});
|
|
464
|
-
this._executor = executor;
|
|
465
|
-
}
|
|
466
|
-
static from(function_) {
|
|
467
|
-
return new PLazy((resolve) => {
|
|
468
|
-
resolve(function_());
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
static resolve(value) {
|
|
472
|
-
return new PLazy((resolve) => {
|
|
473
|
-
resolve(value);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
static reject(error) {
|
|
477
|
-
return new PLazy((_resolve, reject) => {
|
|
478
|
-
reject(error);
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
then(onFulfilled, onRejected) {
|
|
482
|
-
this._promise = this._promise || new Promise(this._executor);
|
|
483
|
-
return this._promise.then(onFulfilled, onRejected);
|
|
484
|
-
}
|
|
485
|
-
catch(onRejected) {
|
|
486
|
-
this._promise = this._promise || new Promise(this._executor);
|
|
487
|
-
return this._promise.catch(onRejected);
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
function from(function_) {
|
|
491
|
-
return new PLazy((resolve) => {
|
|
492
|
-
resolve(function_());
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
|
|
496
539
|
// src/cubing/twisty/heavy-code-imports/3d.ts
|
|
497
540
|
var cachedConstructorProxy = null;
|
|
498
541
|
async function proxy3D() {
|
|
499
|
-
return cachedConstructorProxy ?? (cachedConstructorProxy = import("../3d-
|
|
542
|
+
return cachedConstructorProxy ?? (cachedConstructorProxy = import("../3d-3WQVOHX5.js"));
|
|
500
543
|
}
|
|
501
544
|
var THREEJS = from(async () => (await proxy3D()).T3I);
|
|
502
545
|
|
|
503
|
-
// src/cubing/twisty/
|
|
504
|
-
var
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
return Array.from(__privateGet(this, _children).values());
|
|
524
|
-
}
|
|
525
|
-
addChild(child) {
|
|
526
|
-
__privateGet(this, _children).add(child);
|
|
527
|
-
}
|
|
528
|
-
removeChild(child) {
|
|
529
|
-
__privateGet(this, _children).delete(child);
|
|
530
|
-
}
|
|
531
|
-
markStale(sourceEvent) {
|
|
532
|
-
if (sourceEvent.detail.generation !== globalSourceGeneration) {
|
|
533
|
-
throw new Error("A TwistyProp was marked stale too late!");
|
|
534
|
-
}
|
|
535
|
-
if (this.lastSourceGeneration === sourceEvent.detail.generation) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
this.lastSourceGeneration = sourceEvent.detail.generation;
|
|
539
|
-
for (const child of __privateGet(this, _children)) {
|
|
540
|
-
child.markStale(sourceEvent);
|
|
541
|
-
}
|
|
542
|
-
__privateMethod(this, _scheduleRawDispatch, scheduleRawDispatch_fn).call(this);
|
|
543
|
-
}
|
|
544
|
-
addRawListener(listener, options) {
|
|
545
|
-
__privateGet(this, _rawListeners).add(listener);
|
|
546
|
-
if (options?.initial) {
|
|
547
|
-
listener();
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
removeRawListener(listener) {
|
|
551
|
-
__privateGet(this, _rawListeners).delete(listener);
|
|
552
|
-
}
|
|
553
|
-
addFreshListener(listener) {
|
|
554
|
-
const staleDropper = new StaleDropper();
|
|
555
|
-
let lastResult = null;
|
|
556
|
-
const callback = async () => {
|
|
557
|
-
const result = await staleDropper.queue(this.get());
|
|
558
|
-
if (lastResult !== null && this.canReuse(lastResult, result)) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
lastResult = result;
|
|
562
|
-
listener(result);
|
|
563
|
-
};
|
|
564
|
-
__privateGet(this, _freshListeners).set(listener, callback);
|
|
565
|
-
this.addRawListener(callback, { initial: true });
|
|
566
|
-
}
|
|
567
|
-
removeFreshListener(listener) {
|
|
568
|
-
this.removeRawListener(__privateGet(this, _freshListeners).get(listener));
|
|
569
|
-
__privateGet(this, _freshListeners).delete(listener);
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
_children = new WeakMap();
|
|
573
|
-
_rawListeners = new WeakMap();
|
|
574
|
-
_scheduleRawDispatch = new WeakSet();
|
|
575
|
-
scheduleRawDispatch_fn = function() {
|
|
576
|
-
if (!__privateGet(this, _rawDispatchPending)) {
|
|
577
|
-
__privateSet(this, _rawDispatchPending, true);
|
|
578
|
-
setTimeout(() => __privateMethod(this, _dispatchRawListeners, dispatchRawListeners_fn).call(this), 0);
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
_rawDispatchPending = new WeakMap();
|
|
582
|
-
_dispatchRawListeners = new WeakSet();
|
|
583
|
-
dispatchRawListeners_fn = function() {
|
|
584
|
-
if (!__privateGet(this, _rawDispatchPending)) {
|
|
585
|
-
throw new Error("Invalid dispatch state!");
|
|
586
|
-
}
|
|
587
|
-
for (const listener of __privateGet(this, _rawListeners)) {
|
|
588
|
-
listener();
|
|
589
|
-
}
|
|
590
|
-
__privateSet(this, _rawDispatchPending, false);
|
|
591
|
-
};
|
|
592
|
-
_freshListeners = new WeakMap();
|
|
593
|
-
var _value;
|
|
594
|
-
var TwistyPropSource = class extends TwistyPropParent {
|
|
595
|
-
constructor(initialValue) {
|
|
596
|
-
super();
|
|
597
|
-
__privateAdd(this, _value, void 0);
|
|
598
|
-
__privateSet(this, _value, from(() => this.getDefaultValue()));
|
|
599
|
-
if (initialValue) {
|
|
600
|
-
__privateSet(this, _value, this.deriveFromPromiseOrValue(initialValue, __privateGet(this, _value)));
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
set(input) {
|
|
604
|
-
__privateSet(this, _value, this.deriveFromPromiseOrValue(input, __privateGet(this, _value)));
|
|
605
|
-
const sourceEventDetail = {
|
|
606
|
-
sourceProp: this,
|
|
607
|
-
value: __privateGet(this, _value),
|
|
608
|
-
generation: ++globalSourceGeneration
|
|
609
|
-
};
|
|
610
|
-
this.markStale(new CustomEvent("stale", {
|
|
611
|
-
detail: sourceEventDetail
|
|
612
|
-
}));
|
|
613
|
-
}
|
|
614
|
-
async get() {
|
|
615
|
-
return __privateGet(this, _value);
|
|
616
|
-
}
|
|
617
|
-
async deriveFromPromiseOrValue(input, oldValuePromise) {
|
|
618
|
-
return this.derive(await input, oldValuePromise);
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
_value = new WeakMap();
|
|
622
|
-
var SimpleTwistyPropSource = class extends TwistyPropSource {
|
|
623
|
-
derive(input) {
|
|
624
|
-
return input;
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
var NO_VALUE = Symbol("no value");
|
|
628
|
-
var _parents, _cachedLastSuccessfulCalculation, _cachedLatestGenerationCalculation, _getParents, getParents_fn, _cacheDerive, cacheDerive_fn;
|
|
629
|
-
var TwistyPropDerived = class extends TwistyPropParent {
|
|
630
|
-
constructor(parents, userVisibleErrorTracker) {
|
|
631
|
-
super();
|
|
632
|
-
this.userVisibleErrorTracker = userVisibleErrorTracker;
|
|
633
|
-
__privateAdd(this, _getParents);
|
|
634
|
-
__privateAdd(this, _cacheDerive);
|
|
635
|
-
__privateAdd(this, _parents, void 0);
|
|
636
|
-
__privateAdd(this, _cachedLastSuccessfulCalculation, null);
|
|
637
|
-
__privateAdd(this, _cachedLatestGenerationCalculation, null);
|
|
638
|
-
__privateSet(this, _parents, parents);
|
|
639
|
-
for (const parent of Object.values(parents)) {
|
|
640
|
-
parent.addChild(this);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
async get() {
|
|
644
|
-
const generation = this.lastSourceGeneration;
|
|
645
|
-
if (__privateGet(this, _cachedLatestGenerationCalculation)?.generation === generation) {
|
|
646
|
-
return __privateGet(this, _cachedLatestGenerationCalculation).output;
|
|
647
|
-
}
|
|
648
|
-
const latestGenerationCalculation = {
|
|
649
|
-
generation,
|
|
650
|
-
output: __privateMethod(this, _cacheDerive, cacheDerive_fn).call(this, __privateMethod(this, _getParents, getParents_fn).call(this), generation, __privateGet(this, _cachedLastSuccessfulCalculation))
|
|
651
|
-
};
|
|
652
|
-
__privateSet(this, _cachedLatestGenerationCalculation, latestGenerationCalculation);
|
|
653
|
-
this.userVisibleErrorTracker?.reset();
|
|
654
|
-
return latestGenerationCalculation.output;
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
_parents = new WeakMap();
|
|
658
|
-
_cachedLastSuccessfulCalculation = new WeakMap();
|
|
659
|
-
_cachedLatestGenerationCalculation = new WeakMap();
|
|
660
|
-
_getParents = new WeakSet();
|
|
661
|
-
getParents_fn = async function() {
|
|
662
|
-
const inputValuePromises = {};
|
|
663
|
-
for (const [key, parent] of Object.entries(__privateGet(this, _parents))) {
|
|
664
|
-
inputValuePromises[key] = parent.get();
|
|
665
|
-
}
|
|
666
|
-
const inputs = {};
|
|
667
|
-
for (const key in __privateGet(this, _parents)) {
|
|
668
|
-
inputs[key] = await inputValuePromises[key];
|
|
669
|
-
}
|
|
670
|
-
return inputs;
|
|
671
|
-
};
|
|
672
|
-
_cacheDerive = new WeakSet();
|
|
673
|
-
cacheDerive_fn = async function(inputsPromise, generation, cachedLatestGenerationCalculation = null) {
|
|
674
|
-
const inputs = await inputsPromise;
|
|
675
|
-
const cache = (output) => {
|
|
676
|
-
__privateSet(this, _cachedLastSuccessfulCalculation, {
|
|
677
|
-
inputs,
|
|
678
|
-
output: Promise.resolve(output),
|
|
679
|
-
generation
|
|
680
|
-
});
|
|
681
|
-
return output;
|
|
682
|
-
};
|
|
683
|
-
if (!cachedLatestGenerationCalculation) {
|
|
684
|
-
return cache(await this.derive(inputs));
|
|
685
|
-
}
|
|
686
|
-
const cachedInputs = cachedLatestGenerationCalculation.inputs;
|
|
687
|
-
for (const key in __privateGet(this, _parents)) {
|
|
688
|
-
const parent = __privateGet(this, _parents)[key];
|
|
689
|
-
if (!parent.canReuse(inputs[key], cachedInputs[key])) {
|
|
690
|
-
return cache(await this.derive(inputs));
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
return cachedLatestGenerationCalculation.output;
|
|
694
|
-
};
|
|
695
|
-
var _disconnectionFunctions;
|
|
696
|
-
var FreshListenerManager = class {
|
|
697
|
-
constructor() {
|
|
698
|
-
__privateAdd(this, _disconnectionFunctions, []);
|
|
699
|
-
}
|
|
700
|
-
addListener(prop, listener) {
|
|
701
|
-
let disconnected = false;
|
|
702
|
-
const wrappedListener = (value) => {
|
|
703
|
-
if (disconnected) {
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
listener(value);
|
|
707
|
-
};
|
|
708
|
-
prop.addFreshListener(wrappedListener);
|
|
709
|
-
__privateGet(this, _disconnectionFunctions).push(() => {
|
|
710
|
-
prop.removeFreshListener(wrappedListener);
|
|
711
|
-
disconnected = true;
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
addMultiListener(props, listener) {
|
|
715
|
-
let disconnected = false;
|
|
716
|
-
const wrappedListener = async (_) => {
|
|
717
|
-
if (disconnected) {
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
const promises = props.map((prop) => prop.get());
|
|
721
|
-
const values = await Promise.all(promises);
|
|
722
|
-
listener(values);
|
|
723
|
-
};
|
|
724
|
-
for (const prop of props) {
|
|
725
|
-
prop.addFreshListener(wrappedListener);
|
|
726
|
-
}
|
|
727
|
-
__privateGet(this, _disconnectionFunctions).push(() => {
|
|
728
|
-
for (const prop of props) {
|
|
729
|
-
prop.removeFreshListener(wrappedListener);
|
|
730
|
-
}
|
|
731
|
-
disconnected = true;
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
disconnect() {
|
|
735
|
-
for (const disconnectionFunction of __privateGet(this, _disconnectionFunctions)) {
|
|
736
|
-
disconnectionFunction();
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
_disconnectionFunctions = new WeakMap();
|
|
546
|
+
// src/cubing/twisty/views/TwistyViewerWrapper.css.ts
|
|
547
|
+
var twistyViewerWrapperCSS = new CSSSource(`
|
|
548
|
+
:host {
|
|
549
|
+
width: 384px;
|
|
550
|
+
height: 256px;
|
|
551
|
+
display: grid;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.wrapper {
|
|
555
|
+
width: 100%;
|
|
556
|
+
height: 100%;
|
|
557
|
+
display: grid;
|
|
558
|
+
overflow: hidden;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.wrapper > * {
|
|
562
|
+
width: 100%;
|
|
563
|
+
height: 100%;
|
|
564
|
+
overflow: hidden;
|
|
565
|
+
}
|
|
741
566
|
|
|
742
|
-
|
|
567
|
+
.wrapper.back-view-side-by-side {
|
|
568
|
+
grid-template-columns: 1fr 1fr;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
.wrapper.back-view-top-right {
|
|
572
|
+
grid-template-columns: 3fr 1fr;
|
|
573
|
+
grid-template-rows: 1fr 3fr;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.wrapper.back-view-top-right > :nth-child(1) {
|
|
577
|
+
grid-row: 1 / 3;
|
|
578
|
+
grid-column: 1 / 3;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.wrapper.back-view-top-right > :nth-child(2) {
|
|
582
|
+
grid-row: 1 / 2;
|
|
583
|
+
grid-column: 2 / 3;
|
|
584
|
+
}
|
|
585
|
+
`);
|
|
586
|
+
|
|
587
|
+
// src/cubing/twisty/views/2D/Twisty2DPuzzle.css.ts
|
|
743
588
|
var twisty2DSVGCSS = new CSSSource(`
|
|
744
589
|
:host {
|
|
745
590
|
width: 384px;
|
|
@@ -922,6 +767,9 @@ _cachedScene = new WeakMap();
|
|
|
922
767
|
_currentTwisty2DPuzzleWrapper = new WeakMap();
|
|
923
768
|
customElementsShim.define("twisty-2d-scene-wrapper", Twisty2DSceneWrapper);
|
|
924
769
|
|
|
770
|
+
// src/cubing/twisty/views/3D/Twisty3DSceneWrapper.ts
|
|
771
|
+
import { Vector2 } from "three";
|
|
772
|
+
|
|
925
773
|
// src/cubing/twisty/views/3D/Twisty3DPuzzleWrapper.ts
|
|
926
774
|
var _freshListenerManager4, _cachedTwisty3DPuzzle;
|
|
927
775
|
var Twisty3DPuzzleWrapper = class {
|
|
@@ -952,6 +800,12 @@ var Twisty3DPuzzleWrapper = class {
|
|
|
952
800
|
});
|
|
953
801
|
this.scheduleRender();
|
|
954
802
|
});
|
|
803
|
+
__privateGet(this, _freshListenerManager4).addListener(this.model.foundationDisplayProp, async (foundationDisplay) => {
|
|
804
|
+
(await this.twisty3DPuzzle()).experimentalUpdateOptions({
|
|
805
|
+
showFoundation: foundationDisplay !== "none"
|
|
806
|
+
});
|
|
807
|
+
this.scheduleRender();
|
|
808
|
+
});
|
|
955
809
|
__privateGet(this, _freshListenerManager4).addListener(this.model.stickeringProp, async (stickering) => {
|
|
956
810
|
if ("setStickering" in await this.twisty3DPuzzle()) {
|
|
957
811
|
(await this.twisty3DPuzzle()).setStickering(stickering);
|
|
@@ -1015,10 +869,281 @@ var Twisty3DPuzzleWrapper = class {
|
|
|
1015
869
|
}
|
|
1016
870
|
})());
|
|
1017
871
|
}
|
|
872
|
+
async raycastMove(raycasterPromise, transformations) {
|
|
873
|
+
const puzzle = await this.twisty3DPuzzle();
|
|
874
|
+
if (!(puzzle instanceof PG3D)) {
|
|
875
|
+
console.info("not PG3D! skipping raycast");
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
const targets = puzzle.experimentalGetControlTargets();
|
|
879
|
+
const [raycaster] = await Promise.all([raycasterPromise]);
|
|
880
|
+
const intersects = raycaster.intersectObjects(targets);
|
|
881
|
+
if (intersects.length > 0) {
|
|
882
|
+
const closestMove = puzzle.getClosestMoveToAxis(intersects[0].point, transformations);
|
|
883
|
+
if (closestMove) {
|
|
884
|
+
this.model.experimentalAddMove(closestMove.move, {
|
|
885
|
+
coalesce: true,
|
|
886
|
+
mod: closestMove.order
|
|
887
|
+
});
|
|
888
|
+
} else {
|
|
889
|
+
console.info("Skipping move!");
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
1018
893
|
};
|
|
1019
894
|
_freshListenerManager4 = new WeakMap();
|
|
1020
895
|
_cachedTwisty3DPuzzle = new WeakMap();
|
|
1021
896
|
|
|
897
|
+
// src/cubing/vendor/three/examples/jsm/libs/stats.modified.module.ts
|
|
898
|
+
var performance2 = globalThis.performance;
|
|
899
|
+
var Stats = class {
|
|
900
|
+
constructor() {
|
|
901
|
+
this.mode = 0;
|
|
902
|
+
this.dom = document.createElement("div");
|
|
903
|
+
this.beginTime = (performance2 || Date).now();
|
|
904
|
+
this.prevTime = this.beginTime;
|
|
905
|
+
this.frames = 0;
|
|
906
|
+
this.fpsPanel = this.addPanel(new StatsPanel("FPS", "#0ff", "#002"));
|
|
907
|
+
this.msPanel = this.addPanel(new StatsPanel("MS", "#0f0", "#020"));
|
|
908
|
+
this.memPanel = performance2?.memory ? this.addPanel(new StatsPanel("MB", "#f08", "#201")) : null;
|
|
909
|
+
this.REVISION = 16;
|
|
910
|
+
this.dom.style.cssText = "position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";
|
|
911
|
+
this.dom.addEventListener("click", (event) => {
|
|
912
|
+
event.preventDefault();
|
|
913
|
+
this.showPanel(++this.mode % this.dom.children.length);
|
|
914
|
+
}, false);
|
|
915
|
+
this.showPanel(0);
|
|
916
|
+
}
|
|
917
|
+
addPanel(panel) {
|
|
918
|
+
this.dom.appendChild(panel.dom);
|
|
919
|
+
return panel;
|
|
920
|
+
}
|
|
921
|
+
showPanel(id) {
|
|
922
|
+
for (let i = 0; i < this.dom.children.length; i++) {
|
|
923
|
+
this.dom.children[i].style.display = i === id ? "block" : "none";
|
|
924
|
+
}
|
|
925
|
+
this.mode = id;
|
|
926
|
+
}
|
|
927
|
+
begin() {
|
|
928
|
+
this.beginTime = (performance2 || Date).now();
|
|
929
|
+
}
|
|
930
|
+
end() {
|
|
931
|
+
this.frames++;
|
|
932
|
+
const time = (performance2 || Date).now();
|
|
933
|
+
this.msPanel.update(time - this.beginTime, 200);
|
|
934
|
+
if (time >= this.prevTime + 1e3) {
|
|
935
|
+
this.fpsPanel.update(this.frames * 1e3 / (time - this.prevTime), 100);
|
|
936
|
+
this.prevTime = time;
|
|
937
|
+
this.frames = 0;
|
|
938
|
+
if (this.memPanel) {
|
|
939
|
+
const memory = performance2.memory;
|
|
940
|
+
this.memPanel.update(memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return time;
|
|
944
|
+
}
|
|
945
|
+
update() {
|
|
946
|
+
this.beginTime = this.end();
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
var PR = Math.round(globalThis?.window?.devicePixelRatio ?? 1);
|
|
950
|
+
var WIDTH = 80 * PR;
|
|
951
|
+
var HEIGHT = 48 * PR;
|
|
952
|
+
var TEXT_X = 3 * PR;
|
|
953
|
+
var TEXT_Y = 2 * PR;
|
|
954
|
+
var GRAPH_X = 3 * PR;
|
|
955
|
+
var GRAPH_Y = 15 * PR;
|
|
956
|
+
var GRAPH_WIDTH = 74 * PR;
|
|
957
|
+
var GRAPH_HEIGHT = 30 * PR;
|
|
958
|
+
var StatsPanel = class {
|
|
959
|
+
constructor(name, fg, bg) {
|
|
960
|
+
this.name = name;
|
|
961
|
+
this.fg = fg;
|
|
962
|
+
this.bg = bg;
|
|
963
|
+
this.min = Infinity;
|
|
964
|
+
this.max = 0;
|
|
965
|
+
this.dom = document.createElement("canvas");
|
|
966
|
+
this.context = this.dom.getContext("2d");
|
|
967
|
+
this.dom.width = WIDTH;
|
|
968
|
+
this.dom.height = HEIGHT;
|
|
969
|
+
this.dom.style.cssText = "width:80px;height:48px";
|
|
970
|
+
this.context.font = `bold ${9 * PR}px Helvetica,Arial,sans-serif`;
|
|
971
|
+
this.context.textBaseline = "top";
|
|
972
|
+
this.context.fillStyle = bg;
|
|
973
|
+
this.context.fillRect(0, 0, WIDTH, HEIGHT);
|
|
974
|
+
this.context.fillStyle = fg;
|
|
975
|
+
this.context.fillText(name, TEXT_X, TEXT_Y);
|
|
976
|
+
this.context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
|
|
977
|
+
this.context.fillStyle = bg;
|
|
978
|
+
this.context.globalAlpha = 0.9;
|
|
979
|
+
this.context.fillRect(GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT);
|
|
980
|
+
}
|
|
981
|
+
update(value, maxValue) {
|
|
982
|
+
this.min = Math.min(this.min, value);
|
|
983
|
+
this.max = Math.max(this.max, value);
|
|
984
|
+
this.context.fillStyle = this.bg;
|
|
985
|
+
this.context.globalAlpha = 1;
|
|
986
|
+
this.context.fillRect(0, 0, WIDTH, GRAPH_Y);
|
|
987
|
+
this.context.fillStyle = this.fg;
|
|
988
|
+
this.context.fillText(Math.round(value) + " " + this.name + " (" + Math.round(this.min) + "-" + Math.round(this.max) + ")", TEXT_X, TEXT_Y);
|
|
989
|
+
this.context.drawImage(this.dom, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT);
|
|
990
|
+
this.context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT);
|
|
991
|
+
this.context.fillStyle = this.bg;
|
|
992
|
+
this.context.globalAlpha = 0.9;
|
|
993
|
+
this.context.fillRect(GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, Math.round((1 - value / maxValue) * GRAPH_HEIGHT));
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
// src/cubing/twisty/views/canvas.ts
|
|
998
|
+
var globalPixelRatioOverride = null;
|
|
999
|
+
function pixelRatio() {
|
|
1000
|
+
return globalPixelRatioOverride ?? (devicePixelRatio || 1);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// src/cubing/twisty/views/3D/Twisty3DVantage.css.ts
|
|
1004
|
+
var twisty3DVantageCSS = new CSSSource(`
|
|
1005
|
+
:host {
|
|
1006
|
+
width: 384px;
|
|
1007
|
+
height: 256px;
|
|
1008
|
+
display: grid;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
.wrapper {
|
|
1012
|
+
width: 100%;
|
|
1013
|
+
height: 100%;
|
|
1014
|
+
display: grid;
|
|
1015
|
+
overflow: hidden;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/* TODO: This is due to stats hack. Replace with \`canvas\`. */
|
|
1019
|
+
.wrapper > canvas {
|
|
1020
|
+
max-width: 100%;
|
|
1021
|
+
max-height: 100%;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
.wrapper.invisible {
|
|
1025
|
+
opacity: 0;
|
|
1026
|
+
}
|
|
1027
|
+
`);
|
|
1028
|
+
|
|
1029
|
+
// src/cubing/twisty/views/3D/DragTracker.ts
|
|
1030
|
+
var MOVEMENT_EPSILON = 0.1;
|
|
1031
|
+
var _dragInfoMap, _lazyListenersRegistered, _registerLazyListeners, registerLazyListeners_fn, _clear, clear_fn, _trackDrag, trackDrag_fn;
|
|
1032
|
+
var DragTracker = class extends EventTarget {
|
|
1033
|
+
constructor(target) {
|
|
1034
|
+
super();
|
|
1035
|
+
this.target = target;
|
|
1036
|
+
__privateAdd(this, _registerLazyListeners);
|
|
1037
|
+
__privateAdd(this, _clear);
|
|
1038
|
+
__privateAdd(this, _trackDrag);
|
|
1039
|
+
__privateAdd(this, _dragInfoMap, new Map());
|
|
1040
|
+
__privateAdd(this, _lazyListenersRegistered, false);
|
|
1041
|
+
target.addEventListener("pointerdown", this.onPointerDown.bind(this));
|
|
1042
|
+
this.target.addEventListener("contextmenu", (e) => {
|
|
1043
|
+
if (e.buttons & 2) {
|
|
1044
|
+
e.preventDefault();
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
this.target.addEventListener("touchmove", (e) => e.preventDefault());
|
|
1048
|
+
this.target.addEventListener("dblclick", (e) => e.preventDefault());
|
|
1049
|
+
}
|
|
1050
|
+
onPointerDown(e) {
|
|
1051
|
+
__privateMethod(this, _registerLazyListeners, registerLazyListeners_fn).call(this);
|
|
1052
|
+
const newDragInfo = {
|
|
1053
|
+
attachedInfo: {},
|
|
1054
|
+
hasMoved: false,
|
|
1055
|
+
lastClientX: e.clientX,
|
|
1056
|
+
lastClientY: e.clientY,
|
|
1057
|
+
lastTimeStamp: e.timeStamp
|
|
1058
|
+
};
|
|
1059
|
+
__privateGet(this, _dragInfoMap).set(e.pointerId, newDragInfo);
|
|
1060
|
+
this.target.setPointerCapture(e.pointerId);
|
|
1061
|
+
}
|
|
1062
|
+
onPointerMove(e) {
|
|
1063
|
+
const movementInfo = __privateMethod(this, _trackDrag, trackDrag_fn).call(this, e).movementInfo;
|
|
1064
|
+
if (movementInfo) {
|
|
1065
|
+
e.preventDefault();
|
|
1066
|
+
this.dispatchEvent(new CustomEvent("move", {
|
|
1067
|
+
detail: movementInfo
|
|
1068
|
+
}));
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
onPointerUp(e) {
|
|
1072
|
+
const trackDragResult = __privateMethod(this, _trackDrag, trackDrag_fn).call(this, e);
|
|
1073
|
+
const existing = __privateGet(this, _dragInfoMap).get(e.pointerId);
|
|
1074
|
+
__privateMethod(this, _clear, clear_fn).call(this, e);
|
|
1075
|
+
this.target.releasePointerCapture(e.pointerId);
|
|
1076
|
+
let event;
|
|
1077
|
+
if (trackDragResult.hasMoved) {
|
|
1078
|
+
event = new CustomEvent("up", {
|
|
1079
|
+
detail: { attachedInfo: existing.attachedInfo }
|
|
1080
|
+
});
|
|
1081
|
+
} else {
|
|
1082
|
+
const { altKey, ctrlKey, metaKey, shiftKey } = e;
|
|
1083
|
+
event = new CustomEvent("press", {
|
|
1084
|
+
detail: {
|
|
1085
|
+
normalizedX: e.offsetX / this.target.offsetWidth * 2 - 1,
|
|
1086
|
+
normalizedY: 1 - e.offsetY / this.target.offsetHeight * 2,
|
|
1087
|
+
rightClick: !!(e.button & 2),
|
|
1088
|
+
keys: {
|
|
1089
|
+
altKey,
|
|
1090
|
+
ctrlOrMetaKey: ctrlKey || metaKey,
|
|
1091
|
+
shiftKey
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
this.dispatchEvent(event);
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
_dragInfoMap = new WeakMap();
|
|
1100
|
+
_lazyListenersRegistered = new WeakMap();
|
|
1101
|
+
_registerLazyListeners = new WeakSet();
|
|
1102
|
+
registerLazyListeners_fn = function() {
|
|
1103
|
+
if (__privateGet(this, _lazyListenersRegistered)) {
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
this.target.addEventListener("pointermove", this.onPointerMove.bind(this));
|
|
1107
|
+
this.target.addEventListener("pointerup", this.onPointerUp.bind(this));
|
|
1108
|
+
__privateSet(this, _lazyListenersRegistered, true);
|
|
1109
|
+
};
|
|
1110
|
+
_clear = new WeakSet();
|
|
1111
|
+
clear_fn = function(e) {
|
|
1112
|
+
__privateGet(this, _dragInfoMap).delete(e.pointerId);
|
|
1113
|
+
};
|
|
1114
|
+
_trackDrag = new WeakSet();
|
|
1115
|
+
trackDrag_fn = function(e) {
|
|
1116
|
+
const existing = __privateGet(this, _dragInfoMap).get(e.pointerId);
|
|
1117
|
+
if (!existing) {
|
|
1118
|
+
return { movementInfo: null, hasMoved: false };
|
|
1119
|
+
}
|
|
1120
|
+
let movementInfo;
|
|
1121
|
+
if ((e.movementX ?? 0) !== 0 || (e.movementY ?? 0) !== 0) {
|
|
1122
|
+
movementInfo = {
|
|
1123
|
+
attachedInfo: existing.attachedInfo,
|
|
1124
|
+
movementX: e.movementX,
|
|
1125
|
+
movementY: e.movementY,
|
|
1126
|
+
elapsedMs: e.timeStamp - existing.lastTimeStamp
|
|
1127
|
+
};
|
|
1128
|
+
} else {
|
|
1129
|
+
movementInfo = {
|
|
1130
|
+
attachedInfo: existing.attachedInfo,
|
|
1131
|
+
movementX: e.clientX - existing.lastClientX,
|
|
1132
|
+
movementY: e.clientY - existing.lastClientY,
|
|
1133
|
+
elapsedMs: e.timeStamp - existing.lastTimeStamp
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
existing.lastClientX = e.clientX;
|
|
1137
|
+
existing.lastClientY = e.clientY;
|
|
1138
|
+
existing.lastTimeStamp = e.timeStamp;
|
|
1139
|
+
if (Math.abs(movementInfo.movementX) < MOVEMENT_EPSILON && Math.abs(movementInfo.movementY) < MOVEMENT_EPSILON) {
|
|
1140
|
+
return { movementInfo: null, hasMoved: existing.hasMoved };
|
|
1141
|
+
} else {
|
|
1142
|
+
existing.hasMoved = true;
|
|
1143
|
+
return { movementInfo, hasMoved: existing.hasMoved };
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1022
1147
|
// src/cubing/twisty/views/3D/RendererPool.ts
|
|
1023
1148
|
var renderers = [];
|
|
1024
1149
|
async function renderPooled(width, height, canvas, scene, camera) {
|
|
@@ -1045,10 +1170,9 @@ async function newRenderer() {
|
|
|
1045
1170
|
return renderer;
|
|
1046
1171
|
}
|
|
1047
1172
|
|
|
1048
|
-
// src/cubing/twisty/views/3D/
|
|
1173
|
+
// src/cubing/twisty/views/3D/TwistyOrbitControls.ts
|
|
1049
1174
|
import { Spherical } from "three";
|
|
1050
1175
|
var INERTIA_DEFAULT = true;
|
|
1051
|
-
var LATITUDE_LIMITS_DEFAULT = "auto";
|
|
1052
1176
|
var INERTIA_DURATION_MS = 500;
|
|
1053
1177
|
var INERTIA_TIMEOUT_MS = 50;
|
|
1054
1178
|
var VERTICAL_MOVEMENT_BASE_SCALE = 0.75;
|
|
@@ -1079,137 +1203,58 @@ var Inertia = class {
|
|
|
1079
1203
|
this.lastTimestamp = now;
|
|
1080
1204
|
}
|
|
1081
1205
|
};
|
|
1082
|
-
var
|
|
1083
|
-
constructor(model, mirror, canvas) {
|
|
1206
|
+
var TwistyOrbitControls = class {
|
|
1207
|
+
constructor(model, mirror, canvas, dragTracker) {
|
|
1084
1208
|
this.model = model;
|
|
1085
1209
|
this.mirror = mirror;
|
|
1086
1210
|
this.canvas = canvas;
|
|
1211
|
+
this.dragTracker = dragTracker;
|
|
1087
1212
|
this.experimentalInertia = INERTIA_DEFAULT;
|
|
1088
|
-
this.
|
|
1089
|
-
this.lastTouchClientX = 0;
|
|
1090
|
-
this.lastTouchClientY = 0;
|
|
1091
|
-
this.currentTouchID = null;
|
|
1092
|
-
this.onMoveBound = this.onMove.bind(this);
|
|
1093
|
-
this.onMouseMoveBound = this.onMouseMove.bind(this);
|
|
1094
|
-
this.onMouseEndBound = this.onMouseEnd.bind(this);
|
|
1095
|
-
this.onTouchMoveBound = this.onTouchMove.bind(this);
|
|
1096
|
-
this.onTouchEndBound = this.onTouchEnd.bind(this);
|
|
1097
|
-
this.lastTouchTimestamp = 0;
|
|
1098
|
-
this.lastTouchMoveMomentumX = 0;
|
|
1099
|
-
this.lastTouchMoveMomentumY = 0;
|
|
1100
|
-
this.lastMouseTimestamp = 0;
|
|
1101
|
-
this.lastMouseMoveMomentumX = 0;
|
|
1102
|
-
this.lastMouseMoveMomentumY = 0;
|
|
1213
|
+
this.onMovementBound = this.onMovement.bind(this);
|
|
1103
1214
|
this.experimentalHasBeenMoved = false;
|
|
1104
|
-
|
|
1105
|
-
|
|
1215
|
+
this.dragTracker.addEventListener("move", this.onMove.bind(this));
|
|
1216
|
+
this.dragTracker.addEventListener("up", this.onUp.bind(this));
|
|
1106
1217
|
}
|
|
1107
1218
|
temperMovement(f) {
|
|
1108
1219
|
return Math.sign(f) * Math.log(Math.abs(f * 10) + 1) / 6;
|
|
1109
1220
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
this.
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
this.onMouseEnd(e);
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
if (e.movementX === 0 && e.movementY === 0) {
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
const minDim = Math.min(this.canvas.offsetWidth, this.canvas.offsetHeight);
|
|
1125
|
-
const movementX = this.temperMovement(e.movementX / minDim);
|
|
1126
|
-
const movementY = this.temperMovement(e.movementY / minDim * VERTICAL_MOVEMENT_BASE_SCALE);
|
|
1127
|
-
this.onMove(movementX, movementY);
|
|
1128
|
-
const deltaMs = e.timeStamp - this.lastMouseTimestamp;
|
|
1129
|
-
if (deltaMs > 0) {
|
|
1130
|
-
this.lastMouseMoveMomentumX = movementX / deltaMs;
|
|
1131
|
-
this.lastMouseMoveMomentumY = movementY / deltaMs;
|
|
1132
|
-
this.lastMouseTimestamp = e.timeStamp;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
onMouseEnd(e) {
|
|
1136
|
-
window.removeEventListener("mousemove", this.onMouseMoveBound);
|
|
1137
|
-
window.removeEventListener("mouseup", this.onMouseEndBound);
|
|
1138
|
-
this.onEnd(e);
|
|
1139
|
-
if (this.experimentalInertia) {
|
|
1140
|
-
new Inertia(this.lastMouseTimestamp, this.lastMouseMoveMomentumX, this.lastMouseMoveMomentumY, this.onMoveBound);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
onTouchStart(e) {
|
|
1144
|
-
if (this.currentTouchID === null) {
|
|
1145
|
-
if (e.touches[0].clientX === 0 && e.touches[0].clientY === 0) {
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
this.currentTouchID = e.changedTouches[0].identifier;
|
|
1149
|
-
this.lastTouchClientX = e.touches[0].clientX;
|
|
1150
|
-
this.lastTouchClientY = e.touches[0].clientY;
|
|
1151
|
-
window.addEventListener("touchmove", this.onTouchMoveBound);
|
|
1152
|
-
window.addEventListener("touchend", this.onTouchEndBound);
|
|
1153
|
-
window.addEventListener("touchcancel", this.onTouchEndBound);
|
|
1154
|
-
this.onStart(e);
|
|
1155
|
-
this.lastTouchTimestamp = e.timeStamp;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
onTouchMove(e) {
|
|
1159
|
-
for (let i = 0; i < e.changedTouches.length; i++) {
|
|
1160
|
-
const touch = e.changedTouches[i];
|
|
1161
|
-
if (touch.identifier === this.currentTouchID) {
|
|
1162
|
-
const minDim = Math.min(this.canvas.offsetWidth, this.canvas.offsetHeight);
|
|
1163
|
-
const movementX = this.temperMovement((touch.clientX - this.lastTouchClientX) / minDim);
|
|
1164
|
-
const movementY = this.temperMovement((touch.clientY - this.lastTouchClientY) / minDim * VERTICAL_MOVEMENT_BASE_SCALE);
|
|
1165
|
-
this.onMove(movementX, movementY);
|
|
1166
|
-
this.lastTouchClientX = touch.clientX;
|
|
1167
|
-
this.lastTouchClientY = touch.clientY;
|
|
1168
|
-
const deltaMs = e.timeStamp - this.lastTouchTimestamp;
|
|
1169
|
-
if (deltaMs > 0) {
|
|
1170
|
-
this.lastTouchMoveMomentumX = movementX / deltaMs;
|
|
1171
|
-
this.lastTouchMoveMomentumY = movementY / deltaMs;
|
|
1172
|
-
this.lastTouchTimestamp = e.timeStamp;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
onTouchEnd(e) {
|
|
1178
|
-
for (let i = 0; i < e.changedTouches.length; i++) {
|
|
1179
|
-
const touch = e.changedTouches[i];
|
|
1180
|
-
if (touch.identifier === this.currentTouchID) {
|
|
1181
|
-
this.currentTouchID = null;
|
|
1182
|
-
window.removeEventListener("touchmove", this.onTouchMoveBound);
|
|
1183
|
-
window.removeEventListener("touchend", this.onTouchEndBound);
|
|
1184
|
-
window.removeEventListener("touchcancel", this.onTouchEndBound);
|
|
1185
|
-
this.onEnd(e);
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
if (this.experimentalInertia) {
|
|
1189
|
-
new Inertia(this.lastTouchTimestamp, this.lastTouchMoveMomentumX, this.lastTouchMoveMomentumY, this.onMoveBound);
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
onStart(e) {
|
|
1193
|
-
e.preventDefault();
|
|
1221
|
+
onMove(e) {
|
|
1222
|
+
var _a;
|
|
1223
|
+
(_a = e.detail).attachedInfo ?? (_a.attachedInfo = {});
|
|
1224
|
+
const { temperedX, temperedY } = this.onMovement(e.detail.movementX, e.detail.movementY);
|
|
1225
|
+
const attachedInfo = e.detail.attachedInfo;
|
|
1226
|
+
attachedInfo.lastTemperedX = temperedX * 10;
|
|
1227
|
+
attachedInfo.lastTemperedY = temperedY * 10;
|
|
1228
|
+
attachedInfo.timestamp = e.timeStamp;
|
|
1194
1229
|
}
|
|
1195
|
-
|
|
1230
|
+
onMovement(movementX, movementY) {
|
|
1196
1231
|
const scale = this.mirror ? -1 : 1;
|
|
1232
|
+
const minDim = Math.min(this.canvas.offsetWidth, this.canvas.offsetHeight);
|
|
1233
|
+
const temperedX = this.temperMovement(movementX / minDim);
|
|
1234
|
+
const temperedY = this.temperMovement(movementY / minDim * VERTICAL_MOVEMENT_BASE_SCALE);
|
|
1197
1235
|
this.model.orbitCoordinatesRequestProp.set((async () => {
|
|
1198
1236
|
const prevCoords = await this.model.orbitCoordinatesProp.get();
|
|
1199
1237
|
const newCoords = {
|
|
1200
|
-
latitude: prevCoords.latitude + 2 *
|
|
1201
|
-
longitude: prevCoords.longitude - 2 *
|
|
1238
|
+
latitude: prevCoords.latitude + 2 * temperedY * DEGREES_PER_RADIAN * scale,
|
|
1239
|
+
longitude: prevCoords.longitude - 2 * temperedX * DEGREES_PER_RADIAN
|
|
1202
1240
|
};
|
|
1203
1241
|
return newCoords;
|
|
1204
1242
|
})());
|
|
1243
|
+
return { temperedX, temperedY };
|
|
1205
1244
|
}
|
|
1206
|
-
|
|
1245
|
+
onUp(e) {
|
|
1207
1246
|
e.preventDefault();
|
|
1247
|
+
if ("lastTemperedX" in e.detail.attachedInfo && "lastTemperedY" in e.detail.attachedInfo && "timestamp" in e.detail.attachedInfo && e.timeStamp - e.detail.attachedInfo.timestamp < 60) {
|
|
1248
|
+
new Inertia(e.timeStamp, e.detail.attachedInfo.lastTemperedX, e.detail.attachedInfo.lastTemperedY, this.onMovementBound);
|
|
1249
|
+
}
|
|
1208
1250
|
}
|
|
1209
1251
|
};
|
|
1210
1252
|
|
|
1211
1253
|
// src/cubing/twisty/views/3D/Twisty3DVantage.ts
|
|
1212
1254
|
var SHOW_STATS = false;
|
|
1255
|
+
function debugShowRenderStats(enable) {
|
|
1256
|
+
SHOW_STATS = enable;
|
|
1257
|
+
}
|
|
1213
1258
|
async function setCameraFromOrbitCoordinates(camera, orbitCoordinates, backView = false) {
|
|
1214
1259
|
const spherical = new (await THREEJS).Spherical(orbitCoordinates.distance, (90 - (backView ? -1 : 1) * orbitCoordinates.latitude) / DEGREES_PER_RADIAN, ((backView ? 180 : 0) + orbitCoordinates.longitude) / DEGREES_PER_RADIAN);
|
|
1215
1260
|
spherical.makeSafe();
|
|
@@ -1236,13 +1281,15 @@ function shareRenderer() {
|
|
|
1236
1281
|
return true;
|
|
1237
1282
|
}
|
|
1238
1283
|
}
|
|
1239
|
-
var _onResizeStaleDropper, _width, _height, _onResize, onResize_fn, _cachedRenderer, _cachedCanvas, _cachedCamera, _cachedOrbitControls,
|
|
1284
|
+
var _setupBasicPresses, setupBasicPresses_fn, _onResizeStaleDropper, _width, _height, _onResize, onResize_fn, _cachedRenderer, _cachedCanvas, _cachedDragTracker, _dragTracker, dragTracker_fn, _cachedCamera, _cachedOrbitControls, _disconnectionFunctions, _scheduler;
|
|
1240
1285
|
var Twisty3DVantage = class extends ManagedCustomElement {
|
|
1241
1286
|
constructor(model, scene, options) {
|
|
1242
1287
|
super();
|
|
1243
1288
|
this.model = model;
|
|
1244
1289
|
this.options = options;
|
|
1290
|
+
__privateAdd(this, _setupBasicPresses);
|
|
1245
1291
|
__privateAdd(this, _onResize);
|
|
1292
|
+
__privateAdd(this, _dragTracker);
|
|
1246
1293
|
this.scene = null;
|
|
1247
1294
|
this.stats = null;
|
|
1248
1295
|
this.rendererIsShared = shareRenderer();
|
|
@@ -1251,9 +1298,10 @@ var Twisty3DVantage = class extends ManagedCustomElement {
|
|
|
1251
1298
|
__privateAdd(this, _height, 0);
|
|
1252
1299
|
__privateAdd(this, _cachedRenderer, null);
|
|
1253
1300
|
__privateAdd(this, _cachedCanvas, null);
|
|
1301
|
+
__privateAdd(this, _cachedDragTracker, null);
|
|
1254
1302
|
__privateAdd(this, _cachedCamera, null);
|
|
1255
1303
|
__privateAdd(this, _cachedOrbitControls, null);
|
|
1256
|
-
__privateAdd(this,
|
|
1304
|
+
__privateAdd(this, _disconnectionFunctions, []);
|
|
1257
1305
|
__privateAdd(this, _scheduler, new RenderScheduler(this.render.bind(this)));
|
|
1258
1306
|
this.scene = scene ?? null;
|
|
1259
1307
|
if (SHOW_STATS) {
|
|
@@ -1263,27 +1311,42 @@ var Twisty3DVantage = class extends ManagedCustomElement {
|
|
|
1263
1311
|
}
|
|
1264
1312
|
}
|
|
1265
1313
|
async connectedCallback() {
|
|
1266
|
-
this.addCSS(
|
|
1267
|
-
this.addElement(await this.
|
|
1314
|
+
this.addCSS(twisty3DVantageCSS);
|
|
1315
|
+
this.addElement((await this.canvasInfo()).canvas);
|
|
1268
1316
|
__privateMethod(this, _onResize, onResize_fn).call(this);
|
|
1269
1317
|
const observer = new ResizeObserver(__privateMethod(this, _onResize, onResize_fn).bind(this));
|
|
1270
1318
|
observer.observe(this.contentWrapper);
|
|
1271
1319
|
this.orbitControls();
|
|
1320
|
+
__privateMethod(this, _setupBasicPresses, setupBasicPresses_fn).call(this);
|
|
1272
1321
|
this.scheduleRender();
|
|
1273
1322
|
}
|
|
1274
|
-
async
|
|
1323
|
+
async clearCanvas() {
|
|
1275
1324
|
if (this.rendererIsShared) {
|
|
1276
|
-
|
|
1325
|
+
const canvasInfo = await this.canvasInfo();
|
|
1326
|
+
canvasInfo.context.clearRect(0, 0, canvasInfo.canvas.width, canvasInfo.canvas.height);
|
|
1327
|
+
} else {
|
|
1328
|
+
const renderer = await this.renderer();
|
|
1329
|
+
const context = renderer.getContext();
|
|
1330
|
+
context.clear(context.COLOR_BUFFER_BIT);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
async renderer() {
|
|
1334
|
+
if (this.rendererIsShared) {
|
|
1335
|
+
throw new Error("renderer expected to be shared.");
|
|
1277
1336
|
}
|
|
1278
1337
|
return __privateGet(this, _cachedRenderer) ?? __privateSet(this, _cachedRenderer, newRenderer());
|
|
1279
1338
|
}
|
|
1280
|
-
async
|
|
1339
|
+
async canvasInfo() {
|
|
1281
1340
|
return __privateGet(this, _cachedCanvas) ?? __privateSet(this, _cachedCanvas, (async () => {
|
|
1341
|
+
let canvas;
|
|
1282
1342
|
if (this.rendererIsShared) {
|
|
1283
|
-
|
|
1343
|
+
canvas = this.addElement(document.createElement("canvas"));
|
|
1344
|
+
} else {
|
|
1345
|
+
const renderer = await this.renderer();
|
|
1346
|
+
canvas = this.addElement(renderer.domElement);
|
|
1284
1347
|
}
|
|
1285
|
-
const
|
|
1286
|
-
return
|
|
1348
|
+
const context = canvas.getContext("2d");
|
|
1349
|
+
return { canvas, context };
|
|
1287
1350
|
})());
|
|
1288
1351
|
}
|
|
1289
1352
|
async camera() {
|
|
@@ -1296,7 +1359,7 @@ var Twisty3DVantage = class extends ManagedCustomElement {
|
|
|
1296
1359
|
}
|
|
1297
1360
|
async orbitControls() {
|
|
1298
1361
|
return __privateGet(this, _cachedOrbitControls) ?? __privateSet(this, _cachedOrbitControls, (async () => {
|
|
1299
|
-
const orbitControls = new
|
|
1362
|
+
const orbitControls = new TwistyOrbitControls(this.model, !!this.options?.backView, (await this.canvasInfo()).canvas, await __privateMethod(this, _dragTracker, dragTracker_fn).call(this));
|
|
1300
1363
|
if (this.model) {
|
|
1301
1364
|
this.addListener(this.model.orbitCoordinatesProp, async (orbitCoordinates) => {
|
|
1302
1365
|
const camera = await this.camera();
|
|
@@ -1309,15 +1372,15 @@ var Twisty3DVantage = class extends ManagedCustomElement {
|
|
|
1309
1372
|
}
|
|
1310
1373
|
addListener(prop, listener) {
|
|
1311
1374
|
prop.addFreshListener(listener);
|
|
1312
|
-
__privateGet(this,
|
|
1375
|
+
__privateGet(this, _disconnectionFunctions).push(() => {
|
|
1313
1376
|
prop.removeFreshListener(listener);
|
|
1314
1377
|
});
|
|
1315
1378
|
}
|
|
1316
1379
|
disconnect() {
|
|
1317
|
-
for (const fn of __privateGet(this,
|
|
1380
|
+
for (const fn of __privateGet(this, _disconnectionFunctions)) {
|
|
1318
1381
|
fn();
|
|
1319
1382
|
}
|
|
1320
|
-
__privateSet(this,
|
|
1383
|
+
__privateSet(this, _disconnectionFunctions, []);
|
|
1321
1384
|
}
|
|
1322
1385
|
async render() {
|
|
1323
1386
|
if (!this.scene) {
|
|
@@ -1327,10 +1390,10 @@ var Twisty3DVantage = class extends ManagedCustomElement {
|
|
|
1327
1390
|
const [scene, camera, canvas] = await Promise.all([
|
|
1328
1391
|
this.scene.scene(),
|
|
1329
1392
|
this.camera(),
|
|
1330
|
-
this.
|
|
1393
|
+
this.canvasInfo()
|
|
1331
1394
|
]);
|
|
1332
1395
|
if (this.rendererIsShared) {
|
|
1333
|
-
renderPooled(__privateGet(this, _width), __privateGet(this, _height), canvas, scene, camera);
|
|
1396
|
+
renderPooled(__privateGet(this, _width), __privateGet(this, _height), canvas.canvas, scene, camera);
|
|
1334
1397
|
} else {
|
|
1335
1398
|
(await this.renderer()).render(scene, camera);
|
|
1336
1399
|
}
|
|
@@ -1340,6 +1403,22 @@ var Twisty3DVantage = class extends ManagedCustomElement {
|
|
|
1340
1403
|
__privateGet(this, _scheduler).requestAnimFrame();
|
|
1341
1404
|
}
|
|
1342
1405
|
};
|
|
1406
|
+
_setupBasicPresses = new WeakSet();
|
|
1407
|
+
setupBasicPresses_fn = async function() {
|
|
1408
|
+
const dragTracker = await __privateMethod(this, _dragTracker, dragTracker_fn).call(this);
|
|
1409
|
+
dragTracker.addEventListener("press", async (e) => {
|
|
1410
|
+
const movePressInput = await this.model.movePressInputProp.get();
|
|
1411
|
+
if (movePressInput !== "basic") {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
this.dispatchEvent(new CustomEvent("press", {
|
|
1415
|
+
detail: {
|
|
1416
|
+
pressInfo: e.detail,
|
|
1417
|
+
cameraPromise: this.camera()
|
|
1418
|
+
}
|
|
1419
|
+
}));
|
|
1420
|
+
});
|
|
1421
|
+
};
|
|
1343
1422
|
_onResizeStaleDropper = new WeakMap();
|
|
1344
1423
|
_width = new WeakMap();
|
|
1345
1424
|
_height = new WeakMap();
|
|
@@ -1360,24 +1439,33 @@ onResize_fn = async function() {
|
|
|
1360
1439
|
camera.aspect = w / h;
|
|
1361
1440
|
camera.setViewOffset(w, h - excess, off, yoff, w, h);
|
|
1362
1441
|
camera.updateProjectionMatrix();
|
|
1442
|
+
this.clearCanvas();
|
|
1363
1443
|
if (this.rendererIsShared) {
|
|
1364
|
-
const
|
|
1365
|
-
canvas.width = w * pixelRatio();
|
|
1366
|
-
canvas.height = h * pixelRatio();
|
|
1367
|
-
canvas.style.width = w.toString();
|
|
1368
|
-
canvas.style.height = w.toString();
|
|
1444
|
+
const canvasInfo = await this.canvasInfo();
|
|
1445
|
+
canvasInfo.canvas.width = w * pixelRatio();
|
|
1446
|
+
canvasInfo.canvas.height = h * pixelRatio();
|
|
1447
|
+
canvasInfo.canvas.style.width = w.toString();
|
|
1448
|
+
canvasInfo.canvas.style.height = w.toString();
|
|
1369
1449
|
} else {
|
|
1370
|
-
|
|
1450
|
+
const renderer = await this.renderer();
|
|
1451
|
+
renderer.setSize(w, h, true);
|
|
1371
1452
|
}
|
|
1372
1453
|
this.scheduleRender();
|
|
1373
1454
|
};
|
|
1374
1455
|
_cachedRenderer = new WeakMap();
|
|
1375
1456
|
_cachedCanvas = new WeakMap();
|
|
1457
|
+
_cachedDragTracker = new WeakMap();
|
|
1458
|
+
_dragTracker = new WeakSet();
|
|
1459
|
+
dragTracker_fn = async function() {
|
|
1460
|
+
return __privateGet(this, _cachedDragTracker) ?? __privateSet(this, _cachedDragTracker, (async () => {
|
|
1461
|
+
return new DragTracker((await this.canvasInfo()).canvas);
|
|
1462
|
+
})());
|
|
1463
|
+
};
|
|
1376
1464
|
_cachedCamera = new WeakMap();
|
|
1377
1465
|
_cachedOrbitControls = new WeakMap();
|
|
1378
|
-
|
|
1466
|
+
_disconnectionFunctions = new WeakMap();
|
|
1379
1467
|
_scheduler = new WeakMap();
|
|
1380
|
-
customElementsShim.define("twisty-3d-vantage
|
|
1468
|
+
customElementsShim.define("twisty-3d-vantage", Twisty3DVantage);
|
|
1381
1469
|
|
|
1382
1470
|
// src/cubing/twisty/views/3D/Twisty3DSceneWrapper.ts
|
|
1383
1471
|
var _backViewClassListManager, _freshListenerManager5, _backViewVantage, _cachedScene2, _vantages, _currentTwisty3DPuzzleWrapper, _twisty3DStaleDropper;
|
|
@@ -1433,10 +1521,32 @@ var Twisty3DSceneWrapper = class extends ManagedCustomElement {
|
|
|
1433
1521
|
onBackView(backView) {
|
|
1434
1522
|
this.setBackView(backView);
|
|
1435
1523
|
}
|
|
1524
|
+
async onPress(e) {
|
|
1525
|
+
const twisty3DPuzzleWrapper = __privateGet(this, _currentTwisty3DPuzzleWrapper);
|
|
1526
|
+
if (!twisty3DPuzzleWrapper) {
|
|
1527
|
+
console.info("no wrapper; skipping scene wrapper press!");
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
const raycasterPromise = (async () => {
|
|
1531
|
+
const [camera, three] = await Promise.all([
|
|
1532
|
+
e.detail.cameraPromise,
|
|
1533
|
+
THREEJS
|
|
1534
|
+
]);
|
|
1535
|
+
const raycaster = new three.Raycaster();
|
|
1536
|
+
const mouse = new Vector2(e.detail.pressInfo.normalizedX, e.detail.pressInfo.normalizedY);
|
|
1537
|
+
raycaster.setFromCamera(mouse, camera);
|
|
1538
|
+
return raycaster;
|
|
1539
|
+
})();
|
|
1540
|
+
twisty3DPuzzleWrapper.raycastMove(raycasterPromise, {
|
|
1541
|
+
invert: !e.detail.pressInfo.rightClick,
|
|
1542
|
+
depth: e.detail.pressInfo.keys.ctrlOrMetaKey ? "rotation" : e.detail.pressInfo.keys.shiftKey ? "secondSlice" : "none"
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1436
1545
|
async scene() {
|
|
1437
1546
|
return __privateGet(this, _cachedScene2) ?? __privateSet(this, _cachedScene2, (async () => new (await THREEJS).Scene())());
|
|
1438
1547
|
}
|
|
1439
1548
|
addVantage(vantage) {
|
|
1549
|
+
vantage.addEventListener("press", this.onPress.bind(this));
|
|
1440
1550
|
__privateGet(this, _vantages).add(vantage);
|
|
1441
1551
|
this.contentWrapper.appendChild(vantage);
|
|
1442
1552
|
}
|
|
@@ -1481,7 +1591,7 @@ _currentTwisty3DPuzzleWrapper = new WeakMap();
|
|
|
1481
1591
|
_twisty3DStaleDropper = new WeakMap();
|
|
1482
1592
|
customElementsShim.define("twisty-3d-scene-wrapper", Twisty3DSceneWrapper);
|
|
1483
1593
|
|
|
1484
|
-
// src/cubing/twisty/
|
|
1594
|
+
// src/cubing/twisty/views/control-panel/TwistyButtonsV2.css.ts
|
|
1485
1595
|
var buttonGridCSS = new CSSSource(`
|
|
1486
1596
|
:host {
|
|
1487
1597
|
width: 384px;
|
|
@@ -1799,7 +1909,7 @@ var TwistyButtonV2 = class extends ManagedCustomElement {
|
|
|
1799
1909
|
_iconManager = new WeakMap();
|
|
1800
1910
|
customElementsShim.define("twisty-button-v2", TwistyButtonV2);
|
|
1801
1911
|
|
|
1802
|
-
// src/cubing/twisty/
|
|
1912
|
+
// src/cubing/twisty/views/control-panel/TwistyScrubber.css.ts
|
|
1803
1913
|
var twistyScrubberCSS = new CSSSource(`
|
|
1804
1914
|
:host {
|
|
1805
1915
|
width: 384px;
|
|
@@ -2064,21 +2174,12 @@ var BackgroundProp = class extends SimpleTwistyPropSource {
|
|
|
2064
2174
|
};
|
|
2065
2175
|
|
|
2066
2176
|
// src/cubing/twisty/model/props/viewer/BackViewProp.ts
|
|
2067
|
-
var
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
};
|
|
2072
|
-
|
|
2073
|
-
// src/cubing/twisty/model/props/viewer/ControlPanelProp.ts
|
|
2074
|
-
var ControlPanelProp = class extends SimpleTwistyPropSource {
|
|
2075
|
-
getDefaultValue() {
|
|
2076
|
-
return "auto";
|
|
2077
|
-
}
|
|
2177
|
+
var backViewLayouts = {
|
|
2178
|
+
"none": true,
|
|
2179
|
+
"side-by-side": true,
|
|
2180
|
+
"top-right": true
|
|
2078
2181
|
};
|
|
2079
|
-
|
|
2080
|
-
// src/cubing/twisty/model/props/puzzle/display/HintFaceletProp.ts
|
|
2081
|
-
var HintFaceletProp = class extends SimpleTwistyPropSource {
|
|
2182
|
+
var BackViewProp = class extends SimpleTwistyPropSource {
|
|
2082
2183
|
getDefaultValue() {
|
|
2083
2184
|
return "auto";
|
|
2084
2185
|
}
|
|
@@ -2191,13 +2292,6 @@ var SetupAnchorProp = class extends SimpleTwistyPropSource {
|
|
|
2191
2292
|
}
|
|
2192
2293
|
};
|
|
2193
2294
|
|
|
2194
|
-
// src/cubing/twisty/model/props/puzzle/display/StickeringProp.ts
|
|
2195
|
-
var StickeringProp = class extends SimpleTwistyPropSource {
|
|
2196
|
-
getDefaultValue() {
|
|
2197
|
-
return "full";
|
|
2198
|
-
}
|
|
2199
|
-
};
|
|
2200
|
-
|
|
2201
2295
|
// src/cubing/twisty/model/props/timeline/TempoScaleProp.ts
|
|
2202
2296
|
var TempoScaleProp = class extends TwistyPropSource {
|
|
2203
2297
|
getDefaultValue() {
|
|
@@ -2285,6 +2379,53 @@ var OrbitCoordinatesProp = class extends TwistyPropDerived {
|
|
|
2285
2379
|
}
|
|
2286
2380
|
}
|
|
2287
2381
|
};
|
|
2382
|
+
var centeredCameraOrbitCoordinates = {
|
|
2383
|
+
latitude: 31.717474411461005,
|
|
2384
|
+
longitude: 0,
|
|
2385
|
+
distance: 5.877852522924731
|
|
2386
|
+
};
|
|
2387
|
+
var cubeCube3DCameraOrbitCoordinates = {
|
|
2388
|
+
latitude: 35,
|
|
2389
|
+
longitude: 30,
|
|
2390
|
+
distance: 6
|
|
2391
|
+
};
|
|
2392
|
+
var cubePG3DCameraOrbitCoordinates = {
|
|
2393
|
+
latitude: 35,
|
|
2394
|
+
longitude: 30,
|
|
2395
|
+
distance: 6.25
|
|
2396
|
+
};
|
|
2397
|
+
var megaminxCameraOrbitCoordinates = {
|
|
2398
|
+
latitude: Math.atan(1 / 2) * DEGREES_PER_RADIAN,
|
|
2399
|
+
longitude: 0,
|
|
2400
|
+
distance: 6.7
|
|
2401
|
+
};
|
|
2402
|
+
var pyraminxCameraOrbitCoordinates = {
|
|
2403
|
+
latitude: 26.56505117707799,
|
|
2404
|
+
longitude: 0,
|
|
2405
|
+
distance: 6
|
|
2406
|
+
};
|
|
2407
|
+
function defaultCameraOrbitCoordinates(puzzleID, strategy) {
|
|
2408
|
+
if (puzzleID[1] === "x") {
|
|
2409
|
+
if (strategy === "Cube3D") {
|
|
2410
|
+
return cubeCube3DCameraOrbitCoordinates;
|
|
2411
|
+
} else {
|
|
2412
|
+
return cubePG3DCameraOrbitCoordinates;
|
|
2413
|
+
}
|
|
2414
|
+
} else {
|
|
2415
|
+
switch (puzzleID) {
|
|
2416
|
+
case "megaminx":
|
|
2417
|
+
case "gigaminx":
|
|
2418
|
+
return megaminxCameraOrbitCoordinates;
|
|
2419
|
+
case "pyraminx":
|
|
2420
|
+
case "master_tetraminx":
|
|
2421
|
+
return pyraminxCameraOrbitCoordinates;
|
|
2422
|
+
case "skewb":
|
|
2423
|
+
return cubePG3DCameraOrbitCoordinates;
|
|
2424
|
+
default:
|
|
2425
|
+
return centeredCameraOrbitCoordinates;
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2288
2429
|
|
|
2289
2430
|
// src/cubing/twisty/model/props/puzzle/structure/PuzzleIDProp.ts
|
|
2290
2431
|
var PuzzleIDProp = class extends TwistyPropDerived {
|
|
@@ -2347,7 +2488,7 @@ var VisualizationStrategyProp = class extends TwistyPropDerived {
|
|
|
2347
2488
|
}
|
|
2348
2489
|
};
|
|
2349
2490
|
|
|
2350
|
-
// src/cubing/twisty/
|
|
2491
|
+
// src/cubing/twisty/controllers/indexer/AlgDuration.ts
|
|
2351
2492
|
function defaultDurationForAmount(amount) {
|
|
2352
2493
|
switch (Math.abs(amount)) {
|
|
2353
2494
|
case 0:
|
|
@@ -2395,7 +2536,7 @@ var AlgDuration = class extends TraversalUp {
|
|
|
2395
2536
|
}
|
|
2396
2537
|
};
|
|
2397
2538
|
|
|
2398
|
-
// src/cubing/twisty/
|
|
2539
|
+
// src/cubing/twisty/controllers/indexer/SimpleAlgIndexer.ts
|
|
2399
2540
|
var SimpleAlgIndexer = class {
|
|
2400
2541
|
constructor(puzzle, alg) {
|
|
2401
2542
|
this.puzzle = puzzle;
|
|
@@ -2441,7 +2582,7 @@ var SimpleAlgIndexer = class {
|
|
|
2441
2582
|
}
|
|
2442
2583
|
};
|
|
2443
2584
|
|
|
2444
|
-
// src/cubing/twisty/
|
|
2585
|
+
// src/cubing/twisty/controllers/indexer/simultaneous-moves/simul-moves.ts
|
|
2445
2586
|
var axisLookup = {
|
|
2446
2587
|
u: "y",
|
|
2447
2588
|
l: "x",
|
|
@@ -2571,7 +2712,7 @@ function simulMoves(a) {
|
|
|
2571
2712
|
return l;
|
|
2572
2713
|
}
|
|
2573
2714
|
|
|
2574
|
-
// src/cubing/twisty/
|
|
2715
|
+
// src/cubing/twisty/controllers/indexer/simultaneous-moves/SimultaneousMoveIndexerV2.ts
|
|
2575
2716
|
var demos = {
|
|
2576
2717
|
"y' y' U' E D R2 r2 F2 B2 U E D' R2 L2' z2 S2 U U D D S2 F2' B2": [
|
|
2577
2718
|
{ animLeaf: new Move("y", -1), start: 0, end: 1e3 },
|
|
@@ -2762,7 +2903,7 @@ var SimultaneousMoveIndexerV2 = class {
|
|
|
2762
2903
|
}
|
|
2763
2904
|
};
|
|
2764
2905
|
|
|
2765
|
-
// src/cubing/twisty/
|
|
2906
|
+
// src/cubing/twisty/controllers/indexer/tree/chunkAlgs.ts
|
|
2766
2907
|
var MIN_CHUNKING_THRESHOLD = 16;
|
|
2767
2908
|
function chunkifyAlg(alg, chunkMaxLength) {
|
|
2768
2909
|
const mainAlgBuilder = new AlgBuilder();
|
|
@@ -2810,7 +2951,7 @@ var ChunkAlgs = class extends TraversalUp {
|
|
|
2810
2951
|
var chunkAlgsInstance = new ChunkAlgs();
|
|
2811
2952
|
var chunkAlgs = chunkAlgsInstance.traverseAlg.bind(chunkAlgsInstance);
|
|
2812
2953
|
|
|
2813
|
-
// src/cubing/twisty/
|
|
2954
|
+
// src/cubing/twisty/controllers/indexer/tree/AlgWalker.ts
|
|
2814
2955
|
var AlgPartDecoration = class {
|
|
2815
2956
|
constructor(_puz, moveCount, duration, forward, backward, children = []) {
|
|
2816
2957
|
this.moveCount = moveCount;
|
|
@@ -3047,7 +3188,7 @@ var AlgWalker = class extends TraversalDownUp {
|
|
|
3047
3188
|
}
|
|
3048
3189
|
};
|
|
3049
3190
|
|
|
3050
|
-
// src/cubing/twisty/
|
|
3191
|
+
// src/cubing/twisty/controllers/indexer/tree/TreeAlgIndexer.ts
|
|
3051
3192
|
var TreeAlgIndexer = class {
|
|
3052
3193
|
constructor(puzzle, alg) {
|
|
3053
3194
|
this.puzzle = puzzle;
|
|
@@ -3442,6 +3583,30 @@ var CatchUpMoveProp = class extends SimpleTwistyPropSource {
|
|
|
3442
3583
|
}
|
|
3443
3584
|
};
|
|
3444
3585
|
|
|
3586
|
+
// src/cubing/twisty/model/props/puzzle/state/NaiveMoveCountProp.ts
|
|
3587
|
+
var NaiveMoveCountProp = class extends TwistyPropDerived {
|
|
3588
|
+
derive(inputs) {
|
|
3589
|
+
if (inputs.alg.issues.errors.length > 0) {
|
|
3590
|
+
return null;
|
|
3591
|
+
}
|
|
3592
|
+
return countMoves(inputs.alg.alg);
|
|
3593
|
+
}
|
|
3594
|
+
};
|
|
3595
|
+
|
|
3596
|
+
// src/cubing/twisty/model/props/puzzle/state/MovePressInputProp.ts
|
|
3597
|
+
var MovePressInputProp = class extends SimpleTwistyPropSource {
|
|
3598
|
+
getDefaultValue() {
|
|
3599
|
+
return "auto";
|
|
3600
|
+
}
|
|
3601
|
+
};
|
|
3602
|
+
|
|
3603
|
+
// src/cubing/twisty/model/props/puzzle/display/FoundationDisplayProp.ts
|
|
3604
|
+
var FoundationDisplayProp = class extends SimpleTwistyPropSource {
|
|
3605
|
+
getDefaultValue() {
|
|
3606
|
+
return "auto";
|
|
3607
|
+
}
|
|
3608
|
+
};
|
|
3609
|
+
|
|
3445
3610
|
// src/cubing/twisty/model/TwistyPlayerModel.ts
|
|
3446
3611
|
var TwistyPlayerModel = class {
|
|
3447
3612
|
constructor() {
|
|
@@ -3451,11 +3616,13 @@ var TwistyPlayerModel = class {
|
|
|
3451
3616
|
this.backViewProp = new BackViewProp();
|
|
3452
3617
|
this.controlPanelProp = new ControlPanelProp();
|
|
3453
3618
|
this.catchUpMoveProp = new CatchUpMoveProp();
|
|
3619
|
+
this.foundationDisplayProp = new FoundationDisplayProp();
|
|
3454
3620
|
this.foundationStickerSpriteURL = new URLProp();
|
|
3455
3621
|
this.hintFaceletProp = new HintFaceletProp();
|
|
3456
3622
|
this.hintStickerSpriteURL = new URLProp();
|
|
3457
3623
|
this.indexerConstructorRequestProp = new IndexerConstructorRequestProp();
|
|
3458
3624
|
this.latitudeLimitProp = new LatitudeLimitProp();
|
|
3625
|
+
this.movePressInputProp = new MovePressInputProp();
|
|
3459
3626
|
this.orbitCoordinatesRequestProp = new OrbitCoordinatesRequestProp();
|
|
3460
3627
|
this.playingInfoProp = new PlayingInfoProp();
|
|
3461
3628
|
this.puzzleDescriptionRequestProp = new PGPuzzleDescriptionStringProp();
|
|
@@ -3497,6 +3664,7 @@ var TwistyPlayerModel = class {
|
|
|
3497
3664
|
visualizationStrategy: this.visualizationStrategyProp,
|
|
3498
3665
|
indexerConstructorRequest: this.indexerConstructorRequestProp
|
|
3499
3666
|
});
|
|
3667
|
+
this.moveCountProp = new NaiveMoveCountProp({ alg: this.puzzleAlgProp });
|
|
3500
3668
|
this.orbitCoordinatesProp = new OrbitCoordinatesProp({
|
|
3501
3669
|
orbitCoordinatesRequest: this.orbitCoordinatesRequestProp,
|
|
3502
3670
|
latitudeLimit: this.latitudeLimitProp,
|
|
@@ -3575,6 +3743,22 @@ var TwistyPlayerModel = class {
|
|
|
3575
3743
|
}
|
|
3576
3744
|
return url.toString();
|
|
3577
3745
|
}
|
|
3746
|
+
experimentalAddMove(flexibleMove, options = {}) {
|
|
3747
|
+
const move = typeof flexibleMove === "string" ? new Move(flexibleMove) : flexibleMove;
|
|
3748
|
+
(async () => {
|
|
3749
|
+
const alg = (await this.algProp.get()).alg;
|
|
3750
|
+
const newAlg = experimentalAppendMove(alg, move, {
|
|
3751
|
+
coalesce: options?.coalesce,
|
|
3752
|
+
mod: options?.mod
|
|
3753
|
+
});
|
|
3754
|
+
this.algProp.set(newAlg);
|
|
3755
|
+
this.timestampRequestProp.set("end");
|
|
3756
|
+
this.catchUpMoveProp.set({
|
|
3757
|
+
move,
|
|
3758
|
+
amount: 0
|
|
3759
|
+
});
|
|
3760
|
+
})();
|
|
3761
|
+
}
|
|
3578
3762
|
};
|
|
3579
3763
|
|
|
3580
3764
|
// src/cubing/twisty/views/TwistyPlayerSettable.ts
|
|
@@ -3651,13 +3835,13 @@ var TwistyPlayerSettable = class extends ManagedCustomElement {
|
|
|
3651
3835
|
this.experimentalModel.controlPanelProp.set(newControlPanel);
|
|
3652
3836
|
}
|
|
3653
3837
|
get controlPanel() {
|
|
3654
|
-
throw
|
|
3838
|
+
throw err("controlPanel");
|
|
3655
3839
|
}
|
|
3656
3840
|
set visualization(visualizationFormat) {
|
|
3657
3841
|
this.experimentalModel.visualizationFormatProp.set(visualizationFormat);
|
|
3658
3842
|
}
|
|
3659
3843
|
get visualization() {
|
|
3660
|
-
throw
|
|
3844
|
+
throw err("visualization");
|
|
3661
3845
|
}
|
|
3662
3846
|
set viewerLink(viewerLinkPage) {
|
|
3663
3847
|
this.experimentalModel.viewerLinkProp.set(viewerLinkPage);
|
|
@@ -3665,29 +3849,35 @@ var TwistyPlayerSettable = class extends ManagedCustomElement {
|
|
|
3665
3849
|
get viewerLink() {
|
|
3666
3850
|
throw err("viewerLink");
|
|
3667
3851
|
}
|
|
3852
|
+
set experimentalMovePressInput(movePressInput) {
|
|
3853
|
+
this.experimentalModel.movePressInputProp.set(movePressInput);
|
|
3854
|
+
}
|
|
3855
|
+
get experimentalMovePressInput() {
|
|
3856
|
+
throw err("experimentalMovePressInput");
|
|
3857
|
+
}
|
|
3668
3858
|
set cameraLatitude(latitude) {
|
|
3669
3859
|
this.experimentalModel.orbitCoordinatesRequestProp.set({ latitude });
|
|
3670
3860
|
}
|
|
3671
3861
|
get cameraLatitude() {
|
|
3672
|
-
throw
|
|
3862
|
+
throw err("cameraLatitude");
|
|
3673
3863
|
}
|
|
3674
3864
|
set cameraLongitude(longitude) {
|
|
3675
3865
|
this.experimentalModel.orbitCoordinatesRequestProp.set({ longitude });
|
|
3676
3866
|
}
|
|
3677
3867
|
get cameraLongitude() {
|
|
3678
|
-
throw
|
|
3868
|
+
throw err("cameraLongitude");
|
|
3679
3869
|
}
|
|
3680
3870
|
set cameraDistance(distance) {
|
|
3681
3871
|
this.experimentalModel.orbitCoordinatesRequestProp.set({ distance });
|
|
3682
3872
|
}
|
|
3683
3873
|
get cameraDistance() {
|
|
3684
|
-
throw
|
|
3874
|
+
throw err("cameraDistance");
|
|
3685
3875
|
}
|
|
3686
3876
|
set cameraLatitudeLimit(latitudeLimit) {
|
|
3687
3877
|
this.experimentalModel.latitudeLimitProp.set(latitudeLimit);
|
|
3688
3878
|
}
|
|
3689
3879
|
get cameraLatitudeLimit() {
|
|
3690
|
-
throw
|
|
3880
|
+
throw err("cameraLatitudeLimit");
|
|
3691
3881
|
}
|
|
3692
3882
|
set indexer(indexer) {
|
|
3693
3883
|
this.experimentalModel.indexerConstructorRequestProp.set(indexer);
|
|
@@ -3746,6 +3936,7 @@ var twistyPlayerAttributeMap = {
|
|
|
3746
3936
|
"control-panel": "controlPanel",
|
|
3747
3937
|
"back-view": "backView",
|
|
3748
3938
|
"viewer-link": "viewerLink",
|
|
3939
|
+
"experimental-move-press-input": "experimentalMovePressInput",
|
|
3749
3940
|
"camera-latitude": "cameraLatitude",
|
|
3750
3941
|
"camera-longitude": "cameraLongitude",
|
|
3751
3942
|
"camera-distance": "cameraDistance",
|
|
@@ -3818,7 +4009,7 @@ var TwistyPlayer = class extends TwistyPlayerSettable {
|
|
|
3818
4009
|
if (wrapper instanceof Twisty3DSceneWrapper) {
|
|
3819
4010
|
const vantages = wrapper.experimentalVantages();
|
|
3820
4011
|
for (const vantage of vantages) {
|
|
3821
|
-
canvases.push(await vantage.
|
|
4012
|
+
canvases.push((await vantage.canvasInfo()).canvas);
|
|
3822
4013
|
}
|
|
3823
4014
|
}
|
|
3824
4015
|
return canvases;
|
|
@@ -3847,19 +4038,7 @@ var TwistyPlayer = class extends TwistyPlayerSettable {
|
|
|
3847
4038
|
this.controller.togglePlay(play);
|
|
3848
4039
|
}
|
|
3849
4040
|
experimentalAddMove(flexibleMove, options = {}) {
|
|
3850
|
-
|
|
3851
|
-
(async () => {
|
|
3852
|
-
const alg = (await this.experimentalModel.algProp.get()).alg;
|
|
3853
|
-
const newAlg = experimentalAppendMove(alg, move, {
|
|
3854
|
-
coalesce: options?.coalesce
|
|
3855
|
-
});
|
|
3856
|
-
this.experimentalModel.algProp.set(newAlg);
|
|
3857
|
-
this.experimentalModel.timestampRequestProp.set("end");
|
|
3858
|
-
this.experimentalModel.catchUpMoveProp.set({
|
|
3859
|
-
move,
|
|
3860
|
-
amount: 0
|
|
3861
|
-
});
|
|
3862
|
-
})();
|
|
4041
|
+
this.experimentalModel.experimentalAddMove(flexibleMove, options);
|
|
3863
4042
|
}
|
|
3864
4043
|
static get observedAttributes() {
|
|
3865
4044
|
return Object.keys(twistyPlayerAttributeMap);
|
|
@@ -4515,6 +4694,7 @@ var TwistyAlgEditor = class extends ManagedCustomElement {
|
|
|
4515
4694
|
]));
|
|
4516
4695
|
__privateAdd(this, _twistyPlayer, null);
|
|
4517
4696
|
__privateAdd(this, _twistyPlayerProp, void 0);
|
|
4697
|
+
this.debugNeverRequestTimestamp = false;
|
|
4518
4698
|
__privateAdd(this, _onInputHasFired, false);
|
|
4519
4699
|
__privateAdd(this, _highlightedLeaf, null);
|
|
4520
4700
|
__privateGet(this, _carbonCopy).classList.add("carbon-copy");
|
|
@@ -4662,7 +4842,9 @@ var TwistyAlgEditor = class extends ManagedCustomElement {
|
|
|
4662
4842
|
console.log("invalid where");
|
|
4663
4843
|
throw new Error("Invalid where!");
|
|
4664
4844
|
}
|
|
4665
|
-
|
|
4845
|
+
if (!this.debugNeverRequestTimestamp) {
|
|
4846
|
+
twistyPlayer.experimentalModel.timestampRequestProp.set(newTimestamp);
|
|
4847
|
+
}
|
|
4666
4848
|
});
|
|
4667
4849
|
twistyPlayer.experimentalModel.currentLeavesSimplifiedProp.addFreshListener(async (currentLeavesSimplified) => {
|
|
4668
4850
|
const indexer = await twistyPlayer.experimentalModel.indexerProp.get();
|
|
@@ -4729,1826 +4911,18 @@ padSuffix_fn = function(s) {
|
|
|
4729
4911
|
};
|
|
4730
4912
|
_highlightedLeaf = new WeakMap();
|
|
4731
4913
|
customElementsShim.define("twisty-alg-editor", TwistyAlgEditor);
|
|
4732
|
-
|
|
4733
|
-
// src/cubing/twisty/old/dom/TwistyPlayer.ts
|
|
4734
|
-
import { Vector3 as Vector32 } from "three";
|
|
4735
|
-
|
|
4736
|
-
// src/cubing/twisty/old/animation/cursor/AlgCursor.ts
|
|
4737
|
-
var AlgCursor = class {
|
|
4738
|
-
constructor(timeline, def, alg, startStateAlg, indexerConstructor) {
|
|
4739
|
-
this.timeline = timeline;
|
|
4740
|
-
this.def = def;
|
|
4741
|
-
this.alg = alg;
|
|
4742
|
-
this.positionListeners = new Set();
|
|
4743
|
-
this.indexerConstructor = TreeAlgIndexer;
|
|
4744
|
-
this.ksolvePuzzle = new KPuzzleWrapper(def);
|
|
4745
|
-
if (indexerConstructor) {
|
|
4746
|
-
this.indexerConstructor = indexerConstructor;
|
|
4747
|
-
}
|
|
4748
|
-
this.instantiateIndexer(alg);
|
|
4749
|
-
this.startState = startStateAlg ? this.algToState(startStateAlg) : this.ksolvePuzzle.startState();
|
|
4750
|
-
timeline.addTimestampListener(this);
|
|
4751
|
-
}
|
|
4752
|
-
setStartState(startState) {
|
|
4753
|
-
this.startState = startState;
|
|
4754
|
-
this.dispatchPositionForTimestamp(this.timeline.timestamp);
|
|
4755
|
-
}
|
|
4756
|
-
experimentalSetIndexer(indexerConstructor) {
|
|
4757
|
-
this.indexerConstructor = indexerConstructor;
|
|
4758
|
-
this.instantiateIndexer(this.alg);
|
|
4759
|
-
this.timeline.onCursorChange(this);
|
|
4760
|
-
this.dispatchPositionForTimestamp(this.timeline.timestamp);
|
|
4761
|
-
}
|
|
4762
|
-
instantiateIndexer(alg) {
|
|
4763
|
-
this.indexer = new this.indexerConstructor(this.ksolvePuzzle, alg);
|
|
4764
|
-
}
|
|
4765
|
-
algToState(s) {
|
|
4766
|
-
const kpuzzle = new KPuzzle(this.def);
|
|
4767
|
-
kpuzzle.applyAlg(s);
|
|
4768
|
-
return this.ksolvePuzzle.combine(this.def.startPieces, kpuzzle.state);
|
|
4769
|
-
}
|
|
4770
|
-
timeRange() {
|
|
4771
|
-
return {
|
|
4772
|
-
start: 0,
|
|
4773
|
-
end: this.indexer.algDuration()
|
|
4774
|
-
};
|
|
4775
|
-
}
|
|
4776
|
-
experimentalTimestampForStartOfLastMove() {
|
|
4777
|
-
const numMoves = this.indexer.numAnimatedLeaves();
|
|
4778
|
-
if (numMoves > 0) {
|
|
4779
|
-
return this.indexer.indexToMoveStartTimestamp(numMoves - 1);
|
|
4780
|
-
}
|
|
4781
|
-
return 0;
|
|
4782
|
-
}
|
|
4783
|
-
addPositionListener(positionListener) {
|
|
4784
|
-
this.positionListeners.add(positionListener);
|
|
4785
|
-
this.dispatchPositionForTimestamp(this.timeline.timestamp, [
|
|
4786
|
-
positionListener
|
|
4787
|
-
]);
|
|
4788
|
-
}
|
|
4789
|
-
removePositionListener(positionListener) {
|
|
4790
|
-
this.positionListeners.delete(positionListener);
|
|
4791
|
-
}
|
|
4792
|
-
onTimelineTimestampChange(timestamp) {
|
|
4793
|
-
this.dispatchPositionForTimestamp(timestamp);
|
|
4794
|
-
}
|
|
4795
|
-
dispatchPositionForTimestamp(timestamp, listeners = this.positionListeners) {
|
|
4796
|
-
let position;
|
|
4797
|
-
if (this.indexer.timestampToPosition) {
|
|
4798
|
-
position = this.indexer.timestampToPosition(timestamp, this.startState);
|
|
4799
|
-
} else {
|
|
4800
|
-
const idx = this.indexer.timestampToIndex(timestamp);
|
|
4801
|
-
const state = this.indexer.stateAtIndex(idx, this.startState);
|
|
4802
|
-
position = {
|
|
4803
|
-
state,
|
|
4804
|
-
movesInProgress: []
|
|
4805
|
-
};
|
|
4806
|
-
if (this.indexer.numAnimatedLeaves() > 0) {
|
|
4807
|
-
const move = this.indexer.getAnimLeaf(idx)?.as(Move);
|
|
4808
|
-
if (!move) {
|
|
4809
|
-
return;
|
|
4810
|
-
}
|
|
4811
|
-
const fraction = (timestamp - this.indexer.indexToMoveStartTimestamp(idx)) / this.indexer.moveDuration(idx);
|
|
4812
|
-
if (fraction === 1) {
|
|
4813
|
-
position.state = this.ksolvePuzzle.combine(state, this.ksolvePuzzle.stateFromMove(move));
|
|
4814
|
-
} else if (fraction > 0) {
|
|
4815
|
-
if (move) {
|
|
4816
|
-
position.movesInProgress.push({
|
|
4817
|
-
move,
|
|
4818
|
-
direction: Direction.Forwards,
|
|
4819
|
-
fraction
|
|
4820
|
-
});
|
|
4821
|
-
}
|
|
4822
|
-
}
|
|
4823
|
-
}
|
|
4824
|
-
}
|
|
4825
|
-
for (const listener of listeners) {
|
|
4826
|
-
listener.onPositionChange(position);
|
|
4827
|
-
}
|
|
4828
|
-
}
|
|
4829
|
-
onTimeRangeChange(_timeRange) {
|
|
4830
|
-
}
|
|
4831
|
-
setAlg(alg, indexerConstructor) {
|
|
4832
|
-
indexerConstructor ?? (indexerConstructor = this.indexerConstructor);
|
|
4833
|
-
if (alg.isIdentical(this.alg) && this.indexerConstructor === indexerConstructor) {
|
|
4834
|
-
return;
|
|
4835
|
-
}
|
|
4836
|
-
this.indexerConstructor = indexerConstructor;
|
|
4837
|
-
this.alg = alg;
|
|
4838
|
-
this.instantiateIndexer(alg);
|
|
4839
|
-
this.timeline.onCursorChange(this);
|
|
4840
|
-
this.dispatchPositionForTimestamp(this.timeline.timestamp);
|
|
4841
|
-
}
|
|
4842
|
-
moveBoundary(timestamp, direction) {
|
|
4843
|
-
if (this.indexer.numAnimatedLeaves() === 0) {
|
|
4844
|
-
return null;
|
|
4845
|
-
}
|
|
4846
|
-
const offsetHack = directionScalar(direction) * 1e-3;
|
|
4847
|
-
const idx = this.indexer.timestampToIndex(timestamp + offsetHack);
|
|
4848
|
-
const moveStart = this.indexer.indexToMoveStartTimestamp(idx);
|
|
4849
|
-
if (direction === Direction.Backwards) {
|
|
4850
|
-
return timestamp >= moveStart ? moveStart : null;
|
|
4851
|
-
} else {
|
|
4852
|
-
const moveEnd = moveStart + this.indexer.moveDuration(idx);
|
|
4853
|
-
return timestamp <= moveEnd ? moveEnd : null;
|
|
4854
|
-
}
|
|
4855
|
-
}
|
|
4856
|
-
setPuzzle(def, alg = this.alg, startStateAlg) {
|
|
4857
|
-
this.ksolvePuzzle = new KPuzzleWrapper(def);
|
|
4858
|
-
this.def = def;
|
|
4859
|
-
this.indexer = new this.indexerConstructor(this.ksolvePuzzle, alg);
|
|
4860
|
-
if (alg !== this.alg) {
|
|
4861
|
-
this.timeline.onCursorChange(this);
|
|
4862
|
-
}
|
|
4863
|
-
this.setStartState(startStateAlg ? this.algToState(startStateAlg) : this.ksolvePuzzle.startState());
|
|
4864
|
-
this.alg = alg;
|
|
4865
|
-
}
|
|
4866
|
-
experimentalTimestampFromIndex(index) {
|
|
4867
|
-
return this.indexer.indexToMoveStartTimestamp(index);
|
|
4868
|
-
}
|
|
4869
|
-
experimentalIndexFromTimestamp(timestamp) {
|
|
4870
|
-
return this.indexer.timestampToIndex(timestamp);
|
|
4871
|
-
}
|
|
4872
|
-
experimentalLeafAtIndex(index) {
|
|
4873
|
-
return this.indexer.getAnimLeaf(index);
|
|
4874
|
-
}
|
|
4875
|
-
};
|
|
4876
|
-
|
|
4877
|
-
// src/cubing/twisty/old/animation/indexer/simultaneous-moves/SimultaneousMoveIndexer.ts
|
|
4878
|
-
var demos2 = {
|
|
4879
|
-
"y' y' U' E D R2 r2 F2 B2 U E D' R2 L2' z2 S2 U U D D S2 F2' B2": [
|
|
4880
|
-
{ animLeaf: new Move("y", -1), start: 0, end: 1e3 },
|
|
4881
|
-
{ animLeaf: new Move("y", -1), start: 1e3, end: 2e3 },
|
|
4882
|
-
{ animLeaf: new Move("U", -1), start: 1e3, end: 1600 },
|
|
4883
|
-
{ animLeaf: new Move("E", 1), start: 1200, end: 1800 },
|
|
4884
|
-
{ animLeaf: new Move("D"), start: 1400, end: 2e3 },
|
|
4885
|
-
{ animLeaf: new Move("R", 2), start: 2e3, end: 3500 },
|
|
4886
|
-
{ animLeaf: new Move("r", 2), start: 2e3, end: 3500 },
|
|
4887
|
-
{ animLeaf: new Move("F", 2), start: 3500, end: 4200 },
|
|
4888
|
-
{ animLeaf: new Move("B", 2), start: 3800, end: 4500 },
|
|
4889
|
-
{ animLeaf: new Move("U", 1), start: 4500, end: 5500 },
|
|
4890
|
-
{ animLeaf: new Move("E", 1), start: 4500, end: 5500 },
|
|
4891
|
-
{ animLeaf: new Move("D", -1), start: 4500, end: 5500 },
|
|
4892
|
-
{ animLeaf: new Move("R", 2), start: 5500, end: 6500 },
|
|
4893
|
-
{ animLeaf: new Move("L", -2), start: 5500, end: 6500 },
|
|
4894
|
-
{ animLeaf: new Move("z", 2), start: 5500, end: 6500 },
|
|
4895
|
-
{ animLeaf: new Move("S", 2), start: 6500, end: 7500 },
|
|
4896
|
-
{ animLeaf: new Move("U"), start: 7500, end: 8e3 },
|
|
4897
|
-
{ animLeaf: new Move("U"), start: 8e3, end: 8500 },
|
|
4898
|
-
{ animLeaf: new Move("D"), start: 7750, end: 8250 },
|
|
4899
|
-
{ animLeaf: new Move("D"), start: 8250, end: 8750 },
|
|
4900
|
-
{ animLeaf: new Move("S", 2), start: 8750, end: 9250 },
|
|
4901
|
-
{ animLeaf: new Move("F", -2), start: 8750, end: 1e4 },
|
|
4902
|
-
{ animLeaf: new Move("B", 2), start: 8750, end: 1e4 }
|
|
4903
|
-
],
|
|
4904
|
-
"M' R' U' D' M R": [
|
|
4905
|
-
{ animLeaf: new Move("M", -1), start: 0, end: 1e3 },
|
|
4906
|
-
{ animLeaf: new Move("R", -1), start: 0, end: 1e3 },
|
|
4907
|
-
{ animLeaf: new Move("U", -1), start: 1e3, end: 2e3 },
|
|
4908
|
-
{ animLeaf: new Move("D", -1), start: 1e3, end: 2e3 },
|
|
4909
|
-
{ animLeaf: new Move("M"), start: 2e3, end: 3e3 },
|
|
4910
|
-
{ animLeaf: new Move("R"), start: 2e3, end: 3e3 }
|
|
4911
|
-
],
|
|
4912
|
-
"U' E' r E r2' E r U E": [
|
|
4913
|
-
{ animLeaf: new Move("U", -1), start: 0, end: 1e3 },
|
|
4914
|
-
{ animLeaf: new Move("E", -1), start: 0, end: 1e3 },
|
|
4915
|
-
{ animLeaf: new Move("r"), start: 1e3, end: 2500 },
|
|
4916
|
-
{ animLeaf: new Move("E"), start: 2500, end: 3500 },
|
|
4917
|
-
{ animLeaf: new Move("r", -2), start: 3500, end: 5e3 },
|
|
4918
|
-
{ animLeaf: new Move("E"), start: 5e3, end: 6e3 },
|
|
4919
|
-
{ animLeaf: new Move("r"), start: 6e3, end: 7e3 },
|
|
4920
|
-
{ animLeaf: new Move("U"), start: 7e3, end: 8e3 },
|
|
4921
|
-
{ animLeaf: new Move("E"), start: 7e3, end: 8e3 }
|
|
4922
|
-
]
|
|
4923
|
-
};
|
|
4924
|
-
var SimultaneousMoveIndexer = class {
|
|
4925
|
-
constructor(puzzle, alg) {
|
|
4926
|
-
this.puzzle = puzzle;
|
|
4927
|
-
this.animLeaves = demos2[alg.toString()] ?? simulMoves(alg);
|
|
4928
|
-
}
|
|
4929
|
-
getAnimLeaf(index) {
|
|
4930
|
-
return this.animLeaves[Math.min(index, this.animLeaves.length - 1)]?.animLeaf ?? null;
|
|
4931
|
-
}
|
|
4932
|
-
getAnimLeafWithRange(index) {
|
|
4933
|
-
return this.animLeaves[Math.min(index, this.animLeaves.length - 1)];
|
|
4934
|
-
}
|
|
4935
|
-
indexToMoveStartTimestamp(index) {
|
|
4936
|
-
let start = 0;
|
|
4937
|
-
if (this.animLeaves.length > 0) {
|
|
4938
|
-
start = this.animLeaves[Math.min(index, this.animLeaves.length - 1)].start;
|
|
4939
|
-
}
|
|
4940
|
-
return start;
|
|
4941
|
-
}
|
|
4942
|
-
timestampToIndex(timestamp) {
|
|
4943
|
-
let i = 0;
|
|
4944
|
-
for (i = 0; i < this.animLeaves.length; i++) {
|
|
4945
|
-
if (this.animLeaves[i].start >= timestamp) {
|
|
4946
|
-
return Math.max(0, i - 1);
|
|
4947
|
-
}
|
|
4948
|
-
}
|
|
4949
|
-
return Math.max(0, i - 1);
|
|
4950
|
-
}
|
|
4951
|
-
timestampToPosition(timestamp, startTransformation) {
|
|
4952
|
-
const position = {
|
|
4953
|
-
state: startTransformation ?? this.puzzle.identity(),
|
|
4954
|
-
movesInProgress: []
|
|
4955
|
-
};
|
|
4956
|
-
for (const leafWithRange of this.animLeaves) {
|
|
4957
|
-
if (leafWithRange.end <= timestamp) {
|
|
4958
|
-
const move = leafWithRange.animLeaf.as(Move);
|
|
4959
|
-
if (move !== null) {
|
|
4960
|
-
position.state = this.puzzle.combine(position.state, this.puzzle.stateFromMove(move));
|
|
4961
|
-
}
|
|
4962
|
-
} else if (leafWithRange.start < timestamp && timestamp < leafWithRange.end) {
|
|
4963
|
-
const move = leafWithRange.animLeaf.as(Move);
|
|
4964
|
-
if (move !== null) {
|
|
4965
|
-
position.movesInProgress.push({
|
|
4966
|
-
move,
|
|
4967
|
-
direction: Direction.Forwards,
|
|
4968
|
-
fraction: (timestamp - leafWithRange.start) / (leafWithRange.end - leafWithRange.start)
|
|
4969
|
-
});
|
|
4970
|
-
}
|
|
4971
|
-
} else if (timestamp < leafWithRange.start) {
|
|
4972
|
-
continue;
|
|
4973
|
-
}
|
|
4974
|
-
}
|
|
4975
|
-
return position;
|
|
4976
|
-
}
|
|
4977
|
-
stateAtIndex(index, startTransformation) {
|
|
4978
|
-
let state = startTransformation ?? this.puzzle.startState();
|
|
4979
|
-
for (let i = 0; i < this.animLeaves.length && i < index; i++) {
|
|
4980
|
-
const leafWithRange = this.animLeaves[i];
|
|
4981
|
-
const move = leafWithRange.animLeaf.as(Move);
|
|
4982
|
-
if (move !== null) {
|
|
4983
|
-
state = this.puzzle.combine(state, this.puzzle.stateFromMove(move));
|
|
4984
|
-
}
|
|
4985
|
-
}
|
|
4986
|
-
return state;
|
|
4987
|
-
}
|
|
4988
|
-
transformAtIndex(index) {
|
|
4989
|
-
let state = this.puzzle.identity();
|
|
4990
|
-
for (const leafWithRange of this.animLeaves.slice(0, index)) {
|
|
4991
|
-
const move = leafWithRange.animLeaf.as(Move);
|
|
4992
|
-
if (move !== null) {
|
|
4993
|
-
state = this.puzzle.combine(state, this.puzzle.stateFromMove(move));
|
|
4994
|
-
}
|
|
4995
|
-
}
|
|
4996
|
-
return state;
|
|
4997
|
-
}
|
|
4998
|
-
algDuration() {
|
|
4999
|
-
let max = 0;
|
|
5000
|
-
for (const leafWithRange of this.animLeaves) {
|
|
5001
|
-
max = Math.max(max, leafWithRange.end);
|
|
5002
|
-
}
|
|
5003
|
-
return max;
|
|
5004
|
-
}
|
|
5005
|
-
numAnimatedLeaves() {
|
|
5006
|
-
return this.animLeaves.length;
|
|
5007
|
-
}
|
|
5008
|
-
moveDuration(index) {
|
|
5009
|
-
const move = this.getAnimLeafWithRange(index);
|
|
5010
|
-
return move.end - move.start;
|
|
5011
|
-
}
|
|
5012
|
-
};
|
|
5013
|
-
|
|
5014
|
-
// src/cubing/twisty/old/animation/Timeline.ts
|
|
5015
|
-
var PAUSE_ON_JUMP = true;
|
|
5016
|
-
var TimelineAction;
|
|
5017
|
-
(function(TimelineAction2) {
|
|
5018
|
-
TimelineAction2["StartingToPlay"] = "StartingToPlay";
|
|
5019
|
-
TimelineAction2["Pausing"] = "Pausing";
|
|
5020
|
-
TimelineAction2["Jumping"] = "Jumping";
|
|
5021
|
-
})(TimelineAction || (TimelineAction = {}));
|
|
5022
|
-
var TimestampLocationType;
|
|
5023
|
-
(function(TimestampLocationType2) {
|
|
5024
|
-
TimestampLocationType2["StartOfTimeline"] = "Start";
|
|
5025
|
-
TimestampLocationType2["EndOfTimeline"] = "End";
|
|
5026
|
-
TimestampLocationType2["StartOfMove"] = "StartOfMove";
|
|
5027
|
-
TimestampLocationType2["EndOfMove"] = "EndOfMove";
|
|
5028
|
-
TimestampLocationType2["MiddleOfMove"] = "MiddleOfMove";
|
|
5029
|
-
TimestampLocationType2["BetweenMoves"] = "BetweenMoves";
|
|
5030
|
-
})(TimestampLocationType || (TimestampLocationType = {}));
|
|
5031
|
-
function getNow() {
|
|
5032
|
-
return Math.round(performance.now());
|
|
5033
|
-
}
|
|
5034
|
-
var Timeline = class {
|
|
5035
|
-
constructor() {
|
|
5036
|
-
this.animating = false;
|
|
5037
|
-
this.tempoScale = 1;
|
|
5038
|
-
this.cursors = new Set();
|
|
5039
|
-
this.timestampListeners = new Set();
|
|
5040
|
-
this.actionListeners = new Set();
|
|
5041
|
-
this.timestamp = 0;
|
|
5042
|
-
this.lastAnimFrameNow = 0;
|
|
5043
|
-
this.direction = Direction.Forwards;
|
|
5044
|
-
this.boundaryType = BoundaryType.EntireTimeline;
|
|
5045
|
-
const animFrame = (_now) => {
|
|
5046
|
-
if (this.animating) {
|
|
5047
|
-
const now = getNow();
|
|
5048
|
-
this.timestamp = this.timestamp + this.tempoScale * directionScalar(this.direction) * (now - this.lastAnimFrameNow);
|
|
5049
|
-
this.lastAnimFrameNow = now;
|
|
5050
|
-
const atOrPastBoundary = this.direction === Direction.Backwards ? this.timestamp <= this.cachedNextBoundary : this.timestamp >= this.cachedNextBoundary;
|
|
5051
|
-
if (atOrPastBoundary) {
|
|
5052
|
-
this.timestamp = this.cachedNextBoundary;
|
|
5053
|
-
if (this.animating) {
|
|
5054
|
-
this.animating = false;
|
|
5055
|
-
this.dispatchAction(TimelineAction.Pausing);
|
|
5056
|
-
}
|
|
5057
|
-
}
|
|
5058
|
-
}
|
|
5059
|
-
if (this.timestamp !== this.lastAnimFrameTimestamp) {
|
|
5060
|
-
this.dispatchTimestamp();
|
|
5061
|
-
this.lastAnimFrameTimestamp = this.timestamp;
|
|
5062
|
-
}
|
|
5063
|
-
if (this.animating) {
|
|
5064
|
-
this.scheduler.requestAnimFrame();
|
|
5065
|
-
}
|
|
5066
|
-
};
|
|
5067
|
-
this.scheduler = new RenderScheduler(animFrame);
|
|
5068
|
-
}
|
|
5069
|
-
addCursor(cursor) {
|
|
5070
|
-
this.cursors.add(cursor);
|
|
5071
|
-
this.dispatchTimeRange();
|
|
5072
|
-
}
|
|
5073
|
-
removeCursor(cursor) {
|
|
5074
|
-
this.cursors.delete(cursor);
|
|
5075
|
-
this.clampTimestampToRange();
|
|
5076
|
-
this.dispatchTimeRange();
|
|
5077
|
-
}
|
|
5078
|
-
clampTimestampToRange() {
|
|
5079
|
-
const timeRange = this.timeRange();
|
|
5080
|
-
if (this.timestamp < timeRange.start) {
|
|
5081
|
-
this.setTimestamp(timeRange.start);
|
|
5082
|
-
}
|
|
5083
|
-
if (this.timestamp > timeRange.end) {
|
|
5084
|
-
this.setTimestamp(timeRange.end);
|
|
5085
|
-
}
|
|
5086
|
-
}
|
|
5087
|
-
onCursorChange(_cursor) {
|
|
5088
|
-
if (this.timestamp > this.maxTimestamp()) {
|
|
5089
|
-
this.timestamp = this.maxTimestamp();
|
|
5090
|
-
}
|
|
5091
|
-
this.dispatchTimeRange();
|
|
5092
|
-
}
|
|
5093
|
-
timeRange() {
|
|
5094
|
-
let start = 0;
|
|
5095
|
-
let end = 0;
|
|
5096
|
-
for (const cursor of this.cursors) {
|
|
5097
|
-
const cursorTimeRange = cursor.timeRange();
|
|
5098
|
-
start = Math.min(start, cursorTimeRange.start);
|
|
5099
|
-
end = Math.max(end, cursorTimeRange.end);
|
|
5100
|
-
}
|
|
5101
|
-
return { start, end };
|
|
5102
|
-
}
|
|
5103
|
-
minTimestamp() {
|
|
5104
|
-
return this.timeRange().start;
|
|
5105
|
-
}
|
|
5106
|
-
maxTimestamp() {
|
|
5107
|
-
return this.timeRange().end;
|
|
5108
|
-
}
|
|
5109
|
-
dispatchTimeRange() {
|
|
5110
|
-
const timeRange = this.timeRange();
|
|
5111
|
-
for (const listener of this.cursors) {
|
|
5112
|
-
listener.onTimeRangeChange(timeRange);
|
|
5113
|
-
}
|
|
5114
|
-
for (const listener of this.timestampListeners) {
|
|
5115
|
-
listener.onTimeRangeChange(timeRange);
|
|
5116
|
-
}
|
|
5117
|
-
}
|
|
5118
|
-
dispatchTimestamp() {
|
|
5119
|
-
for (const listener of this.cursors) {
|
|
5120
|
-
listener.onTimelineTimestampChange(this.timestamp);
|
|
5121
|
-
}
|
|
5122
|
-
for (const listener of this.timestampListeners) {
|
|
5123
|
-
listener.onTimelineTimestampChange(this.timestamp);
|
|
5124
|
-
}
|
|
5125
|
-
}
|
|
5126
|
-
addTimestampListener(timestampListener) {
|
|
5127
|
-
this.timestampListeners.add(timestampListener);
|
|
5128
|
-
}
|
|
5129
|
-
removeTimestampListener(timestampListener) {
|
|
5130
|
-
this.timestampListeners.delete(timestampListener);
|
|
5131
|
-
}
|
|
5132
|
-
addActionListener(actionListener) {
|
|
5133
|
-
this.actionListeners.add(actionListener);
|
|
5134
|
-
}
|
|
5135
|
-
removeActionListener(actionListener) {
|
|
5136
|
-
this.actionListeners.delete(actionListener);
|
|
5137
|
-
}
|
|
5138
|
-
play() {
|
|
5139
|
-
this.experimentalPlay(Direction.Forwards, BoundaryType.EntireTimeline);
|
|
5140
|
-
}
|
|
5141
|
-
experimentalPlay(direction, boundaryType = BoundaryType.EntireTimeline) {
|
|
5142
|
-
this.direction = direction;
|
|
5143
|
-
this.boundaryType = boundaryType;
|
|
5144
|
-
const nextBoundary = this.nextBoundary(this.timestamp, direction, this.boundaryType);
|
|
5145
|
-
if (nextBoundary === null) {
|
|
5146
|
-
return;
|
|
5147
|
-
}
|
|
5148
|
-
this.cachedNextBoundary = nextBoundary;
|
|
5149
|
-
if (!this.animating) {
|
|
5150
|
-
this.animating = true;
|
|
5151
|
-
this.lastAnimFrameNow = getNow();
|
|
5152
|
-
this.dispatchAction(TimelineAction.StartingToPlay);
|
|
5153
|
-
this.scheduler.requestAnimFrame();
|
|
5154
|
-
}
|
|
5155
|
-
}
|
|
5156
|
-
nextBoundary(timestamp, direction, boundaryType = BoundaryType.EntireTimeline) {
|
|
5157
|
-
switch (boundaryType) {
|
|
5158
|
-
case BoundaryType.EntireTimeline: {
|
|
5159
|
-
switch (direction) {
|
|
5160
|
-
case Direction.Backwards:
|
|
5161
|
-
return timestamp <= this.minTimestamp() ? null : this.minTimestamp();
|
|
5162
|
-
case Direction.Forwards:
|
|
5163
|
-
return timestamp >= this.maxTimestamp() ? null : this.maxTimestamp();
|
|
5164
|
-
default:
|
|
5165
|
-
throw new Error("invalid direction");
|
|
5166
|
-
}
|
|
5167
|
-
}
|
|
5168
|
-
case BoundaryType.Move: {
|
|
5169
|
-
let result = null;
|
|
5170
|
-
for (const cursor of this.cursors) {
|
|
5171
|
-
const boundaryTimestamp = cursor.moveBoundary(timestamp, direction);
|
|
5172
|
-
if (boundaryTimestamp !== null) {
|
|
5173
|
-
switch (direction) {
|
|
5174
|
-
case Direction.Backwards: {
|
|
5175
|
-
result = Math.min(result ?? boundaryTimestamp, boundaryTimestamp);
|
|
5176
|
-
break;
|
|
5177
|
-
}
|
|
5178
|
-
case Direction.Forwards: {
|
|
5179
|
-
result = Math.max(result ?? boundaryTimestamp, boundaryTimestamp);
|
|
5180
|
-
break;
|
|
5181
|
-
}
|
|
5182
|
-
default:
|
|
5183
|
-
throw new Error("invalid direction");
|
|
5184
|
-
}
|
|
5185
|
-
}
|
|
5186
|
-
}
|
|
5187
|
-
return result;
|
|
5188
|
-
}
|
|
5189
|
-
default:
|
|
5190
|
-
throw new Error("invalid boundary type");
|
|
5191
|
-
}
|
|
5192
|
-
}
|
|
5193
|
-
pause() {
|
|
5194
|
-
if (this.animating) {
|
|
5195
|
-
this.animating = false;
|
|
5196
|
-
this.dispatchAction(TimelineAction.Pausing);
|
|
5197
|
-
this.scheduler.requestAnimFrame();
|
|
5198
|
-
}
|
|
5199
|
-
}
|
|
5200
|
-
playPause() {
|
|
5201
|
-
if (this.animating) {
|
|
5202
|
-
this.pause();
|
|
5203
|
-
} else {
|
|
5204
|
-
if (this.timestamp >= this.maxTimestamp()) {
|
|
5205
|
-
this.timestamp = 0;
|
|
5206
|
-
}
|
|
5207
|
-
this.experimentalPlay(Direction.Forwards, BoundaryType.EntireTimeline);
|
|
5208
|
-
}
|
|
5209
|
-
}
|
|
5210
|
-
setTimestamp(timestamp) {
|
|
5211
|
-
const oldTimestamp = this.timestamp;
|
|
5212
|
-
this.timestamp = timestamp;
|
|
5213
|
-
this.lastAnimFrameNow = getNow();
|
|
5214
|
-
if (oldTimestamp !== timestamp) {
|
|
5215
|
-
this.dispatchAction(TimelineAction.Jumping);
|
|
5216
|
-
this.scheduler.requestAnimFrame();
|
|
5217
|
-
}
|
|
5218
|
-
if (PAUSE_ON_JUMP) {
|
|
5219
|
-
this.animating = false;
|
|
5220
|
-
this.dispatchAction(TimelineAction.Pausing);
|
|
5221
|
-
}
|
|
5222
|
-
}
|
|
5223
|
-
jumpToStart() {
|
|
5224
|
-
this.setTimestamp(this.minTimestamp());
|
|
5225
|
-
}
|
|
5226
|
-
jumpToEnd() {
|
|
5227
|
-
this.setTimestamp(this.maxTimestamp());
|
|
5228
|
-
}
|
|
5229
|
-
experimentalJumpToLastMove() {
|
|
5230
|
-
let max = 0;
|
|
5231
|
-
for (const cursor of this.cursors) {
|
|
5232
|
-
max = Math.max(max, cursor.experimentalTimestampForStartOfLastMove() ?? 0);
|
|
5233
|
-
}
|
|
5234
|
-
this.setTimestamp(max);
|
|
5235
|
-
}
|
|
5236
|
-
dispatchAction(event) {
|
|
5237
|
-
let locationType = TimestampLocationType.MiddleOfMove;
|
|
5238
|
-
switch (this.timestamp) {
|
|
5239
|
-
case this.minTimestamp():
|
|
5240
|
-
locationType = TimestampLocationType.StartOfTimeline;
|
|
5241
|
-
break;
|
|
5242
|
-
case this.maxTimestamp():
|
|
5243
|
-
locationType = TimestampLocationType.EndOfTimeline;
|
|
5244
|
-
break;
|
|
5245
|
-
}
|
|
5246
|
-
const actionEvent = {
|
|
5247
|
-
action: event,
|
|
5248
|
-
locationType
|
|
5249
|
-
};
|
|
5250
|
-
for (const listener of this.actionListeners) {
|
|
5251
|
-
listener.onTimelineAction(actionEvent);
|
|
5252
|
-
}
|
|
5253
|
-
}
|
|
5254
|
-
};
|
|
5255
|
-
|
|
5256
|
-
// src/cubing/twisty/old/dom/controls/buttons.ts
|
|
5257
|
-
var TwistyControlButton = class extends ManagedCustomElement {
|
|
5258
|
-
constructor(timeline, timelineCommand, options) {
|
|
5259
|
-
super();
|
|
5260
|
-
this.currentIconName = null;
|
|
5261
|
-
this.button = document.createElement("button");
|
|
5262
|
-
this.fullscreenElement = null;
|
|
5263
|
-
this.visitTwizzleLinkCallback = null;
|
|
5264
|
-
this.fullscreenElement = options?.fullscreenElement ?? null;
|
|
5265
|
-
this.visitTwizzleLinkCallback = options?.visitTwizzleLinkCallback ?? null;
|
|
5266
|
-
if (!timeline) {
|
|
5267
|
-
console.warn("Must have timeline!");
|
|
5268
|
-
}
|
|
5269
|
-
this.timeline = timeline;
|
|
5270
|
-
if (!timelineCommand) {
|
|
5271
|
-
console.warn("Must have timelineCommand!");
|
|
5272
|
-
}
|
|
5273
|
-
this.timelineCommand = timelineCommand;
|
|
5274
|
-
this.addCSS(buttonCSS);
|
|
5275
|
-
this.setIcon(this.initialIcon());
|
|
5276
|
-
this.setHoverTitle(this.initialHoverTitle());
|
|
5277
|
-
this.addElement(this.button);
|
|
5278
|
-
this.addEventListener("click", this.onPress.bind(this));
|
|
5279
|
-
switch (this.timelineCommand) {
|
|
5280
|
-
case "fullscreen":
|
|
5281
|
-
if (!document.fullscreenEnabled) {
|
|
5282
|
-
this.button.disabled = true;
|
|
5283
|
-
}
|
|
5284
|
-
break;
|
|
5285
|
-
case "jump-to-start":
|
|
5286
|
-
case "play-step-backwards":
|
|
5287
|
-
this.button.disabled = true;
|
|
5288
|
-
break;
|
|
5289
|
-
}
|
|
5290
|
-
if (this.timeline) {
|
|
5291
|
-
this.timeline.addActionListener(this);
|
|
5292
|
-
switch (this.timelineCommand) {
|
|
5293
|
-
case "play-pause":
|
|
5294
|
-
case "play-step-backwards":
|
|
5295
|
-
case "play-step":
|
|
5296
|
-
this.timeline.addTimestampListener(this);
|
|
5297
|
-
break;
|
|
5298
|
-
}
|
|
5299
|
-
this.autoSetTimelineBasedDisabled();
|
|
5300
|
-
}
|
|
5301
|
-
}
|
|
5302
|
-
autoSetTimelineBasedDisabled() {
|
|
5303
|
-
switch (this.timelineCommand) {
|
|
5304
|
-
case "jump-to-start":
|
|
5305
|
-
case "play-pause":
|
|
5306
|
-
case "play-step-backwards":
|
|
5307
|
-
case "play-step":
|
|
5308
|
-
case "jump-to-end": {
|
|
5309
|
-
const timeRange = this.timeline.timeRange();
|
|
5310
|
-
if (timeRange.start === timeRange.end) {
|
|
5311
|
-
this.button.disabled = true;
|
|
5312
|
-
return;
|
|
5313
|
-
}
|
|
5314
|
-
switch (this.timelineCommand) {
|
|
5315
|
-
case "jump-to-start":
|
|
5316
|
-
case "play-step-backwards":
|
|
5317
|
-
this.button.disabled = this.timeline.timestamp < this.timeline.maxTimestamp();
|
|
5318
|
-
break;
|
|
5319
|
-
case "jump-to-end":
|
|
5320
|
-
case "play-step":
|
|
5321
|
-
this.button.disabled = this.timeline.timestamp > this.timeline.minTimestamp();
|
|
5322
|
-
break;
|
|
5323
|
-
default:
|
|
5324
|
-
this.button.disabled = false;
|
|
5325
|
-
}
|
|
5326
|
-
break;
|
|
5327
|
-
}
|
|
5328
|
-
}
|
|
5329
|
-
}
|
|
5330
|
-
setIcon(buttonIconName) {
|
|
5331
|
-
if (this.currentIconName === buttonIconName) {
|
|
5332
|
-
return;
|
|
5333
|
-
}
|
|
5334
|
-
if (this.currentIconName) {
|
|
5335
|
-
this.button.classList.remove(`svg-${this.currentIconName}`);
|
|
5336
|
-
}
|
|
5337
|
-
this.button.classList.add(`svg-${buttonIconName}`);
|
|
5338
|
-
this.currentIconName = buttonIconName;
|
|
5339
|
-
}
|
|
5340
|
-
initialIcon() {
|
|
5341
|
-
const map = {
|
|
5342
|
-
"jump-to-start": "skip-to-start",
|
|
5343
|
-
"play-pause": "play",
|
|
5344
|
-
"play-step": "step-forward",
|
|
5345
|
-
"play-step-backwards": "step-backward",
|
|
5346
|
-
"jump-to-end": "skip-to-end",
|
|
5347
|
-
"fullscreen": "enter-fullscreen",
|
|
5348
|
-
"twizzle-link": "twizzle-tw"
|
|
5349
|
-
};
|
|
5350
|
-
return map[this.timelineCommand];
|
|
5351
|
-
}
|
|
5352
|
-
initialHoverTitle() {
|
|
5353
|
-
const map = {
|
|
5354
|
-
"jump-to-start": "Restart",
|
|
5355
|
-
"play-pause": "Play",
|
|
5356
|
-
"play-step": "Step forward",
|
|
5357
|
-
"play-step-backwards": "Step backward",
|
|
5358
|
-
"jump-to-end": "Skip to End",
|
|
5359
|
-
"fullscreen": "Enter fullscreen",
|
|
5360
|
-
"twizzle-link": "View at Twizzle"
|
|
5361
|
-
};
|
|
5362
|
-
return map[this.timelineCommand];
|
|
5363
|
-
}
|
|
5364
|
-
setHoverTitle(title) {
|
|
5365
|
-
this.button.title = title;
|
|
5366
|
-
}
|
|
5367
|
-
onPress() {
|
|
5368
|
-
switch (this.timelineCommand) {
|
|
5369
|
-
case "fullscreen":
|
|
5370
|
-
if (document.fullscreenElement === this.fullscreenElement) {
|
|
5371
|
-
document.exitFullscreen();
|
|
5372
|
-
} else {
|
|
5373
|
-
this.setIcon("exit-fullscreen");
|
|
5374
|
-
this.fullscreenElement.requestFullscreen().then(() => {
|
|
5375
|
-
const onFullscreen = () => {
|
|
5376
|
-
if (document.fullscreenElement !== this.fullscreenElement) {
|
|
5377
|
-
this.setIcon("enter-fullscreen");
|
|
5378
|
-
window.removeEventListener("fullscreenchange", onFullscreen);
|
|
5379
|
-
}
|
|
5380
|
-
};
|
|
5381
|
-
window.addEventListener("fullscreenchange", onFullscreen);
|
|
5382
|
-
});
|
|
5383
|
-
}
|
|
5384
|
-
break;
|
|
5385
|
-
case "jump-to-start":
|
|
5386
|
-
this.timeline.setTimestamp(0);
|
|
5387
|
-
break;
|
|
5388
|
-
case "jump-to-end":
|
|
5389
|
-
this.timeline.jumpToEnd();
|
|
5390
|
-
break;
|
|
5391
|
-
case "play-pause":
|
|
5392
|
-
this.timeline.playPause();
|
|
5393
|
-
break;
|
|
5394
|
-
case "play-step":
|
|
5395
|
-
this.timeline.experimentalPlay(Direction.Forwards, BoundaryType.Move);
|
|
5396
|
-
break;
|
|
5397
|
-
case "play-step-backwards":
|
|
5398
|
-
this.timeline.experimentalPlay(Direction.Backwards, BoundaryType.Move);
|
|
5399
|
-
break;
|
|
5400
|
-
case "twizzle-link":
|
|
5401
|
-
if (this.visitTwizzleLinkCallback) {
|
|
5402
|
-
this.visitTwizzleLinkCallback();
|
|
5403
|
-
}
|
|
5404
|
-
break;
|
|
5405
|
-
}
|
|
5406
|
-
}
|
|
5407
|
-
onTimelineAction(actionEvent) {
|
|
5408
|
-
switch (this.timelineCommand) {
|
|
5409
|
-
case "jump-to-start":
|
|
5410
|
-
this.button.disabled = actionEvent.locationType === TimestampLocationType.StartOfTimeline && actionEvent.action !== TimelineAction.StartingToPlay;
|
|
5411
|
-
break;
|
|
5412
|
-
case "jump-to-end":
|
|
5413
|
-
this.button.disabled = actionEvent.locationType === TimestampLocationType.EndOfTimeline && actionEvent.action !== TimelineAction.StartingToPlay;
|
|
5414
|
-
break;
|
|
5415
|
-
case "play-pause":
|
|
5416
|
-
switch (actionEvent.action) {
|
|
5417
|
-
case TimelineAction.Pausing:
|
|
5418
|
-
this.setIcon("play");
|
|
5419
|
-
this.setHoverTitle("Play");
|
|
5420
|
-
break;
|
|
5421
|
-
case TimelineAction.StartingToPlay:
|
|
5422
|
-
this.setIcon("pause");
|
|
5423
|
-
this.setHoverTitle("Pause");
|
|
5424
|
-
break;
|
|
5425
|
-
}
|
|
5426
|
-
break;
|
|
5427
|
-
case "play-step":
|
|
5428
|
-
this.button.disabled = actionEvent.locationType === TimestampLocationType.EndOfTimeline && actionEvent.action !== TimelineAction.StartingToPlay;
|
|
5429
|
-
break;
|
|
5430
|
-
case "play-step-backwards":
|
|
5431
|
-
this.button.disabled = actionEvent.locationType === TimestampLocationType.StartOfTimeline && actionEvent.action !== TimelineAction.StartingToPlay;
|
|
5432
|
-
break;
|
|
5433
|
-
}
|
|
5434
|
-
}
|
|
5435
|
-
onTimelineTimestampChange(_timestamp) {
|
|
5436
|
-
}
|
|
5437
|
-
onTimeRangeChange(_timeRange) {
|
|
5438
|
-
this.autoSetTimelineBasedDisabled();
|
|
5439
|
-
}
|
|
5440
|
-
};
|
|
5441
|
-
customElementsShim.define("twisty-control-button", TwistyControlButton);
|
|
5442
|
-
var _viewerLinkClassListManager;
|
|
5443
|
-
var TwistyControlButtonPanel = class extends ManagedCustomElement {
|
|
5444
|
-
constructor(timeline, options) {
|
|
5445
|
-
super();
|
|
5446
|
-
__privateAdd(this, _viewerLinkClassListManager, new ClassListManager(this, "viewer-link-", ["none", "twizzle"]));
|
|
5447
|
-
this.addCSS(buttonGridCSS);
|
|
5448
|
-
__privateGet(this, _viewerLinkClassListManager).setValue(options?.viewerLink ?? "none");
|
|
5449
|
-
this.addElement(new TwistyControlButton(timeline, "fullscreen", {
|
|
5450
|
-
fullscreenElement: options?.fullscreenElement
|
|
5451
|
-
}));
|
|
5452
|
-
this.addElement(new TwistyControlButton(timeline, "jump-to-start"));
|
|
5453
|
-
this.addElement(new TwistyControlButton(timeline, "play-step-backwards"));
|
|
5454
|
-
this.addElement(new TwistyControlButton(timeline, "play-pause"));
|
|
5455
|
-
this.addElement(new TwistyControlButton(timeline, "play-step"));
|
|
5456
|
-
this.addElement(new TwistyControlButton(timeline, "jump-to-end"));
|
|
5457
|
-
this.addElement(new TwistyControlButton(timeline, "twizzle-link", {
|
|
5458
|
-
visitTwizzleLinkCallback: options?.viewerLinkCallback
|
|
5459
|
-
})).classList.add("twizzle-link-button");
|
|
5460
|
-
}
|
|
5461
|
-
setViewerLink(viewerLink) {
|
|
5462
|
-
__privateGet(this, _viewerLinkClassListManager).setValue(viewerLink);
|
|
5463
|
-
}
|
|
5464
|
-
};
|
|
5465
|
-
_viewerLinkClassListManager = new WeakMap();
|
|
5466
|
-
customElementsShim.define("twisty-control-button-panel", TwistyControlButtonPanel);
|
|
5467
|
-
|
|
5468
|
-
// src/cubing/twisty/old/dom/controls/TwistyScrubber.ts
|
|
5469
|
-
var TwistyScrubber = class extends ManagedCustomElement {
|
|
5470
|
-
constructor(timeline) {
|
|
5471
|
-
super();
|
|
5472
|
-
this.range = document.createElement("input");
|
|
5473
|
-
this.timeline = timeline;
|
|
5474
|
-
this.addCSS(twistyScrubberCSS);
|
|
5475
|
-
this.timeline?.addTimestampListener(this);
|
|
5476
|
-
this.range.type = "range";
|
|
5477
|
-
this.range.step = 1 .toString();
|
|
5478
|
-
this.range.min = this.timeline?.minTimestamp().toString();
|
|
5479
|
-
this.range.max = this.timeline?.maxTimestamp().toString();
|
|
5480
|
-
this.range.value = this.timeline?.timestamp.toString();
|
|
5481
|
-
this.range.addEventListener("input", this.onInput.bind(this));
|
|
5482
|
-
this.addElement(this.range);
|
|
5483
|
-
}
|
|
5484
|
-
onTimelineTimestampChange(timestamp) {
|
|
5485
|
-
this.range.value = timestamp.toString();
|
|
5486
|
-
}
|
|
5487
|
-
onTimeRangeChange(timeRange) {
|
|
5488
|
-
this.range.min = timeRange.start.toString();
|
|
5489
|
-
this.range.max = timeRange.end.toString();
|
|
5490
|
-
}
|
|
5491
|
-
onInput() {
|
|
5492
|
-
this.timeline.setTimestamp(parseInt(this.range.value, 10));
|
|
5493
|
-
}
|
|
5494
|
-
};
|
|
5495
|
-
customElementsShim.define("twisty-scrubber", TwistyScrubber);
|
|
5496
|
-
|
|
5497
|
-
// src/cubing/twisty/old/dom/viewers/Twisty2DSVG.ts
|
|
5498
|
-
var _cachedPosition2;
|
|
5499
|
-
var Twisty2DSVG = class extends ManagedCustomElement {
|
|
5500
|
-
constructor(cursor, def, svgSource, options, puzzleLoader) {
|
|
5501
|
-
super();
|
|
5502
|
-
this.svgSource = svgSource;
|
|
5503
|
-
this.options = options;
|
|
5504
|
-
this.puzzleLoader = puzzleLoader;
|
|
5505
|
-
this.scheduler = new RenderScheduler(this.render.bind(this));
|
|
5506
|
-
__privateAdd(this, _cachedPosition2, null);
|
|
5507
|
-
this.addCSS(twisty2DSVGCSS);
|
|
5508
|
-
this.definition = def;
|
|
5509
|
-
this.resetSVG();
|
|
5510
|
-
cursor?.addPositionListener(this);
|
|
5511
|
-
if (this.options?.experimentalStickering) {
|
|
5512
|
-
this.experimentalSetStickering(this.options.experimentalStickering);
|
|
5513
|
-
}
|
|
5514
|
-
}
|
|
5515
|
-
onPositionChange(position) {
|
|
5516
|
-
if (position.movesInProgress.length > 0) {
|
|
5517
|
-
const move = position.movesInProgress[0].move;
|
|
5518
|
-
const def = this.definition;
|
|
5519
|
-
let partialMove = move;
|
|
5520
|
-
if (position.movesInProgress[0].direction === Direction.Backwards) {
|
|
5521
|
-
partialMove = move.invert();
|
|
5522
|
-
}
|
|
5523
|
-
const newState = combineTransformations(def, position.state, transformationForMove(def, partialMove));
|
|
5524
|
-
this.svg.draw(this.definition, position.state, newState, position.movesInProgress[0].fraction);
|
|
5525
|
-
} else {
|
|
5526
|
-
this.svg.draw(this.definition, position.state);
|
|
5527
|
-
__privateSet(this, _cachedPosition2, position);
|
|
5528
|
-
}
|
|
5529
|
-
}
|
|
5530
|
-
scheduleRender() {
|
|
5531
|
-
this.scheduler.requestAnimFrame();
|
|
5532
|
-
}
|
|
5533
|
-
experimentalSetStickering(stickering) {
|
|
5534
|
-
(async () => {
|
|
5535
|
-
if (!this.puzzleLoader?.appearance) {
|
|
5536
|
-
return;
|
|
5537
|
-
}
|
|
5538
|
-
const appearance = await this.puzzleLoader.appearance(stickering);
|
|
5539
|
-
this.resetSVG(appearance);
|
|
5540
|
-
})();
|
|
5541
|
-
}
|
|
5542
|
-
resetSVG(appearance) {
|
|
5543
|
-
if (this.svg) {
|
|
5544
|
-
this.removeElement(this.svg.element);
|
|
5545
|
-
}
|
|
5546
|
-
if (!this.definition) {
|
|
5547
|
-
return;
|
|
5548
|
-
}
|
|
5549
|
-
this.svg = new KPuzzleSVGWrapper(this.definition, this.svgSource, appearance);
|
|
5550
|
-
this.addElement(this.svg.element);
|
|
5551
|
-
if (__privateGet(this, _cachedPosition2)) {
|
|
5552
|
-
this.onPositionChange(__privateGet(this, _cachedPosition2));
|
|
5553
|
-
}
|
|
5554
|
-
}
|
|
5555
|
-
render() {
|
|
5556
|
-
}
|
|
5557
|
-
};
|
|
5558
|
-
_cachedPosition2 = new WeakMap();
|
|
5559
|
-
customElementsShim.define("twisty-2d-svg", Twisty2DSVG);
|
|
5560
|
-
|
|
5561
|
-
// src/cubing/twisty/old/dom/TwistyPlayer.ts
|
|
5562
|
-
function is3DVisualization(visualizationFormat) {
|
|
5563
|
-
return ["3D", "PG3D"].includes(visualizationFormat);
|
|
5564
|
-
}
|
|
5565
|
-
var indexerMap = {
|
|
5566
|
-
simple: SimpleAlgIndexer,
|
|
5567
|
-
tree: TreeAlgIndexer,
|
|
5568
|
-
simultaneous: SimultaneousMoveIndexer
|
|
5569
|
-
};
|
|
5570
|
-
var _config, _connected, _legacyExperimentalPG3DViewConfig, _experimentalStartStateOverride, _hackyPendingFinalMoveCoalesce, _viewerWrapper, _controlsClassListManager, _experimentalInvalidInitialAlgCallback, _initialized, _setCursorStartState, setCursorStartState_fn, _cursorStartAlg, cursorStartAlg_fn, _orbitControls, orbitControls_fn, _backOrbitControls, backOrbitControls_fn, _lookAt, lookAt_fn, _cursorIndexerName, _indexerConstructor, indexerConstructor_fn, _pendingPuzzleUpdates, _renderMode, _clearRenderMode, clearRenderMode_fn, _setRenderMode2D, setRenderMode2D_fn, _setTwisty2DSVG, setTwisty2DSVG_fn, _setRenderMode3D, setRenderMode3D_fn, _setTwisty3D, setTwisty3D_fn, _setCursor, setCursor_fn, _getPG3DAppearance, getPG3DAppearance_fn, _createBackViewer, createBackViewer_fn, _removeBackViewerElem, removeBackViewerElem_fn, _hackyCoalescePending, hackyCoalescePending_fn;
|
|
5571
|
-
var TwistyPlayerV1 = class extends ManagedCustomElement {
|
|
5572
|
-
constructor(initialConfig = {}, legacyExperimentalPG3DViewConfig = null, experimentalInvalidInitialAlgCallback = () => {
|
|
5573
|
-
}) {
|
|
5574
|
-
super();
|
|
5575
|
-
__privateAdd(this, _setCursorStartState);
|
|
5576
|
-
__privateAdd(this, _cursorStartAlg);
|
|
5577
|
-
__privateAdd(this, _orbitControls);
|
|
5578
|
-
__privateAdd(this, _backOrbitControls);
|
|
5579
|
-
__privateAdd(this, _lookAt);
|
|
5580
|
-
__privateAdd(this, _indexerConstructor);
|
|
5581
|
-
__privateAdd(this, _clearRenderMode);
|
|
5582
|
-
__privateAdd(this, _setRenderMode2D);
|
|
5583
|
-
__privateAdd(this, _setTwisty2DSVG);
|
|
5584
|
-
__privateAdd(this, _setRenderMode3D);
|
|
5585
|
-
__privateAdd(this, _setTwisty3D);
|
|
5586
|
-
__privateAdd(this, _setCursor);
|
|
5587
|
-
__privateAdd(this, _getPG3DAppearance);
|
|
5588
|
-
__privateAdd(this, _createBackViewer);
|
|
5589
|
-
__privateAdd(this, _removeBackViewerElem);
|
|
5590
|
-
__privateAdd(this, _hackyCoalescePending);
|
|
5591
|
-
__privateAdd(this, _config, void 0);
|
|
5592
|
-
this.scene = null;
|
|
5593
|
-
this.twisty3D = null;
|
|
5594
|
-
__privateAdd(this, _connected, false);
|
|
5595
|
-
__privateAdd(this, _legacyExperimentalPG3DViewConfig, null);
|
|
5596
|
-
this.legacyExperimentalPG3D = null;
|
|
5597
|
-
__privateAdd(this, _experimentalStartStateOverride, null);
|
|
5598
|
-
this.viewerElems = [];
|
|
5599
|
-
this.controlElems = [];
|
|
5600
|
-
__privateAdd(this, _hackyPendingFinalMoveCoalesce, false);
|
|
5601
|
-
__privateAdd(this, _viewerWrapper, void 0);
|
|
5602
|
-
this.legacyExperimentalCoalesceModFunc = (_move) => 0;
|
|
5603
|
-
__privateAdd(this, _controlsClassListManager, new ClassListManager(this, "controls-", ["none", "bottom-row"]));
|
|
5604
|
-
__privateAdd(this, _experimentalInvalidInitialAlgCallback, void 0);
|
|
5605
|
-
__privateAdd(this, _initialized, false);
|
|
5606
|
-
__privateAdd(this, _cursorIndexerName, "tree");
|
|
5607
|
-
__privateAdd(this, _pendingPuzzleUpdates, []);
|
|
5608
|
-
__privateAdd(this, _renderMode, null);
|
|
5609
|
-
this.addCSS(twistyPlayerCSS);
|
|
5610
|
-
__privateSet(this, _config, new TwistyPlayerConfig(this, initialConfig));
|
|
5611
|
-
__privateSet(this, _experimentalInvalidInitialAlgCallback, experimentalInvalidInitialAlgCallback);
|
|
5612
|
-
this.timeline = new Timeline();
|
|
5613
|
-
this.timeline.addActionListener(this);
|
|
5614
|
-
this.contentWrapper.classList.add("checkered");
|
|
5615
|
-
__privateSet(this, _legacyExperimentalPG3DViewConfig, legacyExperimentalPG3DViewConfig);
|
|
5616
|
-
}
|
|
5617
|
-
set alg(newAlg) {
|
|
5618
|
-
if (typeof newAlg === "string") {
|
|
5619
|
-
newAlg = Alg.fromString(newAlg);
|
|
5620
|
-
}
|
|
5621
|
-
__privateGet(this, _config).attributes["alg"].setValue(newAlg);
|
|
5622
|
-
this.cursor?.setAlg(newAlg, __privateMethod(this, _indexerConstructor, indexerConstructor_fn).call(this));
|
|
5623
|
-
__privateMethod(this, _setCursorStartState, setCursorStartState_fn).call(this);
|
|
5624
|
-
this.dispatchEvent(new CustomEvent("experimental-alg-update", { detail: { alg: this.alg } }));
|
|
5625
|
-
}
|
|
5626
|
-
get alg() {
|
|
5627
|
-
return __privateGet(this, _config).attributes["alg"].value;
|
|
5628
|
-
}
|
|
5629
|
-
set experimentalSetupAlg(newAlg) {
|
|
5630
|
-
if (typeof newAlg === "string") {
|
|
5631
|
-
console.warn("`experimentalSetupAlg` for a `TwistyPlayer` was set using a string. It should be set using a `Sequence`!");
|
|
5632
|
-
newAlg = new Alg(newAlg);
|
|
5633
|
-
}
|
|
5634
|
-
__privateGet(this, _config).attributes["experimental-setup-alg"].setValue(newAlg);
|
|
5635
|
-
__privateMethod(this, _setCursorStartState, setCursorStartState_fn).call(this);
|
|
5636
|
-
}
|
|
5637
|
-
get experimentalSetupAlg() {
|
|
5638
|
-
return __privateGet(this, _config).attributes["experimental-setup-alg"].value;
|
|
5639
|
-
}
|
|
5640
|
-
set experimentalSetupAnchor(setupToLocation) {
|
|
5641
|
-
__privateGet(this, _config).attributes["experimental-setup-anchor"].setValue(setupToLocation);
|
|
5642
|
-
__privateMethod(this, _setCursorStartState, setCursorStartState_fn).call(this);
|
|
5643
|
-
}
|
|
5644
|
-
get experimentalSetupAnchor() {
|
|
5645
|
-
return __privateGet(this, _config).attributes["experimental-setup-anchor"].value;
|
|
5646
|
-
}
|
|
5647
|
-
set puzzle(puzzle) {
|
|
5648
|
-
if (__privateGet(this, _config).attributes["puzzle"].setValue(puzzle)) {
|
|
5649
|
-
this.updatePuzzleDOM();
|
|
5650
|
-
}
|
|
5651
|
-
}
|
|
5652
|
-
get puzzle() {
|
|
5653
|
-
return __privateGet(this, _config).attributes["puzzle"].value;
|
|
5654
|
-
}
|
|
5655
|
-
set visualization(visualization) {
|
|
5656
|
-
if (__privateGet(this, _config).attributes["visualization"].setValue(visualization)) {
|
|
5657
|
-
this.updatePuzzleDOM();
|
|
5658
|
-
}
|
|
5659
|
-
}
|
|
5660
|
-
get visualization() {
|
|
5661
|
-
return __privateGet(this, _config).attributes["visualization"].value;
|
|
5662
|
-
}
|
|
5663
|
-
set hintFacelets(hintFacelets) {
|
|
5664
|
-
if (__privateGet(this, _config).attributes["hint-facelets"].setValue(hintFacelets)) {
|
|
5665
|
-
if (this.twisty3D instanceof Cube3D) {
|
|
5666
|
-
this.twisty3D.experimentalUpdateOptions({ hintFacelets });
|
|
5667
|
-
}
|
|
5668
|
-
}
|
|
5669
|
-
}
|
|
5670
|
-
get hintFacelets() {
|
|
5671
|
-
return __privateGet(this, _config).attributes["hint-facelets"].value;
|
|
5672
|
-
}
|
|
5673
|
-
set experimentalStickering(experimentalStickering) {
|
|
5674
|
-
if (__privateGet(this, _config).attributes["experimental-stickering"].setValue(experimentalStickering)) {
|
|
5675
|
-
const twisty3D = this.twisty3D;
|
|
5676
|
-
if (twisty3D instanceof Cube3D) {
|
|
5677
|
-
twisty3D.experimentalUpdateOptions({
|
|
5678
|
-
experimentalStickering
|
|
5679
|
-
});
|
|
5680
|
-
}
|
|
5681
|
-
if (twisty3D instanceof PG3D) {
|
|
5682
|
-
(async () => {
|
|
5683
|
-
const appearance = await __privateMethod(this, _getPG3DAppearance, getPG3DAppearance_fn).call(this);
|
|
5684
|
-
twisty3D.experimentalSetAppearance(appearance);
|
|
5685
|
-
})();
|
|
5686
|
-
}
|
|
5687
|
-
if (this.viewerElems[0] instanceof Twisty2DSVG) {
|
|
5688
|
-
this.viewerElems[0].experimentalSetStickering(this.experimentalStickering);
|
|
5689
|
-
}
|
|
5690
|
-
}
|
|
5691
|
-
}
|
|
5692
|
-
get experimentalStickering() {
|
|
5693
|
-
return __privateGet(this, _config).attributes["experimental-stickering"].value;
|
|
5694
|
-
}
|
|
5695
|
-
set background(background) {
|
|
5696
|
-
if (__privateGet(this, _config).attributes["background"].setValue(background)) {
|
|
5697
|
-
this.contentWrapper.classList.toggle("checkered", background === "checkered");
|
|
5698
|
-
}
|
|
5699
|
-
}
|
|
5700
|
-
get background() {
|
|
5701
|
-
return __privateGet(this, _config).attributes["background"].value;
|
|
5702
|
-
}
|
|
5703
|
-
set controlPanel(controlPanel) {
|
|
5704
|
-
__privateGet(this, _config).attributes["control-panel"].setValue(controlPanel);
|
|
5705
|
-
__privateGet(this, _controlsClassListManager).setValue(controlPanel);
|
|
5706
|
-
}
|
|
5707
|
-
get controlPanel() {
|
|
5708
|
-
return __privateGet(this, _config).attributes["control-panel"].value;
|
|
5709
|
-
}
|
|
5710
|
-
set controls(controls) {
|
|
5711
|
-
this.controlPanel = controls;
|
|
5712
|
-
}
|
|
5713
|
-
get controls() {
|
|
5714
|
-
return this.controlPanel;
|
|
5715
|
-
}
|
|
5716
|
-
set backView(backView) {
|
|
5717
|
-
__privateGet(this, _config).attributes["back-view"].setValue(backView);
|
|
5718
|
-
if (backView !== "none" && this.viewerElems.length === 1) {
|
|
5719
|
-
__privateMethod(this, _createBackViewer, createBackViewer_fn).call(this);
|
|
5720
|
-
}
|
|
5721
|
-
if (backView === "none" && this.viewerElems.length > 1) {
|
|
5722
|
-
__privateMethod(this, _removeBackViewerElem, removeBackViewerElem_fn).call(this);
|
|
5723
|
-
}
|
|
5724
|
-
if (__privateGet(this, _viewerWrapper) && __privateGet(this, _viewerWrapper).setBackView(backView)) {
|
|
5725
|
-
for (const viewer of this.viewerElems) {
|
|
5726
|
-
viewer.makeInvisibleUntilRender();
|
|
5727
|
-
}
|
|
5728
|
-
}
|
|
5729
|
-
}
|
|
5730
|
-
get backView() {
|
|
5731
|
-
return __privateGet(this, _config).attributes["back-view"].value;
|
|
5732
|
-
}
|
|
5733
|
-
set experimentalCameraLatitude(latitude) {
|
|
5734
|
-
__privateGet(this, _config).attributes["experimental-camera-latitude"].setValue(latitude);
|
|
5735
|
-
const orbitControls = __privateMethod(this, _orbitControls, orbitControls_fn).call(this);
|
|
5736
|
-
if (orbitControls && latitude !== null) {
|
|
5737
|
-
orbitControls.latitude = latitude;
|
|
5738
|
-
this.viewerElems[0].scheduleRender();
|
|
5739
|
-
this.viewerElems[1]?.scheduleRender();
|
|
5740
|
-
}
|
|
5741
|
-
}
|
|
5742
|
-
get experimentalCameraLatitude() {
|
|
5743
|
-
if (__privateGet(this, _config).attributes["experimental-camera-latitude"].value !== null) {
|
|
5744
|
-
return __privateGet(this, _config).attributes["experimental-camera-latitude"].value;
|
|
5745
|
-
}
|
|
5746
|
-
return __privateMethod(this, _orbitControls, orbitControls_fn).call(this)?.latitude ?? null;
|
|
5747
|
-
}
|
|
5748
|
-
set experimentalCameraLongitude(longitude) {
|
|
5749
|
-
__privateGet(this, _config).attributes["experimental-camera-longitude"].setValue(longitude);
|
|
5750
|
-
const orbitControls = __privateMethod(this, _orbitControls, orbitControls_fn).call(this);
|
|
5751
|
-
if (orbitControls && longitude !== null) {
|
|
5752
|
-
orbitControls.longitude = longitude;
|
|
5753
|
-
this.viewerElems[0].scheduleRender();
|
|
5754
|
-
this.viewerElems[1]?.scheduleRender();
|
|
5755
|
-
}
|
|
5756
|
-
}
|
|
5757
|
-
get experimentalCameraLongitude() {
|
|
5758
|
-
if (__privateGet(this, _config).attributes["experimental-camera-longitude"].value !== null) {
|
|
5759
|
-
return __privateGet(this, _config).attributes["experimental-camera-longitude"].value;
|
|
5760
|
-
}
|
|
5761
|
-
return __privateMethod(this, _orbitControls, orbitControls_fn).call(this)?.longitude ?? null;
|
|
5762
|
-
}
|
|
5763
|
-
set experimentalCameraLatitudeLimits(latitudeLimits) {
|
|
5764
|
-
__privateGet(this, _config).attributes["experimental-camera-latitude-limits"].setValue(latitudeLimits);
|
|
5765
|
-
const orbitControls = __privateMethod(this, _orbitControls, orbitControls_fn).call(this);
|
|
5766
|
-
console.log({ orbitControls });
|
|
5767
|
-
if (orbitControls) {
|
|
5768
|
-
orbitControls.experimentalLatitudeLimits = latitudeLimits;
|
|
5769
|
-
}
|
|
5770
|
-
const backOrbitControls = __privateMethod(this, _backOrbitControls, backOrbitControls_fn).call(this);
|
|
5771
|
-
if (backOrbitControls) {
|
|
5772
|
-
backOrbitControls.experimentalLatitudeLimits = latitudeLimits;
|
|
5773
|
-
}
|
|
5774
|
-
}
|
|
5775
|
-
get experimentalCameraLatitudeLimits() {
|
|
5776
|
-
return __privateGet(this, _config).attributes["experimental-camera-latitude-limits"].value;
|
|
5777
|
-
}
|
|
5778
|
-
set viewerLink(viewerLinkPage) {
|
|
5779
|
-
__privateGet(this, _config).attributes["viewer-link"].setValue(viewerLinkPage);
|
|
5780
|
-
const maybePanel = this.controlElems[1];
|
|
5781
|
-
if (maybePanel?.setViewerLink) {
|
|
5782
|
-
maybePanel.setViewerLink(viewerLinkPage);
|
|
5783
|
-
}
|
|
5784
|
-
}
|
|
5785
|
-
get viewerLink() {
|
|
5786
|
-
return __privateGet(this, _config).attributes["viewer-link"].value;
|
|
5787
|
-
}
|
|
5788
|
-
experimentalSetCameraOrbitCoordinates(coords) {
|
|
5789
|
-
this.experimentalCameraLatitude = coords.latitude;
|
|
5790
|
-
this.experimentalCameraLongitude = coords.longitude;
|
|
5791
|
-
const orbitControls = __privateMethod(this, _orbitControls, orbitControls_fn).call(this);
|
|
5792
|
-
if (orbitControls) {
|
|
5793
|
-
orbitControls.distance = coords.distance;
|
|
5794
|
-
}
|
|
5795
|
-
}
|
|
5796
|
-
experimentalDerivedCameraOrbitCoordinates() {
|
|
5797
|
-
const defaultCoordinatesForPuzzle = defaultCameraOrbitCoordinates(this.puzzle, this.twisty3D instanceof PG3D ? "PG3D" : "Cube3D");
|
|
5798
|
-
return {
|
|
5799
|
-
latitude: this.experimentalCameraLatitude ?? defaultCoordinatesForPuzzle.latitude,
|
|
5800
|
-
longitude: this.experimentalCameraLongitude ?? defaultCoordinatesForPuzzle.longitude,
|
|
5801
|
-
distance: defaultCoordinatesForPuzzle.distance
|
|
5802
|
-
};
|
|
5803
|
-
}
|
|
5804
|
-
static get observedAttributes() {
|
|
5805
|
-
return TwistyPlayerConfig.observedAttributes;
|
|
5806
|
-
}
|
|
5807
|
-
attributeChangedCallback(attributeName, oldValue, newValue) {
|
|
5808
|
-
__privateGet(this, _config).attributeChangedCallback(attributeName, oldValue, newValue);
|
|
5809
|
-
}
|
|
5810
|
-
experimentalSetStartStateOverride(state) {
|
|
5811
|
-
__privateSet(this, _experimentalStartStateOverride, state);
|
|
5812
|
-
__privateMethod(this, _setCursorStartState, setCursorStartState_fn).call(this);
|
|
5813
|
-
}
|
|
5814
|
-
experimentalSetCursorIndexer(cursorName) {
|
|
5815
|
-
if (__privateGet(this, _cursorIndexerName) === cursorName) {
|
|
5816
|
-
return;
|
|
5817
|
-
}
|
|
5818
|
-
__privateSet(this, _cursorIndexerName, cursorName);
|
|
5819
|
-
this.cursor?.experimentalSetIndexer(__privateMethod(this, _indexerConstructor, indexerConstructor_fn).call(this));
|
|
5820
|
-
}
|
|
5821
|
-
connectedCallback() {
|
|
5822
|
-
this.contentWrapper.classList.toggle("checkered", this.background === "checkered");
|
|
5823
|
-
const setBackView = this.backView && is3DVisualization(this.visualization);
|
|
5824
|
-
const backView = setBackView ? this.backView : "none";
|
|
5825
|
-
__privateSet(this, _viewerWrapper, new TwistyViewerWrapper({
|
|
5826
|
-
backView
|
|
5827
|
-
}));
|
|
5828
|
-
this.addElement(__privateGet(this, _viewerWrapper));
|
|
5829
|
-
const scrubber = new TwistyScrubber(this.timeline);
|
|
5830
|
-
const controlButtonGrid = new TwistyControlButtonPanel(this.timeline, {
|
|
5831
|
-
fullscreenElement: this,
|
|
5832
|
-
viewerLinkCallback: this.visitTwizzleLink.bind(this),
|
|
5833
|
-
viewerLink: this.viewerLink
|
|
5834
|
-
});
|
|
5835
|
-
this.controlElems = [scrubber, controlButtonGrid];
|
|
5836
|
-
__privateGet(this, _controlsClassListManager).setValue(this.controlPanel);
|
|
5837
|
-
this.addElement(this.controlElems[0]);
|
|
5838
|
-
this.addElement(this.controlElems[1]);
|
|
5839
|
-
__privateSet(this, _connected, true);
|
|
5840
|
-
this.updatePuzzleDOM(true).then(() => {
|
|
5841
|
-
if (!__privateGet(this, _initialized)) {
|
|
5842
|
-
__privateSet(this, _initialized, true);
|
|
5843
|
-
this.dispatchEvent(new CustomEvent("initialized"));
|
|
5844
|
-
}
|
|
5845
|
-
});
|
|
5846
|
-
}
|
|
5847
|
-
get initialized() {
|
|
5848
|
-
return __privateGet(this, _initialized);
|
|
5849
|
-
}
|
|
5850
|
-
twizzleLink() {
|
|
5851
|
-
const url = new URL("https://alpha.twizzle.net/edit/");
|
|
5852
|
-
if (!this.alg.experimentalIsEmpty()) {
|
|
5853
|
-
url.searchParams.set("alg", this.alg.toString());
|
|
5854
|
-
}
|
|
5855
|
-
if (!this.experimentalSetupAlg.experimentalIsEmpty()) {
|
|
5856
|
-
url.searchParams.set("experimental-setup-alg", this.experimentalSetupAlg.toString());
|
|
5857
|
-
}
|
|
5858
|
-
if (this.experimentalSetupAnchor !== "start") {
|
|
5859
|
-
url.searchParams.set("experimental-setup-anchor", this.experimentalSetupAnchor);
|
|
5860
|
-
}
|
|
5861
|
-
if (this.experimentalStickering !== "full") {
|
|
5862
|
-
url.searchParams.set("experimental-stickering", this.experimentalStickering);
|
|
5863
|
-
}
|
|
5864
|
-
if (this.puzzle !== "3x3x3") {
|
|
5865
|
-
url.searchParams.set("puzzle", this.puzzle);
|
|
5866
|
-
}
|
|
5867
|
-
return url.toString();
|
|
5868
|
-
}
|
|
5869
|
-
visitTwizzleLink() {
|
|
5870
|
-
const a = document.createElement("a");
|
|
5871
|
-
a.href = this.twizzleLink();
|
|
5872
|
-
a.target = "_blank";
|
|
5873
|
-
a.click();
|
|
5874
|
-
}
|
|
5875
|
-
async updatePuzzleDOM(initial = false) {
|
|
5876
|
-
if (!__privateGet(this, _connected)) {
|
|
5877
|
-
return;
|
|
5878
|
-
}
|
|
5879
|
-
let puzzleLoader;
|
|
5880
|
-
if (this.puzzle === "custom") {
|
|
5881
|
-
puzzleLoader = {
|
|
5882
|
-
id: "custom",
|
|
5883
|
-
fullName: "Custom (PG3D)",
|
|
5884
|
-
def: () => Promise.resolve(__privateGet(this, _legacyExperimentalPG3DViewConfig).def),
|
|
5885
|
-
svg: () => {
|
|
5886
|
-
throw "unimplemented";
|
|
5887
|
-
}
|
|
5888
|
-
};
|
|
5889
|
-
} else {
|
|
5890
|
-
puzzleLoader = puzzles[this.puzzle];
|
|
5891
|
-
}
|
|
5892
|
-
for (const pendingPuzzleUpdate2 of __privateGet(this, _pendingPuzzleUpdates)) {
|
|
5893
|
-
pendingPuzzleUpdate2.cancelled = true;
|
|
5894
|
-
}
|
|
5895
|
-
__privateSet(this, _pendingPuzzleUpdates, []);
|
|
5896
|
-
const pendingPuzzleUpdate = { cancelled: false };
|
|
5897
|
-
__privateGet(this, _pendingPuzzleUpdates).push(pendingPuzzleUpdate);
|
|
5898
|
-
const def = await puzzleLoader.def();
|
|
5899
|
-
if (pendingPuzzleUpdate.cancelled) {
|
|
5900
|
-
return;
|
|
5901
|
-
}
|
|
5902
|
-
let cursor;
|
|
5903
|
-
try {
|
|
5904
|
-
cursor = new AlgCursor(this.timeline, def, this.alg, __privateMethod(this, _cursorStartAlg, cursorStartAlg_fn).call(this), __privateMethod(this, _indexerConstructor, indexerConstructor_fn).call(this));
|
|
5905
|
-
__privateMethod(this, _setCursor, setCursor_fn).call(this, cursor);
|
|
5906
|
-
} catch (e) {
|
|
5907
|
-
if (initial) {
|
|
5908
|
-
__privateGet(this, _experimentalInvalidInitialAlgCallback).call(this, this.alg);
|
|
5909
|
-
}
|
|
5910
|
-
cursor = new AlgCursor(this.timeline, def, new Alg(), new Alg(), __privateMethod(this, _indexerConstructor, indexerConstructor_fn).call(this));
|
|
5911
|
-
__privateMethod(this, _setCursor, setCursor_fn).call(this, cursor);
|
|
5912
|
-
}
|
|
5913
|
-
if (initial && this.experimentalSetupAlg.experimentalIsEmpty() && this.experimentalSetupAnchor !== "end") {
|
|
5914
|
-
this.timeline.jumpToEnd();
|
|
5915
|
-
}
|
|
5916
|
-
switch (this.visualization) {
|
|
5917
|
-
case "2D":
|
|
5918
|
-
case "experimental-2D-LL":
|
|
5919
|
-
{
|
|
5920
|
-
const options = {};
|
|
5921
|
-
if (this.experimentalStickering) {
|
|
5922
|
-
options.experimentalStickering = this.experimentalStickering;
|
|
5923
|
-
}
|
|
5924
|
-
__privateMethod(this, _setRenderMode2D, setRenderMode2D_fn).call(this);
|
|
5925
|
-
const svgPromiseFn = this.visualization === "2D" ? puzzleLoader.svg : puzzleLoader.llSVG ?? puzzleLoader.svg;
|
|
5926
|
-
const mainViewer = new Twisty2DSVG(cursor, def, await svgPromiseFn(), options, puzzleLoader);
|
|
5927
|
-
if (!pendingPuzzleUpdate.cancelled) {
|
|
5928
|
-
__privateMethod(this, _setTwisty2DSVG, setTwisty2DSVG_fn).call(this, mainViewer);
|
|
5929
|
-
}
|
|
5930
|
-
}
|
|
5931
|
-
break;
|
|
5932
|
-
case "3D":
|
|
5933
|
-
case "PG3D":
|
|
5934
|
-
{
|
|
5935
|
-
__privateMethod(this, _setRenderMode3D, setRenderMode3D_fn).call(this);
|
|
5936
|
-
const scene = this.scene;
|
|
5937
|
-
let twisty3D;
|
|
5938
|
-
if (this.visualization === "3D" && this.puzzle === "3x3x3") {
|
|
5939
|
-
twisty3D = new Cube3D(def, cursor, scene.scheduleRender.bind(scene), {
|
|
5940
|
-
hintFacelets: this.hintFacelets,
|
|
5941
|
-
experimentalStickering: this.experimentalStickering
|
|
5942
|
-
});
|
|
5943
|
-
} else {
|
|
5944
|
-
let def2;
|
|
5945
|
-
let stickerDat;
|
|
5946
|
-
const pgGetter = puzzleLoader.pg;
|
|
5947
|
-
if (this.puzzle === "custom") {
|
|
5948
|
-
def2 = __privateGet(this, _legacyExperimentalPG3DViewConfig).def;
|
|
5949
|
-
stickerDat = __privateGet(this, _legacyExperimentalPG3DViewConfig).stickerDat;
|
|
5950
|
-
} else if (pgGetter) {
|
|
5951
|
-
const pg = await pgGetter();
|
|
5952
|
-
if (pendingPuzzleUpdate.cancelled) {
|
|
5953
|
-
return;
|
|
5954
|
-
}
|
|
5955
|
-
def2 = pg.writekpuzzle(true);
|
|
5956
|
-
stickerDat = pg.get3d();
|
|
5957
|
-
} else {
|
|
5958
|
-
throw "Unimplemented!";
|
|
5959
|
-
}
|
|
5960
|
-
const options = {};
|
|
5961
|
-
const heightMap = {
|
|
5962
|
-
megaminx: 1.5,
|
|
5963
|
-
pyraminx: 1.75
|
|
5964
|
-
};
|
|
5965
|
-
const hintStickerHeightScale = __privateGet(this, _legacyExperimentalPG3DViewConfig)?.hintStickerHeightScale ?? heightMap[this.puzzle] ?? 1;
|
|
5966
|
-
const pg3d = new PG3D(cursor, scene.scheduleRender.bind(scene), def2, stickerDat, __privateGet(this, _legacyExperimentalPG3DViewConfig)?.showFoundation ?? true, __privateGet(this, _legacyExperimentalPG3DViewConfig)?.hintStickers ?? this.hintFacelets === "floating", hintStickerHeightScale, options);
|
|
5967
|
-
(async () => {
|
|
5968
|
-
const appearance = await __privateMethod(this, _getPG3DAppearance, getPG3DAppearance_fn).call(this);
|
|
5969
|
-
if (appearance) {
|
|
5970
|
-
pg3d.experimentalSetAppearance(appearance);
|
|
5971
|
-
}
|
|
5972
|
-
})();
|
|
5973
|
-
this.legacyExperimentalPG3D = pg3d;
|
|
5974
|
-
twisty3D = pg3d;
|
|
5975
|
-
}
|
|
5976
|
-
__privateMethod(this, _setTwisty3D, setTwisty3D_fn).call(this, twisty3D);
|
|
5977
|
-
}
|
|
5978
|
-
break;
|
|
5979
|
-
}
|
|
5980
|
-
}
|
|
5981
|
-
async setCustomPuzzleGeometry(legacyExperimentalPG3DViewConfig) {
|
|
5982
|
-
this.puzzle = "custom";
|
|
5983
|
-
__privateSet(this, _legacyExperimentalPG3DViewConfig, legacyExperimentalPG3DViewConfig);
|
|
5984
|
-
await this.updatePuzzleDOM();
|
|
5985
|
-
}
|
|
5986
|
-
experimentalAddMove(move, coalesce = false, coalesceDelayed = false) {
|
|
5987
|
-
if (__privateGet(this, _hackyPendingFinalMoveCoalesce)) {
|
|
5988
|
-
__privateMethod(this, _hackyCoalescePending, hackyCoalescePending_fn).call(this);
|
|
5989
|
-
}
|
|
5990
|
-
const oldNumMoves = countMoves(this.alg);
|
|
5991
|
-
const newAlg = experimentalAppendMove(this.alg, move, {
|
|
5992
|
-
coalesce: coalesce && !coalesceDelayed,
|
|
5993
|
-
mod: this.legacyExperimentalCoalesceModFunc(move)
|
|
5994
|
-
});
|
|
5995
|
-
if (coalesce && coalesceDelayed) {
|
|
5996
|
-
__privateSet(this, _hackyPendingFinalMoveCoalesce, true);
|
|
5997
|
-
}
|
|
5998
|
-
this.alg = newAlg;
|
|
5999
|
-
if (oldNumMoves <= countMoves(newAlg)) {
|
|
6000
|
-
this.timeline.experimentalJumpToLastMove();
|
|
6001
|
-
} else {
|
|
6002
|
-
this.timeline.jumpToEnd();
|
|
6003
|
-
}
|
|
6004
|
-
this.timeline.play();
|
|
6005
|
-
}
|
|
6006
|
-
onTimelineAction(actionEvent) {
|
|
6007
|
-
if (actionEvent.action === TimelineAction.Pausing && actionEvent.locationType === TimestampLocationType.EndOfTimeline && __privateGet(this, _hackyPendingFinalMoveCoalesce)) {
|
|
6008
|
-
__privateMethod(this, _hackyCoalescePending, hackyCoalescePending_fn).call(this);
|
|
6009
|
-
this.timeline.jumpToEnd();
|
|
6010
|
-
}
|
|
6011
|
-
}
|
|
6012
|
-
fullscreen() {
|
|
6013
|
-
this.requestFullscreen();
|
|
6014
|
-
}
|
|
6015
|
-
};
|
|
6016
|
-
_config = new WeakMap();
|
|
6017
|
-
_connected = new WeakMap();
|
|
6018
|
-
_legacyExperimentalPG3DViewConfig = new WeakMap();
|
|
6019
|
-
_experimentalStartStateOverride = new WeakMap();
|
|
6020
|
-
_hackyPendingFinalMoveCoalesce = new WeakMap();
|
|
6021
|
-
_viewerWrapper = new WeakMap();
|
|
6022
|
-
_controlsClassListManager = new WeakMap();
|
|
6023
|
-
_experimentalInvalidInitialAlgCallback = new WeakMap();
|
|
6024
|
-
_initialized = new WeakMap();
|
|
6025
|
-
_setCursorStartState = new WeakSet();
|
|
6026
|
-
setCursorStartState_fn = function() {
|
|
6027
|
-
if (this.cursor) {
|
|
6028
|
-
this.cursor.setStartState(__privateGet(this, _experimentalStartStateOverride) ?? this.cursor.algToState(__privateMethod(this, _cursorStartAlg, cursorStartAlg_fn).call(this)));
|
|
6029
|
-
}
|
|
6030
|
-
};
|
|
6031
|
-
_cursorStartAlg = new WeakSet();
|
|
6032
|
-
cursorStartAlg_fn = function() {
|
|
6033
|
-
let startAlg = this.experimentalSetupAlg;
|
|
6034
|
-
if (this.experimentalSetupAnchor === "end") {
|
|
6035
|
-
startAlg = startAlg.concat(this.alg.invert());
|
|
6036
|
-
}
|
|
6037
|
-
return startAlg;
|
|
6038
|
-
};
|
|
6039
|
-
_orbitControls = new WeakSet();
|
|
6040
|
-
orbitControls_fn = function() {
|
|
6041
|
-
if (!["3D", "PG3D"].includes(__privateGet(this, _config).attributes["visualization"].value)) {
|
|
6042
|
-
return null;
|
|
6043
|
-
}
|
|
6044
|
-
return this.viewerElems[0]?.orbitControls ?? null;
|
|
6045
|
-
};
|
|
6046
|
-
_backOrbitControls = new WeakSet();
|
|
6047
|
-
backOrbitControls_fn = function() {
|
|
6048
|
-
if (!["3D", "PG3D"].includes(__privateGet(this, _config).attributes["visualization"].value)) {
|
|
6049
|
-
return null;
|
|
6050
|
-
}
|
|
6051
|
-
return this.viewerElems[1]?.orbitControls ?? null;
|
|
6052
|
-
};
|
|
6053
|
-
_lookAt = new WeakSet();
|
|
6054
|
-
lookAt_fn = function() {
|
|
6055
|
-
switch (this.puzzle) {
|
|
6056
|
-
case "pyraminx":
|
|
6057
|
-
case "master_tetraminx":
|
|
6058
|
-
return pyraminxLookAt;
|
|
6059
|
-
default:
|
|
6060
|
-
return new Vector32(0, 0, 0);
|
|
6061
|
-
}
|
|
6062
|
-
};
|
|
6063
|
-
_cursorIndexerName = new WeakMap();
|
|
6064
|
-
_indexerConstructor = new WeakSet();
|
|
6065
|
-
indexerConstructor_fn = function() {
|
|
6066
|
-
return indexerMap[__privateGet(this, _cursorIndexerName)];
|
|
6067
|
-
};
|
|
6068
|
-
_pendingPuzzleUpdates = new WeakMap();
|
|
6069
|
-
_renderMode = new WeakMap();
|
|
6070
|
-
_clearRenderMode = new WeakSet();
|
|
6071
|
-
clearRenderMode_fn = function() {
|
|
6072
|
-
switch (__privateGet(this, _renderMode)) {
|
|
6073
|
-
case "3D":
|
|
6074
|
-
this.scene = null;
|
|
6075
|
-
this.twisty3D = null;
|
|
6076
|
-
this.legacyExperimentalPG3D = null;
|
|
6077
|
-
this.viewerElems = [];
|
|
6078
|
-
__privateGet(this, _viewerWrapper).clear();
|
|
6079
|
-
break;
|
|
6080
|
-
case "2D":
|
|
6081
|
-
this.viewerElems = [];
|
|
6082
|
-
__privateGet(this, _viewerWrapper).clear();
|
|
6083
|
-
break;
|
|
6084
|
-
}
|
|
6085
|
-
__privateSet(this, _renderMode, null);
|
|
6086
|
-
};
|
|
6087
|
-
_setRenderMode2D = new WeakSet();
|
|
6088
|
-
setRenderMode2D_fn = function() {
|
|
6089
|
-
if (__privateGet(this, _renderMode) === "2D") {
|
|
6090
|
-
return;
|
|
6091
|
-
}
|
|
6092
|
-
__privateMethod(this, _clearRenderMode, clearRenderMode_fn).call(this);
|
|
6093
|
-
__privateSet(this, _renderMode, "2D");
|
|
6094
|
-
};
|
|
6095
|
-
_setTwisty2DSVG = new WeakSet();
|
|
6096
|
-
setTwisty2DSVG_fn = function(twisty2DSVG) {
|
|
6097
|
-
__privateMethod(this, _setRenderMode2D, setRenderMode2D_fn).call(this);
|
|
6098
|
-
__privateGet(this, _viewerWrapper).clear();
|
|
6099
|
-
__privateGet(this, _viewerWrapper).addElement(twisty2DSVG);
|
|
6100
|
-
this.viewerElems.push(twisty2DSVG);
|
|
6101
|
-
};
|
|
6102
|
-
_setRenderMode3D = new WeakSet();
|
|
6103
|
-
setRenderMode3D_fn = function() {
|
|
6104
|
-
if (__privateGet(this, _renderMode) === "3D") {
|
|
6105
|
-
return;
|
|
6106
|
-
}
|
|
6107
|
-
__privateMethod(this, _clearRenderMode, clearRenderMode_fn).call(this);
|
|
6108
|
-
this.scene = new Twisty3DScene();
|
|
6109
|
-
const mainViewer = new Twisty3DCanvas(this.scene, {
|
|
6110
|
-
orbitCoordinates: this.experimentalDerivedCameraOrbitCoordinates()
|
|
6111
|
-
});
|
|
6112
|
-
mainViewer.orbitControls.experimentalLatitudeLimits = this.experimentalCameraLatitudeLimits;
|
|
6113
|
-
this.viewerElems.push(mainViewer);
|
|
6114
|
-
__privateGet(this, _viewerWrapper).addElement(mainViewer);
|
|
6115
|
-
if (this.backView !== "none") {
|
|
6116
|
-
__privateMethod(this, _createBackViewer, createBackViewer_fn).call(this);
|
|
6117
|
-
}
|
|
6118
|
-
__privateSet(this, _renderMode, "3D");
|
|
6119
|
-
};
|
|
6120
|
-
_setTwisty3D = new WeakSet();
|
|
6121
|
-
setTwisty3D_fn = function(twisty3D) {
|
|
6122
|
-
if (this.twisty3D) {
|
|
6123
|
-
this.scene.removeTwisty3DPuzzle(this.twisty3D);
|
|
6124
|
-
if (this.twisty3D instanceof PG3D) {
|
|
6125
|
-
this.twisty3D.dispose();
|
|
6126
|
-
}
|
|
6127
|
-
this.twisty3D = null;
|
|
6128
|
-
}
|
|
6129
|
-
this.twisty3D = twisty3D;
|
|
6130
|
-
this.scene.addTwisty3DPuzzle(twisty3D);
|
|
6131
|
-
const orbitControls = __privateMethod(this, _orbitControls, orbitControls_fn).call(this);
|
|
6132
|
-
if (orbitControls) {
|
|
6133
|
-
orbitControls.lookAt(__privateMethod(this, _lookAt, lookAt_fn).call(this));
|
|
6134
|
-
}
|
|
6135
|
-
};
|
|
6136
|
-
_setCursor = new WeakSet();
|
|
6137
|
-
setCursor_fn = function(cursor) {
|
|
6138
|
-
const oldCursor = this.cursor;
|
|
6139
|
-
this.cursor = cursor;
|
|
6140
|
-
try {
|
|
6141
|
-
this.cursor.setAlg(this.alg, __privateMethod(this, _indexerConstructor, indexerConstructor_fn).call(this));
|
|
6142
|
-
__privateMethod(this, _setCursorStartState, setCursorStartState_fn).call(this);
|
|
6143
|
-
} catch (e) {
|
|
6144
|
-
this.cursor.setAlg(new Alg(), __privateMethod(this, _indexerConstructor, indexerConstructor_fn).call(this));
|
|
6145
|
-
this.cursor.setStartState(this.cursor.algToState(new Alg()));
|
|
6146
|
-
__privateGet(this, _experimentalInvalidInitialAlgCallback).call(this, this.alg);
|
|
6147
|
-
}
|
|
6148
|
-
__privateMethod(this, _setCursorStartState, setCursorStartState_fn).call(this);
|
|
6149
|
-
this.timeline.addCursor(cursor);
|
|
6150
|
-
if (oldCursor) {
|
|
6151
|
-
this.timeline.removeCursor(oldCursor);
|
|
6152
|
-
this.timeline.removeTimestampListener(oldCursor);
|
|
6153
|
-
}
|
|
6154
|
-
this.experimentalSetCursorIndexer(__privateGet(this, _cursorIndexerName));
|
|
6155
|
-
};
|
|
6156
|
-
_getPG3DAppearance = new WeakSet();
|
|
6157
|
-
getPG3DAppearance_fn = async function() {
|
|
6158
|
-
const puzzleLoader = puzzles[this.puzzle];
|
|
6159
|
-
if (puzzleLoader?.appearance) {
|
|
6160
|
-
return puzzleLoader.appearance(this.experimentalStickering ?? "full");
|
|
6161
|
-
}
|
|
6162
|
-
return null;
|
|
6163
|
-
};
|
|
6164
|
-
_createBackViewer = new WeakSet();
|
|
6165
|
-
createBackViewer_fn = function() {
|
|
6166
|
-
if (!is3DVisualization(this.visualization)) {
|
|
6167
|
-
throw new Error("Back viewer requires a 3D visualization");
|
|
6168
|
-
}
|
|
6169
|
-
const backViewer = new Twisty3DCanvas(this.scene, {
|
|
6170
|
-
orbitCoordinates: this.experimentalDerivedCameraOrbitCoordinates(),
|
|
6171
|
-
negateCameraPosition: true
|
|
6172
|
-
});
|
|
6173
|
-
backViewer.orbitControls.experimentalLatitudeLimits = this.experimentalCameraLatitudeLimits;
|
|
6174
|
-
this.viewerElems.push(backViewer);
|
|
6175
|
-
this.viewerElems[0].setMirror(backViewer);
|
|
6176
|
-
__privateGet(this, _viewerWrapper).addElement(backViewer);
|
|
6177
|
-
};
|
|
6178
|
-
_removeBackViewerElem = new WeakSet();
|
|
6179
|
-
removeBackViewerElem_fn = function() {
|
|
6180
|
-
if (this.viewerElems.length !== 2) {
|
|
6181
|
-
throw new Error("Tried to remove non-existent back view!");
|
|
6182
|
-
}
|
|
6183
|
-
__privateGet(this, _viewerWrapper).removeElement(this.viewerElems.pop());
|
|
6184
|
-
};
|
|
6185
|
-
_hackyCoalescePending = new WeakSet();
|
|
6186
|
-
hackyCoalescePending_fn = function() {
|
|
6187
|
-
const units = Array.from(this.alg.units());
|
|
6188
|
-
const length = units.length;
|
|
6189
|
-
const pending = __privateGet(this, _hackyPendingFinalMoveCoalesce);
|
|
6190
|
-
__privateSet(this, _hackyPendingFinalMoveCoalesce, false);
|
|
6191
|
-
if (pending && length > 1 && units[length - 1].is(Move)) {
|
|
6192
|
-
const finalMove = units[length - 1];
|
|
6193
|
-
const newAlg = experimentalAppendMove(new Alg(units.slice(0, length - 1)), finalMove, {
|
|
6194
|
-
coalesce: true,
|
|
6195
|
-
mod: this.legacyExperimentalCoalesceModFunc(finalMove)
|
|
6196
|
-
});
|
|
6197
|
-
this.alg = newAlg;
|
|
6198
|
-
}
|
|
6199
|
-
};
|
|
6200
|
-
customElementsShim.define("twisty-player-v1", TwistyPlayerV1);
|
|
6201
|
-
|
|
6202
|
-
// src/cubing/twisty/old/dom/TwistyAlgViewerV1.css.ts
|
|
6203
|
-
var twistyAlgViewerCSS2 = new CSSSource(`
|
|
6204
|
-
:host {
|
|
6205
|
-
display: inline-grid;
|
|
6206
|
-
}
|
|
6207
|
-
|
|
6208
|
-
a:not(:hover) {
|
|
6209
|
-
color: inherit;
|
|
6210
|
-
text-decoration: none;
|
|
6211
|
-
}
|
|
6212
|
-
|
|
6213
|
-
twisty-alg-leaf-elem.twisty-alg-comment {
|
|
6214
|
-
color: rgba(0, 0, 0, 0.4);
|
|
6215
|
-
}
|
|
6216
|
-
|
|
6217
|
-
.wrapper.current-move {
|
|
6218
|
-
background: rgba(66, 133, 244, 0.3);
|
|
6219
|
-
margin-left: -0.1em;
|
|
6220
|
-
margin-right: -0.1em;
|
|
6221
|
-
padding-left: 0.1em;
|
|
6222
|
-
padding-right: 0.1em;
|
|
6223
|
-
border-radius: 0.1em;
|
|
6224
|
-
}
|
|
6225
|
-
`);
|
|
6226
|
-
|
|
6227
|
-
// src/cubing/twisty/old/dom/TwistyAlgViewerV1.ts
|
|
6228
|
-
var DEFAULT_OFFSET_MS2 = 250;
|
|
6229
|
-
var TwistyAlgLeafElemV1 = class extends ManagedCustomElement {
|
|
6230
|
-
constructor(className, text, dataDown, algOrUnit, offsetIntoMove, clickable) {
|
|
6231
|
-
super({ mode: "open" });
|
|
6232
|
-
this.algOrUnit = algOrUnit;
|
|
6233
|
-
this.classList.add(className);
|
|
6234
|
-
this.addCSS(twistyAlgViewerCSS2);
|
|
6235
|
-
if (clickable) {
|
|
6236
|
-
const anchor = this.contentWrapper.appendChild(document.createElement("a"));
|
|
6237
|
-
anchor.href = "#";
|
|
6238
|
-
anchor.textContent = text;
|
|
6239
|
-
anchor.addEventListener("click", (e) => {
|
|
6240
|
-
e.preventDefault();
|
|
6241
|
-
dataDown.twistyAlgViewer.jumpToIndex(dataDown.earliestMoveIndex, offsetIntoMove);
|
|
6242
|
-
});
|
|
6243
|
-
} else {
|
|
6244
|
-
this.contentWrapper.appendChild(document.createElement("span")).textContent = text;
|
|
6245
|
-
}
|
|
6246
|
-
}
|
|
6247
|
-
pathToIndex(_index) {
|
|
6248
|
-
return [];
|
|
6249
|
-
}
|
|
6250
|
-
setCurrentMove(current) {
|
|
6251
|
-
this.contentWrapper.classList.toggle("current-move", current);
|
|
6252
|
-
}
|
|
6253
|
-
};
|
|
6254
|
-
customElementsShim.define("twisty-alg-leaf-elem-v1", TwistyAlgLeafElemV1);
|
|
6255
|
-
var TwistyAlgWrapperElemV1 = class extends HTMLElementShim {
|
|
6256
|
-
constructor(className, algOrUnit) {
|
|
6257
|
-
super();
|
|
6258
|
-
this.algOrUnit = algOrUnit;
|
|
6259
|
-
this.queue = [];
|
|
6260
|
-
this.classList.add(className);
|
|
6261
|
-
}
|
|
6262
|
-
addString(str) {
|
|
6263
|
-
this.queue.push(document.createTextNode(str));
|
|
6264
|
-
}
|
|
6265
|
-
addElem(dataUp) {
|
|
6266
|
-
this.queue.push(dataUp.element);
|
|
6267
|
-
return dataUp.moveCount;
|
|
6268
|
-
}
|
|
6269
|
-
flushQueue(direction = IterationDirection.Forwards) {
|
|
6270
|
-
for (const node of maybeReverseList2(this.queue, direction)) {
|
|
6271
|
-
this.append(node);
|
|
6272
|
-
}
|
|
6273
|
-
this.queue = [];
|
|
6274
|
-
}
|
|
6275
|
-
pathToIndex(_index) {
|
|
6276
|
-
return [];
|
|
6277
|
-
}
|
|
6278
|
-
};
|
|
6279
|
-
customElementsShim.define("twisty-alg-wrapper-elem-v1", TwistyAlgWrapperElemV1);
|
|
6280
|
-
function oppositeDirection2(direction) {
|
|
6281
|
-
return direction === IterationDirection.Forwards ? IterationDirection.Backwards : IterationDirection.Forwards;
|
|
6282
|
-
}
|
|
6283
|
-
function updateDirectionByAmount2(currentDirection, amount) {
|
|
6284
|
-
return amount < 0 ? oppositeDirection2(currentDirection) : currentDirection;
|
|
6285
|
-
}
|
|
6286
|
-
function maybeReverseList2(l, direction) {
|
|
6287
|
-
if (direction === IterationDirection.Forwards) {
|
|
6288
|
-
return l;
|
|
6289
|
-
}
|
|
6290
|
-
const copy = Array.from(l);
|
|
6291
|
-
copy.reverse();
|
|
6292
|
-
return copy;
|
|
6293
|
-
}
|
|
6294
|
-
var AlgToDOMTree2 = class extends TraversalDownUp {
|
|
6295
|
-
traverseAlg(alg, dataDown) {
|
|
6296
|
-
let moveCount = 0;
|
|
6297
|
-
const element = new TwistyAlgWrapperElemV1("twisty-alg-alg", alg);
|
|
6298
|
-
let first = true;
|
|
6299
|
-
for (const unit of direct(alg.units(), dataDown.direction)) {
|
|
6300
|
-
if (!first) {
|
|
6301
|
-
element.addString(" ");
|
|
6302
|
-
}
|
|
6303
|
-
first = false;
|
|
6304
|
-
moveCount += element.addElem(this.traverseUnit(unit, {
|
|
6305
|
-
earliestMoveIndex: dataDown.earliestMoveIndex + moveCount,
|
|
6306
|
-
twistyAlgViewer: dataDown.twistyAlgViewer,
|
|
6307
|
-
direction: dataDown.direction
|
|
6308
|
-
}));
|
|
6309
|
-
}
|
|
6310
|
-
element.flushQueue(dataDown.direction);
|
|
6311
|
-
return {
|
|
6312
|
-
moveCount,
|
|
6313
|
-
element
|
|
6314
|
-
};
|
|
6315
|
-
}
|
|
6316
|
-
traverseGrouping(grouping, dataDown) {
|
|
6317
|
-
const square1Tuple = grouping.experimentalAsSquare1Tuple();
|
|
6318
|
-
const direction = updateDirectionByAmount2(dataDown.direction, grouping.amount);
|
|
6319
|
-
let moveCount = 0;
|
|
6320
|
-
const element = new TwistyAlgWrapperElemV1("twisty-alg-grouping", grouping);
|
|
6321
|
-
element.addString("(");
|
|
6322
|
-
if (square1Tuple) {
|
|
6323
|
-
moveCount += element.addElem({
|
|
6324
|
-
moveCount: 1,
|
|
6325
|
-
element: new TwistyAlgLeafElemV1("twisty-alg-move", square1Tuple[0].amount.toString(), dataDown, square1Tuple[0], true, true)
|
|
6326
|
-
});
|
|
6327
|
-
element.addString(", ");
|
|
6328
|
-
moveCount += element.addElem({
|
|
6329
|
-
moveCount: 1,
|
|
6330
|
-
element: new TwistyAlgLeafElemV1("twisty-alg-move", square1Tuple[1].amount.toString(), dataDown, square1Tuple[1], true, true)
|
|
6331
|
-
});
|
|
6332
|
-
} else {
|
|
6333
|
-
moveCount += element.addElem(this.traverseAlg(grouping.alg, {
|
|
6334
|
-
earliestMoveIndex: dataDown.earliestMoveIndex + moveCount,
|
|
6335
|
-
twistyAlgViewer: dataDown.twistyAlgViewer,
|
|
6336
|
-
direction
|
|
6337
|
-
}));
|
|
6338
|
-
}
|
|
6339
|
-
element.addString(")" + grouping.experimentalRepetitionSuffix);
|
|
6340
|
-
element.flushQueue();
|
|
6341
|
-
return {
|
|
6342
|
-
moveCount: moveCount * Math.abs(grouping.amount),
|
|
6343
|
-
element
|
|
6344
|
-
};
|
|
6345
|
-
}
|
|
6346
|
-
traverseMove(move, dataDown) {
|
|
6347
|
-
const element = new TwistyAlgLeafElemV1("twisty-alg-move", move.toString(), dataDown, move, true, true);
|
|
6348
|
-
dataDown.twistyAlgViewer.highlighter.addMove(move.startCharIndex, element);
|
|
6349
|
-
return {
|
|
6350
|
-
moveCount: 1,
|
|
6351
|
-
element
|
|
6352
|
-
};
|
|
6353
|
-
}
|
|
6354
|
-
traverseCommutator(commutator, dataDown) {
|
|
6355
|
-
let moveCount = 0;
|
|
6356
|
-
const element = new TwistyAlgWrapperElemV1("twisty-alg-commutator", commutator);
|
|
6357
|
-
element.addString("[");
|
|
6358
|
-
element.flushQueue();
|
|
6359
|
-
const [first, second] = maybeReverseList2([commutator.A, commutator.B], dataDown.direction);
|
|
6360
|
-
moveCount += element.addElem(this.traverseAlg(first, {
|
|
6361
|
-
earliestMoveIndex: dataDown.earliestMoveIndex + moveCount,
|
|
6362
|
-
twistyAlgViewer: dataDown.twistyAlgViewer,
|
|
6363
|
-
direction: dataDown.direction
|
|
6364
|
-
}));
|
|
6365
|
-
element.addString(", ");
|
|
6366
|
-
moveCount += element.addElem(this.traverseAlg(second, {
|
|
6367
|
-
earliestMoveIndex: dataDown.earliestMoveIndex + moveCount,
|
|
6368
|
-
twistyAlgViewer: dataDown.twistyAlgViewer,
|
|
6369
|
-
direction: dataDown.direction
|
|
6370
|
-
}));
|
|
6371
|
-
element.flushQueue(dataDown.direction);
|
|
6372
|
-
element.addString("]");
|
|
6373
|
-
element.flushQueue();
|
|
6374
|
-
return {
|
|
6375
|
-
moveCount: moveCount * 2,
|
|
6376
|
-
element
|
|
6377
|
-
};
|
|
6378
|
-
}
|
|
6379
|
-
traverseConjugate(conjugate, dataDown) {
|
|
6380
|
-
let moveCount = 0;
|
|
6381
|
-
const element = new TwistyAlgWrapperElemV1("twisty-alg-conjugate", conjugate);
|
|
6382
|
-
element.addString("[");
|
|
6383
|
-
const aLen = element.addElem(this.traverseAlg(conjugate.A, {
|
|
6384
|
-
earliestMoveIndex: dataDown.earliestMoveIndex + moveCount,
|
|
6385
|
-
twistyAlgViewer: dataDown.twistyAlgViewer,
|
|
6386
|
-
direction: dataDown.direction
|
|
6387
|
-
}));
|
|
6388
|
-
moveCount += aLen;
|
|
6389
|
-
element.addString(": ");
|
|
6390
|
-
moveCount += element.addElem(this.traverseAlg(conjugate.B, {
|
|
6391
|
-
earliestMoveIndex: dataDown.earliestMoveIndex + moveCount,
|
|
6392
|
-
twistyAlgViewer: dataDown.twistyAlgViewer,
|
|
6393
|
-
direction: dataDown.direction
|
|
6394
|
-
}));
|
|
6395
|
-
element.addString("]");
|
|
6396
|
-
element.flushQueue();
|
|
6397
|
-
return {
|
|
6398
|
-
moveCount: moveCount + aLen,
|
|
6399
|
-
element
|
|
6400
|
-
};
|
|
6401
|
-
}
|
|
6402
|
-
traversePause(pause, dataDown) {
|
|
6403
|
-
return {
|
|
6404
|
-
moveCount: 1,
|
|
6405
|
-
element: new TwistyAlgLeafElemV1("twisty-alg-pause", ".", dataDown, pause, true, true)
|
|
6406
|
-
};
|
|
6407
|
-
}
|
|
6408
|
-
traverseNewline(newline, _dataDown) {
|
|
6409
|
-
const element = new TwistyAlgWrapperElemV1("twisty-alg-newline", newline);
|
|
6410
|
-
element.append(document.createElement("br"));
|
|
6411
|
-
return {
|
|
6412
|
-
moveCount: 0,
|
|
6413
|
-
element
|
|
6414
|
-
};
|
|
6415
|
-
}
|
|
6416
|
-
traverseLineComment(lineComment, dataDown) {
|
|
6417
|
-
return {
|
|
6418
|
-
moveCount: 0,
|
|
6419
|
-
element: new TwistyAlgLeafElemV1("twisty-alg-line-comment", `//${lineComment.text}`, dataDown, lineComment, false, false)
|
|
6420
|
-
};
|
|
6421
|
-
}
|
|
6422
|
-
};
|
|
6423
|
-
var algToDOMTreeInstance2 = new AlgToDOMTree2();
|
|
6424
|
-
var algToDOMTree2 = algToDOMTreeInstance2.traverseAlg.bind(algToDOMTreeInstance2);
|
|
6425
|
-
var MoveHighlighter2 = class {
|
|
6426
|
-
constructor() {
|
|
6427
|
-
this.moveCharIndexMap = new Map();
|
|
6428
|
-
this.currentElem = null;
|
|
6429
|
-
}
|
|
6430
|
-
addMove(charIndex, elem) {
|
|
6431
|
-
this.moveCharIndexMap.set(charIndex, elem);
|
|
6432
|
-
}
|
|
6433
|
-
set(move) {
|
|
6434
|
-
const newElem = move ? this.moveCharIndexMap.get(move.startCharIndex) ?? null : null;
|
|
6435
|
-
if (this.currentElem === newElem) {
|
|
6436
|
-
return;
|
|
6437
|
-
}
|
|
6438
|
-
this.currentElem?.classList.remove("twisty-alg-current-move");
|
|
6439
|
-
this.currentElem?.setCurrentMove(false);
|
|
6440
|
-
newElem?.classList.add("twisty-alg-current-move");
|
|
6441
|
-
newElem?.setCurrentMove(true);
|
|
6442
|
-
this.currentElem = newElem;
|
|
6443
|
-
}
|
|
6444
|
-
};
|
|
6445
|
-
var _domTree2;
|
|
6446
|
-
var TwistyAlgViewerV1 = class extends HTMLElementShim {
|
|
6447
|
-
constructor(options) {
|
|
6448
|
-
super();
|
|
6449
|
-
this.highlighter = new MoveHighlighter2();
|
|
6450
|
-
__privateAdd(this, _domTree2, void 0);
|
|
6451
|
-
this.twistyPlayer = null;
|
|
6452
|
-
this.lastClickTimestamp = null;
|
|
6453
|
-
if (options?.twistyPlayer) {
|
|
6454
|
-
this.setTwistyPlayer(options?.twistyPlayer);
|
|
6455
|
-
}
|
|
6456
|
-
}
|
|
6457
|
-
connectedCallback() {
|
|
6458
|
-
}
|
|
6459
|
-
setAlg(alg) {
|
|
6460
|
-
__privateSet(this, _domTree2, algToDOMTree2(alg, {
|
|
6461
|
-
earliestMoveIndex: 0,
|
|
6462
|
-
twistyAlgViewer: this,
|
|
6463
|
-
direction: IterationDirection.Forwards
|
|
6464
|
-
}).element);
|
|
6465
|
-
this.textContent = "";
|
|
6466
|
-
this.appendChild(__privateGet(this, _domTree2));
|
|
6467
|
-
}
|
|
6468
|
-
setTwistyPlayer(twistyPlayer) {
|
|
6469
|
-
if (this.twistyPlayer) {
|
|
6470
|
-
console.warn("twisty-player reassignment is not supported");
|
|
6471
|
-
return;
|
|
6472
|
-
}
|
|
6473
|
-
this.twistyPlayer = twistyPlayer;
|
|
6474
|
-
this.twistyPlayer.addEventListener("experimental-alg-update", (e) => {
|
|
6475
|
-
this.setAlg(e.detail.alg);
|
|
6476
|
-
});
|
|
6477
|
-
const sourceAlg = this.twistyPlayer.alg;
|
|
6478
|
-
const parsedAlg = "charIndex" in sourceAlg ? sourceAlg : Alg.fromString(sourceAlg.toString());
|
|
6479
|
-
this.setAlg(parsedAlg);
|
|
6480
|
-
(async () => {
|
|
6481
|
-
const wrapper = new KPuzzleWrapper(await puzzles[twistyPlayer.puzzle].def());
|
|
6482
|
-
const indexer = new TreeAlgIndexer(wrapper, parsedAlg);
|
|
6483
|
-
twistyPlayer.timeline.addTimestampListener({
|
|
6484
|
-
onTimelineTimestampChange: (timestamp) => {
|
|
6485
|
-
this.highlighter.set(indexer.getAnimLeaf(indexer.timestampToIndex(timestamp)));
|
|
6486
|
-
},
|
|
6487
|
-
onTimeRangeChange(_timeRange) {
|
|
6488
|
-
}
|
|
6489
|
-
});
|
|
6490
|
-
})();
|
|
6491
|
-
twistyPlayer.timeline.addTimestampListener({
|
|
6492
|
-
onTimelineTimestampChange: (timestamp) => {
|
|
6493
|
-
if (timestamp !== this.lastClickTimestamp) {
|
|
6494
|
-
this.lastClickTimestamp = null;
|
|
6495
|
-
}
|
|
6496
|
-
const index = this.twistyPlayer?.cursor?.experimentalIndexFromTimestamp(timestamp) ?? null;
|
|
6497
|
-
if (index !== null) {
|
|
6498
|
-
}
|
|
6499
|
-
},
|
|
6500
|
-
onTimeRangeChange: (_timeRange) => {
|
|
6501
|
-
}
|
|
6502
|
-
});
|
|
6503
|
-
}
|
|
6504
|
-
jumpToIndex(index, offsetIntoMove) {
|
|
6505
|
-
if (this.twistyPlayer && this.twistyPlayer.cursor) {
|
|
6506
|
-
const offset = offsetIntoMove ? DEFAULT_OFFSET_MS2 : 0;
|
|
6507
|
-
const timestamp = (this.twistyPlayer.cursor.experimentalTimestampFromIndex(index) ?? -offset) + offset;
|
|
6508
|
-
this.twistyPlayer?.timeline.setTimestamp(timestamp);
|
|
6509
|
-
if (this.lastClickTimestamp === timestamp) {
|
|
6510
|
-
this.twistyPlayer.timeline.play();
|
|
6511
|
-
this.lastClickTimestamp = null;
|
|
6512
|
-
} else {
|
|
6513
|
-
this.lastClickTimestamp = timestamp;
|
|
6514
|
-
}
|
|
6515
|
-
}
|
|
6516
|
-
}
|
|
6517
|
-
attributeChangedCallback(attributeName, _oldValue, newValue) {
|
|
6518
|
-
if (attributeName === "for") {
|
|
6519
|
-
const elem = document.getElementById(newValue);
|
|
6520
|
-
if (!elem) {
|
|
6521
|
-
console.warn("for= elem does not exist");
|
|
6522
|
-
return;
|
|
6523
|
-
}
|
|
6524
|
-
if (!(elem instanceof TwistyPlayerV1)) {
|
|
6525
|
-
console.warn("for= elem is not a twisty-player");
|
|
6526
|
-
return;
|
|
6527
|
-
}
|
|
6528
|
-
this.setTwistyPlayer(elem);
|
|
6529
|
-
}
|
|
6530
|
-
}
|
|
6531
|
-
static get observedAttributes() {
|
|
6532
|
-
return ["for"];
|
|
6533
|
-
}
|
|
6534
|
-
};
|
|
6535
|
-
_domTree2 = new WeakMap();
|
|
6536
|
-
customElementsShim.define("twisty-alg-viewer-v1", TwistyAlgViewerV1);
|
|
6537
4914
|
export {
|
|
6538
4915
|
Cube3D,
|
|
6539
4916
|
NO_VALUE as EXPERIMENTAL_PROP_NO_VALUE,
|
|
6540
4917
|
KPuzzleWrapper as KSolvePuzzle,
|
|
6541
4918
|
PG3D,
|
|
6542
4919
|
SimpleAlgIndexer,
|
|
6543
|
-
TimestampLocationType,
|
|
6544
4920
|
TreeAlgIndexer,
|
|
6545
|
-
Twisty3DCanvas,
|
|
6546
4921
|
TwistyAlgEditor,
|
|
6547
4922
|
TwistyAlgViewer,
|
|
6548
|
-
TwistyAlgViewerV1,
|
|
6549
4923
|
TwistyPlayer,
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
4924
|
+
backViewLayouts,
|
|
4925
|
+
debugShowRenderStats as experimentalDebugShowRenderStats,
|
|
4926
|
+
experimentalForceNewRendererSharing
|
|
6553
4927
|
};
|
|
6554
4928
|
//# sourceMappingURL=index.js.map
|