@pretty-chitty/core 2.0.0 → 2.3.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/README.md +8 -0
- package/dist/components/ActionLogDisplay.d.ts.map +1 -1
- package/dist/components/ActionLogDisplay.js +1 -1
- package/dist/components/ActionLogDisplay.js.map +1 -1
- package/dist/components/BottomBarButton.d.ts +3 -1
- package/dist/components/BottomBarButton.d.ts.map +1 -1
- package/dist/components/BottomBarButton.js +3 -2
- package/dist/components/BottomBarButton.js.map +1 -1
- package/dist/components/ContextGalleryDisplay.d.ts.map +1 -1
- package/dist/components/ContextGalleryDisplay.js +1 -1
- package/dist/components/ContextGalleryDisplay.js.map +1 -1
- package/dist/components/DemoWrapper.d.ts +33 -2
- package/dist/components/DemoWrapper.d.ts.map +1 -1
- package/dist/components/DemoWrapper.js +77 -36
- package/dist/components/DemoWrapper.js.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.d.ts.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.js +2 -2
- package/dist/components/FullScreenGalleryDisplay.js.map +1 -1
- package/dist/components/Gallery/BuiltItem.d.ts +16 -2
- package/dist/components/Gallery/BuiltItem.d.ts.map +1 -1
- package/dist/components/Gallery/BuiltItem.js +92 -16
- package/dist/components/Gallery/BuiltItem.js.map +1 -1
- package/dist/components/Gallery/GalleryController.d.ts +26 -0
- package/dist/components/Gallery/GalleryController.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryController.js +106 -6
- package/dist/components/Gallery/GalleryController.js.map +1 -1
- package/dist/components/Gallery/GalleryViewer.d.ts +6 -1
- package/dist/components/Gallery/GalleryViewer.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryViewer.js +139 -12
- package/dist/components/Gallery/GalleryViewer.js.map +1 -1
- package/dist/components/Gallery/LayoutManager.d.ts +10 -0
- package/dist/components/Gallery/LayoutManager.d.ts.map +1 -1
- package/dist/components/Gallery/LayoutManager.js +49 -3
- package/dist/components/Gallery/LayoutManager.js.map +1 -1
- package/dist/components/Gallery/constants.d.ts +6 -0
- package/dist/components/Gallery/constants.d.ts.map +1 -1
- package/dist/components/Gallery/constants.js +6 -0
- package/dist/components/Gallery/constants.js.map +1 -1
- package/dist/components/Gallery/registry.d.ts +34 -0
- package/dist/components/Gallery/registry.d.ts.map +1 -0
- package/dist/components/Gallery/registry.js +17 -0
- package/dist/components/Gallery/registry.js.map +1 -0
- package/dist/components/Gallery/types.d.ts +5 -0
- package/dist/components/Gallery/types.d.ts.map +1 -1
- package/dist/components/GameDesigner.d.ts.map +1 -1
- package/dist/components/GameDesigner.js +84 -10
- package/dist/components/GameDesigner.js.map +1 -1
- package/dist/components/InlineGalleryDisplay.d.ts.map +1 -1
- package/dist/components/InlineGalleryDisplay.js +35 -8
- package/dist/components/InlineGalleryDisplay.js.map +1 -1
- package/dist/components/LiveButton.d.ts.map +1 -1
- package/dist/components/LiveButton.js +5 -2
- package/dist/components/LiveButton.js.map +1 -1
- package/dist/components/MatchViewer.d.ts +6 -1
- package/dist/components/MatchViewer.d.ts.map +1 -1
- package/dist/components/MatchViewer.js +9 -3
- package/dist/components/MatchViewer.js.map +1 -1
- package/dist/components/Panel/ExternalDrag.d.ts +30 -0
- package/dist/components/Panel/ExternalDrag.d.ts.map +1 -0
- package/dist/components/Panel/ExternalDrag.js +87 -0
- package/dist/components/Panel/ExternalDrag.js.map +1 -0
- package/dist/components/Panel/MultiPanel.d.ts.map +1 -1
- package/dist/components/Panel/MultiPanel.js +18 -0
- package/dist/components/Panel/MultiPanel.js.map +1 -1
- package/dist/components/Panel/PanelContents.d.ts +3 -0
- package/dist/components/Panel/PanelContents.d.ts.map +1 -1
- package/dist/components/Panel/PanelContents.js +116 -23
- package/dist/components/Panel/PanelContents.js.map +1 -1
- package/dist/components/Panel/PanelTabStack.d.ts.map +1 -1
- package/dist/components/Panel/PanelTabStack.js +1 -1
- package/dist/components/Panel/PanelTabStack.js.map +1 -1
- package/dist/components/PanelSpark.d.ts.map +1 -1
- package/dist/components/PanelSpark.js +6 -3
- package/dist/components/PanelSpark.js.map +1 -1
- package/dist/components/Playground.d.ts.map +1 -1
- package/dist/components/Playground.js +10 -4
- package/dist/components/Playground.js.map +1 -1
- package/dist/components/PromptControls.d.ts.map +1 -1
- package/dist/components/PromptControls.js +4 -2
- package/dist/components/PromptControls.js.map +1 -1
- package/dist/components/SparkLineChart.d.ts.map +1 -1
- package/dist/components/SparkLineChart.js +22 -26
- package/dist/components/SparkLineChart.js.map +1 -1
- package/dist/components/TimeControlBar.d.ts.map +1 -1
- package/dist/components/TimeControlBar.js +5 -3
- package/dist/components/TimeControlBar.js.map +1 -1
- package/dist/components/TokenizedMarkdown.d.ts +23 -0
- package/dist/components/TokenizedMarkdown.d.ts.map +1 -0
- package/dist/components/TokenizedMarkdown.js +144 -0
- package/dist/components/TokenizedMarkdown.js.map +1 -0
- package/dist/components/TokenizedMessage.d.ts +6 -0
- package/dist/components/TokenizedMessage.d.ts.map +1 -1
- package/dist/components/TokenizedMessage.js +20 -19
- package/dist/components/TokenizedMessage.js.map +1 -1
- package/dist/components/TopBar.d.ts.map +1 -1
- package/dist/components/TopBar.js +3 -1
- package/dist/components/TopBar.js.map +1 -1
- package/dist/components/TopBarPlayers.d.ts.map +1 -1
- package/dist/components/TopBarPlayers.js +2 -2
- package/dist/components/TopBarPlayers.js.map +1 -1
- package/dist/components/Tutorial/BrowserNarration.d.ts +55 -0
- package/dist/components/Tutorial/BrowserNarration.d.ts.map +1 -0
- package/dist/components/Tutorial/BrowserNarration.js +240 -0
- package/dist/components/Tutorial/BrowserNarration.js.map +1 -0
- package/dist/components/Tutorial/TutorialBox.d.ts +26 -0
- package/dist/components/Tutorial/TutorialBox.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialBox.js +239 -0
- package/dist/components/Tutorial/TutorialBox.js.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts +9 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.js +92 -0
- package/dist/components/Tutorial/TutorialDevPanel.js.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts +7 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.js +1147 -0
- package/dist/components/Tutorial/TutorialOverlay.js.map +1 -0
- package/dist/components/Tutorial/targetRects.d.ts +67 -0
- package/dist/components/Tutorial/targetRects.d.ts.map +1 -0
- package/dist/components/Tutorial/targetRects.js +241 -0
- package/dist/components/Tutorial/targetRects.js.map +1 -0
- package/dist/components/Viewer.d.ts.map +1 -1
- package/dist/components/Viewer.js +1 -0
- package/dist/components/Viewer.js.map +1 -1
- package/dist/game/Chit.d.ts +10 -1
- package/dist/game/Chit.d.ts.map +1 -1
- package/dist/game/Chit.js +24 -6
- package/dist/game/Chit.js.map +1 -1
- package/dist/game/ClientTimeState.d.ts +14 -0
- package/dist/game/ClientTimeState.d.ts.map +1 -1
- package/dist/game/ClientTimeState.js +17 -0
- package/dist/game/ClientTimeState.js.map +1 -1
- package/dist/game/GalleryItemChitChildrenSource.d.ts +1 -0
- package/dist/game/GalleryItemChitChildrenSource.d.ts.map +1 -1
- package/dist/game/GalleryItemChitChildrenSource.js +1 -0
- package/dist/game/GalleryItemChitChildrenSource.js.map +1 -1
- package/dist/game/GalleryItemRawSource.d.ts +1 -0
- package/dist/game/GalleryItemRawSource.d.ts.map +1 -1
- package/dist/game/GalleryItemRawSource.js +1 -0
- package/dist/game/GalleryItemRawSource.js.map +1 -1
- package/dist/game/Game.d.ts +6 -0
- package/dist/game/Game.d.ts.map +1 -1
- package/dist/game/GameButton.d.ts +8 -0
- package/dist/game/GameButton.d.ts.map +1 -1
- package/dist/game/GameButton.js +13 -1
- package/dist/game/GameButton.js.map +1 -1
- package/dist/game/GameTheme.d.ts +3 -0
- package/dist/game/GameTheme.d.ts.map +1 -1
- package/dist/game/GameTheme.js +2 -0
- package/dist/game/GameTheme.js.map +1 -1
- package/dist/game/Match.d.ts +8 -2
- package/dist/game/Match.d.ts.map +1 -1
- package/dist/game/Match.js +4 -1
- package/dist/game/Match.js.map +1 -1
- package/dist/game/ModalState.d.ts +3 -0
- package/dist/game/ModalState.d.ts.map +1 -1
- package/dist/game/ModalState.js +2 -0
- package/dist/game/ModalState.js.map +1 -1
- package/dist/game/Pick.d.ts +2 -0
- package/dist/game/Pick.d.ts.map +1 -1
- package/dist/game/Pick.js +18 -4
- package/dist/game/Pick.js.map +1 -1
- package/dist/game/PlayerPromptStatusChit.d.ts +8 -0
- package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -1
- package/dist/game/PlayerPromptStatusChit.js +6 -4
- package/dist/game/PlayerPromptStatusChit.js.map +1 -1
- package/dist/game/Prompt.d.ts +18 -1
- package/dist/game/Prompt.d.ts.map +1 -1
- package/dist/game/Prompt.js +29 -1
- package/dist/game/Prompt.js.map +1 -1
- package/dist/game/SparkChit.d.ts +6 -0
- package/dist/game/SparkChit.d.ts.map +1 -1
- package/dist/game/SparkChit.js +8 -0
- package/dist/game/SparkChit.js.map +1 -1
- package/dist/game/Turn.d.ts +17 -6
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +179 -69
- package/dist/game/Turn.js.map +1 -1
- package/dist/game/TurnState.d.ts +12 -1
- package/dist/game/TurnState.d.ts.map +1 -1
- package/dist/game/TurnState.js +15 -3
- package/dist/game/TurnState.js.map +1 -1
- package/dist/game/ai/AiClientPrompts.d.ts +20 -3
- package/dist/game/ai/AiClientPrompts.d.ts.map +1 -1
- package/dist/game/ai/AiClientPrompts.js +42 -6
- package/dist/game/ai/AiClientPrompts.js.map +1 -1
- package/dist/game/ai/AiPlayerView.js +2 -0
- package/dist/game/ai/AiPlayerView.js.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts +22 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.js +72 -5
- package/dist/game/clientTransport/ClientPrompts.js.map +1 -1
- package/dist/game/clientTransport/ClientTime.d.ts +13 -0
- package/dist/game/clientTransport/ClientTime.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientTime.js +71 -12
- package/dist/game/clientTransport/ClientTime.js.map +1 -1
- package/dist/game/tutorial/TutorialController.d.ts +308 -0
- package/dist/game/tutorial/TutorialController.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialController.js +1195 -0
- package/dist/game/tutorial/TutorialController.js.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts +89 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.js +261 -0
- package/dist/game/tutorial/TutorialRuntime.js.map +1 -0
- package/dist/game/tutorial/TutorialTheme.d.ts +28 -0
- package/dist/game/tutorial/TutorialTheme.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialTheme.js +39 -0
- package/dist/game/tutorial/TutorialTheme.js.map +1 -0
- package/dist/game/tutorial/allowed.d.ts +2 -0
- package/dist/game/tutorial/allowed.d.ts.map +1 -0
- package/dist/game/tutorial/allowed.js +119 -0
- package/dist/game/tutorial/allowed.js.map +1 -0
- package/dist/game/tutorial/checks.d.ts +58 -0
- package/dist/game/tutorial/checks.d.ts.map +1 -0
- package/dist/game/tutorial/checks.js +144 -0
- package/dist/game/tutorial/checks.js.map +1 -0
- package/dist/game/tutorial/createDemoMatch.d.ts +47 -0
- package/dist/game/tutorial/createDemoMatch.d.ts.map +1 -0
- package/dist/game/tutorial/createDemoMatch.js +67 -0
- package/dist/game/tutorial/createDemoMatch.js.map +1 -0
- package/dist/game/tutorial/defineTutorial.d.ts +353 -0
- package/dist/game/tutorial/defineTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/defineTutorial.js +86 -0
- package/dist/game/tutorial/defineTutorial.js.map +1 -0
- package/dist/game/tutorial/runTutorial.d.ts +64 -0
- package/dist/game/tutorial/runTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/runTutorial.js +293 -0
- package/dist/game/tutorial/runTutorial.js.map +1 -0
- package/dist/hooks/usePanelNavigation.d.ts +28 -0
- package/dist/hooks/usePanelNavigation.d.ts.map +1 -0
- package/dist/hooks/usePanelNavigation.js +36 -0
- package/dist/hooks/usePanelNavigation.js.map +1 -0
- package/dist/hooks/useTimeController.d.ts +4 -1
- package/dist/hooks/useTimeController.d.ts.map +1 -1
- package/dist/hooks/useTimeController.js +10 -2
- package/dist/hooks/useTimeController.js.map +1 -1
- package/dist/hooks/useTutorial.d.ts +51 -0
- package/dist/hooks/useTutorial.d.ts.map +1 -0
- package/dist/hooks/useTutorial.js +16 -0
- package/dist/hooks/useTutorial.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/rendering/CameraWrapperPerspective.d.ts +5 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -1
- package/dist/rendering/CameraWrapperPerspective.js +16 -0
- package/dist/rendering/CameraWrapperPerspective.js.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.d.ts +14 -3
- package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.js +29 -1
- package/dist/rendering/ChitGalleryItemInstance.js.map +1 -1
- package/dist/rendering/ChitRenderInstance.d.ts +15 -1
- package/dist/rendering/ChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/ChitRenderInstance.js +49 -4
- package/dist/rendering/ChitRenderInstance.js.map +1 -1
- package/dist/rendering/LightWrapper.d.ts.map +1 -1
- package/dist/rendering/LightWrapper.js +10 -1
- package/dist/rendering/LightWrapper.js.map +1 -1
- package/dist/rendering/RootChitRenderInstance.d.ts +2 -0
- package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/RootChitRenderInstance.js +29 -0
- package/dist/rendering/RootChitRenderInstance.js.map +1 -1
- package/dist/rendering/Splay.d.ts +11 -0
- package/dist/rendering/Splay.d.ts.map +1 -1
- package/dist/rendering/Splay.js +20 -10
- package/dist/rendering/Splay.js.map +1 -1
- package/dist/utilities/Annotations.d.ts +15 -0
- package/dist/utilities/Annotations.d.ts.map +1 -1
- package/dist/utilities/Annotations.js +31 -7
- package/dist/utilities/Annotations.js.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.d.ts +2 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.js +4 -0
- package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -1
- package/dist/utilities/CanvasStack/RichTextRenderer.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/RichTextRenderer.js +12 -0
- package/dist/utilities/CanvasStack/RichTextRenderer.js.map +1 -1
- package/dist/utilities/Dice.d.ts +2 -0
- package/dist/utilities/Dice.d.ts.map +1 -1
- package/dist/utilities/Dice.js +5 -1
- package/dist/utilities/Dice.js.map +1 -1
- package/dist/utilities/GalleryItemConversion.d.ts.map +1 -1
- package/dist/utilities/GalleryItemConversion.js +5 -7
- package/dist/utilities/GalleryItemConversion.js.map +1 -1
- package/dist/utilities/TokenizedText.d.ts +6 -0
- package/dist/utilities/TokenizedText.d.ts.map +1 -1
- package/dist/utilities/TokenizedText.js.map +1 -1
- package/dist/utilities/zIndex.d.ts +1 -0
- package/dist/utilities/zIndex.d.ts.map +1 -1
- package/dist/utilities/zIndex.js +1 -0
- package/dist/utilities/zIndex.js.map +1 -1
- package/package.json +3 -2
- package/src/library/components/ActionLogDisplay.tsx +1 -0
- package/src/library/components/BottomBarButton.tsx +5 -0
- package/src/library/components/ContextGalleryDisplay.tsx +2 -0
- package/src/library/components/DemoWrapper.tsx +150 -44
- package/src/library/components/FullScreenGalleryDisplay.tsx +3 -0
- package/src/library/components/Gallery/BuiltItem.ts +92 -16
- package/src/library/components/Gallery/GalleryController.ts +111 -10
- package/src/library/components/Gallery/GalleryViewer.tsx +144 -12
- package/src/library/components/Gallery/LayoutManager.ts +55 -6
- package/src/library/components/Gallery/constants.ts +6 -0
- package/src/library/components/Gallery/registry.ts +44 -0
- package/src/library/components/Gallery/types.ts +6 -0
- package/src/library/components/GameDesigner.tsx +165 -12
- package/src/library/components/InlineGalleryDisplay.tsx +41 -6
- package/src/library/components/LiveButton.tsx +8 -5
- package/src/library/components/MatchViewer.tsx +14 -3
- package/src/library/components/Panel/ExternalDrag.ts +122 -0
- package/src/library/components/Panel/MultiPanel.tsx +21 -0
- package/src/library/components/Panel/PanelContents.tsx +96 -1
- package/src/library/components/Panel/PanelTabStack.tsx +1 -0
- package/src/library/components/PanelSpark.tsx +12 -5
- package/src/library/components/Playground.tsx +48 -21
- package/src/library/components/PromptControls.tsx +7 -3
- package/src/library/components/SparkLineChart.tsx +23 -27
- package/src/library/components/TimeControlBar.tsx +5 -3
- package/src/library/components/TokenizedMarkdown.tsx +224 -0
- package/src/library/components/TokenizedMessage.tsx +28 -32
- package/src/library/components/TopBar.tsx +2 -1
- package/src/library/components/TopBarPlayers.tsx +13 -15
- package/src/library/components/Tutorial/BrowserNarration.ts +233 -0
- package/src/library/components/Tutorial/TutorialBox.tsx +506 -0
- package/src/library/components/Tutorial/TutorialDevPanel.tsx +297 -0
- package/src/library/components/Tutorial/TutorialOverlay.tsx +1316 -0
- package/src/library/components/Tutorial/targetRects.ts +273 -0
- package/src/library/components/Viewer.tsx +1 -0
- package/src/library/game/Chit.ts +28 -7
- package/src/library/game/ClientTimeState.ts +18 -0
- package/src/library/game/GalleryItemChitChildrenSource.ts +1 -0
- package/src/library/game/GalleryItemRawSource.ts +1 -0
- package/src/library/game/Game.ts +7 -0
- package/src/library/game/GameButton.ts +13 -1
- package/src/library/game/GameTheme.ts +4 -0
- package/src/library/game/Match.ts +12 -2
- package/src/library/game/ModalState.ts +3 -0
- package/src/library/game/Pick.ts +17 -4
- package/src/library/game/PlayerPromptStatusChit.ts +6 -4
- package/src/library/game/Prompt.ts +33 -2
- package/src/library/game/SparkChit.ts +9 -0
- package/src/library/game/Turn.ts +185 -70
- package/src/library/game/TurnState.ts +26 -3
- package/src/library/game/ai/AI_GUIDE.md +10 -0
- package/src/library/game/ai/AiClientPrompts.ts +60 -11
- package/src/library/game/ai/AiPlayerView.ts +2 -0
- package/src/library/game/clientTransport/ClientPrompts.ts +76 -5
- package/src/library/game/clientTransport/ClientTime.ts +75 -14
- package/src/library/game/serialize.test.ts +275 -0
- package/src/library/game/tutorial/TUTORIAL_GUIDE.md +416 -0
- package/src/library/game/tutorial/TutorialController.test.ts +731 -0
- package/src/library/game/tutorial/TutorialController.ts +1299 -0
- package/src/library/game/tutorial/TutorialRuntime.ts +311 -0
- package/src/library/game/tutorial/TutorialTheme.ts +67 -0
- package/src/library/game/tutorial/allowed.ts +145 -0
- package/src/library/game/tutorial/checks.ts +186 -0
- package/src/library/game/tutorial/createDemoMatch.ts +115 -0
- package/src/library/game/tutorial/defineTutorial.ts +414 -0
- package/src/library/game/tutorial/runTutorial.ts +350 -0
- package/src/library/game/undo.test.ts +282 -0
- package/src/library/hooks/usePanelNavigation.tsx +65 -0
- package/src/library/hooks/useTimeController.tsx +10 -2
- package/src/library/hooks/useTutorial.tsx +80 -0
- package/src/library/index.ts +58 -2
- package/src/library/rendering/CameraWrapperPerspective.ts +17 -0
- package/src/library/rendering/ChitGalleryItemInstance.ts +30 -1
- package/src/library/rendering/ChitRenderInstance.ts +57 -4
- package/src/library/rendering/LightWrapper.ts +10 -1
- package/src/library/rendering/RootChitRenderInstance.ts +30 -1
- package/src/library/rendering/Splay.test.ts +60 -0
- package/src/library/rendering/Splay.ts +30 -9
- package/src/library/utilities/Annotations.ts +35 -7
- package/src/library/utilities/CanvasStack/CanvasStack.ts +6 -1
- package/src/library/utilities/CanvasStack/RichTextRenderer.ts +13 -0
- package/src/library/utilities/Dice.tsx +5 -1
- package/src/library/utilities/GalleryItemConversion.ts +5 -6
- package/src/library/utilities/TokenizedText.ts +6 -0
- package/src/library/utilities/zIndex.ts +1 -0
|
@@ -43,6 +43,10 @@ export function useClientPrompts() {
|
|
|
43
43
|
}
|
|
44
44
|
return result.clientPrompts;
|
|
45
45
|
}
|
|
46
|
+
/** The client prompts, or undefined where there is no connection (a viewer with no seat). */
|
|
47
|
+
export function useOptionalClientPrompts() {
|
|
48
|
+
return useContext(TimeControllerContext).clientPrompts;
|
|
49
|
+
}
|
|
46
50
|
export function useClientStatus() {
|
|
47
51
|
const result = useContext(TimeControllerContext);
|
|
48
52
|
if (!result.clientStatus) {
|
|
@@ -60,11 +64,15 @@ export function useAnimationSpeedMultiplier() {
|
|
|
60
64
|
return speed;
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
export function TimeControllerProvider({ children }: { children: ReactNode }) {
|
|
67
|
+
export function TimeControllerProvider({ children, skipReplay = false }: { children: ReactNode; skipReplay?: boolean }) {
|
|
64
68
|
const connection = useConnection();
|
|
65
69
|
const playerId = usePlayerId();
|
|
66
70
|
const game = useGame();
|
|
67
|
-
const [clientTimeState] = useState<ClientTimeState>(
|
|
71
|
+
const [clientTimeState] = useState<ClientTimeState>(() => {
|
|
72
|
+
const state = new ClientTimeState();
|
|
73
|
+
state.skipInitialReplay = skipReplay;
|
|
74
|
+
return state;
|
|
75
|
+
});
|
|
68
76
|
const [clientTime, setClientTime] = useState<ClientTime | null>(null);
|
|
69
77
|
const [clientPrompts, setClientPrompts] = useState<ClientPrompts<any, any> | undefined>(undefined);
|
|
70
78
|
const [clientStatus, setClientStatus] = useState<ClientStatus<any, any> | undefined>(undefined);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { createContext, ReactNode, useContext, useMemo, useState } from "react";
|
|
2
|
+
import { EventChannel } from "../utilities/EventChannel";
|
|
3
|
+
import { TutorialSpec } from "../game/tutorial/defineTutorial";
|
|
4
|
+
import { TutorialController, TutorialEvent } from "../game/tutorial/TutorialController";
|
|
5
|
+
import { TutorialRuntime } from "../game/tutorial/TutorialRuntime";
|
|
6
|
+
import { TutorialTheme } from "../game/tutorial/TutorialTheme";
|
|
7
|
+
import { MatchAiControls } from "../game/Match";
|
|
8
|
+
|
|
9
|
+
export type TutorialDevSettings = {
|
|
10
|
+
showTargetRects: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type TutorialContextValue = {
|
|
14
|
+
spec: TutorialSpec<any, any>;
|
|
15
|
+
runtime: TutorialRuntime<any, any>;
|
|
16
|
+
themeOverrides?: Partial<TutorialTheme>;
|
|
17
|
+
ai?: MatchAiControls;
|
|
18
|
+
onEvent?: (e: TutorialEvent) => void;
|
|
19
|
+
/** Set by the overlay once it has built the controller (it needs the match view, which lives inside MatchViewer) */
|
|
20
|
+
controller: EventChannel<TutorialController<any, any> | undefined>;
|
|
21
|
+
dev: EventChannel<TutorialDevSettings>;
|
|
22
|
+
/** Start muted (dev panel toggle) */
|
|
23
|
+
muted: EventChannel<boolean>;
|
|
24
|
+
/** Step to start on (dev panel restarts, rewinds) */
|
|
25
|
+
startAt: number;
|
|
26
|
+
/** Start the script without the Start tap (after a rewind or a dev restart) */
|
|
27
|
+
autoStart: boolean;
|
|
28
|
+
/** Start held (after Back): silent until the player presses Play */
|
|
29
|
+
startPaused: boolean;
|
|
30
|
+
/** A step id to go straight to once the board loads, played up to headlessly (a reload of /demo?step=) */
|
|
31
|
+
resumeAt?: string;
|
|
32
|
+
/** Serializes the match for a step snapshot; undefined when the host cannot rebuild the match */
|
|
33
|
+
snapshot?: () => unknown;
|
|
34
|
+
/** Puts the match back to the snapshot taken when `stepId` went live; false when there is none */
|
|
35
|
+
rewind?: (stepId: string) => Promise<boolean>;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const TutorialContext = createContext<TutorialContextValue | undefined>(undefined);
|
|
39
|
+
|
|
40
|
+
/** The running tutorial, or undefined when the match has none. */
|
|
41
|
+
export function useTutorial(): TutorialContextValue | undefined {
|
|
42
|
+
return useContext(TutorialContext);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function TutorialProvider({
|
|
46
|
+
spec,
|
|
47
|
+
runtime,
|
|
48
|
+
themeOverrides,
|
|
49
|
+
ai,
|
|
50
|
+
onEvent,
|
|
51
|
+
startAt = 0,
|
|
52
|
+
autoStart = false,
|
|
53
|
+
startPaused = false,
|
|
54
|
+
resumeAt,
|
|
55
|
+
snapshot,
|
|
56
|
+
rewind,
|
|
57
|
+
children,
|
|
58
|
+
}: {
|
|
59
|
+
spec: TutorialSpec<any, any>;
|
|
60
|
+
runtime: TutorialRuntime<any, any>;
|
|
61
|
+
themeOverrides?: Partial<TutorialTheme>;
|
|
62
|
+
ai?: MatchAiControls;
|
|
63
|
+
onEvent?: (e: TutorialEvent) => void;
|
|
64
|
+
startAt?: number;
|
|
65
|
+
autoStart?: boolean;
|
|
66
|
+
startPaused?: boolean;
|
|
67
|
+
resumeAt?: string;
|
|
68
|
+
snapshot?: () => unknown;
|
|
69
|
+
rewind?: (stepId: string) => Promise<boolean>;
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
}) {
|
|
72
|
+
const [controller] = useState(() => new EventChannel<TutorialController<any, any> | undefined>(undefined));
|
|
73
|
+
const [dev] = useState(() => new EventChannel<TutorialDevSettings>({ showTargetRects: false }));
|
|
74
|
+
const [muted] = useState(() => new EventChannel<boolean>(false));
|
|
75
|
+
const value = useMemo<TutorialContextValue>(
|
|
76
|
+
() => ({ spec, runtime, themeOverrides, ai, onEvent, controller, dev, muted, startAt, autoStart, startPaused, resumeAt, snapshot, rewind }),
|
|
77
|
+
[spec, runtime, themeOverrides, ai, onEvent, controller, dev, muted, startAt, autoStart, startPaused, resumeAt, snapshot, rewind],
|
|
78
|
+
);
|
|
79
|
+
return <TutorialContext.Provider value={value}>{children}</TutorialContext.Provider>;
|
|
80
|
+
}
|
package/src/library/index.ts
CHANGED
|
@@ -62,6 +62,60 @@ export { simulateMatches } from "./game/ai/simulateMatches";
|
|
|
62
62
|
/** @group AI */
|
|
63
63
|
export type { SimulateMatchesOptions, SimulatedMatch, SimulationReport } from "./game/ai/simulateMatches";
|
|
64
64
|
|
|
65
|
+
/** @group Tutorials */
|
|
66
|
+
export { defineTutorial, listTutorials, findTutorial, splitSentences } from "./game/tutorial/defineTutorial";
|
|
67
|
+
/** @group Tutorials */
|
|
68
|
+
export type {
|
|
69
|
+
TutorialSpec,
|
|
70
|
+
TutorialStep,
|
|
71
|
+
TutorialMatchSetup,
|
|
72
|
+
TutorialContext,
|
|
73
|
+
TutorialSummary,
|
|
74
|
+
Checker,
|
|
75
|
+
CheckResult,
|
|
76
|
+
ChitSelector,
|
|
77
|
+
Target,
|
|
78
|
+
UiTarget,
|
|
79
|
+
Focus,
|
|
80
|
+
Cue,
|
|
81
|
+
BoxPlacement,
|
|
82
|
+
BoxAnchor,
|
|
83
|
+
ForcedDecision,
|
|
84
|
+
AllowedAction,
|
|
85
|
+
GalleryCommand,
|
|
86
|
+
Pose,
|
|
87
|
+
TimelineCommand,
|
|
88
|
+
TutorialGalleryState,
|
|
89
|
+
} from "./game/tutorial/defineTutorial";
|
|
90
|
+
/** @group Tutorials */
|
|
91
|
+
export { checks } from "./game/tutorial/checks";
|
|
92
|
+
/** @group Tutorials */
|
|
93
|
+
export { runTutorial } from "./game/tutorial/runTutorial";
|
|
94
|
+
/** @group Tutorials */
|
|
95
|
+
export type { RunTutorialOptions, RunTutorialResult } from "./game/tutorial/runTutorial";
|
|
96
|
+
/** @group Tutorials */
|
|
97
|
+
export { createDemoMatch } from "./game/tutorial/createDemoMatch";
|
|
98
|
+
/** @group Tutorials */
|
|
99
|
+
export type { DemoMatch, CreateDemoMatchOptions } from "./game/tutorial/createDemoMatch";
|
|
100
|
+
/** @group Tutorials */
|
|
101
|
+
export { TutorialController } from "./game/tutorial/TutorialController";
|
|
102
|
+
/** @group Tutorials */
|
|
103
|
+
export type { TutorialEvent, TutorialStatus, TutorialView, NarrationPlayer } from "./game/tutorial/TutorialController";
|
|
104
|
+
/** @group Tutorials */
|
|
105
|
+
export { TutorialRuntime } from "./game/tutorial/TutorialRuntime";
|
|
106
|
+
/** @group Tutorials */
|
|
107
|
+
export type { TutorialTheme } from "./game/tutorial/TutorialTheme";
|
|
108
|
+
/** @group Tutorials */
|
|
109
|
+
export { resolveTutorialTheme } from "./game/tutorial/TutorialTheme";
|
|
110
|
+
/** @group Tutorials */
|
|
111
|
+
export { TokenizedMarkdown } from "./components/TokenizedMarkdown";
|
|
112
|
+
/** @group Tutorials */
|
|
113
|
+
export { TutorialDevPanel } from "./components/Tutorial/TutorialDevPanel";
|
|
114
|
+
/** @group Supporting Types */
|
|
115
|
+
export type { RngSource } from "./game/TurnState";
|
|
116
|
+
/** @group Supporting Types */
|
|
117
|
+
export type { MatchConfig } from "./game/Match";
|
|
118
|
+
|
|
65
119
|
/** @group Buttons */
|
|
66
120
|
export { GameButton, DynamicGameButton, ToggleGalleryButton } from "./game/GameButton";
|
|
67
121
|
|
|
@@ -87,6 +141,7 @@ export { HighlightSpec } from "./rendering/HighlightSpec";
|
|
|
87
141
|
export { LightSpec, Light } from "./rendering/LightSpec";
|
|
88
142
|
/** @group 3D Rendering */
|
|
89
143
|
export { Splay } from "./rendering/Splay";
|
|
144
|
+
export type { SplayFill, SplayOrientation } from "./rendering/Splay";
|
|
90
145
|
|
|
91
146
|
/** @group Utilities */
|
|
92
147
|
export { extrudeSVGToGeometry } from "./utilities/SvgExtruder";
|
|
@@ -115,9 +170,10 @@ export type { IPlayerInfo, AiSeatInfo } from "./game/PlayerInfo";
|
|
|
115
170
|
/** @internal */
|
|
116
171
|
/** @group Supporting Types */
|
|
117
172
|
export { MatchViewer } from "./components/MatchViewer";
|
|
118
|
-
/** @
|
|
119
|
-
/** @group Supporting Types */
|
|
173
|
+
/** @group Tutorials */
|
|
120
174
|
export { DemoWrapper } from "./components/DemoWrapper";
|
|
175
|
+
/** @group Tutorials */
|
|
176
|
+
export type { DemoWrapperProps } from "./components/DemoWrapper";
|
|
121
177
|
/** @internal */
|
|
122
178
|
/** @group Supporting Types */
|
|
123
179
|
export { Match, MatchAiControls } from "./game/Match";
|
|
@@ -151,6 +151,23 @@ export class CameraWrapperPerspective {
|
|
|
151
151
|
this.adjust(this.bbox, !animate);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Zooms to `zoom` (clamped to the camera's range) and brings the point at panel pixel (x, y) to the
|
|
156
|
+
* middle of the panel, as far as panning allows. Animated. Zoom 1 is the whole table.
|
|
157
|
+
*/
|
|
158
|
+
public focusOn(x: number, y: number, zoom: number): void {
|
|
159
|
+
const z = Math.max(1, Math.min(zoom, this.cameraSpec.maxZoom));
|
|
160
|
+
// A point on screen sits at (content * zoom + offset) from the middle: keep the content under
|
|
161
|
+
// (x, y) and move it to the middle
|
|
162
|
+
const sx = x - this.width / 2;
|
|
163
|
+
const sy = y - this.height / 2;
|
|
164
|
+
this.current.x = -(sx - this.current.x) * (z / this.current.z);
|
|
165
|
+
this.current.y = -(sy - this.current.y) * (z / this.current.z);
|
|
166
|
+
this.current.z = z;
|
|
167
|
+
this.lockZoom();
|
|
168
|
+
this.adjust(this.bbox, false);
|
|
169
|
+
}
|
|
170
|
+
|
|
154
171
|
private lockZoom() {
|
|
155
172
|
const maxZoom = this.cameraSpec.maxZoom;
|
|
156
173
|
if (this.current.z <= 1) {
|
|
@@ -19,13 +19,26 @@ export class ChitGalleryItemInstance implements GalleryItem {
|
|
|
19
19
|
preferredHeight?: number;
|
|
20
20
|
|
|
21
21
|
originalSummary?: string;
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* How many functionally identical chits this item stands for in its gallery (see
|
|
24
|
+
* `chitsToGalleryItems`); above 1 the summary leads with "Nx". Kept apart from the summary
|
|
25
|
+
* text, so a refresh that copies the render spec's summary back onto the item keeps the count.
|
|
26
|
+
*/
|
|
27
|
+
count?: number;
|
|
28
|
+
private _summary?: string;
|
|
29
|
+
get summary(): string | undefined {
|
|
30
|
+
return this.count && this.count > 1 ? `${this.count}x\n${this._summary ?? ""}` : this._summary;
|
|
31
|
+
}
|
|
32
|
+
set summary(value: string | undefined) {
|
|
33
|
+
this._summary = value;
|
|
34
|
+
}
|
|
23
35
|
shortSummary?: string;
|
|
24
36
|
summaryIconMap?: IconMap;
|
|
25
37
|
summaryRenderingOptions?: RichTextRenderOptionsParameters;
|
|
26
38
|
shortSummaryRenderingOptions?: RichTextRenderOptionsParameters;
|
|
27
39
|
|
|
28
40
|
private sceneWrapper: SceneWrapper | undefined;
|
|
41
|
+
private creatingMesh = false;
|
|
29
42
|
|
|
30
43
|
constructor(public chit: Chit) {
|
|
31
44
|
this.id = chit.id ?? "no id";
|
|
@@ -79,9 +92,22 @@ export class ChitGalleryItemInstance implements GalleryItem {
|
|
|
79
92
|
|
|
80
93
|
createMesh(sceneWrapper: SceneWrapper) {
|
|
81
94
|
this.sceneWrapper = sceneWrapper;
|
|
95
|
+
return this.cloneMesh();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A copy of the chit as drawn, without binding this item to a scene (a drag's ghost on the board). */
|
|
99
|
+
cloneMesh(): Object3D {
|
|
82
100
|
const renderInstance = this.chit.renderInstance;
|
|
83
101
|
const g = new Group();
|
|
84
102
|
if (renderInstance) {
|
|
103
|
+
// a refresh re-renders the chit, which would ask us to rebuild while we're mid-build
|
|
104
|
+
this.creatingMesh = true;
|
|
105
|
+
try {
|
|
106
|
+
renderInstance.refreshDisposedTextures();
|
|
107
|
+
} finally {
|
|
108
|
+
this.creatingMesh = false;
|
|
109
|
+
}
|
|
110
|
+
|
|
85
111
|
const mesh = this.cloneWithUserData(renderInstance.group) ?? new Group();
|
|
86
112
|
mesh.visible = true;
|
|
87
113
|
mesh.rotation.set(0, 0, 0);
|
|
@@ -101,6 +127,9 @@ export class ChitGalleryItemInstance implements GalleryItem {
|
|
|
101
127
|
}
|
|
102
128
|
|
|
103
129
|
update() {
|
|
130
|
+
if (this.creatingMesh) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
104
133
|
this.cbs.forEach((cb) => cb());
|
|
105
134
|
}
|
|
106
135
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Group,
|
|
6
6
|
Mesh,
|
|
7
7
|
MeshBasicMaterial,
|
|
8
|
+
Object3D,
|
|
8
9
|
Plane,
|
|
9
10
|
Quaternion,
|
|
10
11
|
Raycaster,
|
|
@@ -18,6 +19,7 @@ import { Easing, Tween, Group as TweenGroup } from "@tweenjs/tween.js";
|
|
|
18
19
|
import { RootChitRenderInstance } from "./RootChitRenderInstance";
|
|
19
20
|
import { fixBbox } from "../utilities/BboxUtils";
|
|
20
21
|
import { ChitGalleryItemInstance } from "./ChitGalleryItemInstance";
|
|
22
|
+
import { CanvasStack } from "../utilities/CanvasStack/CanvasStack";
|
|
21
23
|
|
|
22
24
|
const LINE_COLOR = new MeshBasicMaterial({ color: 0xff0000, wireframe: true, wireframeLinewidth: 2 });
|
|
23
25
|
const CLICK_LINE_COLOR = new MeshBasicMaterial({ color: 0xffff00, wireframe: true, wireframeLinewidth: 2 });
|
|
@@ -50,6 +52,11 @@ export class ChitRenderInstance {
|
|
|
50
52
|
// rendering info
|
|
51
53
|
protected renderSpec: ChitRenderSpec | null = null;
|
|
52
54
|
|
|
55
|
+
/** The chit's own drawn object (not its children or ornaments), for exact hit tests on a tap. */
|
|
56
|
+
public get hitObject(): Object3D | undefined {
|
|
57
|
+
return this.renderSpec?.object ?? undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
// threejs info
|
|
54
61
|
public group = new Group(); // group storing the visible meshes. Will tween
|
|
55
62
|
protected targetAnchorPoints = new Map<OwnerOriginPosition | string, Vector3>();
|
|
@@ -436,7 +443,7 @@ export class ChitRenderInstance {
|
|
|
436
443
|
item.preferredWidth = this.renderSpec?.galleryPreferredWidth;
|
|
437
444
|
item.summary = this.renderSpec?.summary;
|
|
438
445
|
item.shortSummary = this.renderSpec?.shortSummary;
|
|
439
|
-
item.originalSummary = item.summary
|
|
446
|
+
item.originalSummary = this.renderSpec?.summary; // not item.summary: that leads with the item's "Nx" count
|
|
440
447
|
item.summaryIconMap = this.renderSpec?.summaryIconMap;
|
|
441
448
|
item.summaryRenderingOptions = this.renderSpec?.summaryRenderingOptions;
|
|
442
449
|
item.shortSummaryRenderingOptions = this.renderSpec?.shortSummaryRenderingOptions;
|
|
@@ -453,6 +460,33 @@ export class ChitRenderInstance {
|
|
|
453
460
|
return this._galleryItem;
|
|
454
461
|
}
|
|
455
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Hidden chits (e.g. inside a deck or bag) aren't counted by the TextureReferenceCounter, so their textures get
|
|
465
|
+
* reclaimed while the render spec still points at them. Galleries clone that spec, so re-render first if stale.
|
|
466
|
+
*/
|
|
467
|
+
public refreshDisposedTextures() {
|
|
468
|
+
if (this.usesDisposedTexture()) {
|
|
469
|
+
this.refresh();
|
|
470
|
+
}
|
|
471
|
+
[...this.childrenRenderInstances].forEach((child) => child.refreshDisposedTextures());
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
private usesDisposedTexture() {
|
|
475
|
+
let disposed = false;
|
|
476
|
+
[this.renderSpec?.object, ...(this.renderSpec?.ornaments ?? [])].forEach((root) =>
|
|
477
|
+
root?.traverse((obj) => {
|
|
478
|
+
if (!disposed && obj instanceof Mesh) {
|
|
479
|
+
const materials = Array.isArray(obj.material) ? obj.material : [obj.material];
|
|
480
|
+
disposed = materials.some((m) => {
|
|
481
|
+
const map = (m as MeshBasicMaterial | undefined)?.map;
|
|
482
|
+
return !!map && CanvasStack.isDisposedTexture(map);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}),
|
|
486
|
+
);
|
|
487
|
+
return disposed;
|
|
488
|
+
}
|
|
489
|
+
|
|
456
490
|
public destroyGalleryItem() {
|
|
457
491
|
if (this._galleryItem) {
|
|
458
492
|
this._galleryItem.destroy();
|
|
@@ -550,7 +584,10 @@ export class ChitRenderInstance {
|
|
|
550
584
|
this.renderSpec.ornaments.forEach((ornament) => this.group.add(ornament));
|
|
551
585
|
|
|
552
586
|
this.fixObjectPosition();
|
|
553
|
-
this._galleryItem
|
|
587
|
+
if (this._galleryItem) {
|
|
588
|
+
this.createGalleryItem(this._galleryItem); // copy the new spec's summary and sizes onto it
|
|
589
|
+
this._galleryItem.update();
|
|
590
|
+
}
|
|
554
591
|
|
|
555
592
|
this.rootRenderInstance.markHasChange();
|
|
556
593
|
}
|
|
@@ -563,6 +600,22 @@ export class ChitRenderInstance {
|
|
|
563
600
|
);
|
|
564
601
|
}
|
|
565
602
|
|
|
603
|
+
/** Where this chit sits in world space: what a dragged chit's position is compared with. */
|
|
604
|
+
public worldCenter(): Vector3 {
|
|
605
|
+
return this.bboxGroup.getWorldPosition(new Vector3());
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** Outline (or clear) this chit as the target a drag would drop on. */
|
|
609
|
+
public markAsDropTarget(on: boolean) {
|
|
610
|
+
this.chit.isDropTarget = on;
|
|
611
|
+
this.refresh();
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/** How far a drag lifts this chit (`ChitRenderSpec.dragZLiftAmount`). */
|
|
615
|
+
public get dragLift(): number {
|
|
616
|
+
return this.renderSpec?.dragZLiftAmount ?? 0;
|
|
617
|
+
}
|
|
618
|
+
|
|
566
619
|
public executeDrag(x: number, y: number) {
|
|
567
620
|
const root = this.rootRenderInstance;
|
|
568
621
|
const dragPoint = root.attemptToFindPlaneZ0OfCanvasPoints(x, y) ?? new Vector3(0, 0, 0);
|
|
@@ -622,8 +675,8 @@ export class ChitRenderInstance {
|
|
|
622
675
|
dropTarget.isDropTarget = false;
|
|
623
676
|
dropTarget.renderInstance?.refresh();
|
|
624
677
|
|
|
625
|
-
|
|
626
|
-
dropTarget.add(this.chit);
|
|
678
|
+
// A refused drop (a tutorial's guard) leaves the chit where it was: refresh() puts it back
|
|
679
|
+
if (this.chit.onDrag!(dropTarget) !== false) dropTarget.add(this.chit);
|
|
627
680
|
}
|
|
628
681
|
this.refresh();
|
|
629
682
|
},
|
|
@@ -74,6 +74,9 @@ export class LightWrapper {
|
|
|
74
74
|
l.shadow.camera.right = 0.1;
|
|
75
75
|
l.shadow.camera.top = 0.1;
|
|
76
76
|
l.shadow.camera.bottom = -0.1;
|
|
77
|
+
// the camera is fitted to the whole panel, so a board-sized panel needs more than the default 512 texels for
|
|
78
|
+
// a piece's shadow to read
|
|
79
|
+
l.shadow.mapSize.set(1024, 1024);
|
|
77
80
|
this.group.add(l);
|
|
78
81
|
}
|
|
79
82
|
|
|
@@ -126,12 +129,16 @@ export class LightWrapper {
|
|
|
126
129
|
camera.bottom = -1;
|
|
127
130
|
camera.top = 1;
|
|
128
131
|
camera.updateProjectionMatrix();
|
|
132
|
+
// point the shadow camera along the light now (the renderer would only do it at the next shadow pass), so the
|
|
133
|
+
// projection below is in the light's view
|
|
134
|
+
light.updateMatrixWorld(true);
|
|
135
|
+
light.shadow.updateMatrices(light);
|
|
129
136
|
|
|
130
137
|
const b = new Box2();
|
|
131
138
|
const adjust = (x: number, y: number, z: number) => {
|
|
132
139
|
const v = new Vector3(x, y, z);
|
|
133
140
|
const cameraPoint = v.project(camera);
|
|
134
|
-
b.expandByPoint(new Vector2(cameraPoint.x
|
|
141
|
+
b.expandByPoint(new Vector2(cameraPoint.x, cameraPoint.y));
|
|
135
142
|
};
|
|
136
143
|
|
|
137
144
|
[this.bbox.min.x, this.bbox.max.x].forEach((x) =>
|
|
@@ -142,6 +149,8 @@ export class LightWrapper {
|
|
|
142
149
|
),
|
|
143
150
|
);
|
|
144
151
|
|
|
152
|
+
// with -1..1 bounds the projection is the light's own view coordinates: fit them, with a small margin
|
|
153
|
+
b.expandByScalar(0.5);
|
|
145
154
|
camera.left = Math.min(left, b.min.x);
|
|
146
155
|
camera.right = Math.max(right, b.max.x);
|
|
147
156
|
camera.bottom = Math.min(bottom, b.min.y);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tween, Group as TweenGroup } from "@tweenjs/tween.js";
|
|
2
2
|
import { ChitRenderInstance } from "./ChitRenderInstance";
|
|
3
3
|
import { Chit } from "../game/Chit";
|
|
4
|
-
import { Box3, Group, Object3D, Plane, Raycaster, Vector2, Vector3 } from "three";
|
|
4
|
+
import { Box3, Group, Mesh, Object3D, Plane, Raycaster, Vector2, Vector3 } from "three";
|
|
5
5
|
import { CameraWrapperPerspective } from "./CameraWrapperPerspective";
|
|
6
6
|
import { LightWrapper } from "./LightWrapper";
|
|
7
7
|
import { ModalState } from "../game/ModalState";
|
|
@@ -331,6 +331,11 @@ export class RootChitRenderInstance extends ChitRenderInstance implements Textur
|
|
|
331
331
|
precision: number,
|
|
332
332
|
): Chit[] {
|
|
333
333
|
const result = new Map<Chit, number>();
|
|
334
|
+
// Box hits that the ray also hits on the chit's real shape. A clickbox is the axis-aligned box around the whole
|
|
335
|
+
// object, so a large irregular piece (a sea area, a province) claims every tap inside its rectangle, and
|
|
336
|
+
// neighbours whose rectangles overlap would all be offered in a gallery. See the end of this function.
|
|
337
|
+
const exact = new Map<Chit, number>();
|
|
338
|
+
const hasShape = new Map<Chit, boolean>();
|
|
334
339
|
const chitRenderInstances: ChitRenderInstance[] = [];
|
|
335
340
|
const threeJsToChitLookup: { [threejsId: number]: Chit } = {};
|
|
336
341
|
|
|
@@ -371,10 +376,28 @@ export class RootChitRenderInstance extends ChitRenderInstance implements Textur
|
|
|
371
376
|
const c = threeJsToChitLookup[id];
|
|
372
377
|
if (filter(c)) {
|
|
373
378
|
result.set(c, Math.min(result.get(c) ?? r, r));
|
|
379
|
+
const shape = c.renderInstance?.hitObject;
|
|
380
|
+
if (!hasShape.has(c)) {
|
|
381
|
+
let meshes = false;
|
|
382
|
+
shape?.traverse((o) => {
|
|
383
|
+
if ((o as Mesh).isMesh) meshes = true;
|
|
384
|
+
});
|
|
385
|
+
hasShape.set(c, meshes);
|
|
386
|
+
}
|
|
387
|
+
if (shape && hasShape.get(c) && (exact.get(c) ?? Infinity) > r && raycaster.intersectObject(shape, true).length) {
|
|
388
|
+
exact.set(c, r);
|
|
389
|
+
}
|
|
374
390
|
}
|
|
375
391
|
}
|
|
376
392
|
}
|
|
377
393
|
}
|
|
394
|
+
// Keep the chits whose real shape was hit, plus those with no mesh of their own to test (an empty group that
|
|
395
|
+
// is clicked through its children). If no shape was hit at all (a tap in the gap between pieces, within the
|
|
396
|
+
// finger tolerance), fall back to the boxes so a near miss still lands. Nearest first.
|
|
397
|
+
const precise = [...result.keys()].filter((c) => exact.has(c) || !hasShape.get(c));
|
|
398
|
+
if (precise.length && precise.length < result.size) {
|
|
399
|
+
return precise.sort((a, b) => (exact.get(a) ?? result.get(a)!) - (exact.get(b) ?? result.get(b)!));
|
|
400
|
+
}
|
|
378
401
|
return [...result.keys()];
|
|
379
402
|
}
|
|
380
403
|
|
|
@@ -465,6 +488,12 @@ export class RootChitRenderInstance extends ChitRenderInstance implements Textur
|
|
|
465
488
|
this.markDirty();
|
|
466
489
|
}
|
|
467
490
|
|
|
491
|
+
/** Zooms the camera to `zoom` around panel pixel (x, y), bringing it to the middle (see `CameraWrapperPerspective.focusOn`) */
|
|
492
|
+
public focusCamera(x: number, y: number, zoom: number) {
|
|
493
|
+
this.cameraWrapper.focusOn(x, y, zoom);
|
|
494
|
+
this.markDirty();
|
|
495
|
+
}
|
|
496
|
+
|
|
468
497
|
public get cameraZoom() {
|
|
469
498
|
return this.cameraWrapper.zoom;
|
|
470
499
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { Splay } from "./Splay";
|
|
3
|
+
|
|
4
|
+
/** the grid slot (column, row) each child index lands on, in unit item sizes */
|
|
5
|
+
function slots(s: Splay): string[] {
|
|
6
|
+
const out: string[] = [];
|
|
7
|
+
for (let i = 0; i < s.rows * s.columns; i++) {
|
|
8
|
+
const r = s.processSplay(i, 1, 1, 1);
|
|
9
|
+
out.push(`${r.x},${r.y}`);
|
|
10
|
+
}
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function grid(rows: number, columns: number, set: Partial<Splay> = {}): Splay {
|
|
15
|
+
const s = new Splay();
|
|
16
|
+
s.enabled = true;
|
|
17
|
+
s.rows = rows;
|
|
18
|
+
s.columns = columns;
|
|
19
|
+
Object.assign(s, set);
|
|
20
|
+
return s;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe("Splay fill", () => {
|
|
24
|
+
it("fills a 4×2 window in reading order from the top left with fill 'rows'", () => {
|
|
25
|
+
const s = grid(2, 4, { fill: "rows", columnOrientation: "increasing", rowOrientation: "decreasing" });
|
|
26
|
+
// y up the table: the top row is y 0, the next y -1
|
|
27
|
+
expect(slots(s)).toEqual(["0,0", "1,0", "2,0", "3,0", "0,-1", "1,-1", "2,-1", "3,-1"]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("fills column by column with fill 'columns'", () => {
|
|
31
|
+
const s = grid(2, 4, { fill: "columns", columnOrientation: "increasing", rowOrientation: "decreasing" });
|
|
32
|
+
expect(slots(s)).toEqual(["0,0", "0,-1", "1,0", "1,-1", "2,0", "2,-1", "3,0", "3,-1"]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("keeps 'nearest' as the default: closest to the anchor first", () => {
|
|
36
|
+
const s = grid(2, 4, { columnOrientation: "increasing", rowOrientation: "decreasing" });
|
|
37
|
+
expect(s.fill).toBe("nearest");
|
|
38
|
+
const order = slots(s);
|
|
39
|
+
expect(order[0]).toBe("0,0");
|
|
40
|
+
// distances never decrease
|
|
41
|
+
const d = order.map((o) => o.split(",").reduce((a, v) => a + Math.abs(Number(v)), 0));
|
|
42
|
+
expect([...d].sort((a, b) => a - b)).toEqual(d);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("breaks distance ties in row-major order on a non-square grid", () => {
|
|
46
|
+
// centred 2×4: the four inner slots, then the four outer ones row by row (the old tie-break, row * rows + column,
|
|
47
|
+
// took the outer ones column by column on a grid that is not square)
|
|
48
|
+
const s = grid(2, 4);
|
|
49
|
+
expect(slots(s)).toEqual([
|
|
50
|
+
"-0.5,-0.5", "0.5,-0.5", "-0.5,0.5", "0.5,0.5",
|
|
51
|
+
"-1.5,-0.5", "1.5,-0.5", "-1.5,0.5", "1.5,0.5",
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("piles past the grid: the next child goes back to the first slot, one layer up", () => {
|
|
56
|
+
const s = grid(2, 2, { fill: "rows", columnOrientation: "increasing", rowOrientation: "decreasing" });
|
|
57
|
+
const r = s.processSplay(4, 1, 1, 1);
|
|
58
|
+
expect([r.x, r.y, r.z]).toEqual([0, 0, 1]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
type SplayResults = { x: number; y: number; z: number };
|
|
2
2
|
export type SplayOrientation = "center" | "decreasing" | "increasing";
|
|
3
|
+
/**
|
|
4
|
+
* The order a splay hands out its slots, measured from the anchor (the slot the orientations put at 0,0).
|
|
5
|
+
* - `"nearest"`: closest to the anchor first (Manhattan distance), so a grid fills in rings: a 4×2 fills diagonally.
|
|
6
|
+
* - `"rows"`: the anchor's row first, working away from the anchor column, then the next row away from the anchor.
|
|
7
|
+
* With `columnOrientation = "increasing"` and `rowOrientation = "decreasing"` that is reading order from the top
|
|
8
|
+
* left: a window of identical markers filled the way a person fills it.
|
|
9
|
+
* - `"columns"`: the same, column by column.
|
|
10
|
+
*/
|
|
11
|
+
export type SplayFill = "nearest" | "rows" | "columns";
|
|
3
12
|
|
|
4
13
|
function midFromOrientation(max: number, orientation: SplayOrientation) {
|
|
5
14
|
switch (orientation) {
|
|
@@ -20,6 +29,7 @@ function getSplayOrder(
|
|
|
20
29
|
columns: number,
|
|
21
30
|
rowOrientation: SplayOrientation,
|
|
22
31
|
columnOrientation: SplayOrientation,
|
|
32
|
+
fill: SplayFill,
|
|
23
33
|
): SplayResults[] {
|
|
24
34
|
if (splayOrder[key]) {
|
|
25
35
|
return splayOrder[key];
|
|
@@ -30,17 +40,25 @@ function getSplayOrder(
|
|
|
30
40
|
const order: SplayResults[] = [];
|
|
31
41
|
for (let row = 0; row < rows; row++) {
|
|
32
42
|
for (let column = 0; column < columns; column++) {
|
|
33
|
-
order.push({ x: column - midX, y: row - midY, z: row *
|
|
43
|
+
order.push({ x: column - midX, y: row - midY, z: row * columns + column });
|
|
34
44
|
}
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
// the primary and secondary distance from the anchor for each fill; ties keep row-major order
|
|
48
|
+
const keys = (o: SplayResults): [number, number] => {
|
|
49
|
+
switch (fill) {
|
|
50
|
+
case "rows":
|
|
51
|
+
return [Math.abs(o.y), Math.abs(o.x)];
|
|
52
|
+
case "columns":
|
|
53
|
+
return [Math.abs(o.x), Math.abs(o.y)];
|
|
54
|
+
default:
|
|
55
|
+
return [Math.abs(o.x) + Math.abs(o.y), 0];
|
|
42
56
|
}
|
|
43
|
-
|
|
57
|
+
};
|
|
58
|
+
order.sort((a, b) => {
|
|
59
|
+
const [a1, a2] = keys(a);
|
|
60
|
+
const [b1, b2] = keys(b);
|
|
61
|
+
return a1 - b1 || a2 - b2 || a.z - b.z;
|
|
44
62
|
});
|
|
45
63
|
splayOrder[key] = order;
|
|
46
64
|
return order;
|
|
@@ -51,6 +69,8 @@ export class Splay {
|
|
|
51
69
|
public columns: number = 1;
|
|
52
70
|
public rowOrientation: SplayOrientation = "center";
|
|
53
71
|
public columnOrientation: SplayOrientation = "center";
|
|
72
|
+
/** the order slots fill in (see {@link SplayFill}); `"nearest"` by default */
|
|
73
|
+
public fill: SplayFill = "nearest";
|
|
54
74
|
|
|
55
75
|
public enabled: boolean = false;
|
|
56
76
|
public zSpacingMultiplier: number = 1;
|
|
@@ -60,16 +80,17 @@ export class Splay {
|
|
|
60
80
|
public itemHeight?: number = undefined;
|
|
61
81
|
|
|
62
82
|
toString() {
|
|
63
|
-
return `${this.rows} ${this.columns} ${this.rowOrientation} ${this.columnOrientation} ${this.enabled} ${this.zSpacingMultiplier} ${this.spacingMultiplier} ${this.itemWidth} ${this.itemHeight}`;
|
|
83
|
+
return `${this.rows} ${this.columns} ${this.rowOrientation} ${this.columnOrientation} ${this.fill} ${this.enabled} ${this.zSpacingMultiplier} ${this.spacingMultiplier} ${this.itemWidth} ${this.itemHeight}`;
|
|
64
84
|
}
|
|
65
85
|
|
|
66
86
|
private get splayOrder() {
|
|
67
87
|
return getSplayOrder(
|
|
68
|
-
`${this.rows}_${this.columns}_${this.rowOrientation}_${this.columnOrientation}`,
|
|
88
|
+
`${this.rows}_${this.columns}_${this.rowOrientation}_${this.columnOrientation}_${this.fill}`,
|
|
69
89
|
this.rows,
|
|
70
90
|
this.columns,
|
|
71
91
|
this.rowOrientation,
|
|
72
92
|
this.columnOrientation,
|
|
93
|
+
this.fill,
|
|
73
94
|
);
|
|
74
95
|
}
|
|
75
96
|
|