@pretty-chitty/core 1.1.1

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.
Files changed (779) hide show
  1. package/LICENSE.md +51 -0
  2. package/README.md +152 -0
  3. package/dist/0e0a96423fd742218c61.woff2 +0 -0
  4. package/dist/1e28c9f184923aacc181.woff +0 -0
  5. package/dist/37f3b2ddcbe588b2aaa5.jpg +0 -0
  6. package/dist/3f0fb9058a03e14ad2fa.jpg +0 -0
  7. package/dist/4482e08504d544757971.woff2 +0 -0
  8. package/dist/5212361bfd059a27e2da.woff2 +0 -0
  9. package/dist/699b459f21e39ca4b8df.woff2 +0 -0
  10. package/dist/7e339dfbea59fe54f2e3.png +0 -0
  11. package/dist/a3e6d4ebd8f859f0f1dc.woff +0 -0
  12. package/dist/b8b0d3bc0d26444e4a5a.woff2 +0 -0
  13. package/dist/bce9a6fcc5b3da9a086a.woff +0 -0
  14. package/dist/components/ActionLogDisplay.d.ts +4 -0
  15. package/dist/components/ActionLogDisplay.d.ts.map +1 -0
  16. package/dist/components/ActionLogDisplay.js +144 -0
  17. package/dist/components/ActionLogDisplay.js.map +1 -0
  18. package/dist/components/ActionLogHistory.d.ts +6 -0
  19. package/dist/components/ActionLogHistory.d.ts.map +1 -0
  20. package/dist/components/ActionLogHistory.js +81 -0
  21. package/dist/components/ActionLogHistory.js.map +1 -0
  22. package/dist/components/ActionLogHistoryDisplay.d.ts +2 -0
  23. package/dist/components/ActionLogHistoryDisplay.d.ts.map +1 -0
  24. package/dist/components/ActionLogHistoryDisplay.js +17 -0
  25. package/dist/components/ActionLogHistoryDisplay.js.map +1 -0
  26. package/dist/components/ActionLogSidebar.d.ts +2 -0
  27. package/dist/components/ActionLogSidebar.d.ts.map +1 -0
  28. package/dist/components/ActionLogSidebar.js +9 -0
  29. package/dist/components/ActionLogSidebar.js.map +1 -0
  30. package/dist/components/BottomBar.d.ts +2 -0
  31. package/dist/components/BottomBar.d.ts.map +1 -0
  32. package/dist/components/BottomBar.js +33 -0
  33. package/dist/components/BottomBar.js.map +1 -0
  34. package/dist/components/BottomBarBreak.d.ts +2 -0
  35. package/dist/components/BottomBarBreak.d.ts.map +1 -0
  36. package/dist/components/BottomBarBreak.js +8 -0
  37. package/dist/components/BottomBarBreak.js.map +1 -0
  38. package/dist/components/BottomBarButton.d.ts +16 -0
  39. package/dist/components/BottomBarButton.d.ts.map +1 -0
  40. package/dist/components/BottomBarButton.js +123 -0
  41. package/dist/components/BottomBarButton.js.map +1 -0
  42. package/dist/components/CanvasLibraryViewer.d.ts +8 -0
  43. package/dist/components/CanvasLibraryViewer.d.ts.map +1 -0
  44. package/dist/components/CanvasLibraryViewer.js +29 -0
  45. package/dist/components/CanvasLibraryViewer.js.map +1 -0
  46. package/dist/components/ChitLibraryViewer.d.ts +8 -0
  47. package/dist/components/ChitLibraryViewer.d.ts.map +1 -0
  48. package/dist/components/ChitLibraryViewer.js +101 -0
  49. package/dist/components/ChitLibraryViewer.js.map +1 -0
  50. package/dist/components/ClientTrustMatchViewer.d.ts +11 -0
  51. package/dist/components/ClientTrustMatchViewer.d.ts.map +1 -0
  52. package/dist/components/ClientTrustMatchViewer.js +53 -0
  53. package/dist/components/ClientTrustMatchViewer.js.map +1 -0
  54. package/dist/components/ContextGalleryDisplay.d.ts +4 -0
  55. package/dist/components/ContextGalleryDisplay.d.ts.map +1 -0
  56. package/dist/components/ContextGalleryDisplay.js +49 -0
  57. package/dist/components/ContextGalleryDisplay.js.map +1 -0
  58. package/dist/components/GalleryDisplay.d.ts +2 -0
  59. package/dist/components/GalleryDisplay.d.ts.map +1 -0
  60. package/dist/components/GalleryDisplay.js +42 -0
  61. package/dist/components/GalleryDisplay.js.map +1 -0
  62. package/dist/components/GalleryPlayground.d.ts +14 -0
  63. package/dist/components/GalleryPlayground.d.ts.map +1 -0
  64. package/dist/components/GalleryPlayground.js +36 -0
  65. package/dist/components/GalleryPlayground.js.map +1 -0
  66. package/dist/components/GalleryViewer.d.ts +48 -0
  67. package/dist/components/GalleryViewer.d.ts.map +1 -0
  68. package/dist/components/GalleryViewer.js +567 -0
  69. package/dist/components/GalleryViewer.js.map +1 -0
  70. package/dist/components/GameDesigner.d.ts +5 -0
  71. package/dist/components/GameDesigner.d.ts.map +1 -0
  72. package/dist/components/GameDesigner.js +14 -0
  73. package/dist/components/GameDesigner.js.map +1 -0
  74. package/dist/components/GameDialog.d.ts +7 -0
  75. package/dist/components/GameDialog.d.ts.map +1 -0
  76. package/dist/components/GameDialog.js +24 -0
  77. package/dist/components/GameDialog.js.map +1 -0
  78. package/dist/components/GameModalBackdrop.d.ts +10 -0
  79. package/dist/components/GameModalBackdrop.d.ts.map +1 -0
  80. package/dist/components/GameModalBackdrop.js +33 -0
  81. package/dist/components/GameModalBackdrop.js.map +1 -0
  82. package/dist/components/GameModalDialog.d.ts +11 -0
  83. package/dist/components/GameModalDialog.d.ts.map +1 -0
  84. package/dist/components/GameModalDialog.js +42 -0
  85. package/dist/components/GameModalDialog.js.map +1 -0
  86. package/dist/components/LiveButton.d.ts +4 -0
  87. package/dist/components/LiveButton.d.ts.map +1 -0
  88. package/dist/components/LiveButton.js +17 -0
  89. package/dist/components/LiveButton.js.map +1 -0
  90. package/dist/components/MatchEndDisplay.d.ts +2 -0
  91. package/dist/components/MatchEndDisplay.d.ts.map +1 -0
  92. package/dist/components/MatchEndDisplay.js +67 -0
  93. package/dist/components/MatchEndDisplay.js.map +1 -0
  94. package/dist/components/MatchViewer.d.ts +5 -0
  95. package/dist/components/MatchViewer.d.ts.map +1 -0
  96. package/dist/components/MatchViewer.js +59 -0
  97. package/dist/components/MatchViewer.js.map +1 -0
  98. package/dist/components/ObjectWithPropsEditor.d.ts +5 -0
  99. package/dist/components/ObjectWithPropsEditor.d.ts.map +1 -0
  100. package/dist/components/ObjectWithPropsEditor.js +88 -0
  101. package/dist/components/ObjectWithPropsEditor.js.map +1 -0
  102. package/dist/components/Panel/MultiPanel.d.ts +13 -0
  103. package/dist/components/Panel/MultiPanel.d.ts.map +1 -0
  104. package/dist/components/Panel/MultiPanel.js +196 -0
  105. package/dist/components/Panel/MultiPanel.js.map +1 -0
  106. package/dist/components/Panel/PanelContents.d.ts +27 -0
  107. package/dist/components/Panel/PanelContents.d.ts.map +1 -0
  108. package/dist/components/Panel/PanelContents.js +202 -0
  109. package/dist/components/Panel/PanelContents.js.map +1 -0
  110. package/dist/components/Panel/PanelTabStack.d.ts +9 -0
  111. package/dist/components/Panel/PanelTabStack.d.ts.map +1 -0
  112. package/dist/components/Panel/PanelTabStack.js +56 -0
  113. package/dist/components/Panel/PanelTabStack.js.map +1 -0
  114. package/dist/components/Panel/SinglePanel.d.ts +13 -0
  115. package/dist/components/Panel/SinglePanel.d.ts.map +1 -0
  116. package/dist/components/Panel/SinglePanel.js +44 -0
  117. package/dist/components/Panel/SinglePanel.js.map +1 -0
  118. package/dist/components/Panel/ViewerWrapper.d.ts +17 -0
  119. package/dist/components/Panel/ViewerWrapper.d.ts.map +1 -0
  120. package/dist/components/Panel/ViewerWrapper.js +70 -0
  121. package/dist/components/Panel/ViewerWrapper.js.map +1 -0
  122. package/dist/components/Panel/ViewerZoomControls.d.ts +8 -0
  123. package/dist/components/Panel/ViewerZoomControls.d.ts.map +1 -0
  124. package/dist/components/Panel/ViewerZoomControls.js +152 -0
  125. package/dist/components/Panel/ViewerZoomControls.js.map +1 -0
  126. package/dist/components/Panel/util.d.ts +3 -0
  127. package/dist/components/Panel/util.d.ts.map +1 -0
  128. package/dist/components/Panel/util.js +5 -0
  129. package/dist/components/Panel/util.js.map +1 -0
  130. package/dist/components/PanelSpark.d.ts +7 -0
  131. package/dist/components/PanelSpark.d.ts.map +1 -0
  132. package/dist/components/PanelSpark.js +84 -0
  133. package/dist/components/PanelSpark.js.map +1 -0
  134. package/dist/components/PersistentCanvas.d.ts +12 -0
  135. package/dist/components/PersistentCanvas.d.ts.map +1 -0
  136. package/dist/components/PersistentCanvas.js +44 -0
  137. package/dist/components/PersistentCanvas.js.map +1 -0
  138. package/dist/components/PlayerImage.d.ts +9 -0
  139. package/dist/components/PlayerImage.d.ts.map +1 -0
  140. package/dist/components/PlayerImage.js +21 -0
  141. package/dist/components/PlayerImage.js.map +1 -0
  142. package/dist/components/Playground.d.ts +9 -0
  143. package/dist/components/Playground.d.ts.map +1 -0
  144. package/dist/components/Playground.js +129 -0
  145. package/dist/components/Playground.js.map +1 -0
  146. package/dist/components/PromptControls.d.ts +4 -0
  147. package/dist/components/PromptControls.d.ts.map +1 -0
  148. package/dist/components/PromptControls.js +87 -0
  149. package/dist/components/PromptControls.js.map +1 -0
  150. package/dist/components/SelectableItemAndStage.d.ts +8 -0
  151. package/dist/components/SelectableItemAndStage.d.ts.map +1 -0
  152. package/dist/components/SelectableItemAndStage.js +16 -0
  153. package/dist/components/SelectableItemAndStage.js.map +1 -0
  154. package/dist/components/SettingsDisplay.d.ts +2 -0
  155. package/dist/components/SettingsDisplay.d.ts.map +1 -0
  156. package/dist/components/SettingsDisplay.js +62 -0
  157. package/dist/components/SettingsDisplay.js.map +1 -0
  158. package/dist/components/SparkLineChart.d.ts +21 -0
  159. package/dist/components/SparkLineChart.d.ts.map +1 -0
  160. package/dist/components/SparkLineChart.js +143 -0
  161. package/dist/components/SparkLineChart.js.map +1 -0
  162. package/dist/components/StageAndEditor.d.ts +5 -0
  163. package/dist/components/StageAndEditor.d.ts.map +1 -0
  164. package/dist/components/StageAndEditor.js +12 -0
  165. package/dist/components/StageAndEditor.js.map +1 -0
  166. package/dist/components/TimeControlBar.d.ts +5 -0
  167. package/dist/components/TimeControlBar.d.ts.map +1 -0
  168. package/dist/components/TimeControlBar.js +38 -0
  169. package/dist/components/TimeControlBar.js.map +1 -0
  170. package/dist/components/TokenizedMessage.d.ts +13 -0
  171. package/dist/components/TokenizedMessage.d.ts.map +1 -0
  172. package/dist/components/TokenizedMessage.js +102 -0
  173. package/dist/components/TokenizedMessage.js.map +1 -0
  174. package/dist/components/TopBar.d.ts +4 -0
  175. package/dist/components/TopBar.d.ts.map +1 -0
  176. package/dist/components/TopBar.js +47 -0
  177. package/dist/components/TopBar.js.map +1 -0
  178. package/dist/components/TopBarDropdown.d.ts +6 -0
  179. package/dist/components/TopBarDropdown.d.ts.map +1 -0
  180. package/dist/components/TopBarDropdown.js +69 -0
  181. package/dist/components/TopBarDropdown.js.map +1 -0
  182. package/dist/components/TopBarPlayers.d.ts +2 -0
  183. package/dist/components/TopBarPlayers.d.ts.map +1 -0
  184. package/dist/components/TopBarPlayers.js +70 -0
  185. package/dist/components/TopBarPlayers.js.map +1 -0
  186. package/dist/components/UpdatingCanvasImage.d.ts +7 -0
  187. package/dist/components/UpdatingCanvasImage.d.ts.map +1 -0
  188. package/dist/components/UpdatingCanvasImage.js +22 -0
  189. package/dist/components/UpdatingCanvasImage.js.map +1 -0
  190. package/dist/components/UpdatingCanvasViewer.d.ts +7 -0
  191. package/dist/components/UpdatingCanvasViewer.d.ts.map +1 -0
  192. package/dist/components/UpdatingCanvasViewer.js +50 -0
  193. package/dist/components/UpdatingCanvasViewer.js.map +1 -0
  194. package/dist/components/Viewer.d.ts +16 -0
  195. package/dist/components/Viewer.d.ts.map +1 -0
  196. package/dist/components/Viewer.js +289 -0
  197. package/dist/components/Viewer.js.map +1 -0
  198. package/dist/components/index.d.ts +1 -0
  199. package/dist/components/index.d.ts.map +1 -0
  200. package/dist/components/index.js +2 -0
  201. package/dist/components/index.js.map +1 -0
  202. package/dist/e085acb5e467d8e85d21.woff +0 -0
  203. package/dist/e65dff62134b8879e792.woff +0 -0
  204. package/dist/game/Chit.d.ts +64 -0
  205. package/dist/game/Chit.d.ts.map +1 -0
  206. package/dist/game/Chit.js +524 -0
  207. package/dist/game/Chit.js.map +1 -0
  208. package/dist/game/ClientTimeState.d.ts +16 -0
  209. package/dist/game/ClientTimeState.d.ts.map +1 -0
  210. package/dist/game/ClientTimeState.js +38 -0
  211. package/dist/game/ClientTimeState.js.map +1 -0
  212. package/dist/game/ClockDetails.d.ts +9 -0
  213. package/dist/game/ClockDetails.d.ts.map +1 -0
  214. package/dist/game/ClockDetails.js +19 -0
  215. package/dist/game/ClockDetails.js.map +1 -0
  216. package/dist/game/Connection.d.ts +26 -0
  217. package/dist/game/Connection.d.ts.map +1 -0
  218. package/dist/game/Connection.js +99 -0
  219. package/dist/game/Connection.js.map +1 -0
  220. package/dist/game/ConnectionObject.d.ts +7 -0
  221. package/dist/game/ConnectionObject.d.ts.map +1 -0
  222. package/dist/game/ConnectionObject.js +16 -0
  223. package/dist/game/ConnectionObject.js.map +1 -0
  224. package/dist/game/ConnectionTransport.d.ts +17 -0
  225. package/dist/game/ConnectionTransport.d.ts.map +1 -0
  226. package/dist/game/ConnectionTransport.js +39 -0
  227. package/dist/game/ConnectionTransport.js.map +1 -0
  228. package/dist/game/DropdownChit.d.ts +7 -0
  229. package/dist/game/DropdownChit.d.ts.map +1 -0
  230. package/dist/game/DropdownChit.js +29 -0
  231. package/dist/game/DropdownChit.js.map +1 -0
  232. package/dist/game/GalleryItemChitChildrenSource.d.ts +12 -0
  233. package/dist/game/GalleryItemChitChildrenSource.d.ts.map +1 -0
  234. package/dist/game/GalleryItemChitChildrenSource.js +25 -0
  235. package/dist/game/GalleryItemChitChildrenSource.js.map +1 -0
  236. package/dist/game/GalleryItemRawSource.d.ts +9 -0
  237. package/dist/game/GalleryItemRawSource.d.ts.map +1 -0
  238. package/dist/game/GalleryItemRawSource.js +13 -0
  239. package/dist/game/GalleryItemRawSource.js.map +1 -0
  240. package/dist/game/Game.d.ts +51 -0
  241. package/dist/game/Game.d.ts.map +1 -0
  242. package/dist/game/Game.js +2 -0
  243. package/dist/game/Game.js.map +1 -0
  244. package/dist/game/GameBagChit.d.ts +16 -0
  245. package/dist/game/GameBagChit.d.ts.map +1 -0
  246. package/dist/game/GameBagChit.js +51 -0
  247. package/dist/game/GameBagChit.js.map +1 -0
  248. package/dist/game/GameButton.d.ts +30 -0
  249. package/dist/game/GameButton.d.ts.map +1 -0
  250. package/dist/game/GameButton.js +115 -0
  251. package/dist/game/GameButton.js.map +1 -0
  252. package/dist/game/GameDeckChit.d.ts +23 -0
  253. package/dist/game/GameDeckChit.d.ts.map +1 -0
  254. package/dist/game/GameDeckChit.js +79 -0
  255. package/dist/game/GameDeckChit.js.map +1 -0
  256. package/dist/game/GameTheme.d.ts +75 -0
  257. package/dist/game/GameTheme.d.ts.map +1 -0
  258. package/dist/game/GameTheme.js +103 -0
  259. package/dist/game/GameTheme.js.map +1 -0
  260. package/dist/game/Match.d.ts +34 -0
  261. package/dist/game/Match.d.ts.map +1 -0
  262. package/dist/game/Match.js +151 -0
  263. package/dist/game/Match.js.map +1 -0
  264. package/dist/game/MatchConnection.d.ts +8 -0
  265. package/dist/game/MatchConnection.d.ts.map +1 -0
  266. package/dist/game/MatchConnection.js +6 -0
  267. package/dist/game/MatchConnection.js.map +1 -0
  268. package/dist/game/MatchStorage.d.ts +17 -0
  269. package/dist/game/MatchStorage.d.ts.map +1 -0
  270. package/dist/game/MatchStorage.js +32 -0
  271. package/dist/game/MatchStorage.js.map +1 -0
  272. package/dist/game/ModalState.d.ts +9 -0
  273. package/dist/game/ModalState.d.ts.map +1 -0
  274. package/dist/game/ModalState.js +27 -0
  275. package/dist/game/ModalState.js.map +1 -0
  276. package/dist/game/OrderedOutlet.d.ts +50 -0
  277. package/dist/game/OrderedOutlet.d.ts.map +1 -0
  278. package/dist/game/OrderedOutlet.js +164 -0
  279. package/dist/game/OrderedOutlet.js.map +1 -0
  280. package/dist/game/Pick.d.ts +26 -0
  281. package/dist/game/Pick.d.ts.map +1 -0
  282. package/dist/game/Pick.js +239 -0
  283. package/dist/game/Pick.js.map +1 -0
  284. package/dist/game/PlayerChit.d.ts +16 -0
  285. package/dist/game/PlayerChit.d.ts.map +1 -0
  286. package/dist/game/PlayerChit.js +56 -0
  287. package/dist/game/PlayerChit.js.map +1 -0
  288. package/dist/game/PlayerInfo.d.ts +12 -0
  289. package/dist/game/PlayerInfo.d.ts.map +1 -0
  290. package/dist/game/PlayerInfo.js +20 -0
  291. package/dist/game/PlayerInfo.js.map +1 -0
  292. package/dist/game/PlayerPromptStatusChit.d.ts +5 -0
  293. package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -0
  294. package/dist/game/PlayerPromptStatusChit.js +35 -0
  295. package/dist/game/PlayerPromptStatusChit.js.map +1 -0
  296. package/dist/game/Prompt.d.ts +94 -0
  297. package/dist/game/Prompt.d.ts.map +1 -0
  298. package/dist/game/Prompt.js +229 -0
  299. package/dist/game/Prompt.js.map +1 -0
  300. package/dist/game/RootChit.d.ts +15 -0
  301. package/dist/game/RootChit.d.ts.map +1 -0
  302. package/dist/game/RootChit.js +62 -0
  303. package/dist/game/RootChit.js.map +1 -0
  304. package/dist/game/SparkChit.d.ts +27 -0
  305. package/dist/game/SparkChit.d.ts.map +1 -0
  306. package/dist/game/SparkChit.js +97 -0
  307. package/dist/game/SparkChit.js.map +1 -0
  308. package/dist/game/StaticChitTypeRegistry.d.ts +5 -0
  309. package/dist/game/StaticChitTypeRegistry.d.ts.map +1 -0
  310. package/dist/game/StaticChitTypeRegistry.js +3 -0
  311. package/dist/game/StaticChitTypeRegistry.js.map +1 -0
  312. package/dist/game/Turn.d.ts +169 -0
  313. package/dist/game/Turn.d.ts.map +1 -0
  314. package/dist/game/Turn.js +1031 -0
  315. package/dist/game/Turn.js.map +1 -0
  316. package/dist/game/TurnState.d.ts +30 -0
  317. package/dist/game/TurnState.d.ts.map +1 -0
  318. package/dist/game/TurnState.js +170 -0
  319. package/dist/game/TurnState.js.map +1 -0
  320. package/dist/game/clientTransport/ClientPrompts.d.ts +23 -0
  321. package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -0
  322. package/dist/game/clientTransport/ClientPrompts.js +85 -0
  323. package/dist/game/clientTransport/ClientPrompts.js.map +1 -0
  324. package/dist/game/clientTransport/ClientStatus.d.ts +19 -0
  325. package/dist/game/clientTransport/ClientStatus.d.ts.map +1 -0
  326. package/dist/game/clientTransport/ClientStatus.js +25 -0
  327. package/dist/game/clientTransport/ClientStatus.js.map +1 -0
  328. package/dist/game/clientTransport/ClientTime.d.ts +42 -0
  329. package/dist/game/clientTransport/ClientTime.d.ts.map +1 -0
  330. package/dist/game/clientTransport/ClientTime.js +197 -0
  331. package/dist/game/clientTransport/ClientTime.js.map +1 -0
  332. package/dist/game/index.d.ts +1 -0
  333. package/dist/game/index.d.ts.map +1 -0
  334. package/dist/game/index.js +2 -0
  335. package/dist/game/index.js.map +1 -0
  336. package/dist/game/serverTransport/ServerPrompts.d.ts +17 -0
  337. package/dist/game/serverTransport/ServerPrompts.d.ts.map +1 -0
  338. package/dist/game/serverTransport/ServerPrompts.js +51 -0
  339. package/dist/game/serverTransport/ServerPrompts.js.map +1 -0
  340. package/dist/game/serverTransport/ServerStatus.d.ts +12 -0
  341. package/dist/game/serverTransport/ServerStatus.d.ts.map +1 -0
  342. package/dist/game/serverTransport/ServerStatus.js +16 -0
  343. package/dist/game/serverTransport/ServerStatus.js.map +1 -0
  344. package/dist/game/serverTransport/ServerTime.d.ts +39 -0
  345. package/dist/game/serverTransport/ServerTime.d.ts.map +1 -0
  346. package/dist/game/serverTransport/ServerTime.js +57 -0
  347. package/dist/game/serverTransport/ServerTime.js.map +1 -0
  348. package/dist/hooks/useChits.d.ts +4 -0
  349. package/dist/hooks/useChits.d.ts.map +1 -0
  350. package/dist/hooks/useChits.js +24 -0
  351. package/dist/hooks/useChits.js.map +1 -0
  352. package/dist/hooks/useConnection.d.ts +8 -0
  353. package/dist/hooks/useConnection.d.ts.map +1 -0
  354. package/dist/hooks/useConnection.js +14 -0
  355. package/dist/hooks/useConnection.js.map +1 -0
  356. package/dist/hooks/useEventChannelState.d.ts +4 -0
  357. package/dist/hooks/useEventChannelState.d.ts.map +1 -0
  358. package/dist/hooks/useEventChannelState.js +25 -0
  359. package/dist/hooks/useEventChannelState.js.map +1 -0
  360. package/dist/hooks/useGame.d.ts +8 -0
  361. package/dist/hooks/useGame.d.ts.map +1 -0
  362. package/dist/hooks/useGame.js +14 -0
  363. package/dist/hooks/useGame.js.map +1 -0
  364. package/dist/hooks/useGameTheme.d.ts +8 -0
  365. package/dist/hooks/useGameTheme.d.ts.map +1 -0
  366. package/dist/hooks/useGameTheme.js +11 -0
  367. package/dist/hooks/useGameTheme.js.map +1 -0
  368. package/dist/hooks/useModalState.d.ts +7 -0
  369. package/dist/hooks/useModalState.d.ts.map +1 -0
  370. package/dist/hooks/useModalState.js +12 -0
  371. package/dist/hooks/useModalState.js.map +1 -0
  372. package/dist/hooks/usePanelPositioning.d.ts +22 -0
  373. package/dist/hooks/usePanelPositioning.d.ts.map +1 -0
  374. package/dist/hooks/usePanelPositioning.js +10 -0
  375. package/dist/hooks/usePanelPositioning.js.map +1 -0
  376. package/dist/hooks/usePanelScale.d.ts +7 -0
  377. package/dist/hooks/usePanelScale.d.ts.map +1 -0
  378. package/dist/hooks/usePanelScale.js +22 -0
  379. package/dist/hooks/usePanelScale.js.map +1 -0
  380. package/dist/hooks/usePanelStates.d.ts +9 -0
  381. package/dist/hooks/usePanelStates.d.ts.map +1 -0
  382. package/dist/hooks/usePanelStates.js +19 -0
  383. package/dist/hooks/usePanelStates.js.map +1 -0
  384. package/dist/hooks/usePlayer.d.ts +7 -0
  385. package/dist/hooks/usePlayer.d.ts.map +1 -0
  386. package/dist/hooks/usePlayer.js +14 -0
  387. package/dist/hooks/usePlayer.js.map +1 -0
  388. package/dist/hooks/useSmartDebouncedState.d.ts +27 -0
  389. package/dist/hooks/useSmartDebouncedState.d.ts.map +1 -0
  390. package/dist/hooks/useSmartDebouncedState.js +109 -0
  391. package/dist/hooks/useSmartDebouncedState.js.map +1 -0
  392. package/dist/hooks/useTimeController.d.ts +22 -0
  393. package/dist/hooks/useTimeController.d.ts.map +1 -0
  394. package/dist/hooks/useTimeController.js +89 -0
  395. package/dist/hooks/useTimeController.js.map +1 -0
  396. package/dist/hooks/useTokenMap.d.ts +5 -0
  397. package/dist/hooks/useTokenMap.d.ts.map +1 -0
  398. package/dist/hooks/useTokenMap.js +16 -0
  399. package/dist/hooks/useTokenMap.js.map +1 -0
  400. package/dist/hooks/useWebGlRenderer.d.ts +34 -0
  401. package/dist/hooks/useWebGlRenderer.d.ts.map +1 -0
  402. package/dist/hooks/useWebGlRenderer.js +167 -0
  403. package/dist/hooks/useWebGlRenderer.js.map +1 -0
  404. package/dist/index.d.ts +97 -0
  405. package/dist/index.d.ts.map +1 -0
  406. package/dist/index.html +12 -0
  407. package/dist/index.js +62 -0
  408. package/dist/index.js.map +1 -0
  409. package/dist/pretty-chitty.js +190767 -0
  410. package/dist/pretty-chitty.js.map +1 -0
  411. package/dist/rendering/CameraSpec.d.ts +22 -0
  412. package/dist/rendering/CameraSpec.d.ts.map +1 -0
  413. package/dist/rendering/CameraSpec.js +25 -0
  414. package/dist/rendering/CameraSpec.js.map +1 -0
  415. package/dist/rendering/CameraWrapperPerspective.d.ts +44 -0
  416. package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -0
  417. package/dist/rendering/CameraWrapperPerspective.js +481 -0
  418. package/dist/rendering/CameraWrapperPerspective.js.map +1 -0
  419. package/dist/rendering/ChitGalleryItemInstance.d.ts +31 -0
  420. package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -0
  421. package/dist/rendering/ChitGalleryItemInstance.js +75 -0
  422. package/dist/rendering/ChitGalleryItemInstance.js.map +1 -0
  423. package/dist/rendering/ChitRenderInstance.d.ts +104 -0
  424. package/dist/rendering/ChitRenderInstance.d.ts.map +1 -0
  425. package/dist/rendering/ChitRenderInstance.js +902 -0
  426. package/dist/rendering/ChitRenderInstance.js.map +1 -0
  427. package/dist/rendering/ChitRenderSpec.d.ts +80 -0
  428. package/dist/rendering/ChitRenderSpec.d.ts.map +1 -0
  429. package/dist/rendering/ChitRenderSpec.js +152 -0
  430. package/dist/rendering/ChitRenderSpec.js.map +1 -0
  431. package/dist/rendering/HighlightSpec.d.ts +6 -0
  432. package/dist/rendering/HighlightSpec.d.ts.map +1 -0
  433. package/dist/rendering/HighlightSpec.js +6 -0
  434. package/dist/rendering/HighlightSpec.js.map +1 -0
  435. package/dist/rendering/LightSpec.d.ts +17 -0
  436. package/dist/rendering/LightSpec.d.ts.map +1 -0
  437. package/dist/rendering/LightSpec.js +37 -0
  438. package/dist/rendering/LightSpec.js.map +1 -0
  439. package/dist/rendering/LightWrapper.d.ts +19 -0
  440. package/dist/rendering/LightWrapper.d.ts.map +1 -0
  441. package/dist/rendering/LightWrapper.js +114 -0
  442. package/dist/rendering/LightWrapper.js.map +1 -0
  443. package/dist/rendering/RootChitRenderInstance.d.ts +81 -0
  444. package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -0
  445. package/dist/rendering/RootChitRenderInstance.js +372 -0
  446. package/dist/rendering/RootChitRenderInstance.js.map +1 -0
  447. package/dist/rendering/Splay.d.ts +23 -0
  448. package/dist/rendering/Splay.d.ts.map +1 -0
  449. package/dist/rendering/Splay.js +89 -0
  450. package/dist/rendering/Splay.js.map +1 -0
  451. package/dist/rendering/SplayCounter.d.ts +19 -0
  452. package/dist/rendering/SplayCounter.d.ts.map +1 -0
  453. package/dist/rendering/SplayCounter.js +18 -0
  454. package/dist/rendering/SplayCounter.js.map +1 -0
  455. package/dist/rendering/TextureReferenceCounter.d.ts +12 -0
  456. package/dist/rendering/TextureReferenceCounter.d.ts.map +1 -0
  457. package/dist/rendering/TextureReferenceCounter.js +76 -0
  458. package/dist/rendering/TextureReferenceCounter.js.map +1 -0
  459. package/dist/rendering/index.d.ts +1 -0
  460. package/dist/rendering/index.d.ts.map +1 -0
  461. package/dist/rendering/index.js +2 -0
  462. package/dist/rendering/index.js.map +1 -0
  463. package/dist/rendering/outline/DepthVisualizationPass.d.ts +12 -0
  464. package/dist/rendering/outline/DepthVisualizationPass.d.ts.map +1 -0
  465. package/dist/rendering/outline/DepthVisualizationPass.js +93 -0
  466. package/dist/rendering/outline/DepthVisualizationPass.js.map +1 -0
  467. package/dist/rendering/outline/EffectComposer.d.ts +24 -0
  468. package/dist/rendering/outline/EffectComposer.d.ts.map +1 -0
  469. package/dist/rendering/outline/EffectComposer.js +118 -0
  470. package/dist/rendering/outline/EffectComposer.js.map +1 -0
  471. package/dist/rendering/outline/FullScreenQuad.d.ts +12 -0
  472. package/dist/rendering/outline/FullScreenQuad.d.ts.map +1 -0
  473. package/dist/rendering/outline/FullScreenQuad.js +21 -0
  474. package/dist/rendering/outline/FullScreenQuad.js.map +1 -0
  475. package/dist/rendering/outline/IDBasedOutlinePass.d.ts +49 -0
  476. package/dist/rendering/outline/IDBasedOutlinePass.d.ts.map +1 -0
  477. package/dist/rendering/outline/IDBasedOutlinePass.js +597 -0
  478. package/dist/rendering/outline/IDBasedOutlinePass.js.map +1 -0
  479. package/dist/rendering/outline/OutputPass.d.ts +13 -0
  480. package/dist/rendering/outline/OutputPass.d.ts.map +1 -0
  481. package/dist/rendering/outline/OutputPass.js +57 -0
  482. package/dist/rendering/outline/OutputPass.js.map +1 -0
  483. package/dist/rendering/outline/RenderPass.d.ts +13 -0
  484. package/dist/rendering/outline/RenderPass.d.ts.map +1 -0
  485. package/dist/rendering/outline/RenderPass.js +54 -0
  486. package/dist/rendering/outline/RenderPass.js.map +1 -0
  487. package/dist/rendering/outline/SceneWrapper.d.ts +39 -0
  488. package/dist/rendering/outline/SceneWrapper.d.ts.map +1 -0
  489. package/dist/rendering/outline/SceneWrapper.js +522 -0
  490. package/dist/rendering/outline/SceneWrapper.js.map +1 -0
  491. package/dist/rendering/outline/ShaderPass.d.ts +12 -0
  492. package/dist/rendering/outline/ShaderPass.d.ts.map +1 -0
  493. package/dist/rendering/outline/ShaderPass.js +43 -0
  494. package/dist/rendering/outline/ShaderPass.js.map +1 -0
  495. package/dist/rendering/outline/index.d.ts +8 -0
  496. package/dist/rendering/outline/index.d.ts.map +1 -0
  497. package/dist/rendering/outline/index.js +8 -0
  498. package/dist/rendering/outline/index.js.map +1 -0
  499. package/dist/rendering/outline/passes/DebugIDMappingPass.d.ts +20 -0
  500. package/dist/rendering/outline/passes/DebugIDMappingPass.d.ts.map +1 -0
  501. package/dist/rendering/outline/passes/DebugIDMappingPass.js +131 -0
  502. package/dist/rendering/outline/passes/DebugIDMappingPass.js.map +1 -0
  503. package/dist/rendering/outline/passes/DepthOcclusionPass.d.ts +24 -0
  504. package/dist/rendering/outline/passes/DepthOcclusionPass.d.ts.map +1 -0
  505. package/dist/rendering/outline/passes/DepthOcclusionPass.js +95 -0
  506. package/dist/rendering/outline/passes/DepthOcclusionPass.js.map +1 -0
  507. package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.d.ts +32 -0
  508. package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.d.ts.map +1 -0
  509. package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.js +208 -0
  510. package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.js.map +1 -0
  511. package/dist/rendering/outline/shaders.d.ts +20 -0
  512. package/dist/rendering/outline/shaders.d.ts.map +1 -0
  513. package/dist/rendering/outline/shaders.js +103 -0
  514. package/dist/rendering/outline/shaders.js.map +1 -0
  515. package/dist/rendering/outline/types.d.ts +14 -0
  516. package/dist/rendering/outline/types.d.ts.map +1 -0
  517. package/dist/rendering/outline/types.js +16 -0
  518. package/dist/rendering/outline/types.js.map +1 -0
  519. package/dist/utilities/Annotations.d.ts +60 -0
  520. package/dist/utilities/Annotations.d.ts.map +1 -0
  521. package/dist/utilities/Annotations.js +171 -0
  522. package/dist/utilities/Annotations.js.map +1 -0
  523. package/dist/utilities/BaseTable.d.ts +8 -0
  524. package/dist/utilities/BaseTable.d.ts.map +1 -0
  525. package/dist/utilities/BaseTable.js +35 -0
  526. package/dist/utilities/BaseTable.js.map +1 -0
  527. package/dist/utilities/BboxUtils.d.ts +3 -0
  528. package/dist/utilities/BboxUtils.d.ts.map +1 -0
  529. package/dist/utilities/BboxUtils.js +19 -0
  530. package/dist/utilities/BboxUtils.js.map +1 -0
  531. package/dist/utilities/CanvasStack/CanvasOperations.d.ts +140 -0
  532. package/dist/utilities/CanvasStack/CanvasOperations.d.ts.map +1 -0
  533. package/dist/utilities/CanvasStack/CanvasOperations.js +403 -0
  534. package/dist/utilities/CanvasStack/CanvasOperations.js.map +1 -0
  535. package/dist/utilities/CanvasStack/CanvasStack.d.ts +42 -0
  536. package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -0
  537. package/dist/utilities/CanvasStack/CanvasStack.js +128 -0
  538. package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -0
  539. package/dist/utilities/CanvasStack/IconCanvas.d.ts +10 -0
  540. package/dist/utilities/CanvasStack/IconCanvas.d.ts.map +1 -0
  541. package/dist/utilities/CanvasStack/IconCanvas.js +15 -0
  542. package/dist/utilities/CanvasStack/IconCanvas.js.map +1 -0
  543. package/dist/utilities/CanvasStack/ImageCache.d.ts +8 -0
  544. package/dist/utilities/CanvasStack/ImageCache.d.ts.map +1 -0
  545. package/dist/utilities/CanvasStack/ImageCache.js +29 -0
  546. package/dist/utilities/CanvasStack/ImageCache.js.map +1 -0
  547. package/dist/utilities/CanvasStack/ImageColorOverlayer.d.ts +2 -0
  548. package/dist/utilities/CanvasStack/ImageColorOverlayer.d.ts.map +1 -0
  549. package/dist/utilities/CanvasStack/ImageColorOverlayer.js +31 -0
  550. package/dist/utilities/CanvasStack/ImageColorOverlayer.js.map +1 -0
  551. package/dist/utilities/CanvasStack/PlayerCanvas.d.ts +10 -0
  552. package/dist/utilities/CanvasStack/PlayerCanvas.d.ts.map +1 -0
  553. package/dist/utilities/CanvasStack/PlayerCanvas.js +15 -0
  554. package/dist/utilities/CanvasStack/PlayerCanvas.js.map +1 -0
  555. package/dist/utilities/CanvasStack/ReactCanvas.d.ts +133 -0
  556. package/dist/utilities/CanvasStack/ReactCanvas.d.ts.map +1 -0
  557. package/dist/utilities/CanvasStack/ReactCanvas.js +161 -0
  558. package/dist/utilities/CanvasStack/ReactCanvas.js.map +1 -0
  559. package/dist/utilities/CanvasStack/RichTextRenderer.d.ts +63 -0
  560. package/dist/utilities/CanvasStack/RichTextRenderer.d.ts.map +1 -0
  561. package/dist/utilities/CanvasStack/RichTextRenderer.js +523 -0
  562. package/dist/utilities/CanvasStack/RichTextRenderer.js.map +1 -0
  563. package/dist/utilities/CardMesh.d.ts +17 -0
  564. package/dist/utilities/CardMesh.d.ts.map +1 -0
  565. package/dist/utilities/CardMesh.js +44 -0
  566. package/dist/utilities/CardMesh.js.map +1 -0
  567. package/dist/utilities/Dice.d.ts +24 -0
  568. package/dist/utilities/Dice.d.ts.map +1 -0
  569. package/dist/utilities/Dice.js +148 -0
  570. package/dist/utilities/Dice.js.map +1 -0
  571. package/dist/utilities/EventChannel.d.ts +13 -0
  572. package/dist/utilities/EventChannel.d.ts.map +1 -0
  573. package/dist/utilities/EventChannel.js +47 -0
  574. package/dist/utilities/EventChannel.js.map +1 -0
  575. package/dist/utilities/GalleryItemConversion.d.ts +4 -0
  576. package/dist/utilities/GalleryItemConversion.d.ts.map +1 -0
  577. package/dist/utilities/GalleryItemConversion.js +28 -0
  578. package/dist/utilities/GalleryItemConversion.js.map +1 -0
  579. package/dist/utilities/IUpdatingCanvas.d.ts +19 -0
  580. package/dist/utilities/IUpdatingCanvas.d.ts.map +1 -0
  581. package/dist/utilities/IUpdatingCanvas.js +2 -0
  582. package/dist/utilities/IUpdatingCanvas.js.map +1 -0
  583. package/dist/utilities/LayoutHelper.d.ts +34 -0
  584. package/dist/utilities/LayoutHelper.d.ts.map +1 -0
  585. package/dist/utilities/LayoutHelper.js +451 -0
  586. package/dist/utilities/LayoutHelper.js.map +1 -0
  587. package/dist/utilities/ObjectWithProps.d.ts +5 -0
  588. package/dist/utilities/ObjectWithProps.d.ts.map +1 -0
  589. package/dist/utilities/ObjectWithProps.js +65 -0
  590. package/dist/utilities/ObjectWithProps.js.map +1 -0
  591. package/dist/utilities/OutlineCanvas.d.ts +12 -0
  592. package/dist/utilities/OutlineCanvas.d.ts.map +1 -0
  593. package/dist/utilities/OutlineCanvas.js +31 -0
  594. package/dist/utilities/OutlineCanvas.js.map +1 -0
  595. package/dist/utilities/OutlineGeometry.d.ts +3 -0
  596. package/dist/utilities/OutlineGeometry.d.ts.map +1 -0
  597. package/dist/utilities/OutlineGeometry.js +57 -0
  598. package/dist/utilities/OutlineGeometry.js.map +1 -0
  599. package/dist/utilities/ParameterizedCanvas.d.ts +13 -0
  600. package/dist/utilities/ParameterizedCanvas.d.ts.map +1 -0
  601. package/dist/utilities/ParameterizedCanvas.js +85 -0
  602. package/dist/utilities/ParameterizedCanvas.js.map +1 -0
  603. package/dist/utilities/RequestSharedAnimationFrame.d.ts +2 -0
  604. package/dist/utilities/RequestSharedAnimationFrame.d.ts.map +1 -0
  605. package/dist/utilities/RequestSharedAnimationFrame.js +16 -0
  606. package/dist/utilities/RequestSharedAnimationFrame.js.map +1 -0
  607. package/dist/utilities/StaticImage.d.ts +19 -0
  608. package/dist/utilities/StaticImage.d.ts.map +1 -0
  609. package/dist/utilities/StaticImage.js +38 -0
  610. package/dist/utilities/StaticImage.js.map +1 -0
  611. package/dist/utilities/SvgExtruder.d.ts +20 -0
  612. package/dist/utilities/SvgExtruder.d.ts.map +1 -0
  613. package/dist/utilities/SvgExtruder.js +238 -0
  614. package/dist/utilities/SvgExtruder.js.map +1 -0
  615. package/dist/utilities/ThreeDisposer.d.ts +11 -0
  616. package/dist/utilities/ThreeDisposer.d.ts.map +1 -0
  617. package/dist/utilities/ThreeDisposer.js +53 -0
  618. package/dist/utilities/ThreeDisposer.js.map +1 -0
  619. package/dist/utilities/zIndex.d.ts +14 -0
  620. package/dist/utilities/zIndex.d.ts.map +1 -0
  621. package/dist/utilities/zIndex.js +14 -0
  622. package/dist/utilities/zIndex.js.map +1 -0
  623. package/package.json +138 -0
  624. package/src/library/assets/checker.svg +4 -0
  625. package/src/library/assets/cutout.svg +22 -0
  626. package/src/library/components/ActionLogDisplay.tsx +183 -0
  627. package/src/library/components/ActionLogHistory.tsx +127 -0
  628. package/src/library/components/ActionLogHistoryDisplay.tsx +21 -0
  629. package/src/library/components/ActionLogSidebar.tsx +17 -0
  630. package/src/library/components/BottomBar.tsx +78 -0
  631. package/src/library/components/BottomBarBreak.tsx +12 -0
  632. package/src/library/components/BottomBarButton.tsx +181 -0
  633. package/src/library/components/CanvasLibraryViewer.tsx +86 -0
  634. package/src/library/components/ChitLibraryViewer.tsx +168 -0
  635. package/src/library/components/ClientTrustMatchViewer.tsx +83 -0
  636. package/src/library/components/ContextGalleryDisplay.tsx +72 -0
  637. package/src/library/components/GalleryDisplay.tsx +57 -0
  638. package/src/library/components/GalleryPlayground.tsx +50 -0
  639. package/src/library/components/GalleryViewer.tsx +773 -0
  640. package/src/library/components/GameDesigner.tsx +39 -0
  641. package/src/library/components/GameDialog.tsx +43 -0
  642. package/src/library/components/GameModalBackdrop.tsx +47 -0
  643. package/src/library/components/GameModalDialog.tsx +77 -0
  644. package/src/library/components/LiveButton.tsx +26 -0
  645. package/src/library/components/MatchEndDisplay.tsx +120 -0
  646. package/src/library/components/MatchViewer.tsx +111 -0
  647. package/src/library/components/ObjectWithPropsEditor.tsx +169 -0
  648. package/src/library/components/Panel/MultiPanel.tsx +276 -0
  649. package/src/library/components/Panel/PanelContents.tsx +359 -0
  650. package/src/library/components/Panel/PanelTabStack.tsx +103 -0
  651. package/src/library/components/Panel/SinglePanel.tsx +75 -0
  652. package/src/library/components/Panel/ViewerWrapper.tsx +131 -0
  653. package/src/library/components/Panel/ViewerZoomControls.tsx +216 -0
  654. package/src/library/components/Panel/util.ts +7 -0
  655. package/src/library/components/PanelSpark.tsx +112 -0
  656. package/src/library/components/PersistentCanvas.tsx +81 -0
  657. package/src/library/components/PlayerImage.tsx +40 -0
  658. package/src/library/components/Playground.tsx +285 -0
  659. package/src/library/components/PromptControls.tsx +132 -0
  660. package/src/library/components/SelectableItemAndStage.tsx +49 -0
  661. package/src/library/components/SettingsDisplay.tsx +142 -0
  662. package/src/library/components/SparkLineChart.tsx +307 -0
  663. package/src/library/components/StageAndEditor.tsx +28 -0
  664. package/src/library/components/TimeControlBar.tsx +71 -0
  665. package/src/library/components/TokenizedMessage.tsx +206 -0
  666. package/src/library/components/TopBar.tsx +90 -0
  667. package/src/library/components/TopBarDropdown.tsx +94 -0
  668. package/src/library/components/TopBarPlayers.tsx +163 -0
  669. package/src/library/components/UpdatingCanvasImage.tsx +25 -0
  670. package/src/library/components/UpdatingCanvasViewer.tsx +62 -0
  671. package/src/library/components/Viewer.tsx +360 -0
  672. package/src/library/components/index.ts +0 -0
  673. package/src/library/game/Chit.test.ts +66 -0
  674. package/src/library/game/Chit.ts +575 -0
  675. package/src/library/game/ClientTimeState.ts +42 -0
  676. package/src/library/game/ClockDetails.ts +24 -0
  677. package/src/library/game/Connection.test.ts +50 -0
  678. package/src/library/game/Connection.ts +122 -0
  679. package/src/library/game/ConnectionObject.ts +13 -0
  680. package/src/library/game/ConnectionTransport.ts +52 -0
  681. package/src/library/game/DropdownChit.tsx +17 -0
  682. package/src/library/game/GalleryItemChitChildrenSource.ts +31 -0
  683. package/src/library/game/GalleryItemRawSource.ts +15 -0
  684. package/src/library/game/Game.ts +55 -0
  685. package/src/library/game/GameBagChit.ts +42 -0
  686. package/src/library/game/GameButton.ts +127 -0
  687. package/src/library/game/GameDeckChit.ts +77 -0
  688. package/src/library/game/GameTheme.ts +122 -0
  689. package/src/library/game/Match.ts +187 -0
  690. package/src/library/game/MatchConnection.ts +5 -0
  691. package/src/library/game/MatchStorage.ts +51 -0
  692. package/src/library/game/ModalState.ts +29 -0
  693. package/src/library/game/OrderedOutlet.ts +198 -0
  694. package/src/library/game/Pick.ts +314 -0
  695. package/src/library/game/PlayerChit.ts +43 -0
  696. package/src/library/game/PlayerInfo.ts +30 -0
  697. package/src/library/game/PlayerPromptStatusChit.ts +20 -0
  698. package/src/library/game/Prompt.ts +292 -0
  699. package/src/library/game/RootChit.ts +54 -0
  700. package/src/library/game/SparkChit.ts +97 -0
  701. package/src/library/game/StaticChitTypeRegistry.ts +3 -0
  702. package/src/library/game/Turn.test.ts +611 -0
  703. package/src/library/game/Turn.ts +1249 -0
  704. package/src/library/game/TurnState.ts +187 -0
  705. package/src/library/game/clientTransport/ClientPrompts.ts +102 -0
  706. package/src/library/game/clientTransport/ClientStatus.ts +36 -0
  707. package/src/library/game/clientTransport/ClientTime.ts +256 -0
  708. package/src/library/game/index.ts +0 -0
  709. package/src/library/game/serverTransport/ServerPrompts.ts +76 -0
  710. package/src/library/game/serverTransport/ServerStatus.ts +31 -0
  711. package/src/library/game/serverTransport/ServerTime.ts +74 -0
  712. package/src/library/hooks/useChits.ts +32 -0
  713. package/src/library/hooks/useConnection.tsx +16 -0
  714. package/src/library/hooks/useEventChannelState.ts +33 -0
  715. package/src/library/hooks/useGame.tsx +16 -0
  716. package/src/library/hooks/useGameTheme.tsx +12 -0
  717. package/src/library/hooks/useModalState.tsx +13 -0
  718. package/src/library/hooks/usePanelPositioning.tsx +31 -0
  719. package/src/library/hooks/usePanelScale.tsx +23 -0
  720. package/src/library/hooks/usePanelStates.ts +30 -0
  721. package/src/library/hooks/usePlayer.tsx +15 -0
  722. package/src/library/hooks/useSmartDebouncedState.ts +161 -0
  723. package/src/library/hooks/useTimeController.tsx +108 -0
  724. package/src/library/hooks/useTokenMap.ts +20 -0
  725. package/src/library/hooks/useWebGlRenderer.tsx +227 -0
  726. package/src/library/index.ts +116 -0
  727. package/src/library/rendering/CameraSpec.ts +25 -0
  728. package/src/library/rendering/CameraWrapperPerspective.ts +612 -0
  729. package/src/library/rendering/ChitGalleryItemInstance.ts +108 -0
  730. package/src/library/rendering/ChitRenderInstance.ts +1141 -0
  731. package/src/library/rendering/ChitRenderSpec.ts +213 -0
  732. package/src/library/rendering/HighlightSpec.ts +5 -0
  733. package/src/library/rendering/LightSpec.ts +41 -0
  734. package/src/library/rendering/LightWrapper.ts +152 -0
  735. package/src/library/rendering/RootChitRenderInstance.ts +460 -0
  736. package/src/library/rendering/Splay.ts +118 -0
  737. package/src/library/rendering/SplayCounter.tsx +37 -0
  738. package/src/library/rendering/TextureReferenceCounter.ts +86 -0
  739. package/src/library/rendering/index.ts +0 -0
  740. package/src/library/rendering/outline/DepthVisualizationPass.ts +117 -0
  741. package/src/library/rendering/outline/EffectComposer.ts +187 -0
  742. package/src/library/rendering/outline/FullScreenQuad.ts +32 -0
  743. package/src/library/rendering/outline/IDBasedOutlinePass.ts +741 -0
  744. package/src/library/rendering/outline/OutputPass.ts +88 -0
  745. package/src/library/rendering/outline/RenderPass.ts +72 -0
  746. package/src/library/rendering/outline/SceneWrapper.ts +617 -0
  747. package/src/library/rendering/outline/ShaderPass.ts +50 -0
  748. package/src/library/rendering/outline/index.ts +8 -0
  749. package/src/library/rendering/outline/passes/DebugIDMappingPass.ts +154 -0
  750. package/src/library/rendering/outline/passes/DepthOcclusionPass.ts +106 -0
  751. package/src/library/rendering/outline/passes/InterMeshEdgeDetectionPass.ts +244 -0
  752. package/src/library/rendering/outline/shaders.ts +110 -0
  753. package/src/library/rendering/outline/types.ts +25 -0
  754. package/src/library/utilities/Annotations.ts +188 -0
  755. package/src/library/utilities/BaseTable.tsx +58 -0
  756. package/src/library/utilities/BboxUtils.ts +23 -0
  757. package/src/library/utilities/CanvasStack/CanvasOperations.tsx +630 -0
  758. package/src/library/utilities/CanvasStack/CanvasStack.ts +191 -0
  759. package/src/library/utilities/CanvasStack/IconCanvas.tsx +17 -0
  760. package/src/library/utilities/CanvasStack/ImageCache.ts +38 -0
  761. package/src/library/utilities/CanvasStack/ImageColorOverlayer.ts +36 -0
  762. package/src/library/utilities/CanvasStack/PlayerCanvas.tsx +17 -0
  763. package/src/library/utilities/CanvasStack/ReactCanvas.tsx +293 -0
  764. package/src/library/utilities/CanvasStack/RichTextRenderer.ts +719 -0
  765. package/src/library/utilities/CardMesh.ts +55 -0
  766. package/src/library/utilities/Dice.tsx +183 -0
  767. package/src/library/utilities/EventChannel.ts +52 -0
  768. package/src/library/utilities/GalleryItemConversion.ts +30 -0
  769. package/src/library/utilities/IUpdatingCanvas.ts +14 -0
  770. package/src/library/utilities/LayoutHelper.ts +586 -0
  771. package/src/library/utilities/ObjectWithProps.ts +52 -0
  772. package/src/library/utilities/OutlineCanvas.tsx +45 -0
  773. package/src/library/utilities/OutlineGeometry.ts +69 -0
  774. package/src/library/utilities/ParameterizedCanvas.ts +78 -0
  775. package/src/library/utilities/RequestSharedAnimationFrame.ts +16 -0
  776. package/src/library/utilities/StaticImage.tsx +58 -0
  777. package/src/library/utilities/SvgExtruder.ts +330 -0
  778. package/src/library/utilities/ThreeDisposer.ts +66 -0
  779. package/src/library/utilities/zIndex.ts +15 -0
@@ -0,0 +1,1141 @@
1
+ import {
2
+ Box3,
3
+ BoxGeometry,
4
+ Euler,
5
+ FrontSide,
6
+ Group,
7
+ Mesh,
8
+ MeshBasicMaterial,
9
+ MeshPhongMaterial,
10
+ Plane,
11
+ PlaneGeometry,
12
+ Quaternion,
13
+ Raycaster,
14
+ Shape,
15
+ Vector2,
16
+ Vector3,
17
+ Color as ThreeColor,
18
+ } from "three";
19
+ import { Chit } from "../game/Chit";
20
+ import { ChitRenderSpec, OwnerOriginPosition } from "./ChitRenderSpec";
21
+ import { Easing, Tween, Group as TweenGroup } from "@tweenjs/tween.js";
22
+ import { RootChitRenderInstance } from "./RootChitRenderInstance";
23
+ import { OutlineCanvas } from "../utilities/OutlineCanvas";
24
+ import { outlineGeometry } from "../utilities/OutlineGeometry";
25
+ import { fixBbox } from "../utilities/BboxUtils";
26
+ import { ChitGalleryItemInstance } from "./ChitGalleryItemInstance";
27
+ import Color from "color";
28
+ import nextTick from "next-tick";
29
+
30
+ const LINE_COLOR = new MeshBasicMaterial({ color: 0xff0000, wireframe: true, wireframeLinewidth: 2 });
31
+ const CLICK_LINE_COLOR = new MeshBasicMaterial({ color: 0xffff00, wireframe: true, wireframeLinewidth: 2 });
32
+ const BOX_GEO = new BoxGeometry(1, 1, 1);
33
+
34
+ interface Point2d {
35
+ x: number;
36
+ y: number;
37
+ }
38
+ interface Point3d {
39
+ x: number;
40
+ y: number;
41
+ z: number;
42
+ }
43
+ interface PointZ {
44
+ z: number;
45
+ }
46
+
47
+ class DestroyedError extends Error {}
48
+
49
+ export class ChitRenderInstance {
50
+ private static ID_COUNTER = 0;
51
+ public id: string;
52
+
53
+ // rendering info
54
+ protected renderSpec: ChitRenderSpec | null = null;
55
+
56
+ // threejs info
57
+ public group = new Group(); // group storing the visible meshes. Will tween
58
+ protected anchorPoints = new Map<OwnerOriginPosition | string, Group>();
59
+
60
+ protected sizeX = 0;
61
+ protected sizeY = 0;
62
+ protected sizeZ = 0;
63
+
64
+ protected centerX = 0;
65
+ protected centerY = 0;
66
+ protected centerZ = 0;
67
+
68
+ protected innateObjectZ = 0;
69
+ protected innateOrnamentZs: number[] = [];
70
+
71
+ protected bboxGroup = new Group(); // group storing bounding boxes. Will not tween. Usually not visible.
72
+ protected bboxAnchorPoints = new Map<OwnerOriginPosition | string, Group>();
73
+ public bbox = new Mesh(BOX_GEO, LINE_COLOR);
74
+ public clickbox = new Mesh(BOX_GEO, CLICK_LINE_COLOR);
75
+ protected isUsingSyntheticBbox = false;
76
+
77
+ protected parentRenderInstance?: ChitRenderInstance;
78
+ protected childrenRenderInstances: ChitRenderInstance[] = [];
79
+
80
+ // tween info
81
+ protected rotationTween = new Tween<Point3d>({ x: 0, y: 0, z: 0 });
82
+ protected offsetTween = new Tween<Point2d>({ x: 0, y: 0 });
83
+ protected zOffsetTween = new Tween<PointZ>({ z: 0 });
84
+
85
+ private unsubscribeToOnChange = () => {};
86
+
87
+ constructor(public chit: Chit) {
88
+ this.id = `cri${++ChitRenderInstance.ID_COUNTER}`;
89
+ this.group.visible = false;
90
+
91
+ let currentPosition: Vector2 | undefined;
92
+ if (chit.renderInstance) {
93
+ currentPosition = chit.screenCoordinates();
94
+ }
95
+
96
+ this.log("Render instance on owning chit is attached");
97
+ chit.renderInstance = this;
98
+
99
+ // handle refreshes.
100
+ const cb1 = chit.onChange("deserialized parent", () => {
101
+ try {
102
+ this.refresh();
103
+ if (this.renderSpec?.worthSlidingToPanelToShowChange) {
104
+ this.rootRenderInstance.markHasPendingChange();
105
+ }
106
+ } catch (e) {
107
+ if (e instanceof DestroyedError) {
108
+ // eat it
109
+ } else {
110
+ throw e;
111
+ }
112
+ }
113
+ });
114
+
115
+ const cb2 = chit.onChange("onClick", () => {
116
+ this.refresh();
117
+ });
118
+ this.unsubscribeToOnChange = () => {
119
+ cb1();
120
+ cb2();
121
+ };
122
+
123
+ this.handleHierarchy();
124
+
125
+ // start it from where it should be - be it a spark chit or a bag or an old parent chit
126
+ const positionEntranceChit = chit.lastParent ?? chit.parentFallback ?? currentPosition;
127
+ if (this.rootRenderInstance) {
128
+ const oldParent = this.group.parent;
129
+ let intersection = this.attemptToFindPlaneZ0(this.rootRenderInstance, positionEntranceChit);
130
+
131
+ if (intersection && oldParent) {
132
+ // Ensure entrance coordinates are outside visible region if they overlap
133
+ intersection = this.ensureCoordinatesOutsideVisibleRegion(intersection);
134
+
135
+ this.group.removeFromParent();
136
+ this.group.position.set(intersection.x, intersection.y, intersection.z);
137
+ oldParent.attach(this.group);
138
+ }
139
+ }
140
+
141
+ this.bboxGroup.add(this.bbox);
142
+ this.bboxGroup.add(this.clickbox);
143
+ }
144
+
145
+ public get effectiveParent() {
146
+ return this.chit.parent ?? this.chit.parentFallback;
147
+ }
148
+
149
+ private log(message: string) {
150
+ if (localStorage.verbose) {
151
+ console.log(`${new Date().getTime()} [ChitRenderInstance] ${this.chit} ${this.id} ${message}`);
152
+ }
153
+ }
154
+
155
+ public init() {
156
+ this.log("init");
157
+ this.chit.children.forEach((child) => {
158
+ if (child.canRender()) {
159
+ if (!child.renderInstance) {
160
+ this.log(`Found child to init: ${child.id}`);
161
+ const c = new ChitRenderInstance(child);
162
+ c.init();
163
+
164
+ // move the new render instance immediately to where it belongs
165
+ this.zeroTween();
166
+ } else {
167
+ child.renderInstance.refresh();
168
+ }
169
+ }
170
+ });
171
+
172
+ this.refresh();
173
+ }
174
+
175
+ zeroTween() {
176
+ this.offsetTween.duration(0);
177
+ this.zOffsetTween.duration(0);
178
+ this.rotationTween.duration(0);
179
+ this.childrenRenderInstances.forEach((child) => child.zeroTween());
180
+ }
181
+
182
+ public galleryRotation() {
183
+ if (this.renderSpec) {
184
+ return new Vector3(
185
+ this.renderSpec.galleryRotateX,
186
+ this.renderSpec.galleryRotateY,
187
+ this.renderSpec.galleryRotateZ,
188
+ );
189
+ }
190
+ return new Vector3(0, 0, 0);
191
+ }
192
+
193
+ public childAdded(chit: Chit, existingRenderInstance?: ChitRenderInstance) {
194
+ if (existingRenderInstance && (existingRenderInstance as RootChitRenderInstance).cameraWrapper) {
195
+ return;
196
+ }
197
+
198
+ if (existingRenderInstance?.rootRenderInstance === this.rootRenderInstance) {
199
+ return;
200
+ }
201
+
202
+ if (!chit.canRender()) {
203
+ return;
204
+ }
205
+
206
+ const c = new ChitRenderInstance(chit);
207
+ if (c.renderSpec?.worthSlidingToPanelToShowChange) {
208
+ this.rootRenderInstance.markHasChitsEntering();
209
+ }
210
+
211
+ if (existingRenderInstance) {
212
+ const refreshParent = (chitRenderInstance: ChitRenderInstance) => {
213
+ if (chitRenderInstance.parentRenderInstance) {
214
+ refreshParent(chitRenderInstance.parentRenderInstance);
215
+ }
216
+ chitRenderInstance.refresh();
217
+ };
218
+ refreshParent(existingRenderInstance);
219
+ }
220
+
221
+ // initializing before the existing renderer has a chance to remove itself will possibly cause weird behavior
222
+ // for attached children chits
223
+ c.init();
224
+ this.notifyBoundingBoxChanged();
225
+ }
226
+
227
+ public get absorbsClickEventsForChildren() {
228
+ return this.renderSpec?.isShowingChildrenAsGallery ?? false;
229
+ }
230
+
231
+ public get tweenGroup(): TweenGroup | undefined {
232
+ return this.parentRenderInstance?.tweenGroup;
233
+ }
234
+ public get rootGroup(): Group | undefined {
235
+ return this.parentRenderInstance?.rootGroup;
236
+ }
237
+
238
+ public invalidateRootRenderInstance() {
239
+ this.rootRenderInstance?.markDirty();
240
+ this._rootRenderInstance = undefined;
241
+ this.childrenRenderInstances.forEach((child) => child.invalidateRootRenderInstance());
242
+ }
243
+
244
+ private _rootRenderInstance?: RootChitRenderInstance;
245
+ public get rootRenderInstance(): RootChitRenderInstance {
246
+ if (this._rootRenderInstance) {
247
+ return this._rootRenderInstance;
248
+ }
249
+ if (!this.parentRenderInstance) {
250
+ this.destroy();
251
+ throw new DestroyedError("Must have parent");
252
+ }
253
+ return (this._rootRenderInstance = this.parentRenderInstance?.rootRenderInstance);
254
+ }
255
+
256
+ public get parentGroup(): Group | undefined {
257
+ return this.parentRenderInstance?.group ?? this.rootGroup;
258
+ }
259
+ public get parentBboxGroup(): Group | undefined {
260
+ return this.parentRenderInstance?.bboxGroup ?? this.rootGroup;
261
+ }
262
+
263
+ public get animationSpeedMultiplier(): number {
264
+ return this.parentRenderInstance?.animationSpeedMultiplier ?? 1;
265
+ }
266
+
267
+ /**
268
+ * Ensures coordinates are outside current viewer's screen bounds for overlapping viewers.
269
+ * If coordinates would be visible in current screen area, moves them to upper left corner.
270
+ */
271
+ private ensureCoordinatesOutsideVisibleRegion(coordinates: Vector3): Vector3 {
272
+ if (!this.rootRenderInstance) {
273
+ return coordinates;
274
+ }
275
+
276
+ // Convert world coordinates to global page coordinates using the same method as screenCoordinates()
277
+ const vector = new Vector3(coordinates.x, coordinates.y, coordinates.z);
278
+ vector.project(this.rootRenderInstance.camera);
279
+ const globalScreenCoords = this.rootRenderInstance.convertCameraSpaceToScreenSpace(vector.x, vector.y);
280
+
281
+ if (!globalScreenCoords) {
282
+ return coordinates;
283
+ }
284
+
285
+ // Get the current viewer's bounds in global page coordinates
286
+ // We need to reverse-engineer the viewer's bounds from the conversion function
287
+ // The conversion function does: rect.left + ((1 + x) / 2) * rect.width
288
+ // So we can get bounds by testing corner positions
289
+ const topLeftGlobal = this.rootRenderInstance.convertCameraSpaceToScreenSpace(-1, 1); // Top-left corner in camera space
290
+ const bottomRightGlobal = this.rootRenderInstance.convertCameraSpaceToScreenSpace(1, -1); // Bottom-right corner in camera space
291
+
292
+ if (!topLeftGlobal || !bottomRightGlobal) {
293
+ return coordinates;
294
+ }
295
+
296
+ // Current viewer bounds in global page coordinates
297
+ const viewerBounds = {
298
+ left: topLeftGlobal.x,
299
+ top: topLeftGlobal.y,
300
+ right: bottomRightGlobal.x,
301
+ bottom: bottomRightGlobal.y,
302
+ };
303
+
304
+ // Add safety margin (50% of viewer dimensions) to account for overlapping viewers
305
+ const marginX = (viewerBounds.right - viewerBounds.left) * 0.5;
306
+ const marginY = (viewerBounds.bottom - viewerBounds.top) * 0.5;
307
+
308
+ // Check if global screen coordinates are within viewer bounds (including margin)
309
+ const isWithinBounds =
310
+ globalScreenCoords.x >= viewerBounds.left &&
311
+ globalScreenCoords.x <= viewerBounds.right &&
312
+ globalScreenCoords.y >= viewerBounds.top &&
313
+ globalScreenCoords.y <= viewerBounds.bottom;
314
+
315
+ if (isWithinBounds) {
316
+ // Target position: upper left of viewer with margin (in global page coordinates)
317
+ const targetGlobalX = viewerBounds.left - marginX;
318
+ const targetGlobalY = viewerBounds.top - marginY;
319
+
320
+ // Convert global page coordinates back to camera space
321
+ const targetCameraSpace = this.rootRenderInstance.convertScreenSpaceToCameraSpace(targetGlobalX, targetGlobalY);
322
+
323
+ if (targetCameraSpace) {
324
+ // Use raycaster to find world position at Z=0 plane
325
+ const raycaster = new Raycaster();
326
+ raycaster.setFromCamera(targetCameraSpace, this.rootRenderInstance.camera);
327
+ const planeZ = new Plane(new Vector3(0, 0, 1), 0);
328
+ const intersection = new Vector3();
329
+ const intersects = raycaster.ray.intersectPlane(planeZ, intersection);
330
+
331
+ if (intersects) {
332
+ return new Vector3(intersects.x, intersects.y, coordinates.z);
333
+ }
334
+ }
335
+ }
336
+
337
+ return coordinates;
338
+ }
339
+
340
+ public anchor(ownerPosition: OwnerOriginPosition | string): Group {
341
+ let result = this.anchorPoints.get(ownerPosition);
342
+ if (!result) {
343
+ result = new Group();
344
+ this.updateGroupPosition(result, ownerPosition);
345
+ this.group.add(result);
346
+ this.anchorPoints.set(ownerPosition, result);
347
+ }
348
+ return result;
349
+ }
350
+
351
+ public bboxAnchor(ownerPosition: OwnerOriginPosition | string): Group {
352
+ let result = this.bboxAnchorPoints.get(ownerPosition);
353
+ if (!result) {
354
+ result = new Group();
355
+ this.updateGroupPosition(result, ownerPosition);
356
+ this.bboxGroup.add(result);
357
+ this.bboxAnchorPoints.set(ownerPosition, result);
358
+ }
359
+ return result;
360
+ }
361
+
362
+ protected setOutletPosition(positionKey: string, position: Vector3) {
363
+ this.anchor(positionKey).position.set(position.x, position.y, position.z);
364
+ this.bboxAnchor(positionKey).position.set(position.x, position.y, position.z);
365
+ }
366
+
367
+ protected updateGroupPosition(group: Group, position: OwnerOriginPosition | string) {
368
+ const z = this.sizeZ / 2 + (this.renderSpec?.childrenOffsetZ ?? 0);
369
+ switch (position) {
370
+ case OwnerOriginPosition.TopLeft: {
371
+ group.position.set(-this.sizeX / 2, this.sizeY / 2, z);
372
+ break;
373
+ }
374
+ case OwnerOriginPosition.TopCenter: {
375
+ group.position.set(0, this.sizeY / 2, z);
376
+ break;
377
+ }
378
+ case OwnerOriginPosition.TopRight: {
379
+ group.position.set(this.sizeX / 2, this.sizeY / 2, z);
380
+ break;
381
+ }
382
+ case OwnerOriginPosition.MiddleLeft: {
383
+ group.position.set(-this.sizeX / 2, 0, z);
384
+ break;
385
+ }
386
+ case OwnerOriginPosition.MiddleCenter: {
387
+ group.position.set(0, 0, z);
388
+ break;
389
+ }
390
+ case OwnerOriginPosition.MiddleRight: {
391
+ group.position.set(this.sizeX / 2, 0, z);
392
+ break;
393
+ }
394
+ case OwnerOriginPosition.BottomLeft: {
395
+ group.position.set(-this.sizeX / 2, -this.sizeY / 2, z);
396
+ break;
397
+ }
398
+ case OwnerOriginPosition.BottomCenter: {
399
+ group.position.set(0, -this.sizeY / 2, z);
400
+ break;
401
+ }
402
+ case OwnerOriginPosition.BottomRight: {
403
+ group.position.set(this.sizeX / 2, -this.sizeY / 2, z);
404
+ break;
405
+ }
406
+ // named strings --- they will reset the position correctly later (or not if they aren't set and then this will be correct)
407
+ default: {
408
+ group.position.set(0, 0, z);
409
+ break;
410
+ }
411
+ }
412
+ }
413
+
414
+ private _galleryItem?: ChitGalleryItemInstance;
415
+ public createGalleryItem(item: ChitGalleryItemInstance) {
416
+ item.maximumWidth = this.renderSpec?.galleryMaximumWidth;
417
+ item.maximumHeight = this.renderSpec?.galleryMaximumHeight;
418
+ item.preferredHeight = this.renderSpec?.galleryPreferredHeight;
419
+ item.preferredWidth = this.renderSpec?.galleryPreferredWidth;
420
+ item.summary = this.renderSpec?.summary;
421
+ item.originalSummary = item.summary;
422
+ item.summaryIconMap = this.renderSpec?.summaryIconMap;
423
+ item.summaryRenderingOptions = this.renderSpec?.summaryRenderingOptions;
424
+
425
+ if (this._galleryItem === item) {
426
+ return;
427
+ }
428
+
429
+ this.destroyGalleryItem();
430
+ this._galleryItem = item;
431
+ }
432
+
433
+ get currentGalleryItem() {
434
+ return this._galleryItem;
435
+ }
436
+
437
+ public destroyGalleryItem() {
438
+ if (this._galleryItem) {
439
+ this._galleryItem.destroy();
440
+ this._galleryItem = undefined;
441
+ }
442
+ }
443
+
444
+ public destroy() {
445
+ this.rootRenderInstance.markHasChange();
446
+ this.invalidateRootRenderInstance();
447
+ this.unsubscribeToOnChange();
448
+ this.rotationTween.stop();
449
+ this.offsetTween.stop();
450
+ this.zOffsetTween.stop();
451
+ this.rotationTween.onComplete();
452
+ this.offsetTween.onComplete();
453
+ this.zOffsetTween.onComplete();
454
+ this.group.removeFromParent();
455
+ this.bboxGroup.removeFromParent();
456
+ this.parentRenderInstance?.removeChild(this);
457
+ this.childrenRenderInstances.forEach((child) => {
458
+ if (child.chit.parent === this.chit) {
459
+ child.destroy();
460
+ }
461
+ });
462
+ if (this.chit.renderInstance === this) {
463
+ this.chit.renderInstance = undefined;
464
+ }
465
+ }
466
+
467
+ protected shouldMoveToNewViewer() {
468
+ if (this.chit.renderInstance !== this) {
469
+ return true;
470
+ }
471
+
472
+ const rootRenderInstance = this.rootRenderInstance;
473
+ const targetParentRenderInstance = this.effectiveParent?.renderInstance;
474
+ if (
475
+ rootRenderInstance &&
476
+ targetParentRenderInstance?.rootRenderInstance &&
477
+ rootRenderInstance !== targetParentRenderInstance?.rootRenderInstance
478
+ ) {
479
+ return true;
480
+ }
481
+ return false;
482
+ }
483
+
484
+ public showDetailsOnLongPress() {
485
+ return this.renderSpec?.showDetailsOnLongPress ?? false;
486
+ }
487
+
488
+ protected refresh() {
489
+ if (this.checkPreDestroy()) {
490
+ return;
491
+ }
492
+
493
+ if (this.shouldMoveToNewViewer()) {
494
+ this.moveToNewViewer();
495
+ return;
496
+ }
497
+
498
+ this.rootRenderInstance.markDirty();
499
+
500
+ const visibilityBefore = this.group.visible;
501
+ this.fixVisibility();
502
+
503
+ if (this.renderSpec) {
504
+ this.group.remove(this.renderSpec.object);
505
+ this.renderSpec.ornaments.forEach((ornament) => this.group.remove(ornament));
506
+ }
507
+
508
+ // execute the render
509
+ const renderSpec = this.createRenderSpec();
510
+ this.chit.render(renderSpec);
511
+ this.renderSpec = renderSpec;
512
+ this.innateObjectZ = this.renderSpec.object?.position?.z ?? 0;
513
+ this.innateOrnamentZs = this.renderSpec.ornaments.map((o) => o.position?.z ?? 0);
514
+
515
+ // no need to animate anything invisible...
516
+ if (!visibilityBefore && !this.group.visible && !this.chit.lastParent) {
517
+ renderSpec.offsetSpeed = 0;
518
+ renderSpec.rotationSpeed = 0;
519
+ }
520
+
521
+ this.handleHierarchy();
522
+
523
+ this.updateBoundingBox();
524
+
525
+ // update position and rotation
526
+ this.handlePositionAndRotation();
527
+ this.fixOutline();
528
+
529
+ // now update ourselves
530
+ this.group.add(this.renderSpec.object);
531
+ this.renderSpec.ornaments.forEach((ornament) => this.group.add(ornament));
532
+
533
+ this.fixObjectPosition();
534
+ this._galleryItem?.update();
535
+
536
+ this.rootRenderInstance.markHasChange();
537
+ }
538
+
539
+ public outlineContext?: ChitRenderInstance;
540
+
541
+ public hasExplicitOnClick() {
542
+ return this.chit.onClick && !this.renderSpec?.isShowingChildrenAsGallery;
543
+ }
544
+
545
+ public fixOutline() {
546
+ if (
547
+ this.hasExplicitOnClick() &&
548
+ this.renderSpec &&
549
+ this.renderSpec.highlight.childrenInheritOutline === undefined
550
+ ) {
551
+ this.renderSpec.highlight.childrenInheritOutline = true;
552
+ }
553
+
554
+ const myColor = this.hasExplicitOnClick()
555
+ ? this.renderSpec?.highlight.clickColor
556
+ : this.renderSpec?.highlight.color;
557
+
558
+ if (this.hasExplicitOnClick() && this.renderSpec?.highlight.childrenInheritOutline === false) {
559
+ this.outlineContext = undefined;
560
+ } else if (myColor && this.renderSpec?.highlight.childrenInheritOutline === true) {
561
+ this.outlineContext = this;
562
+ } else {
563
+ this.outlineContext = this.parentRenderInstance?.outlineContext;
564
+ }
565
+
566
+ this.childrenRenderInstances.forEach((child) => child.fixOutline());
567
+
568
+ if (!this.renderSpec?.object) {
569
+ return;
570
+ }
571
+
572
+ const outlineContext = this.outlineContext ? this.outlineContext : this;
573
+ const c = outlineContext.hasExplicitOnClick()
574
+ ? outlineContext.renderSpec?.highlight.clickColor
575
+ : outlineContext.renderSpec?.highlight.color;
576
+
577
+ if (outlineContext && this.renderSpec.object && outlineContext.renderSpec?.object && c) {
578
+ const id = outlineContext.renderSpec.object.id % 60000;
579
+ const color = Color(c);
580
+ const threeColor = new ThreeColor(color.red() / 256, color.green() / 256, color.blue() / 256);
581
+ this.renderSpec.object.traverseVisible((o) => {
582
+ o.userData.outlineId = id;
583
+ o.userData.outlineColor = threeColor;
584
+ });
585
+ } else {
586
+ this.renderSpec.object.traverseVisible((o) => {
587
+ delete o.userData.outlineId;
588
+ delete o.userData.outlineColor;
589
+ });
590
+ }
591
+ }
592
+
593
+ public screenCoordinates(): Vector2 | undefined {
594
+ if (!this.group.visible) {
595
+ return undefined;
596
+ }
597
+
598
+ const vector = this.bbox.localToWorld(new Vector3());
599
+ vector.project(this.rootRenderInstance.camera);
600
+ const screenCoords = this.rootRenderInstance.convertCameraSpaceToScreenSpace(vector.x, vector.y);
601
+ return screenCoords;
602
+ }
603
+
604
+ protected attemptToFindPlaneZ0(
605
+ rootRenderInstance: RootChitRenderInstance,
606
+ chit?: Chit | Vector2,
607
+ ): Vector3 | undefined {
608
+ if (chit instanceof Chit && rootRenderInstance === chit?.renderInstance?.rootRenderInstance) {
609
+ return chit.renderInstance!.group.getWorldPosition(new Vector3());
610
+ }
611
+
612
+ const screenCoordsOfNewLocation =
613
+ chit instanceof Vector2 ? chit : chit ? chit.screenCoordinates() : new Vector2(0, 0);
614
+ if (rootRenderInstance && rootRenderInstance.rootGroup && screenCoordsOfNewLocation) {
615
+ // find the current screen coordinates of its new home and map it to "camera space"
616
+ const cameraSpace = rootRenderInstance.convertScreenSpaceToCameraSpace(
617
+ screenCoordsOfNewLocation.x,
618
+ screenCoordsOfNewLocation.y,
619
+ );
620
+
621
+ if (!cameraSpace) {
622
+ return;
623
+ }
624
+
625
+ const scale = Math.max(Math.abs(cameraSpace.x), Math.abs(cameraSpace.y));
626
+ if (!Number.isFinite(scale) || scale === 0) {
627
+ return undefined;
628
+ }
629
+
630
+ let multiplier = scale > 1 ? 1 : 1 / scale;
631
+
632
+ // figure out what camera space means at Z=0
633
+ for (; multiplier > 0.11; multiplier *= 0.75) {
634
+ const raycaster = new Raycaster();
635
+ raycaster.setFromCamera(
636
+ new Vector2(cameraSpace.x * multiplier, cameraSpace.y * multiplier),
637
+ rootRenderInstance.camera,
638
+ );
639
+ const planeZ = new Plane(new Vector3(0, 0, 1), 0);
640
+ const intersection = new Vector3();
641
+ const intersects = raycaster.ray.intersectPlane(planeZ, intersection);
642
+ if (intersects) {
643
+ return intersects;
644
+ }
645
+ }
646
+ // return intersection;
647
+ }
648
+ }
649
+
650
+ protected detach() {
651
+ if (this.chit.renderInstance === this) {
652
+ this.log("detaching");
653
+ this.chit.renderInstance = undefined;
654
+ // this.childrenRenderInstances.forEach((child) => child.detach());
655
+ }
656
+
657
+ if (!this.chit.renderInstance && this.effectiveParent?.renderInstance) {
658
+ this.effectiveParent.renderInstance.childAdded(this.chit);
659
+
660
+ // TODO: this is okay since adding a child has side effects
661
+ (this.chit.renderInstance as unknown as ChitRenderInstance).zeroTween();
662
+ }
663
+ }
664
+
665
+ private _isMovingToNewViewer = false;
666
+ protected moveToNewViewer() {
667
+ if (this._isMovingToNewViewer) {
668
+ return;
669
+ }
670
+
671
+ this._isMovingToNewViewer = true;
672
+
673
+ this.log("needs to move to a new viewer");
674
+
675
+ // no matter what, this instance is going to be useless - we don't want to potentially update mid-destroy
676
+ this.unsubscribeToOnChange();
677
+ this.detach();
678
+
679
+ const renderSpec = this.createRenderSpec();
680
+ this.chit.render(renderSpec);
681
+ this.renderSpec = renderSpec;
682
+
683
+ if (this.parentRenderInstance?._isMovingToNewViewer) {
684
+ return;
685
+ }
686
+
687
+ const rootRenderInstance = this.rootRenderInstance;
688
+ if (this.renderSpec?.worthSlidingToPanelToShowChange) {
689
+ rootRenderInstance.markHasChitsLeaving();
690
+ }
691
+
692
+ const rootGroup = this.rootGroup;
693
+ if (rootGroup && rootRenderInstance && renderSpec) {
694
+ let intersection = this.attemptToFindPlaneZ0(rootRenderInstance, this.chit);
695
+ if (!intersection) {
696
+ // Ensure chit moves outside visible region with safety margin
697
+ // Add extra margin (50% of visible height) to account for overlapping viewers
698
+ const safetyMargin = rootRenderInstance.cameraWrapper.visibleGameHeight * 0.5;
699
+ const targetY = rootRenderInstance.cameraWrapper.visibleGameHeight + safetyMargin;
700
+ intersection = this.group.localToWorld(new Vector3(0, targetY, 0));
701
+ renderSpec.splay.enabled = false;
702
+ }
703
+
704
+ // Ensure exit coordinates are outside visible region if they overlap
705
+ intersection = this.ensureCoordinatesOutsideVisibleRegion(intersection);
706
+
707
+ rootGroup.attach(this.group);
708
+ // now move the chit to the new "location" and then we can kill it.
709
+ renderSpec.offsetY = intersection.y;
710
+ renderSpec.offsetX = intersection.x;
711
+ this.handlePositionAndRotation();
712
+ this.offsetTween.onComplete(() => this.destroy());
713
+ this.offsetTween = new Tween<Point2d>({ x: 0, y: 0 });
714
+ } else {
715
+ this.destroy();
716
+ }
717
+ }
718
+
719
+ protected createRenderSpec() {
720
+ const renderSpec = new ChitRenderSpec(this.chit);
721
+ renderSpec.renderedForPlayerId = this.rootRenderInstance.playerId;
722
+ renderSpec.highlight.clickColor = this.chit.game?.theme.chitHighlightColor ?? renderSpec.highlight.clickColor;
723
+ return renderSpec;
724
+ }
725
+
726
+ private _boundingBoxDirty = false;
727
+ protected notifyBoundingBoxChanged() {
728
+ this.parentRenderInstance?.notifyBoundingBoxChanged();
729
+ if (this.isUsingSyntheticBbox) {
730
+ if (!this._boundingBoxDirty) {
731
+ this._boundingBoxDirty = true;
732
+ nextTick(() => {
733
+ this.updateBoundingBox();
734
+ this._boundingBoxDirty = false;
735
+ });
736
+ }
737
+ }
738
+ }
739
+
740
+ private positionKey(clickBox3: Box3) {
741
+ return [
742
+ !!this.chit.onClick,
743
+ this.parentRenderInstance?.id,
744
+ this.sizeX,
745
+ this.sizeY,
746
+ this.sizeZ,
747
+ this.centerX,
748
+ this.centerY,
749
+ this.centerZ,
750
+ this.renderSpec?.ownerOrigin,
751
+ this.chit.parentOutlet,
752
+ this.chit.parentOutletIndex,
753
+ this.renderSpec?.childrenOffsetZ,
754
+ this.renderSpec?.offsetX,
755
+ this.renderSpec?.offsetY,
756
+ this.renderSpec?.offsetZ,
757
+ this.renderSpec?.rotateX,
758
+ this.renderSpec?.rotateY,
759
+ this.renderSpec?.rotateZ,
760
+ ...clickBox3.min.toArray(),
761
+ ...clickBox3.max.toArray(),
762
+ this.renderSpec?.splay.toString(),
763
+ ].join("___");
764
+ }
765
+
766
+ private _lastUpdateBoudingBoxKey: string = "";
767
+ protected updateBoundingBox() {
768
+ if (!this.renderSpec) {
769
+ // bail?
770
+ return;
771
+ }
772
+
773
+ const box3 = new Box3();
774
+ box3.expandByObject(this.renderSpec.object);
775
+ const clickBox3 = box3.clone();
776
+
777
+ // goofy circumstances where the thing being clicked doesn't have anything to actually highlight - we
778
+ // have to highlight the children (do we care about grandchildren?)
779
+ if (box3.isEmpty() && this.chit.onClick) {
780
+ this.isUsingSyntheticBbox = true;
781
+ this.childrenRenderInstances.forEach((child) => {
782
+ const clone = child.bbox.clone();
783
+ clone.position.add(child.bboxGroup.position); // the child bbox is relative to its own space...
784
+ clickBox3.expandByObject(clone);
785
+ });
786
+ } else {
787
+ this.isUsingSyntheticBbox = false;
788
+ }
789
+
790
+ fixBbox(box3);
791
+ fixBbox(clickBox3);
792
+
793
+ this.bbox.renderOrder = 5;
794
+ this.sizeX = box3.max.x - box3.min.x;
795
+ this.sizeY = box3.max.y - box3.min.y;
796
+ this.sizeZ = box3.max.z - box3.min.z;
797
+
798
+ this.centerX = this.sizeX / 2 + box3.min.x;
799
+ this.centerY = this.sizeY / 2 + box3.min.y;
800
+ this.centerZ = this.sizeZ / 2 + box3.min.z;
801
+
802
+ const newKey = this.positionKey(clickBox3);
803
+ const keyChanged = newKey !== this._lastUpdateBoudingBoxKey;
804
+ if (keyChanged) {
805
+ this._lastUpdateBoudingBoxKey = newKey;
806
+ this.bbox.scale.set(this.sizeX, this.sizeY, this.sizeZ);
807
+ this.clickbox.scale.set(
808
+ clickBox3.max.x - clickBox3.min.x,
809
+ clickBox3.max.y - clickBox3.min.y,
810
+ clickBox3.max.z - clickBox3.min.z,
811
+ );
812
+
813
+ [...this.anchorPoints.entries()].forEach(([key, value]) => this.updateGroupPosition(value, key));
814
+ [...this.bboxAnchorPoints.entries()].forEach(([key, value]) => this.updateGroupPosition(value, key));
815
+
816
+ this.fixObjectPosition();
817
+ this.bbox.position.z = this.centerZ;
818
+ this.bbox.position.x = this.centerX;
819
+ this.bbox.position.y = this.centerY;
820
+
821
+ this.clickbox.position.z = (clickBox3.max.z - clickBox3.min.z) / 2 + clickBox3.min.z;
822
+ this.clickbox.position.x = (clickBox3.max.x - clickBox3.min.x) / 2 + clickBox3.min.x;
823
+ this.clickbox.position.y = (clickBox3.max.y - clickBox3.min.y) / 2 + clickBox3.min.y;
824
+
825
+ const targetOffset = {
826
+ x: this.renderSpec.offsetX,
827
+ y: this.renderSpec.offsetY,
828
+ z: this.renderSpec.offsetZ + this.sizeZ / 2,
829
+ };
830
+ this.handleOffsetForSplay(targetOffset);
831
+
832
+ this.bboxGroup.position.set(targetOffset.x, targetOffset.y, targetOffset.z);
833
+ this.bboxGroup.rotation.order = "ZYX";
834
+ this.bboxGroup.rotation.set(this.renderSpec.rotateX, this.renderSpec.rotateY, this.renderSpec.rotateZ);
835
+
836
+ Object.entries(this.renderSpec.outletPositions).forEach(([key, position]) => {
837
+ this.setOutletPosition(key, new Vector3(position.x, position.y, position.z));
838
+ });
839
+
840
+ if (keyChanged) {
841
+ this.notifyBoundingBoxChanged();
842
+ }
843
+ }
844
+ }
845
+
846
+ private fixObjectPosition() {
847
+ if (this.renderSpec?.object) {
848
+ this.renderSpec.object.position.z = this.innateObjectZ;
849
+ }
850
+
851
+ // this.renderSpec?.ornaments.forEach(
852
+ // (ornament, index) =>
853
+ // (ornament.position.z =
854
+ // this.sizeZ / 2 + (Number.isFinite(this.innateOrnamentZs[index]) ? this.innateOrnamentZs[index] : 0)),
855
+ // );
856
+ }
857
+
858
+ protected addChild(child: ChitRenderInstance) {
859
+ if ((child as RootChitRenderInstance).cameraWrapper) {
860
+ return;
861
+ }
862
+
863
+ this.log(`Child added: ${child.chit} ${child.id}`);
864
+ this.childrenRenderInstances.push(child);
865
+ if (this._isMovingToNewViewer) {
866
+ this.log("While adding child to myself, I am already moving to a new viewer");
867
+ child.chit.renderInstance = undefined;
868
+ child.detach();
869
+ } else {
870
+ child.fixOutline();
871
+ }
872
+ }
873
+
874
+ protected removeChild(child: ChitRenderInstance) {
875
+ this.log("Child removed");
876
+ this.childrenRenderInstances = this.childrenRenderInstances.filter((d) => d !== child);
877
+ this.notifyBoundingBoxChanged();
878
+ }
879
+
880
+ private isDestroying = false;
881
+ protected checkPreDestroy() {
882
+ if (!this.chit.parent && !this.isDestroying && !this.chit.parentFallback) {
883
+ this.log("about to destroy, will move off screen");
884
+ this.isDestroying = true;
885
+ this.chit.renderInstance = undefined;
886
+ this.rootGroup?.attach(this.group);
887
+ const { position } = this.group;
888
+ if (!this.group.visible) {
889
+ this.destroy();
890
+ return this.isDestroying;
891
+ }
892
+
893
+ // where is this going?
894
+ const positionExitChit = this.chit.parent ?? this.chit.parentFallback;
895
+ // Ensure chit moves outside visible region with safety margin
896
+ const safetyMargin = (this.rootRenderInstance?.cameraWrapper.visibleGameHeight ?? 10) * 0.5;
897
+ const targetOffsetY = (this.rootRenderInstance?.cameraWrapper.visibleGameHeight ?? 10) + safetyMargin;
898
+ const target = {
899
+ x: position.x,
900
+ y: position.y + targetOffsetY,
901
+ };
902
+ let duration = 500;
903
+ if (this.rootRenderInstance) {
904
+ const oldParent = this.group.parent;
905
+ const intersection = this.attemptToFindPlaneZ0(this.rootRenderInstance, positionExitChit);
906
+ if (intersection && oldParent) {
907
+ target.x = intersection.x;
908
+ target.y = intersection.y;
909
+
910
+ const distance = Math.sqrt(Math.pow(target.x - position.x, 2) + Math.pow(target.y - position.y, 2));
911
+
912
+ duration =
913
+ this.animationSpeedMultiplier *
914
+ (this.renderSpec ? this.renderSpec.offsetSpeed : 500) *
915
+ Math.min(this.renderSpec ? this.renderSpec.maxDistanceForSpeed : 10, distance);
916
+ }
917
+ }
918
+
919
+ this.offsetTween = this.createTween({ x: position.x, y: position.y }, (tween) =>
920
+ tween
921
+ .to(target, duration)
922
+ .onUpdate((obj) => {
923
+ position.x = obj.x;
924
+ position.y = obj.y;
925
+ })
926
+ .onComplete(() => {
927
+ this.destroy();
928
+ })
929
+ .easing(Easing.Quadratic.In),
930
+ );
931
+ this.offsetTween = new Tween({ x: 0, y: 0 }); // make sure this is not cancellable
932
+ }
933
+ return this.isDestroying;
934
+ }
935
+
936
+ protected handleHierarchy() {
937
+ const targetParentRenderInstance = this.effectiveParent?.renderInstance;
938
+ if (this.parentRenderInstance !== targetParentRenderInstance) {
939
+ this.parentRenderInstance?.removeChild(this);
940
+ targetParentRenderInstance?.addChild(this);
941
+ this.parentRenderInstance = targetParentRenderInstance;
942
+ }
943
+
944
+ let origin: OwnerOriginPosition | string = OwnerOriginPosition.MiddleCenter;
945
+ if (this.renderSpec) {
946
+ origin =
947
+ this.renderSpec.ownerOrigin === OwnerOriginPosition.Default
948
+ ? (this.chit.parentOutlet ?? OwnerOriginPosition.MiddleCenter)
949
+ : this.renderSpec.ownerOrigin;
950
+ }
951
+
952
+ const targetParentGroup = (this.renderSpec && this.parentRenderInstance?.anchor(origin)) ?? this.rootGroup;
953
+ const targetParentBboxGroup = (this.renderSpec && this.parentRenderInstance?.bboxAnchor(origin)) ?? this.rootGroup;
954
+
955
+ if (targetParentGroup && this.group.parent !== targetParentGroup) {
956
+ targetParentGroup.attach(this.group); // add works for the outlet not drifting but obviously messes up animations...
957
+ }
958
+ if (targetParentBboxGroup && this.group.parent !== targetParentBboxGroup) {
959
+ targetParentBboxGroup.attach(this.bboxGroup);
960
+ }
961
+
962
+ if (!this.parentRenderInstance) {
963
+ this.log("no parent render instance, destroying");
964
+ this.destroy();
965
+ }
966
+ }
967
+
968
+ private handleOffsetForSplay(p: Point3d) {
969
+ if (!this.renderSpec) {
970
+ return;
971
+ }
972
+
973
+ if (this.chit.parentOutlet && this.chit.parentOutletIndex !== undefined && this.renderSpec.splay.enabled) {
974
+ const splay = this.renderSpec.splay.processSplay(
975
+ this.chit.parentOutletIndex,
976
+ this.sizeX,
977
+ this.sizeY,
978
+ this.sizeZ + this.renderSpec.childrenOffsetZ,
979
+ );
980
+ p.x += splay.x;
981
+ p.y += splay.y;
982
+ p.z += splay.z;
983
+ }
984
+ }
985
+
986
+ protected handlePositionAndRotation() {
987
+ if (!this.renderSpec) {
988
+ this.offsetTween.stop();
989
+ this.zOffsetTween.stop();
990
+ this.rotationTween.stop();
991
+ return;
992
+ }
993
+
994
+ const { position, rotation } = this.group;
995
+ const targetOffset = {
996
+ x: this.renderSpec.offsetX,
997
+ y: this.renderSpec.offsetY,
998
+ z: this.renderSpec.offsetZ + this.sizeZ / 2,
999
+ };
1000
+ const targetRotation = { x: this.renderSpec.rotateX, y: this.renderSpec.rotateY, z: this.renderSpec.rotateZ };
1001
+
1002
+ this.handleOffsetForSplay(targetOffset);
1003
+
1004
+ let duration = 0;
1005
+ let distanceMoved = 0;
1006
+ let nonZRotations = 0;
1007
+ let offsetEasing: undefined | ((amount: number) => number);
1008
+ let rotationEasing: undefined | ((amount: number) => number);
1009
+
1010
+ this.offsetTween.onComplete();
1011
+ this.offsetTween.stop();
1012
+ this.zOffsetTween.onComplete();
1013
+ this.zOffsetTween.stop();
1014
+ this.rotationTween.onComplete();
1015
+ this.rotationTween.stop();
1016
+
1017
+ // offset has to change
1018
+ if (position.x !== targetOffset.x || position.y !== targetOffset.y || position.z !== targetOffset.z) {
1019
+ offsetEasing = this.offsetTween.isPlaying() ? Easing.Quadratic.Out : Easing.Quadratic.InOut;
1020
+
1021
+ distanceMoved = Math.sqrt(
1022
+ Math.pow(position.x - targetOffset.x, 2) +
1023
+ Math.pow(position.y - targetOffset.y, 2) +
1024
+ Math.pow(position.z - targetOffset.z, 2),
1025
+ );
1026
+
1027
+ duration = Math.max(
1028
+ duration,
1029
+ this.renderSpec.offsetSpeed * Math.min(this.renderSpec.maxDistanceForSpeed, distanceMoved),
1030
+ );
1031
+
1032
+ this.log("offset tween: " + distanceMoved + " " + duration);
1033
+ }
1034
+
1035
+ // rotation has to change
1036
+ // Use quaternions to properly compare rotations, as Euler angles can represent the same rotation differently
1037
+ // Note: quaternions have double-cover property where q and -q represent the same rotation
1038
+ const currentQuat = new Quaternion().setFromEuler(rotation);
1039
+ const targetQuat = new Quaternion().setFromEuler(
1040
+ new Euler(targetRotation.x, targetRotation.y, targetRotation.z, "ZYX"),
1041
+ );
1042
+ let rotationAngleDifference = currentQuat.angleTo(targetQuat);
1043
+
1044
+ // Account for quaternion double-cover: if angle is close to π, check if they're actually the same rotation
1045
+ // by also checking the dot product (which should be close to -1 if they're opposite quaternions)
1046
+ if (Math.abs(rotationAngleDifference - Math.PI) < 0.001) {
1047
+ const dot = currentQuat.dot(targetQuat);
1048
+ if (dot < -0.999) {
1049
+ // They're opposite quaternions representing the same rotation
1050
+ rotationAngleDifference = 0;
1051
+ }
1052
+ }
1053
+
1054
+ if (rotationAngleDifference > 0.00001) {
1055
+ rotationEasing = this.rotationTween.isPlaying() ? Easing.Quadratic.Out : Easing.Quadratic.InOut;
1056
+
1057
+ const rotations = Math.min(rotationAngleDifference / (2 * Math.PI), 2 * Math.PI);
1058
+
1059
+ const nonZRadiansDistance = new Quaternion()
1060
+ .setFromEuler(new Euler(rotation.x, rotation.y, 0, "ZYX"))
1061
+ .angleTo(new Quaternion().setFromEuler(new Euler(targetRotation.x, targetRotation.y, 0, "ZYX")));
1062
+ nonZRotations = Math.min(nonZRadiansDistance / (2 * Math.PI), 2 * Math.PI);
1063
+
1064
+ duration = Math.max(duration, this.renderSpec.rotationSpeed * rotations);
1065
+
1066
+ this.log("rotation tween: " + nonZRotations + " " + duration);
1067
+ }
1068
+
1069
+ if (offsetEasing) {
1070
+ // what the heck is this
1071
+ if (duration > 1) {
1072
+ this.group.visible = true;
1073
+ }
1074
+ this.offsetTween = this.createTween({ x: position.x, y: position.y }, (tween) =>
1075
+ tween
1076
+ .to(targetOffset, duration * this.animationSpeedMultiplier)
1077
+ .onUpdate((obj) => {
1078
+ position.x = obj.x;
1079
+ position.y = obj.y;
1080
+ })
1081
+ .easing(offsetEasing)
1082
+ .onComplete(() => this.fixVisibility()),
1083
+ );
1084
+ }
1085
+
1086
+ if (rotationEasing) {
1087
+ rotation.order = "ZYX";
1088
+ this.rotationTween = this.createTween({ x: rotation.x, y: rotation.y, z: rotation.z }, (tween) =>
1089
+ tween
1090
+ .to(targetRotation, duration * this.animationSpeedMultiplier)
1091
+ .onUpdate((obj) => {
1092
+ rotation.x = obj.x;
1093
+ rotation.y = obj.y;
1094
+ rotation.z = obj.z;
1095
+ })
1096
+ .easing(rotationEasing),
1097
+ );
1098
+ }
1099
+
1100
+ if (offsetEasing || rotationEasing) {
1101
+ // pieces look better when they are "lifted" to their location...
1102
+ // so we have to do goofy stuff to "lift" it a bit
1103
+ const zLiftRatio = this.renderSpec.zLiftRatio;
1104
+ const peak = {
1105
+ z:
1106
+ Math.max(targetOffset.z, position.z) +
1107
+ Math.max(distanceMoved * zLiftRatio, nonZRotations * this.renderSpec.zLiftRotationMultiplier),
1108
+ };
1109
+ this.zOffsetTween = this.createTween({ z: position.z }, (tween) =>
1110
+ tween
1111
+ .to(peak, (duration / 2) * this.animationSpeedMultiplier)
1112
+ .easing(Easing.Quadratic.Out)
1113
+ .onUpdate((obj) => {
1114
+ position.z = obj.z;
1115
+ })
1116
+ .chain(
1117
+ new Tween({ z: peak.z }, this.tweenGroup)
1118
+ .to({ z: targetOffset.z }, (duration / 2) * this.animationSpeedMultiplier)
1119
+ .easing(Easing.Quadratic.In)
1120
+ .onUpdate((obj) => {
1121
+ position.z = obj.z;
1122
+ }),
1123
+ ),
1124
+ );
1125
+
1126
+ this.log("zOffset tween: " + peak.z + " " + duration);
1127
+ }
1128
+ }
1129
+
1130
+ protected fixVisibility() {
1131
+ this.group.visible = this.chit.parent
1132
+ ? this.chit.parent.shouldRenderChild(this.chit)
1133
+ : this.chit.parentFallback
1134
+ ? this.chit.parentFallback.shouldRenderChild(this.chit)
1135
+ : true;
1136
+ }
1137
+
1138
+ public createTween<T extends Record<string, any>>(props: T, cb: (tween: Tween<T>) => void): Tween<T> {
1139
+ return this.rootRenderInstance.createTween(props, cb);
1140
+ }
1141
+ }