1681-engine 0.0.0-stage → 0.5.8

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 (1014) hide show
  1. package/CHANGELOG.md +304 -0
  2. package/LICENSE +21 -0
  3. package/README.md +164 -2
  4. package/dist/1681-engine.js +417 -0
  5. package/dist/1681-engine.js.map +1 -0
  6. package/dist/ambient/ColorGrade.js +41 -0
  7. package/dist/ambient/ColorGrade.js.map +1 -0
  8. package/dist/ambient/DayClock.js +57 -0
  9. package/dist/ambient/DayClock.js.map +1 -0
  10. package/dist/ambient/WeatherLayer.js +91 -0
  11. package/dist/ambient/WeatherLayer.js.map +1 -0
  12. package/dist/ambient/grade.js +13 -0
  13. package/dist/ambient/grade.js.map +1 -0
  14. package/dist/ambient/weather.js +52 -0
  15. package/dist/ambient/weather.js.map +1 -0
  16. package/dist/anim/AnimStateMachine.js +164 -0
  17. package/dist/anim/AnimStateMachine.js.map +1 -0
  18. package/dist/anim/Animator.js +67 -0
  19. package/dist/anim/Animator.js.map +1 -0
  20. package/dist/anim/animStateCompile.js +113 -0
  21. package/dist/anim/animStateCompile.js.map +1 -0
  22. package/dist/anim/animStateSystem.js +17 -0
  23. package/dist/anim/animStateSystem.js.map +1 -0
  24. package/dist/anim/animationSystem.js +15 -0
  25. package/dist/anim/animationSystem.js.map +1 -0
  26. package/dist/anim/asepriteSlices.js +22 -0
  27. package/dist/anim/asepriteSlices.js.map +1 -0
  28. package/dist/anim/asepriteTags.js +35 -0
  29. package/dist/anim/asepriteTags.js.map +1 -0
  30. package/dist/anim/parseAseprite.js +83 -0
  31. package/dist/anim/parseAseprite.js.map +1 -0
  32. package/dist/assets/AssetLoader.js +104 -0
  33. package/dist/assets/AssetLoader.js.map +1 -0
  34. package/dist/assets/loadAseprite.js +50 -0
  35. package/dist/assets/loadAseprite.js.map +1 -0
  36. package/dist/assets/takeCleanerWorker-DTcI_Jqr.js +31 -0
  37. package/dist/assets/takeCleanerWorker-DTcI_Jqr.js.map +1 -0
  38. package/dist/audio/Footsteps.js +26 -0
  39. package/dist/audio/Footsteps.js.map +1 -0
  40. package/dist/audio/MusicPlayer.js +78 -0
  41. package/dist/audio/MusicPlayer.js.map +1 -0
  42. package/dist/audio/SoundEngine.js +119 -0
  43. package/dist/audio/SoundEngine.js.map +1 -0
  44. package/dist/audio/cleanTake.js +30 -0
  45. package/dist/audio/cleanTake.js.map +1 -0
  46. package/dist/audio/music/ElementVoice.js +35 -0
  47. package/dist/audio/music/ElementVoice.js.map +1 -0
  48. package/dist/audio/music/GraphVoice.js +39 -0
  49. package/dist/audio/music/GraphVoice.js.map +1 -0
  50. package/dist/audio/music/MusicChannel.js +58 -0
  51. package/dist/audio/music/MusicChannel.js.map +1 -0
  52. package/dist/audio/music/musicVoice.js +13 -0
  53. package/dist/audio/music/musicVoice.js.map +1 -0
  54. package/dist/audio/sampleBank.js +82 -0
  55. package/dist/audio/sampleBank.js.map +1 -0
  56. package/dist/audio/soundTable.js +9 -0
  57. package/dist/audio/soundTable.js.map +1 -0
  58. package/dist/audio/synth.js +36 -0
  59. package/dist/audio/synth.js.map +1 -0
  60. package/dist/core/BitmapLabel.js +49 -0
  61. package/dist/core/BitmapLabel.js.map +1 -0
  62. package/dist/core/Camera.js +150 -0
  63. package/dist/core/Camera.js.map +1 -0
  64. package/dist/core/Clock.js +30 -0
  65. package/dist/core/Clock.js.map +1 -0
  66. package/dist/core/Graphics.js +69 -0
  67. package/dist/core/Graphics.js.map +1 -0
  68. package/dist/core/Group.js +29 -0
  69. package/dist/core/Group.js.map +1 -0
  70. package/dist/core/Image.js +51 -0
  71. package/dist/core/Image.js.map +1 -0
  72. package/dist/core/ObjectFactory.js +55 -0
  73. package/dist/core/ObjectFactory.js.map +1 -0
  74. package/dist/core/Pointer.js +58 -0
  75. package/dist/core/Pointer.js.map +1 -0
  76. package/dist/core/Rectangle.js +51 -0
  77. package/dist/core/Rectangle.js.map +1 -0
  78. package/dist/core/Stage.js +86 -0
  79. package/dist/core/Stage.js.map +1 -0
  80. package/dist/core/Text.js +22 -0
  81. package/dist/core/Text.js.map +1 -0
  82. package/dist/core/TextureRegistry.js +111 -0
  83. package/dist/core/TextureRegistry.js.map +1 -0
  84. package/dist/core/Timeline.js +211 -0
  85. package/dist/core/Timeline.js.map +1 -0
  86. package/dist/core/TimelineBuilder.js +73 -0
  87. package/dist/core/TimelineBuilder.js.map +1 -0
  88. package/dist/core/TimelineChild.js +84 -0
  89. package/dist/core/TimelineChild.js.map +1 -0
  90. package/dist/core/Tweener.js +136 -0
  91. package/dist/core/Tweener.js.map +1 -0
  92. package/dist/core/atlas.js +38 -0
  93. package/dist/core/atlas.js.map +1 -0
  94. package/dist/core/atlasPlan.js +22 -0
  95. package/dist/core/atlasPlan.js.map +1 -0
  96. package/dist/core/eases.js +21 -0
  97. package/dist/core/eases.js.map +1 -0
  98. package/dist/core/gameObject.js +115 -0
  99. package/dist/core/gameObject.js.map +1 -0
  100. package/dist/core/pixiPatches.js +18 -0
  101. package/dist/core/pixiPatches.js.map +1 -0
  102. package/dist/core/timelinePlace.js +24 -0
  103. package/dist/core/timelinePlace.js.map +1 -0
  104. package/dist/core/tweenProps.js +12 -0
  105. package/dist/core/tweenProps.js.map +1 -0
  106. package/dist/debug/DebugOverlay.js +94 -0
  107. package/dist/debug/DebugOverlay.js.map +1 -0
  108. package/dist/debug/DrawCallCounter.js +41 -0
  109. package/dist/debug/DrawCallCounter.js.map +1 -0
  110. package/dist/debug/ErrorLog.js +22 -0
  111. package/dist/debug/ErrorLog.js.map +1 -0
  112. package/dist/debug/FrameStats.js +42 -0
  113. package/dist/debug/FrameStats.js.map +1 -0
  114. package/dist/debug/inspectWorld.js +29 -0
  115. package/dist/debug/inspectWorld.js.map +1 -0
  116. package/dist/diagnostics/ErrorDeduper.js +27 -0
  117. package/dist/diagnostics/ErrorDeduper.js.map +1 -0
  118. package/dist/diagnostics/FrameSampler.js +42 -0
  119. package/dist/diagnostics/FrameSampler.js.map +1 -0
  120. package/dist/diagnostics/bootWatch.js +21 -0
  121. package/dist/diagnostics/bootWatch.js.map +1 -0
  122. package/dist/diagnostics/captureErrors.js +27 -0
  123. package/dist/diagnostics/captureErrors.js.map +1 -0
  124. package/dist/diagnostics/contextLoss.js +25 -0
  125. package/dist/diagnostics/contextLoss.js.map +1 -0
  126. package/dist/diagnostics/frameStats.js +31 -0
  127. package/dist/diagnostics/frameStats.js.map +1 -0
  128. package/dist/diagnostics/gpuInfo.js +22 -0
  129. package/dist/diagnostics/gpuInfo.js.map +1 -0
  130. package/dist/diagnostics/renderGuard.js +24 -0
  131. package/dist/diagnostics/renderGuard.js.map +1 -0
  132. package/dist/ecs/SparseSet.js +55 -0
  133. package/dist/ecs/SparseSet.js.map +1 -0
  134. package/dist/ecs/World.js +307 -0
  135. package/dist/ecs/World.js.map +1 -0
  136. package/dist/ecs/fields.js +26 -0
  137. package/dist/ecs/fields.js.map +1 -0
  138. package/dist/engine/Engine.js +82 -0
  139. package/dist/engine/Engine.js.map +1 -0
  140. package/dist/engine/FixedLoop.js +37 -0
  141. package/dist/engine/FixedLoop.js.map +1 -0
  142. package/dist/engine/Scene.js +79 -0
  143. package/dist/engine/Scene.js.map +1 -0
  144. package/dist/engine/SceneManager.js +73 -0
  145. package/dist/engine/SceneManager.js.map +1 -0
  146. package/dist/events/EventBus.js +42 -0
  147. package/dist/events/EventBus.js.map +1 -0
  148. package/dist/fx/FloatingText.js +72 -0
  149. package/dist/fx/FloatingText.js.map +1 -0
  150. package/dist/fx/hitStop.js +28 -0
  151. package/dist/fx/hitStop.js.map +1 -0
  152. package/dist/fx/viewCull.js +10 -0
  153. package/dist/fx/viewCull.js.map +1 -0
  154. package/dist/i18n/Translator.js +72 -0
  155. package/dist/i18n/Translator.js.map +1 -0
  156. package/dist/i18n/extractStrings.js +58 -0
  157. package/dist/i18n/extractStrings.js.map +1 -0
  158. package/dist/i18n/formatMessage.js +19 -0
  159. package/dist/i18n/formatMessage.js.map +1 -0
  160. package/dist/input/Actions.js +131 -0
  161. package/dist/input/Actions.js.map +1 -0
  162. package/dist/input/AimGesture.js +75 -0
  163. package/dist/input/AimGesture.js.map +1 -0
  164. package/dist/input/Keyboard.js +54 -0
  165. package/dist/input/Keyboard.js.map +1 -0
  166. package/dist/input/Keymap.js +171 -0
  167. package/dist/input/Keymap.js.map +1 -0
  168. package/dist/input/TargetLock.js +73 -0
  169. package/dist/input/TargetLock.js.map +1 -0
  170. package/dist/input/aimAxis.js +8 -0
  171. package/dist/input/aimAxis.js.map +1 -0
  172. package/dist/input/keyChord.js +29 -0
  173. package/dist/input/keyChord.js.map +1 -0
  174. package/dist/input/longPress.js +32 -0
  175. package/dist/input/longPress.js.map +1 -0
  176. package/dist/input/stickAxis.js +23 -0
  177. package/dist/input/stickAxis.js.map +1 -0
  178. package/dist/input/touchDetect.js +7 -0
  179. package/dist/input/touchDetect.js.map +1 -0
  180. package/dist/light/LightLayer.js +84 -0
  181. package/dist/light/LightLayer.js.map +1 -0
  182. package/dist/nav/MinHeap.js +39 -0
  183. package/dist/nav/MinHeap.js.map +1 -0
  184. package/dist/nav/findPath.js +78 -0
  185. package/dist/nav/findPath.js.map +1 -0
  186. package/dist/nav/navGrid.js +36 -0
  187. package/dist/nav/navGrid.js.map +1 -0
  188. package/dist/nav/nearestOpen.js +19 -0
  189. package/dist/nav/nearestOpen.js.map +1 -0
  190. package/dist/nav/straightenPath.js +51 -0
  191. package/dist/nav/straightenPath.js.map +1 -0
  192. package/dist/net/Connection.js +84 -0
  193. package/dist/net/Connection.js.map +1 -0
  194. package/dist/net/InterpolationBuffer.js +57 -0
  195. package/dist/net/InterpolationBuffer.js.map +1 -0
  196. package/dist/net/PredictedMover.js +61 -0
  197. package/dist/net/PredictedMover.js.map +1 -0
  198. package/dist/net/Room.js +92 -0
  199. package/dist/net/Room.js.map +1 -0
  200. package/dist/net/RoomHost.js +101 -0
  201. package/dist/net/RoomHost.js.map +1 -0
  202. package/dist/net/cadence.js +22 -0
  203. package/dist/net/cadence.js.map +1 -0
  204. package/dist/net/constants.js +11 -0
  205. package/dist/net/constants.js.map +1 -0
  206. package/dist/net/lobby/LobbyClient.js +124 -0
  207. package/dist/net/lobby/LobbyClient.js.map +1 -0
  208. package/dist/net/lobby/LobbyHost.js +366 -0
  209. package/dist/net/lobby/LobbyHost.js.map +1 -0
  210. package/dist/net/lobby/LobbyRooms.js +66 -0
  211. package/dist/net/lobby/LobbyRooms.js.map +1 -0
  212. package/dist/net/lobby/Matchmaker.js +106 -0
  213. package/dist/net/lobby/Matchmaker.js.map +1 -0
  214. package/dist/net/movement.js +83 -0
  215. package/dist/net/movement.js.map +1 -0
  216. package/dist/net/protocol.js +11 -0
  217. package/dist/net/protocol.js.map +1 -0
  218. package/dist/net/serverClock.js +22 -0
  219. package/dist/net/serverClock.js.map +1 -0
  220. package/dist/net/snapshotCodec.js +92 -0
  221. package/dist/net/snapshotCodec.js.map +1 -0
  222. package/dist/parallax/Parallax.js +32 -0
  223. package/dist/parallax/Parallax.js.map +1 -0
  224. package/dist/parallax/ParallaxLayer.js +70 -0
  225. package/dist/parallax/ParallaxLayer.js.map +1 -0
  226. package/dist/parallax/parallaxMath.js +27 -0
  227. package/dist/parallax/parallaxMath.js.map +1 -0
  228. package/dist/particles/Emitter.js +108 -0
  229. package/dist/particles/Emitter.js.map +1 -0
  230. package/dist/particles/ParticleBudget.js +32 -0
  231. package/dist/particles/ParticleBudget.js.map +1 -0
  232. package/dist/particles/ParticleSim.js +60 -0
  233. package/dist/particles/ParticleSim.js.map +1 -0
  234. package/dist/particles/particleCurves.js +48 -0
  235. package/dist/particles/particleCurves.js.map +1 -0
  236. package/dist/particles/particleSampling.js +30 -0
  237. package/dist/particles/particleSampling.js.map +1 -0
  238. package/dist/physics/Body.js +202 -0
  239. package/dist/physics/Body.js.map +1 -0
  240. package/dist/physics/BroadPhase.js +56 -0
  241. package/dist/physics/BroadPhase.js.map +1 -0
  242. package/dist/physics/Contact.js +76 -0
  243. package/dist/physics/Contact.js.map +1 -0
  244. package/dist/physics/ContactSolver.js +70 -0
  245. package/dist/physics/ContactSolver.js.map +1 -0
  246. package/dist/physics/PhysicsWorld.js +221 -0
  247. package/dist/physics/PhysicsWorld.js.map +1 -0
  248. package/dist/physics/SpatialHash.js +39 -0
  249. package/dist/physics/SpatialHash.js.map +1 -0
  250. package/dist/physics/collide.js +76 -0
  251. package/dist/physics/collide.js.map +1 -0
  252. package/dist/physics/collidePolygon.js +94 -0
  253. package/dist/physics/collidePolygon.js.map +1 -0
  254. package/dist/physics/contactReport.js +14 -0
  255. package/dist/physics/contactReport.js.map +1 -0
  256. package/dist/physics/drawColliders.js +31 -0
  257. package/dist/physics/drawColliders.js.map +1 -0
  258. package/dist/physics/physicsSystem.js +8 -0
  259. package/dist/physics/physicsSystem.js.map +1 -0
  260. package/dist/physics/polygon.js +80 -0
  261. package/dist/physics/polygon.js.map +1 -0
  262. package/dist/physics/raycast.js +62 -0
  263. package/dist/physics/raycast.js.map +1 -0
  264. package/dist/physics/syncToBody.js +19 -0
  265. package/dist/physics/syncToBody.js.map +1 -0
  266. package/dist/physics/tileBodies.js +59 -0
  267. package/dist/physics/tileBodies.js.map +1 -0
  268. package/dist/physics/types.js +8 -0
  269. package/dist/physics/types.js.map +1 -0
  270. package/dist/pixel/Darkness.js +166 -0
  271. package/dist/pixel/Darkness.js.map +1 -0
  272. package/dist/pixel/DitherVignette.js +57 -0
  273. package/dist/pixel/DitherVignette.js.map +1 -0
  274. package/dist/pixel/Evaporation.js +85 -0
  275. package/dist/pixel/Evaporation.js.map +1 -0
  276. package/dist/pixel/NightShade.js +34 -0
  277. package/dist/pixel/NightShade.js.map +1 -0
  278. package/dist/pixel/PixelLayer.js +211 -0
  279. package/dist/pixel/PixelLayer.js.map +1 -0
  280. package/dist/pixel/SwayProp.js +75 -0
  281. package/dist/pixel/SwayProp.js.map +1 -0
  282. package/dist/pixel/lights.js +44 -0
  283. package/dist/pixel/lights.js.map +1 -0
  284. package/dist/pixel/nineSlice.js +62 -0
  285. package/dist/pixel/nineSlice.js.map +1 -0
  286. package/dist/pixel/paintLayer.js +36 -0
  287. package/dist/pixel/paintLayer.js.map +1 -0
  288. package/dist/pixel/palette.js +57 -0
  289. package/dist/pixel/palette.js.map +1 -0
  290. package/dist/pixel/pixel.js +278 -0
  291. package/dist/pixel/pixel.js.map +1 -0
  292. package/dist/pixel/pixelPaint.js +194 -0
  293. package/dist/pixel/pixelPaint.js.map +1 -0
  294. package/dist/pixel/pixelTone.js +164 -0
  295. package/dist/pixel/pixelTone.js.map +1 -0
  296. package/dist/pixel/propKit.js +41 -0
  297. package/dist/pixel/propKit.js.map +1 -0
  298. package/dist/pixel/ramp.js +102 -0
  299. package/dist/pixel/ramp.js.map +1 -0
  300. package/dist/pixel/selout.js +35 -0
  301. package/dist/pixel/selout.js.map +1 -0
  302. package/dist/pixel/spritePixels.js +59 -0
  303. package/dist/pixel/spritePixels.js.map +1 -0
  304. package/dist/pixel/swayRig.js +87 -0
  305. package/dist/pixel/swayRig.js.map +1 -0
  306. package/dist/pixel/vignetteMask.js +24 -0
  307. package/dist/pixel/vignetteMask.js.map +1 -0
  308. package/dist/pixel/weatherArt.js +61 -0
  309. package/dist/pixel/weatherArt.js.map +1 -0
  310. package/dist/pixel.js +90 -0
  311. package/dist/pixel.js.map +1 -0
  312. package/dist/platform/touch.js +33 -0
  313. package/dist/platform/touch.js.map +1 -0
  314. package/dist/postfx/BloomFilter.js +65 -0
  315. package/dist/postfx/BloomFilter.js.map +1 -0
  316. package/dist/postfx/ChromaticAberrationFilter.js +25 -0
  317. package/dist/postfx/ChromaticAberrationFilter.js.map +1 -0
  318. package/dist/postfx/ColorAdjustFilter.js +76 -0
  319. package/dist/postfx/ColorAdjustFilter.js.map +1 -0
  320. package/dist/postfx/CrtFilter.js +42 -0
  321. package/dist/postfx/CrtFilter.js.map +1 -0
  322. package/dist/postfx/PixelateFilter.js +27 -0
  323. package/dist/postfx/PixelateFilter.js.map +1 -0
  324. package/dist/postfx/PostFx.js +123 -0
  325. package/dist/postfx/PostFx.js.map +1 -0
  326. package/dist/postfx/ShockwaveFilter.js +49 -0
  327. package/dist/postfx/ShockwaveFilter.js.map +1 -0
  328. package/dist/postfx/VignetteFilter.js +37 -0
  329. package/dist/postfx/VignetteFilter.js.map +1 -0
  330. package/dist/postfx/fxAnimator.js +38 -0
  331. package/dist/postfx/fxAnimator.js.map +1 -0
  332. package/dist/postfx/fxShader.js +128 -0
  333. package/dist/postfx/fxShader.js.map +1 -0
  334. package/dist/postfx.js +26 -0
  335. package/dist/postfx.js.map +1 -0
  336. package/dist/react/ChoiceDialog.js +51 -0
  337. package/dist/react/ChoiceDialog.js.map +1 -0
  338. package/dist/react/ConfirmDialog.js +53 -0
  339. package/dist/react/ConfirmDialog.js.map +1 -0
  340. package/dist/react/Glyph.js +63 -0
  341. package/dist/react/Glyph.js.map +1 -0
  342. package/dist/react/Modal.js +38 -0
  343. package/dist/react/Modal.js.map +1 -0
  344. package/dist/react/Panel.js +24 -0
  345. package/dist/react/Panel.js.map +1 -0
  346. package/dist/react/PixelImage.js +24 -0
  347. package/dist/react/PixelImage.js.map +1 -0
  348. package/dist/react/Select.js +99 -0
  349. package/dist/react/Select.js.map +1 -0
  350. package/dist/react/Slider.js +62 -0
  351. package/dist/react/Slider.js.map +1 -0
  352. package/dist/react/SplitPane.js +24 -0
  353. package/dist/react/SplitPane.js.map +1 -0
  354. package/dist/react/TabStrip.js +32 -0
  355. package/dist/react/TabStrip.js.map +1 -0
  356. package/dist/react/TitleTips.js +42 -0
  357. package/dist/react/TitleTips.js.map +1 -0
  358. package/dist/react/Tooltip.js +28 -0
  359. package/dist/react/Tooltip.js.map +1 -0
  360. package/dist/react/UiProvider.js +50 -0
  361. package/dist/react/UiProvider.js.map +1 -0
  362. package/dist/react/baseCss.js +222 -0
  363. package/dist/react/baseCss.js.map +1 -0
  364. package/dist/react/choiceStore.js +23 -0
  365. package/dist/react/choiceStore.js.map +1 -0
  366. package/dist/react/classNames.js +19 -0
  367. package/dist/react/classNames.js.map +1 -0
  368. package/dist/react/confirmStore.js +30 -0
  369. package/dist/react/confirmStore.js.map +1 -0
  370. package/dist/react/labels.js +18 -0
  371. package/dist/react/labels.js.map +1 -0
  372. package/dist/react/placement.js +49 -0
  373. package/dist/react/placement.js.map +1 -0
  374. package/dist/react/useFillSheet.js +23 -0
  375. package/dist/react/useFillSheet.js.map +1 -0
  376. package/dist/react/useFitToViewport.js +29 -0
  377. package/dist/react/useFitToViewport.js.map +1 -0
  378. package/dist/react/usePicked.js +13 -0
  379. package/dist/react/usePicked.js.map +1 -0
  380. package/dist/react/useStore.js +9 -0
  381. package/dist/react/useStore.js.map +1 -0
  382. package/dist/react/useViewport.js +17 -0
  383. package/dist/react/useViewport.js.map +1 -0
  384. package/dist/react.js +78 -0
  385. package/dist/react.js.map +1 -0
  386. package/dist/rig/PosePlayer.js +92 -0
  387. package/dist/rig/PosePlayer.js.map +1 -0
  388. package/dist/rig/RigView.js +125 -0
  389. package/dist/rig/RigView.js.map +1 -0
  390. package/dist/rig/Skeleton.js +31 -0
  391. package/dist/rig/Skeleton.js.map +1 -0
  392. package/dist/rig/humanoid.js +6 -0
  393. package/dist/rig/humanoid.js.map +1 -0
  394. package/dist/rig/humanoid.json.js +30 -0
  395. package/dist/rig/humanoid.json.js.map +1 -0
  396. package/dist/rig/humanoidPoses.js +30 -0
  397. package/dist/rig/humanoidPoses.js.map +1 -0
  398. package/dist/rig/poseMath.js +54 -0
  399. package/dist/rig/poseMath.js.map +1 -0
  400. package/dist/rig/poses.json.js +150 -0
  401. package/dist/rig/poses.json.js.map +1 -0
  402. package/dist/save/Autosaver.js +54 -0
  403. package/dist/save/Autosaver.js.map +1 -0
  404. package/dist/save/MemoryBackend.js +19 -0
  405. package/dist/save/MemoryBackend.js.map +1 -0
  406. package/dist/save/SaveStore.js +103 -0
  407. package/dist/save/SaveStore.js.map +1 -0
  408. package/dist/save/WebStorageBackend.js +27 -0
  409. package/dist/save/WebStorageBackend.js.map +1 -0
  410. package/dist/save/checksum.js +10 -0
  411. package/dist/save/checksum.js.map +1 -0
  412. package/dist/save/migrateSave.js +27 -0
  413. package/dist/save/migrateSave.js.map +1 -0
  414. package/dist/settings.js +27 -0
  415. package/dist/settings.js.map +1 -0
  416. package/dist/tilemap/TilemapView.js +69 -0
  417. package/dist/tilemap/TilemapView.js.map +1 -0
  418. package/dist/tilemap/collision.js +25 -0
  419. package/dist/tilemap/collision.js.map +1 -0
  420. package/dist/tilemap/tiled.js +138 -0
  421. package/dist/tilemap/tiled.js.map +1 -0
  422. package/dist/transitions/CrossfadeTransition.js +24 -0
  423. package/dist/transitions/CrossfadeTransition.js.map +1 -0
  424. package/dist/transitions/DitherWipeTransition.js +70 -0
  425. package/dist/transitions/DitherWipeTransition.js.map +1 -0
  426. package/dist/transitions/FadeTransition.js +34 -0
  427. package/dist/transitions/FadeTransition.js.map +1 -0
  428. package/dist/transitions/Letterbox.js +42 -0
  429. package/dist/transitions/Letterbox.js.map +1 -0
  430. package/dist/transitions/ditherMask.js +15 -0
  431. package/dist/transitions/ditherMask.js.map +1 -0
  432. package/dist/transitions/transitionTo.js +28 -0
  433. package/dist/transitions/transitionTo.js.map +1 -0
  434. package/dist/transitions/tweenDone.js +15 -0
  435. package/dist/transitions/tweenDone.js.map +1 -0
  436. package/dist/types/ambient/ColorGrade.d.ts +41 -0
  437. package/dist/types/ambient/ColorGrade.d.ts.map +1 -0
  438. package/dist/types/ambient/DayClock.d.ts +80 -0
  439. package/dist/types/ambient/DayClock.d.ts.map +1 -0
  440. package/dist/types/ambient/WeatherLayer.d.ts +78 -0
  441. package/dist/types/ambient/WeatherLayer.d.ts.map +1 -0
  442. package/dist/types/ambient/grade.d.ts +22 -0
  443. package/dist/types/ambient/grade.d.ts.map +1 -0
  444. package/dist/types/ambient/weather.d.ts +49 -0
  445. package/dist/types/ambient/weather.d.ts.map +1 -0
  446. package/dist/types/anim/AnimStateMachine.d.ts +80 -0
  447. package/dist/types/anim/AnimStateMachine.d.ts.map +1 -0
  448. package/dist/types/anim/Animator.d.ts +50 -0
  449. package/dist/types/anim/Animator.d.ts.map +1 -0
  450. package/dist/types/anim/animStateCompile.d.ts +52 -0
  451. package/dist/types/anim/animStateCompile.d.ts.map +1 -0
  452. package/dist/types/anim/animStateSystem.d.ts +10 -0
  453. package/dist/types/anim/animStateSystem.d.ts.map +1 -0
  454. package/dist/types/anim/animStateTypes.d.ts +50 -0
  455. package/dist/types/anim/animStateTypes.d.ts.map +1 -0
  456. package/dist/types/anim/animationSystem.d.ts +13 -0
  457. package/dist/types/anim/animationSystem.d.ts.map +1 -0
  458. package/dist/types/anim/asepriteSlices.d.ts +19 -0
  459. package/dist/types/anim/asepriteSlices.d.ts.map +1 -0
  460. package/dist/types/anim/asepriteTags.d.ts +16 -0
  461. package/dist/types/anim/asepriteTags.d.ts.map +1 -0
  462. package/dist/types/anim/asepriteTypes.d.ts +159 -0
  463. package/dist/types/anim/asepriteTypes.d.ts.map +1 -0
  464. package/dist/types/anim/parseAseprite.d.ts +21 -0
  465. package/dist/types/anim/parseAseprite.d.ts.map +1 -0
  466. package/dist/types/assets/AssetLoader.d.ts +85 -0
  467. package/dist/types/assets/AssetLoader.d.ts.map +1 -0
  468. package/dist/types/assets/loadAseprite.d.ts +27 -0
  469. package/dist/types/assets/loadAseprite.d.ts.map +1 -0
  470. package/dist/types/audio/Footsteps.d.ts +33 -0
  471. package/dist/types/audio/Footsteps.d.ts.map +1 -0
  472. package/dist/types/audio/MusicPlayer.d.ts +65 -0
  473. package/dist/types/audio/MusicPlayer.d.ts.map +1 -0
  474. package/dist/types/audio/SoundEngine.d.ts +42 -0
  475. package/dist/types/audio/SoundEngine.d.ts.map +1 -0
  476. package/dist/types/audio/cleanTake.d.ts +3 -0
  477. package/dist/types/audio/cleanTake.d.ts.map +1 -0
  478. package/dist/types/audio/music/ElementVoice.d.ts +14 -0
  479. package/dist/types/audio/music/ElementVoice.d.ts.map +1 -0
  480. package/dist/types/audio/music/GraphVoice.d.ts +22 -0
  481. package/dist/types/audio/music/GraphVoice.d.ts.map +1 -0
  482. package/dist/types/audio/music/MusicChannel.d.ts +35 -0
  483. package/dist/types/audio/music/MusicChannel.d.ts.map +1 -0
  484. package/dist/types/audio/music/musicVoice.d.ts +26 -0
  485. package/dist/types/audio/music/musicVoice.d.ts.map +1 -0
  486. package/dist/types/audio/sampleBank.d.ts +27 -0
  487. package/dist/types/audio/sampleBank.d.ts.map +1 -0
  488. package/dist/types/audio/soundTable.d.ts +14 -0
  489. package/dist/types/audio/soundTable.d.ts.map +1 -0
  490. package/dist/types/audio/synth.d.ts +34 -0
  491. package/dist/types/audio/synth.d.ts.map +1 -0
  492. package/dist/types/audio/takeCleanerWorker.d.ts +2 -0
  493. package/dist/types/audio/takeCleanerWorker.d.ts.map +1 -0
  494. package/dist/types/core/BitmapLabel.d.ts +36 -0
  495. package/dist/types/core/BitmapLabel.d.ts.map +1 -0
  496. package/dist/types/core/Camera.d.ts +115 -0
  497. package/dist/types/core/Camera.d.ts.map +1 -0
  498. package/dist/types/core/Clock.d.ts +11 -0
  499. package/dist/types/core/Clock.d.ts.map +1 -0
  500. package/dist/types/core/Graphics.d.ts +37 -0
  501. package/dist/types/core/Graphics.d.ts.map +1 -0
  502. package/dist/types/core/Group.d.ts +15 -0
  503. package/dist/types/core/Group.d.ts.map +1 -0
  504. package/dist/types/core/Image.d.ts +25 -0
  505. package/dist/types/core/Image.d.ts.map +1 -0
  506. package/dist/types/core/ObjectFactory.d.ts +34 -0
  507. package/dist/types/core/ObjectFactory.d.ts.map +1 -0
  508. package/dist/types/core/Pointer.d.ts +27 -0
  509. package/dist/types/core/Pointer.d.ts.map +1 -0
  510. package/dist/types/core/Rectangle.d.ts +26 -0
  511. package/dist/types/core/Rectangle.d.ts.map +1 -0
  512. package/dist/types/core/Stage.d.ts +58 -0
  513. package/dist/types/core/Stage.d.ts.map +1 -0
  514. package/dist/types/core/Text.d.ts +22 -0
  515. package/dist/types/core/Text.d.ts.map +1 -0
  516. package/dist/types/core/TextureRegistry.d.ts +51 -0
  517. package/dist/types/core/TextureRegistry.d.ts.map +1 -0
  518. package/dist/types/core/Timeline.d.ts +115 -0
  519. package/dist/types/core/Timeline.d.ts.map +1 -0
  520. package/dist/types/core/TimelineBuilder.d.ts +53 -0
  521. package/dist/types/core/TimelineBuilder.d.ts.map +1 -0
  522. package/dist/types/core/TimelineChild.d.ts +51 -0
  523. package/dist/types/core/TimelineChild.d.ts.map +1 -0
  524. package/dist/types/core/Tweener.d.ts +70 -0
  525. package/dist/types/core/Tweener.d.ts.map +1 -0
  526. package/dist/types/core/atlas.d.ts +16 -0
  527. package/dist/types/core/atlas.d.ts.map +1 -0
  528. package/dist/types/core/atlasPlan.d.ts +34 -0
  529. package/dist/types/core/atlasPlan.d.ts.map +1 -0
  530. package/dist/types/core/eases.d.ts +3 -0
  531. package/dist/types/core/eases.d.ts.map +1 -0
  532. package/dist/types/core/gameObject.d.ts +42 -0
  533. package/dist/types/core/gameObject.d.ts.map +1 -0
  534. package/dist/types/core/pixiPatches.d.ts +9 -0
  535. package/dist/types/core/pixiPatches.d.ts.map +1 -0
  536. package/dist/types/core/timelinePlace.d.ts +23 -0
  537. package/dist/types/core/timelinePlace.d.ts.map +1 -0
  538. package/dist/types/core/tweenProps.d.ts +8 -0
  539. package/dist/types/core/tweenProps.d.ts.map +1 -0
  540. package/dist/types/core/types.d.ts +4 -0
  541. package/dist/types/core/types.d.ts.map +1 -0
  542. package/dist/types/debug/DebugOverlay.d.ts +63 -0
  543. package/dist/types/debug/DebugOverlay.d.ts.map +1 -0
  544. package/dist/types/debug/DrawCallCounter.d.ts +20 -0
  545. package/dist/types/debug/DrawCallCounter.d.ts.map +1 -0
  546. package/dist/types/debug/ErrorLog.d.ts +20 -0
  547. package/dist/types/debug/ErrorLog.d.ts.map +1 -0
  548. package/dist/types/debug/FrameStats.d.ts +21 -0
  549. package/dist/types/debug/FrameStats.d.ts.map +1 -0
  550. package/dist/types/debug/inspectWorld.d.ts +14 -0
  551. package/dist/types/debug/inspectWorld.d.ts.map +1 -0
  552. package/dist/types/diagnostics/ErrorDeduper.d.ts +17 -0
  553. package/dist/types/diagnostics/ErrorDeduper.d.ts.map +1 -0
  554. package/dist/types/diagnostics/FrameSampler.d.ts +37 -0
  555. package/dist/types/diagnostics/FrameSampler.d.ts.map +1 -0
  556. package/dist/types/diagnostics/bootWatch.d.ts +25 -0
  557. package/dist/types/diagnostics/bootWatch.d.ts.map +1 -0
  558. package/dist/types/diagnostics/captureErrors.d.ts +24 -0
  559. package/dist/types/diagnostics/captureErrors.d.ts.map +1 -0
  560. package/dist/types/diagnostics/contextLoss.d.ts +35 -0
  561. package/dist/types/diagnostics/contextLoss.d.ts.map +1 -0
  562. package/dist/types/diagnostics/frameStats.d.ts +30 -0
  563. package/dist/types/diagnostics/frameStats.d.ts.map +1 -0
  564. package/dist/types/diagnostics/gpuInfo.d.ts +9 -0
  565. package/dist/types/diagnostics/gpuInfo.d.ts.map +1 -0
  566. package/dist/types/diagnostics/renderGuard.d.ts +12 -0
  567. package/dist/types/diagnostics/renderGuard.d.ts.map +1 -0
  568. package/dist/types/ecs/SparseSet.d.ts +25 -0
  569. package/dist/types/ecs/SparseSet.d.ts.map +1 -0
  570. package/dist/types/ecs/World.d.ts +137 -0
  571. package/dist/types/ecs/World.d.ts.map +1 -0
  572. package/dist/types/ecs/fields.d.ts +34 -0
  573. package/dist/types/ecs/fields.d.ts.map +1 -0
  574. package/dist/types/engine/Engine.d.ts +80 -0
  575. package/dist/types/engine/Engine.d.ts.map +1 -0
  576. package/dist/types/engine/FixedLoop.d.ts +32 -0
  577. package/dist/types/engine/FixedLoop.d.ts.map +1 -0
  578. package/dist/types/engine/Scene.d.ts +67 -0
  579. package/dist/types/engine/Scene.d.ts.map +1 -0
  580. package/dist/types/engine/SceneManager.d.ts +36 -0
  581. package/dist/types/engine/SceneManager.d.ts.map +1 -0
  582. package/dist/types/events/EventBus.d.ts +20 -0
  583. package/dist/types/events/EventBus.d.ts.map +1 -0
  584. package/dist/types/fx/FloatingText.d.ts +71 -0
  585. package/dist/types/fx/FloatingText.d.ts.map +1 -0
  586. package/dist/types/fx/hitStop.d.ts +20 -0
  587. package/dist/types/fx/hitStop.d.ts.map +1 -0
  588. package/dist/types/fx/viewCull.d.ts +14 -0
  589. package/dist/types/fx/viewCull.d.ts.map +1 -0
  590. package/dist/types/i18n/Translator.d.ts +52 -0
  591. package/dist/types/i18n/Translator.d.ts.map +1 -0
  592. package/dist/types/i18n/extractStrings.d.ts +25 -0
  593. package/dist/types/i18n/extractStrings.d.ts.map +1 -0
  594. package/dist/types/i18n/formatMessage.d.ts +10 -0
  595. package/dist/types/i18n/formatMessage.d.ts.map +1 -0
  596. package/dist/types/index.d.ts +149 -0
  597. package/dist/types/index.d.ts.map +1 -0
  598. package/dist/types/input/Actions.d.ts +94 -0
  599. package/dist/types/input/Actions.d.ts.map +1 -0
  600. package/dist/types/input/AimGesture.d.ts +106 -0
  601. package/dist/types/input/AimGesture.d.ts.map +1 -0
  602. package/dist/types/input/Keyboard.d.ts +30 -0
  603. package/dist/types/input/Keyboard.d.ts.map +1 -0
  604. package/dist/types/input/Keymap.d.ts +85 -0
  605. package/dist/types/input/Keymap.d.ts.map +1 -0
  606. package/dist/types/input/TargetLock.d.ts +56 -0
  607. package/dist/types/input/TargetLock.d.ts.map +1 -0
  608. package/dist/types/input/aimAxis.d.ts +9 -0
  609. package/dist/types/input/aimAxis.d.ts.map +1 -0
  610. package/dist/types/input/keyChord.d.ts +15 -0
  611. package/dist/types/input/keyChord.d.ts.map +1 -0
  612. package/dist/types/input/longPress.d.ts +21 -0
  613. package/dist/types/input/longPress.d.ts.map +1 -0
  614. package/dist/types/input/stickAxis.d.ts +26 -0
  615. package/dist/types/input/stickAxis.d.ts.map +1 -0
  616. package/dist/types/input/touchDetect.d.ts +18 -0
  617. package/dist/types/input/touchDetect.d.ts.map +1 -0
  618. package/dist/types/light/LightLayer.d.ts +65 -0
  619. package/dist/types/light/LightLayer.d.ts.map +1 -0
  620. package/dist/types/nav/MinHeap.d.ts +15 -0
  621. package/dist/types/nav/MinHeap.d.ts.map +1 -0
  622. package/dist/types/nav/findPath.d.ts +38 -0
  623. package/dist/types/nav/findPath.d.ts.map +1 -0
  624. package/dist/types/nav/navGrid.d.ts +48 -0
  625. package/dist/types/nav/navGrid.d.ts.map +1 -0
  626. package/dist/types/nav/nearestOpen.d.ts +8 -0
  627. package/dist/types/nav/nearestOpen.d.ts.map +1 -0
  628. package/dist/types/nav/straightenPath.d.ts +13 -0
  629. package/dist/types/nav/straightenPath.d.ts.map +1 -0
  630. package/dist/types/net/Connection.d.ts +66 -0
  631. package/dist/types/net/Connection.d.ts.map +1 -0
  632. package/dist/types/net/InterpolationBuffer.d.ts +36 -0
  633. package/dist/types/net/InterpolationBuffer.d.ts.map +1 -0
  634. package/dist/types/net/PredictedMover.d.ts +43 -0
  635. package/dist/types/net/PredictedMover.d.ts.map +1 -0
  636. package/dist/types/net/Room.d.ts +69 -0
  637. package/dist/types/net/Room.d.ts.map +1 -0
  638. package/dist/types/net/RoomHost.d.ts +74 -0
  639. package/dist/types/net/RoomHost.d.ts.map +1 -0
  640. package/dist/types/net/cadence.d.ts +22 -0
  641. package/dist/types/net/cadence.d.ts.map +1 -0
  642. package/dist/types/net/constants.d.ts +24 -0
  643. package/dist/types/net/constants.d.ts.map +1 -0
  644. package/dist/types/net/lobby/LobbyClient.d.ts +107 -0
  645. package/dist/types/net/lobby/LobbyClient.d.ts.map +1 -0
  646. package/dist/types/net/lobby/LobbyHost.d.ts +147 -0
  647. package/dist/types/net/lobby/LobbyHost.d.ts.map +1 -0
  648. package/dist/types/net/lobby/LobbyRooms.d.ts +56 -0
  649. package/dist/types/net/lobby/LobbyRooms.d.ts.map +1 -0
  650. package/dist/types/net/lobby/Matchmaker.d.ts +57 -0
  651. package/dist/types/net/lobby/Matchmaker.d.ts.map +1 -0
  652. package/dist/types/net/lobby/index.d.ts +6 -0
  653. package/dist/types/net/lobby/index.d.ts.map +1 -0
  654. package/dist/types/net/lobby/lobbyProtocol.d.ts +143 -0
  655. package/dist/types/net/lobby/lobbyProtocol.d.ts.map +1 -0
  656. package/dist/types/net/movement.d.ts +50 -0
  657. package/dist/types/net/movement.d.ts.map +1 -0
  658. package/dist/types/net/protocol.d.ts +59 -0
  659. package/dist/types/net/protocol.d.ts.map +1 -0
  660. package/dist/types/net/serverClock.d.ts +14 -0
  661. package/dist/types/net/serverClock.d.ts.map +1 -0
  662. package/dist/types/net/snapshotCodec.d.ts +55 -0
  663. package/dist/types/net/snapshotCodec.d.ts.map +1 -0
  664. package/dist/types/parallax/Parallax.d.ts +37 -0
  665. package/dist/types/parallax/Parallax.d.ts.map +1 -0
  666. package/dist/types/parallax/ParallaxLayer.d.ts +80 -0
  667. package/dist/types/parallax/ParallaxLayer.d.ts.map +1 -0
  668. package/dist/types/parallax/parallaxMath.d.ts +50 -0
  669. package/dist/types/parallax/parallaxMath.d.ts.map +1 -0
  670. package/dist/types/particles/Emitter.d.ts +97 -0
  671. package/dist/types/particles/Emitter.d.ts.map +1 -0
  672. package/dist/types/particles/ParticleBudget.d.ts +28 -0
  673. package/dist/types/particles/ParticleBudget.d.ts.map +1 -0
  674. package/dist/types/particles/ParticleSim.d.ts +38 -0
  675. package/dist/types/particles/ParticleSim.d.ts.map +1 -0
  676. package/dist/types/particles/particleCurves.d.ts +21 -0
  677. package/dist/types/particles/particleCurves.d.ts.map +1 -0
  678. package/dist/types/particles/particleSampling.d.ts +20 -0
  679. package/dist/types/particles/particleSampling.d.ts.map +1 -0
  680. package/dist/types/physics/Body.d.ts +130 -0
  681. package/dist/types/physics/Body.d.ts.map +1 -0
  682. package/dist/types/physics/BroadPhase.d.ts +26 -0
  683. package/dist/types/physics/BroadPhase.d.ts.map +1 -0
  684. package/dist/types/physics/Contact.d.ts +62 -0
  685. package/dist/types/physics/Contact.d.ts.map +1 -0
  686. package/dist/types/physics/ContactSolver.d.ts +29 -0
  687. package/dist/types/physics/ContactSolver.d.ts.map +1 -0
  688. package/dist/types/physics/PhysicsWorld.d.ts +78 -0
  689. package/dist/types/physics/PhysicsWorld.d.ts.map +1 -0
  690. package/dist/types/physics/PhysicsWorldOptions.d.ts +24 -0
  691. package/dist/types/physics/PhysicsWorldOptions.d.ts.map +1 -0
  692. package/dist/types/physics/SpatialHash.d.ts +23 -0
  693. package/dist/types/physics/SpatialHash.d.ts.map +1 -0
  694. package/dist/types/physics/collide.d.ts +27 -0
  695. package/dist/types/physics/collide.d.ts.map +1 -0
  696. package/dist/types/physics/collidePolygon.d.ts +14 -0
  697. package/dist/types/physics/collidePolygon.d.ts.map +1 -0
  698. package/dist/types/physics/contactReport.d.ts +8 -0
  699. package/dist/types/physics/contactReport.d.ts.map +1 -0
  700. package/dist/types/physics/drawColliders.d.ts +43 -0
  701. package/dist/types/physics/drawColliders.d.ts.map +1 -0
  702. package/dist/types/physics/physicsSystem.d.ts +5 -0
  703. package/dist/types/physics/physicsSystem.d.ts.map +1 -0
  704. package/dist/types/physics/polygon.d.ts +28 -0
  705. package/dist/types/physics/polygon.d.ts.map +1 -0
  706. package/dist/types/physics/raycast.d.ts +19 -0
  707. package/dist/types/physics/raycast.d.ts.map +1 -0
  708. package/dist/types/physics/syncToBody.d.ts +16 -0
  709. package/dist/types/physics/syncToBody.d.ts.map +1 -0
  710. package/dist/types/physics/tileBodies.d.ts +36 -0
  711. package/dist/types/physics/tileBodies.d.ts.map +1 -0
  712. package/dist/types/physics/types.d.ts +116 -0
  713. package/dist/types/physics/types.d.ts.map +1 -0
  714. package/dist/types/pixel/Darkness.d.ts +78 -0
  715. package/dist/types/pixel/Darkness.d.ts.map +1 -0
  716. package/dist/types/pixel/DitherVignette.d.ts +35 -0
  717. package/dist/types/pixel/DitherVignette.d.ts.map +1 -0
  718. package/dist/types/pixel/Evaporation.d.ts +30 -0
  719. package/dist/types/pixel/Evaporation.d.ts.map +1 -0
  720. package/dist/types/pixel/NightShade.d.ts +38 -0
  721. package/dist/types/pixel/NightShade.d.ts.map +1 -0
  722. package/dist/types/pixel/PixelLayer.d.ts +85 -0
  723. package/dist/types/pixel/PixelLayer.d.ts.map +1 -0
  724. package/dist/types/pixel/SwayProp.d.ts +52 -0
  725. package/dist/types/pixel/SwayProp.d.ts.map +1 -0
  726. package/dist/types/pixel/index.d.ts +31 -0
  727. package/dist/types/pixel/index.d.ts.map +1 -0
  728. package/dist/types/pixel/lights.d.ts +34 -0
  729. package/dist/types/pixel/lights.d.ts.map +1 -0
  730. package/dist/types/pixel/nineSlice.d.ts +71 -0
  731. package/dist/types/pixel/nineSlice.d.ts.map +1 -0
  732. package/dist/types/pixel/paintLayer.d.ts +35 -0
  733. package/dist/types/pixel/paintLayer.d.ts.map +1 -0
  734. package/dist/types/pixel/palette.d.ts +58 -0
  735. package/dist/types/pixel/palette.d.ts.map +1 -0
  736. package/dist/types/pixel/pixel.d.ts +80 -0
  737. package/dist/types/pixel/pixel.d.ts.map +1 -0
  738. package/dist/types/pixel/pixelPaint.d.ts +43 -0
  739. package/dist/types/pixel/pixelPaint.d.ts.map +1 -0
  740. package/dist/types/pixel/pixelTone.d.ts +51 -0
  741. package/dist/types/pixel/pixelTone.d.ts.map +1 -0
  742. package/dist/types/pixel/propKit.d.ts +26 -0
  743. package/dist/types/pixel/propKit.d.ts.map +1 -0
  744. package/dist/types/pixel/ramp.d.ts +57 -0
  745. package/dist/types/pixel/ramp.d.ts.map +1 -0
  746. package/dist/types/pixel/selout.d.ts +3 -0
  747. package/dist/types/pixel/selout.d.ts.map +1 -0
  748. package/dist/types/pixel/spritePixels.d.ts +29 -0
  749. package/dist/types/pixel/spritePixels.d.ts.map +1 -0
  750. package/dist/types/pixel/swayRig.d.ts +72 -0
  751. package/dist/types/pixel/swayRig.d.ts.map +1 -0
  752. package/dist/types/pixel/vignetteMask.d.ts +16 -0
  753. package/dist/types/pixel/vignetteMask.d.ts.map +1 -0
  754. package/dist/types/pixel/weatherArt.d.ts +29 -0
  755. package/dist/types/pixel/weatherArt.d.ts.map +1 -0
  756. package/dist/types/platform/touch.d.ts +10 -0
  757. package/dist/types/platform/touch.d.ts.map +1 -0
  758. package/dist/types/postfx/BloomFilter.d.ts +33 -0
  759. package/dist/types/postfx/BloomFilter.d.ts.map +1 -0
  760. package/dist/types/postfx/ChromaticAberrationFilter.d.ts +11 -0
  761. package/dist/types/postfx/ChromaticAberrationFilter.d.ts.map +1 -0
  762. package/dist/types/postfx/ColorAdjustFilter.d.ts +32 -0
  763. package/dist/types/postfx/ColorAdjustFilter.d.ts.map +1 -0
  764. package/dist/types/postfx/CrtFilter.d.ts +16 -0
  765. package/dist/types/postfx/CrtFilter.d.ts.map +1 -0
  766. package/dist/types/postfx/PixelateFilter.d.ts +8 -0
  767. package/dist/types/postfx/PixelateFilter.d.ts.map +1 -0
  768. package/dist/types/postfx/PostFx.d.ts +92 -0
  769. package/dist/types/postfx/PostFx.d.ts.map +1 -0
  770. package/dist/types/postfx/ShockwaveFilter.d.ts +20 -0
  771. package/dist/types/postfx/ShockwaveFilter.d.ts.map +1 -0
  772. package/dist/types/postfx/VignetteFilter.d.ts +19 -0
  773. package/dist/types/postfx/VignetteFilter.d.ts.map +1 -0
  774. package/dist/types/postfx/fxAnimator.d.ts +32 -0
  775. package/dist/types/postfx/fxAnimator.d.ts.map +1 -0
  776. package/dist/types/postfx/fxShader.d.ts +49 -0
  777. package/dist/types/postfx/fxShader.d.ts.map +1 -0
  778. package/dist/types/postfx/index.d.ts +11 -0
  779. package/dist/types/postfx/index.d.ts.map +1 -0
  780. package/dist/types/react/ChoiceDialog.d.ts +8 -0
  781. package/dist/types/react/ChoiceDialog.d.ts.map +1 -0
  782. package/dist/types/react/ConfirmDialog.d.ts +9 -0
  783. package/dist/types/react/ConfirmDialog.d.ts.map +1 -0
  784. package/dist/types/react/Glyph.d.ts +54 -0
  785. package/dist/types/react/Glyph.d.ts.map +1 -0
  786. package/dist/types/react/Modal.d.ts +22 -0
  787. package/dist/types/react/Modal.d.ts.map +1 -0
  788. package/dist/types/react/Panel.d.ts +29 -0
  789. package/dist/types/react/Panel.d.ts.map +1 -0
  790. package/dist/types/react/PixelImage.d.ts +19 -0
  791. package/dist/types/react/PixelImage.d.ts.map +1 -0
  792. package/dist/types/react/Select.d.ts +27 -0
  793. package/dist/types/react/Select.d.ts.map +1 -0
  794. package/dist/types/react/Slider.d.ts +24 -0
  795. package/dist/types/react/Slider.d.ts.map +1 -0
  796. package/dist/types/react/SplitPane.d.ts +26 -0
  797. package/dist/types/react/SplitPane.d.ts.map +1 -0
  798. package/dist/types/react/TabStrip.d.ts +31 -0
  799. package/dist/types/react/TabStrip.d.ts.map +1 -0
  800. package/dist/types/react/TitleTips.d.ts +15 -0
  801. package/dist/types/react/TitleTips.d.ts.map +1 -0
  802. package/dist/types/react/Tooltip.d.ts +22 -0
  803. package/dist/types/react/Tooltip.d.ts.map +1 -0
  804. package/dist/types/react/UiProvider.d.ts +52 -0
  805. package/dist/types/react/UiProvider.d.ts.map +1 -0
  806. package/dist/types/react/baseCss.d.ts +27 -0
  807. package/dist/types/react/baseCss.d.ts.map +1 -0
  808. package/dist/types/react/choiceStore.d.ts +34 -0
  809. package/dist/types/react/choiceStore.d.ts.map +1 -0
  810. package/dist/types/react/classNames.d.ts +12 -0
  811. package/dist/types/react/classNames.d.ts.map +1 -0
  812. package/dist/types/react/confirmStore.d.ts +30 -0
  813. package/dist/types/react/confirmStore.d.ts.map +1 -0
  814. package/dist/types/react/index.d.ts +33 -0
  815. package/dist/types/react/index.d.ts.map +1 -0
  816. package/dist/types/react/labels.d.ts +24 -0
  817. package/dist/types/react/labels.d.ts.map +1 -0
  818. package/dist/types/react/placement.d.ts +59 -0
  819. package/dist/types/react/placement.d.ts.map +1 -0
  820. package/dist/types/react/useFillSheet.d.ts +9 -0
  821. package/dist/types/react/useFillSheet.d.ts.map +1 -0
  822. package/dist/types/react/useFitToViewport.d.ts +20 -0
  823. package/dist/types/react/useFitToViewport.d.ts.map +1 -0
  824. package/dist/types/react/usePicked.d.ts +9 -0
  825. package/dist/types/react/usePicked.d.ts.map +1 -0
  826. package/dist/types/react/useStore.d.ts +8 -0
  827. package/dist/types/react/useStore.d.ts.map +1 -0
  828. package/dist/types/react/useViewport.d.ts +4 -0
  829. package/dist/types/react/useViewport.d.ts.map +1 -0
  830. package/dist/types/rig/PosePlayer.d.ts +64 -0
  831. package/dist/types/rig/PosePlayer.d.ts.map +1 -0
  832. package/dist/types/rig/RigView.d.ts +68 -0
  833. package/dist/types/rig/RigView.d.ts.map +1 -0
  834. package/dist/types/rig/Skeleton.d.ts +14 -0
  835. package/dist/types/rig/Skeleton.d.ts.map +1 -0
  836. package/dist/types/rig/humanoid.d.ts +4 -0
  837. package/dist/types/rig/humanoid.d.ts.map +1 -0
  838. package/dist/types/rig/humanoidPoses.d.ts +117 -0
  839. package/dist/types/rig/humanoidPoses.d.ts.map +1 -0
  840. package/dist/types/rig/poseMath.d.ts +14 -0
  841. package/dist/types/rig/poseMath.d.ts.map +1 -0
  842. package/dist/types/rig/rigTypes.d.ts +82 -0
  843. package/dist/types/rig/rigTypes.d.ts.map +1 -0
  844. package/dist/types/save/Autosaver.d.ts +43 -0
  845. package/dist/types/save/Autosaver.d.ts.map +1 -0
  846. package/dist/types/save/MemoryBackend.d.ts +10 -0
  847. package/dist/types/save/MemoryBackend.d.ts.map +1 -0
  848. package/dist/types/save/SaveBackend.d.ts +14 -0
  849. package/dist/types/save/SaveBackend.d.ts.map +1 -0
  850. package/dist/types/save/SaveStore.d.ts +73 -0
  851. package/dist/types/save/SaveStore.d.ts.map +1 -0
  852. package/dist/types/save/WebStorageBackend.d.ts +14 -0
  853. package/dist/types/save/WebStorageBackend.d.ts.map +1 -0
  854. package/dist/types/save/checksum.d.ts +7 -0
  855. package/dist/types/save/checksum.d.ts.map +1 -0
  856. package/dist/types/save/migrateSave.d.ts +17 -0
  857. package/dist/types/save/migrateSave.d.ts.map +1 -0
  858. package/dist/types/settings.d.ts +25 -0
  859. package/dist/types/settings.d.ts.map +1 -0
  860. package/dist/types/tilemap/TilemapView.d.ts +42 -0
  861. package/dist/types/tilemap/TilemapView.d.ts.map +1 -0
  862. package/dist/types/tilemap/collision.d.ts +16 -0
  863. package/dist/types/tilemap/collision.d.ts.map +1 -0
  864. package/dist/types/tilemap/tiled.d.ts +104 -0
  865. package/dist/types/tilemap/tiled.d.ts.map +1 -0
  866. package/dist/types/transitions/CrossfadeTransition.d.ts +20 -0
  867. package/dist/types/transitions/CrossfadeTransition.d.ts.map +1 -0
  868. package/dist/types/transitions/DitherWipeTransition.d.ts +35 -0
  869. package/dist/types/transitions/DitherWipeTransition.d.ts.map +1 -0
  870. package/dist/types/transitions/FadeTransition.d.ts +20 -0
  871. package/dist/types/transitions/FadeTransition.d.ts.map +1 -0
  872. package/dist/types/transitions/Letterbox.d.ts +33 -0
  873. package/dist/types/transitions/Letterbox.d.ts.map +1 -0
  874. package/dist/types/transitions/Transition.d.ts +22 -0
  875. package/dist/types/transitions/Transition.d.ts.map +1 -0
  876. package/dist/types/transitions/ditherMask.d.ts +13 -0
  877. package/dist/types/transitions/ditherMask.d.ts.map +1 -0
  878. package/dist/types/transitions/transitionTo.d.ts +16 -0
  879. package/dist/types/transitions/transitionTo.d.ts.map +1 -0
  880. package/dist/types/transitions/tweenDone.d.ts +5 -0
  881. package/dist/types/transitions/tweenDone.d.ts.map +1 -0
  882. package/dist/types/ui/Bar.d.ts +41 -0
  883. package/dist/types/ui/Bar.d.ts.map +1 -0
  884. package/dist/types/ui/Button.d.ts +47 -0
  885. package/dist/types/ui/Button.d.ts.map +1 -0
  886. package/dist/types/ui/Dialog.d.ts +47 -0
  887. package/dist/types/ui/Dialog.d.ts.map +1 -0
  888. package/dist/types/ui/FocusManager.d.ts +53 -0
  889. package/dist/types/ui/FocusManager.d.ts.map +1 -0
  890. package/dist/types/ui/Label.d.ts +24 -0
  891. package/dist/types/ui/Label.d.ts.map +1 -0
  892. package/dist/types/ui/List.d.ts +23 -0
  893. package/dist/types/ui/List.d.ts.map +1 -0
  894. package/dist/types/ui/Panel.d.ts +38 -0
  895. package/dist/types/ui/Panel.d.ts.map +1 -0
  896. package/dist/types/ui/ScrollView.d.ts +56 -0
  897. package/dist/types/ui/ScrollView.d.ts.map +1 -0
  898. package/dist/types/ui/Slider.d.ts +47 -0
  899. package/dist/types/ui/Slider.d.ts.map +1 -0
  900. package/dist/types/ui/Stack.d.ts +16 -0
  901. package/dist/types/ui/Stack.d.ts.map +1 -0
  902. package/dist/types/ui/Toggle.d.ts +31 -0
  903. package/dist/types/ui/Toggle.d.ts.map +1 -0
  904. package/dist/types/ui/UiHost.d.ts +18 -0
  905. package/dist/types/ui/UiHost.d.ts.map +1 -0
  906. package/dist/types/ui/UiPointerGate.d.ts +17 -0
  907. package/dist/types/ui/UiPointerGate.d.ts.map +1 -0
  908. package/dist/types/ui/UiRoot.d.ts +73 -0
  909. package/dist/types/ui/UiRoot.d.ts.map +1 -0
  910. package/dist/types/ui/Widget.d.ts +56 -0
  911. package/dist/types/ui/Widget.d.ts.map +1 -0
  912. package/dist/types/ui/dom/DomOverlay.d.ts +52 -0
  913. package/dist/types/ui/dom/DomOverlay.d.ts.map +1 -0
  914. package/dist/types/ui/dom/DomWorldAnchors.d.ts +50 -0
  915. package/dist/types/ui/dom/DomWorldAnchors.d.ts.map +1 -0
  916. package/dist/types/ui/dom/InputShield.d.ts +20 -0
  917. package/dist/types/ui/dom/InputShield.d.ts.map +1 -0
  918. package/dist/types/ui/dom/createStore.d.ts +22 -0
  919. package/dist/types/ui/dom/createStore.d.ts.map +1 -0
  920. package/dist/types/ui/dom/shieldDecision.d.ts +34 -0
  921. package/dist/types/ui/dom/shieldDecision.d.ts.map +1 -0
  922. package/dist/types/ui/dom/worldToScreen.d.ts +24 -0
  923. package/dist/types/ui/dom/worldToScreen.d.ts.map +1 -0
  924. package/dist/types/ui/index.d.ts +38 -0
  925. package/dist/types/ui/index.d.ts.map +1 -0
  926. package/dist/types/ui/layout/anchor.d.ts +9 -0
  927. package/dist/types/ui/layout/anchor.d.ts.map +1 -0
  928. package/dist/types/ui/layout/barDrain.d.ts +25 -0
  929. package/dist/types/ui/layout/barDrain.d.ts.map +1 -0
  930. package/dist/types/ui/layout/fitToViewport.d.ts +32 -0
  931. package/dist/types/ui/layout/fitToViewport.d.ts.map +1 -0
  932. package/dist/types/ui/layout/focusNav.d.ts +13 -0
  933. package/dist/types/ui/layout/focusNav.d.ts.map +1 -0
  934. package/dist/types/ui/layout/geometry.d.ts +35 -0
  935. package/dist/types/ui/layout/geometry.d.ts.map +1 -0
  936. package/dist/types/ui/layout/listWidth.d.ts +13 -0
  937. package/dist/types/ui/layout/listWidth.d.ts.map +1 -0
  938. package/dist/types/ui/layout/placeTooltip.d.ts +23 -0
  939. package/dist/types/ui/layout/placeTooltip.d.ts.map +1 -0
  940. package/dist/types/ui/layout/scroll.d.ts +17 -0
  941. package/dist/types/ui/layout/scroll.d.ts.map +1 -0
  942. package/dist/types/ui/layout/slider.d.ts +7 -0
  943. package/dist/types/ui/layout/slider.d.ts.map +1 -0
  944. package/dist/types/ui/layout/stack.d.ts +26 -0
  945. package/dist/types/ui/layout/stack.d.ts.map +1 -0
  946. package/dist/types/ui/layout/wrapRow.d.ts +6 -0
  947. package/dist/types/ui/layout/wrapRow.d.ts.map +1 -0
  948. package/dist/ui/Bar.js +54 -0
  949. package/dist/ui/Bar.js.map +1 -0
  950. package/dist/ui/Button.js +58 -0
  951. package/dist/ui/Button.js.map +1 -0
  952. package/dist/ui/Dialog.js +56 -0
  953. package/dist/ui/Dialog.js.map +1 -0
  954. package/dist/ui/FocusManager.js +97 -0
  955. package/dist/ui/FocusManager.js.map +1 -0
  956. package/dist/ui/Label.js +36 -0
  957. package/dist/ui/Label.js.map +1 -0
  958. package/dist/ui/List.js +45 -0
  959. package/dist/ui/List.js.map +1 -0
  960. package/dist/ui/Panel.js +38 -0
  961. package/dist/ui/Panel.js.map +1 -0
  962. package/dist/ui/ScrollView.js +96 -0
  963. package/dist/ui/ScrollView.js.map +1 -0
  964. package/dist/ui/Slider.js +55 -0
  965. package/dist/ui/Slider.js.map +1 -0
  966. package/dist/ui/Stack.js +28 -0
  967. package/dist/ui/Stack.js.map +1 -0
  968. package/dist/ui/Toggle.js +37 -0
  969. package/dist/ui/Toggle.js.map +1 -0
  970. package/dist/ui/UiHost.js +9 -0
  971. package/dist/ui/UiHost.js.map +1 -0
  972. package/dist/ui/UiPointerGate.js +25 -0
  973. package/dist/ui/UiPointerGate.js.map +1 -0
  974. package/dist/ui/UiRoot.js +93 -0
  975. package/dist/ui/UiRoot.js.map +1 -0
  976. package/dist/ui/Widget.js +90 -0
  977. package/dist/ui/Widget.js.map +1 -0
  978. package/dist/ui/dom/DomOverlay.js +59 -0
  979. package/dist/ui/dom/DomOverlay.js.map +1 -0
  980. package/dist/ui/dom/DomWorldAnchors.js +59 -0
  981. package/dist/ui/dom/DomWorldAnchors.js.map +1 -0
  982. package/dist/ui/dom/InputShield.js +27 -0
  983. package/dist/ui/dom/InputShield.js.map +1 -0
  984. package/dist/ui/dom/createStore.js +42 -0
  985. package/dist/ui/dom/createStore.js.map +1 -0
  986. package/dist/ui/dom/shieldDecision.js +36 -0
  987. package/dist/ui/dom/shieldDecision.js.map +1 -0
  988. package/dist/ui/dom/worldToScreen.js +11 -0
  989. package/dist/ui/dom/worldToScreen.js.map +1 -0
  990. package/dist/ui/layout/anchor.js +20 -0
  991. package/dist/ui/layout/anchor.js.map +1 -0
  992. package/dist/ui/layout/barDrain.js +25 -0
  993. package/dist/ui/layout/barDrain.js.map +1 -0
  994. package/dist/ui/layout/fitToViewport.js +17 -0
  995. package/dist/ui/layout/fitToViewport.js.map +1 -0
  996. package/dist/ui/layout/focusNav.js +42 -0
  997. package/dist/ui/layout/focusNav.js.map +1 -0
  998. package/dist/ui/layout/geometry.js +21 -0
  999. package/dist/ui/layout/geometry.js.map +1 -0
  1000. package/dist/ui/layout/listWidth.js +10 -0
  1001. package/dist/ui/layout/listWidth.js.map +1 -0
  1002. package/dist/ui/layout/placeTooltip.js +28 -0
  1003. package/dist/ui/layout/placeTooltip.js.map +1 -0
  1004. package/dist/ui/layout/scroll.js +24 -0
  1005. package/dist/ui/layout/scroll.js.map +1 -0
  1006. package/dist/ui/layout/slider.js +20 -0
  1007. package/dist/ui/layout/slider.js.map +1 -0
  1008. package/dist/ui/layout/stack.js +27 -0
  1009. package/dist/ui/layout/stack.js.map +1 -0
  1010. package/dist/ui/layout/wrapRow.js +13 -0
  1011. package/dist/ui/layout/wrapRow.js.map +1 -0
  1012. package/dist/ui.js +85 -0
  1013. package/dist/ui.js.map +1 -0
  1014. package/package.json +115 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collidePolygon.js","sources":["../../src/physics/collidePolygon.ts"],"sourcesContent":["import type { Body } from './Body';\nimport type { Manifold } from './collide';\nimport { FACE_BOTTOM, FACE_LEFT, FACE_RIGHT, FACE_TOP } from './types';\n\n/** Face bits of a box's corners order (`Body.updateBounds`): face 0 is the top, then right, bottom, left. */\nconst BOX_FACE_BITS = [FACE_TOP, FACE_RIGHT, FACE_BOTTOM, FACE_LEFT] as const;\n\n/** A reference face is kept unless the other side's is deeper by more than this (px): no flip-flopping between equals. */\nconst FLIP_TOLERANCE = 0.05;\n\n/**\n * Whether `body` has an internal face (one lying against more solid ground) whose outward normal is (nx, ny): only\n * a merged tile box at no angle has them.\n */\nfunction internalAlong(body: Body, nx: number, ny: number): boolean {\n if (!body.internalFaces || !body.axisAligned) return false;\n for (let i = 0; i < 4; i++) {\n if (body.internalFaces & BOX_FACE_BITS[i]! && body.wnx[i]! * nx + body.wny[i]! * ny > 0.999) return true;\n }\n return false;\n}\n\n/** A contact normal from a to b that pushes neither body out of an internal face. */\nfunction normalAllowed(a: Body, b: Body, nx: number, ny: number): boolean {\n return !internalAlong(a, nx, ny) && !internalAlong(b, -nx, -ny);\n}\n\n/** Separation of `other`'s corners from face `i` of `ref`: the most negative is how deep the deepest corner lies. */\nfunction faceSeparation(ref: Body, i: number, other: Body): number {\n const nx = ref.wnx[i]!;\n const ny = ref.wny[i]!;\n const vx = ref.wx[i]!;\n const vy = ref.wy[i]!;\n let min = Infinity;\n for (let j = 0; j < other.corners; j++) {\n const d = (other.wx[j]! - vx) * nx + (other.wy[j]! - vy) * ny;\n if (d < min) min = d;\n }\n return min;\n}\n\ninterface Best {\n sep: number;\n face: number;\n}\n\n/** The face of `ref` the two are furthest apart along, among the faces whose normal may be used; also the plain SAT maximum. */\nfunction bestFace(ref: Body, other: Body, refIsA: boolean, best: Best): number {\n let max = -Infinity;\n best.sep = -Infinity;\n best.face = -1;\n for (let i = 0; i < ref.corners; i++) {\n const s = faceSeparation(ref, i, other);\n if (s > max) max = s;\n const nx = refIsA ? ref.wnx[i]! : -ref.wnx[i]!;\n const ny = refIsA ? ref.wny[i]! : -ref.wny[i]!;\n const ok = refIsA ? normalAllowed(ref, other, nx, ny) : normalAllowed(other, ref, nx, ny);\n if (ok && s > best.sep) {\n best.sep = s;\n best.face = i;\n }\n }\n return max;\n}\n\nconst bestA: Best = { sep: 0, face: -1 };\nconst bestB: Best = { sep: 0, face: -1 };\nconst clipX = [0, 0];\nconst clipY = [0, 0];\nconst clipId = [0, 0];\n\n/**\n * Two convex shapes (boxes or polygons, turned or not) by the separating axis test, then the incident edge clipped\n * against the reference face's sides (Box2D's manifold), giving one or two points. A normal out of a merged tile box's\n * internal face is never used, so a turned crate slides over the seams of a tile floor like a square one does.\n */\nexport function polygonPolygon(a: Body, b: Body, margin: number, out: Manifold): boolean {\n const maxA = bestFace(a, b, true, bestA);\n if (maxA > margin) return false;\n const maxB = bestFace(b, a, false, bestB);\n if (maxB > margin) return false;\n let flip: boolean;\n if (bestA.face < 0 && bestB.face < 0) {\n // every axis is an internal face: fall back to the plain shallowest one, as the axis-aligned test does\n flip = maxB > maxA + FLIP_TOLERANCE;\n if (!flip) bestA.face = faceOfSeparation(a, b, maxA);\n else bestB.face = faceOfSeparation(b, a, maxB);\n } else if (bestA.face < 0) flip = true;\n else if (bestB.face < 0) flip = false;\n else flip = bestB.sep > bestA.sep + FLIP_TOLERANCE;\n const ref = flip ? b : a;\n const inc = flip ? a : b;\n const r = flip ? bestB.face : bestA.face;\n const nrx = ref.wnx[r]!;\n const nry = ref.wny[r]!;\n // the incident face: the one of the other body most against the reference normal\n let k = 0;\n let minDot = Infinity;\n for (let j = 0; j < inc.corners; j++) {\n const d = inc.wnx[j]! * nrx + inc.wny[j]! * nry;\n if (d < minDot) {\n minDot = d;\n k = j;\n }\n }\n const k2 = (k + 1) % inc.corners;\n clipX[0] = inc.wx[k]!;\n clipY[0] = inc.wy[k]!;\n clipId[0] = k;\n clipX[1] = inc.wx[k2]!;\n clipY[1] = inc.wy[k2]!;\n clipId[1] = k2;\n const r2 = (r + 1) % ref.corners;\n const r1x = ref.wx[r]!;\n const r1y = ref.wy[r]!;\n const r2x = ref.wx[r2]!;\n const r2y = ref.wy[r2]!;\n const tl = Math.hypot(r2x - r1x, r2y - r1y);\n const tx = (r2x - r1x) / tl;\n const ty = (r2y - r1y) / tl;\n // keep what lies between the reference face's two side planes\n if (!clip(-tx, -ty, -(tx * r1x + ty * r1y), 16)) return false;\n if (!clip(tx, ty, tx * r2x + ty * r2y, 17)) return false;\n out.nx = flip ? -nrx : nrx;\n out.ny = flip ? -nry : nry;\n out.count = 0;\n out.depth = -Infinity;\n for (let i = 0; i < 2; i++) {\n const sep = (clipX[i]! - r1x) * nrx + (clipY[i]! - r1y) * nry;\n if (sep > margin) continue;\n const n = out.count++;\n // halfway between the incident corner and the reference face\n out.px[n] = clipX[i]! - nrx * sep * 0.5;\n out.py[n] = clipY[i]! - nry * sep * 0.5;\n out.pd[n] = -sep;\n out.id[n] = ((flip ? 1 : 0) << 12) | (r << 6) | clipId[i]!;\n if (-sep > out.depth) out.depth = -sep;\n }\n return out.count > 0;\n}\n\n/** The first face of `ref` whose separation is `sep`. */\nfunction faceOfSeparation(ref: Body, other: Body, sep: number): number {\n for (let i = 0; i < ref.corners; i++) if (faceSeparation(ref, i, other) === sep) return i;\n return 0;\n}\n\n/** Clips the two points in `clipX/Y` to the half plane n·p ≤ offset; a cut point gets the feature id `cutId`. */\nfunction clip(nx: number, ny: number, offset: number, cutId: number): boolean {\n const d0 = nx * clipX[0]! + ny * clipY[0]! - offset;\n const d1 = nx * clipX[1]! + ny * clipY[1]! - offset;\n if (d0 > 0 && d1 > 0) return false;\n if (d0 <= 0 && d1 <= 0) return true;\n const t = d0 / (d0 - d1);\n const x = clipX[0]! + (clipX[1]! - clipX[0]!) * t;\n const y = clipY[0]! + (clipY[1]! - clipY[0]!) * t;\n if (d0 > 0) {\n clipX[0] = x;\n clipY[0] = y;\n clipId[0] = cutId;\n } else {\n clipX[1] = x;\n clipY[1] = y;\n clipId[1] = cutId;\n }\n return true;\n}\n\n/**\n * A circle against a box or polygon that is turned (or turns): the face the centre lies furthest out of, then that\n * face's middle or one of its corners. `circleIsA` says which way round the pair is, so the normal runs from a to b.\n */\nexport function circlePolygon(circle: Body, radius: number, poly: Body, margin: number, circleIsA: boolean, out: Manifold): boolean {\n const cx = circle.x;\n const cy = circle.y;\n let face = 0;\n let sep = -Infinity;\n for (let i = 0; i < poly.corners; i++) {\n const s = (cx - poly.wx[i]!) * poly.wnx[i]! + (cy - poly.wy[i]!) * poly.wny[i]!;\n if (s > sep) {\n sep = s;\n face = i;\n }\n }\n if (sep > radius + margin) return false;\n // normal from the polygon to the circle, and the distance from the polygon's surface to the circle's centre\n let nx = poly.wnx[face]!;\n let ny = poly.wny[face]!;\n let dist = sep;\n let id = face;\n if (sep > 0) {\n const f2 = (face + 1) % poly.corners;\n const v1x = poly.wx[face]!;\n const v1y = poly.wy[face]!;\n const v2x = poly.wx[f2]!;\n const v2y = poly.wy[f2]!;\n const u1 = (cx - v1x) * (v2x - v1x) + (cy - v1y) * (v2y - v1y);\n const u2 = (cx - v2x) * (v1x - v2x) + (cy - v2y) * (v1y - v2y);\n if (u1 <= 0 || u2 <= 0) {\n const vx = u1 <= 0 ? v1x : v2x;\n const vy = u1 <= 0 ? v1y : v2y;\n const d = Math.hypot(cx - vx, cy - vy);\n if (d > radius + margin) return false;\n if (d > 1e-9) {\n nx = (cx - vx) / d;\n ny = (cy - vy) / d;\n }\n dist = d;\n id = 32 + (u1 <= 0 ? face : f2);\n }\n }\n const depth = radius - dist;\n out.nx = circleIsA ? -nx : nx;\n out.ny = circleIsA ? -ny : ny;\n out.depth = depth;\n out.count = 1;\n out.px[0] = cx - nx * (radius - depth / 2);\n out.py[0] = cy - ny * (radius - depth / 2);\n out.pd[0] = depth;\n out.id[0] = id;\n return true;\n}\n"],"names":["BOX_FACE_BITS","FACE_TOP","FACE_RIGHT","FACE_BOTTOM","FACE_LEFT","FLIP_TOLERANCE","internalAlong","body","nx","ny","i","normalAllowed","a","b","faceSeparation","ref","other","vx","vy","min","j","d","bestFace","refIsA","best","max","bestA","bestB","clipX","clipY","clipId","polygonPolygon","margin","out","maxA","maxB","flip","faceOfSeparation","inc","r","nrx","nry","k","minDot","k2","r2","r1x","r1y","r2x","r2y","tl","tx","ty","clip","sep","n","offset","cutId","d0","d1","t","x","y","circlePolygon","circle","radius","poly","circleIsA","cx","cy","face","s","dist","id","f2","v1x","v1y","v2x","v2y","u1","u2","depth"],"mappings":";AAKA,MAAMA,IAAgB,CAACC,GAAUC,GAAYC,GAAaC,CAAS,GAG7DC,IAAiB;AAMvB,SAASC,EAAcC,GAAYC,GAAYC,GAAqB;AAClE,MAAI,CAACF,EAAK,iBAAiB,CAACA,EAAK,YAAa,QAAO;AACrD,WAASG,IAAI,GAAGA,IAAI,GAAGA;AACrB,QAAIH,EAAK,gBAAgBP,EAAcU,CAAC,KAAMH,EAAK,IAAIG,CAAC,IAAKF,IAAKD,EAAK,IAAIG,CAAC,IAAKD,IAAK,MAAO,QAAO;AAEtG,SAAO;AACT;AAGA,SAASE,EAAcC,GAASC,GAASL,GAAYC,GAAqB;AACxE,SAAO,CAACH,EAAcM,GAAGJ,GAAIC,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+ function u(n, e, r) {
2
+ if (n.grounded) return;
3
+ n.grounded = !0, n.ground = e;
4
+ const t = n === r.b ? 1 : -1;
5
+ n.groundNx = r.nx * t, n.groundNy = r.ny * t;
6
+ }
7
+ function o(n) {
8
+ return { a: n.a, b: n.b, nx: n.nx, ny: n.ny, depth: n.depth, sensor: n.sensor, points: n.points };
9
+ }
10
+ export {
11
+ o as info,
12
+ u as setGround
13
+ };
14
+ //# sourceMappingURL=contactReport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contactReport.js","sources":["../../src/physics/contactReport.ts"],"sourcesContent":["import type { Body } from './Body';\nimport type { Contact } from './Contact';\nimport type { ContactInfo } from './types';\n\n/** Marks `body` as standing on `ground` through contact `c`; the first ground found in a step wins. */\nexport function setGround(body: Body, ground: Body, c: Contact): void {\n if (body.grounded) return;\n body.grounded = true;\n body.ground = ground;\n const s = body === c.b ? 1 : -1;\n body.groundNx = c.nx * s;\n body.groundNy = c.ny * s;\n}\n\n/** A copy for an event: the contact itself changes on the next step. */\nexport function info(c: Contact): ContactInfo {\n return { a: c.a, b: c.b, nx: c.nx, ny: c.ny, depth: c.depth, sensor: c.sensor, points: c.points };\n}\n"],"names":["setGround","body","ground","c","s","info"],"mappings":"AAKO,SAASA,EAAUC,GAAYC,GAAcC,GAAkB;AACpE,MAAIF,EAAK,SAAU;AACnB,EAAAA,EAAK,WAAW,IAChBA,EAAK,SAASC;AACd,QAAME,IAAIH,MAASE,EAAE,IAAI,IAAI;AAC7B,EAAAF,EAAK,WAAWE,EAAE,KAAKC,GACvBH,EAAK,WAAWE,EAAE,KAAKC;AACzB;AAGO,SAASC,EAAKF,GAAyB;AAC5C,SAAO,EAAE,GAAGA,EAAE,GAAG,GAAGA,EAAE,GAAG,IAAIA,EAAE,IAAI,IAAIA,EAAE,IAAI,OAAOA,EAAE,OAAO,QAAQA,EAAE,QAAQ,QAAQA,EAAE,OAAA;AAC3F;"}
@@ -0,0 +1,31 @@
1
+ const a = {
2
+ static: 4259680,
3
+ kinematic: 4251903,
4
+ grounded: 16777056,
5
+ airborne: 16736352,
6
+ sleeping: 8421504,
7
+ sensor: 16736480
8
+ };
9
+ function m(e, n, c = {}, d, o) {
10
+ const u = { ...a, ...c };
11
+ for (const r of e.bodies) {
12
+ const s = d?.(r) ?? f(r, u);
13
+ if (o && r.corners > 0 && !r.axisAligned) {
14
+ for (let i = 0; i < r.corners; i++) {
15
+ const t = (i + 1) % r.corners;
16
+ o(r.wx[i], r.wy[i], r.wx[t], r.wy[t], s);
17
+ }
18
+ continue;
19
+ }
20
+ n(r.minX, r.minY, r.maxX - r.minX, r.maxY - r.minY, s), o && r.shape.kind === "circle" && r.rotates && o(r.x, r.y, r.x + r.cos * r.shape.radius, r.y + r.sin * r.shape.radius, s);
21
+ }
22
+ }
23
+ function f(e, n = a) {
24
+ return e.sensor ? n.sensor : e.type === "static" ? n.static : e.type === "kinematic" ? n.kinematic : e.awake ? e.grounded ? n.grounded : n.airborne : n.sleeping;
25
+ }
26
+ export {
27
+ a as COLLIDER_COLORS,
28
+ f as colliderColor,
29
+ m as drawColliders
30
+ };
31
+ //# sourceMappingURL=drawColliders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawColliders.js","sources":["../../src/physics/drawColliders.ts"],"sourcesContent":["import type { Body } from './Body';\nimport type { PhysicsWorld } from './PhysicsWorld';\n\n/** Colours `drawColliders` gives each kind of body. */\nexport interface ColliderColors {\n static: number;\n kinematic: number;\n /** A dynamic body standing on something. */\n grounded: number;\n /** A dynamic body in the air. */\n airborne: number;\n /** A dynamic body asleep (only with `allowSleep`). */\n sleeping: number;\n sensor: number;\n}\n\nexport const COLLIDER_COLORS: Readonly<ColliderColors> = {\n static: 0x40ff60,\n kinematic: 0x40e0ff,\n grounded: 0xffff60,\n airborne: 0xff6060,\n sleeping: 0x808080,\n sensor: 0xff60e0,\n};\n\n/**\n * Draws one box in world coordinates. The same shape as `DebugOverlay`'s `BoxDrawer`, written out here so the physics\n * module stays free of anything that draws.\n */\nexport type ColliderBoxDrawer = (x: number, y: number, width: number, height: number, color?: number) => void;\n\n/** Draws one line in world coordinates (`DebugOverlay`'s `LineDrawer`). */\nexport type ColliderLineDrawer = (x0: number, y0: number, x1: number, y1: number, color?: number) => void;\n\n/**\n * Draws every body's bounding box, coloured by what it is: the usual body of a `DebugOverlay`'s `colliders` callback,\n * which otherwise made every game keep a list of its own bodies just to show them.\n *\n * ```ts\n * new DebugOverlay(engine, { colliders: (draw) => drawColliders(physics, draw) });\n * ```\n *\n * `colorOf` picks a game's own colour for a body (a one-way plank, a hazard), or returns undefined for the default.\n * A circle is drawn as its bounding box: the overlay draws boxes, and a box round a circle still shows where it is.\n * Given `line` (the overlay hands it over as its second argument), a turned box or a polygon is drawn as its own\n * outline, and a circle that rotates gets a spoke showing its angle.\n *\n * ```ts\n * new DebugOverlay(engine, { colliders: (draw, line) => drawColliders(physics, draw, {}, undefined, line) });\n * ```\n */\nexport function drawColliders(\n world: PhysicsWorld,\n draw: ColliderBoxDrawer,\n colors: Partial<ColliderColors> = {},\n colorOf?: (body: Body) => number | undefined,\n line?: ColliderLineDrawer,\n): void {\n const c = { ...COLLIDER_COLORS, ...colors };\n for (const b of world.bodies) {\n const color = colorOf?.(b) ?? colliderColor(b, c);\n if (line && b.corners > 0 && !b.axisAligned) {\n for (let i = 0; i < b.corners; i++) {\n const j = (i + 1) % b.corners;\n line(b.wx[i]!, b.wy[i]!, b.wx[j]!, b.wy[j]!, color);\n }\n continue;\n }\n draw(b.minX, b.minY, b.maxX - b.minX, b.maxY - b.minY, color);\n if (line && b.shape.kind === 'circle' && b.rotates) line(b.x, b.y, b.x + b.cos * b.shape.radius, b.y + b.sin * b.shape.radius, color);\n }\n}\n\n/** The default colour of one body. */\nexport function colliderColor(b: Body, c: ColliderColors = COLLIDER_COLORS): number {\n if (b.sensor) return c.sensor;\n if (b.type === 'static') return c.static;\n if (b.type === 'kinematic') return c.kinematic;\n if (!b.awake) return c.sleeping;\n return b.grounded ? c.grounded : c.airborne;\n}\n"],"names":["COLLIDER_COLORS","drawColliders","world","draw","colors","colorOf","line","c","b","color","colliderColor","j"],"mappings":"AAgBO,MAAMA,IAA4C;AAAA,EACvD,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,QAAQ;AACV;AA4BO,SAASC,EACdC,GACAC,GACAC,IAAkC,CAAA,GAClCC,GACAC,GACM;AACN,QAAMC,IAAI,EAAE,GAAGP,GAAiB,GAAGI,EAAA;AACnC,aAAWI,KAAKN,EAAM,QAAQ;AAC5B,UAAMO,IAAQJ,IAAUG,CAAC,KAAKE,EAAcF,GAAGD,CAAC;AAChD,QAAID,KAAQE,EAAE,UAAU,KAAK,CAACA,EAAE,aAAa;AAC3C,eAAS,IAAI,GAAG,IAAIA,EAAE,SAAS,KAAK;AAClC,cAAMG,KAAK,IAAI,KAAKH,EAAE;AACtB,QAAAF,EAAKE,EAAE,GAAG,CAAC,GAAIA,EAAE,GAAG,CAAC,GAAIA,EAAE,GAAGG,CAAC,GAAIH,EAAE,GAAGG,CAAC,GAAIF,CAAK;AAAA,MACpD;AACA;AAAA,IACF;AACA,IAAAN,EAAKK,EAAE,MAAMA,EAAE,MAAMA,EAAE,OAAOA,EAAE,MAAMA,EAAE,OAAOA,EAAE,MAAMC,CAAK,GACxDH,KAAQE,EAAE,MAAM,SAAS,YAAYA,EAAE,WAASF,EAAKE,EAAE,GAAGA,EAAE,GAAGA,EAAE,IAAIA,EAAE,MAAMA,EAAE,MAAM,QAAQA,EAAE,IAAIA,EAAE,MAAMA,EAAE,MAAM,QAAQC,CAAK;AAAA,EACtI;AACF;AAGO,SAASC,EAAcF,GAASD,IAAoBP,GAAyB;AAClF,SAAIQ,EAAE,SAAeD,EAAE,SACnBC,EAAE,SAAS,WAAiBD,EAAE,SAC9BC,EAAE,SAAS,cAAoBD,EAAE,YAChCC,EAAE,QACAA,EAAE,WAAWD,EAAE,WAAWA,EAAE,WADdA,EAAE;AAEzB;"}
@@ -0,0 +1,8 @@
1
+ import { system as i } from "../ecs/World.js";
2
+ function r(s, t = "physics") {
3
+ return i(t, "fixed", ({ dt: e }) => s.step(e));
4
+ }
5
+ export {
6
+ r as physicsSystem
7
+ };
8
+ //# sourceMappingURL=physicsSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physicsSystem.js","sources":["../../src/physics/physicsSystem.ts"],"sourcesContent":["import { system, type System } from '../ecs/World';\nimport type { PhysicsWorld } from './PhysicsWorld';\n\n/** A `fixed` system that steps `physics` once per simulation step, by the loop's own dt. */\nexport function physicsSystem(physics: PhysicsWorld, name = 'physics'): System {\n return system(name, 'fixed', ({ dt }) => physics.step(dt));\n}\n"],"names":["physicsSystem","physics","name","system","dt"],"mappings":";AAIO,SAASA,EAAcC,GAAuBC,IAAO,WAAmB;AAC7E,SAAOC,EAAOD,GAAM,SAAS,CAAC,EAAE,IAAAE,QAASH,EAAQ,KAAKG,CAAE,CAAC;AAC3D;"}
@@ -0,0 +1,80 @@
1
+ const O = 16;
2
+ function M(s) {
3
+ let t = 0;
4
+ for (let n = 0; n < s.length; n++) {
5
+ const o = s[n], r = s[(n + 1) % s.length];
6
+ t += o.x * r.y - r.x * o.y;
7
+ }
8
+ return t;
9
+ }
10
+ function d(s) {
11
+ const t = E(s);
12
+ let n = 0, o = 0, r = 0;
13
+ for (let c = 0; c < t.length; c++) {
14
+ const e = t[c], l = t[(c + 1) % t.length], y = e.x * l.y - l.x * e.y;
15
+ r += y, n += (e.x + l.x) * y, o += (e.y + l.y) * y;
16
+ }
17
+ if (Math.abs(r) < 1e-9) throw new Error("polygonShape: the points enclose no area");
18
+ return { x: n / (3 * r), y: o / (3 * r) };
19
+ }
20
+ function m(s) {
21
+ const t = E(s);
22
+ if (t.length < 3) throw new Error("polygonShape: needs at least three points not on one line");
23
+ if (t.length > 16) throw new Error(`polygonShape: at most 16 corners, got ${t.length}`);
24
+ const n = d(t);
25
+ return { kind: "polygon", vertices: t.map((o) => ({ x: o.x - n.x, y: o.y - n.y })) };
26
+ }
27
+ function S(s, t) {
28
+ const n = Math.max(3, Math.min(16, Math.round(s))), o = [];
29
+ for (let r = 0; r < n; r++) {
30
+ const c = -Math.PI / 2 + r * 2 * Math.PI / n;
31
+ o.push({ x: Math.cos(c) * t, y: Math.sin(c) * t });
32
+ }
33
+ return m(o);
34
+ }
35
+ function E(s) {
36
+ const t = s.map((e) => ({ x: e.x, y: e.y })).sort((e, l) => e.x - l.x || e.y - l.y);
37
+ if (t.length < 3) return t;
38
+ const n = (e, l, y) => (l.x - e.x) * (y.y - e.y) - (l.y - e.y) * (y.x - e.x), o = [];
39
+ for (const e of t) {
40
+ for (; o.length >= 2 && n(o[o.length - 2], o[o.length - 1], e) <= 1e-9; ) o.pop();
41
+ o.push(e);
42
+ }
43
+ const r = [];
44
+ for (let e = t.length - 1; e >= 0; e--) {
45
+ const l = t[e];
46
+ for (; r.length >= 2 && n(r[r.length - 2], r[r.length - 1], l) <= 1e-9; ) r.pop();
47
+ r.push(l);
48
+ }
49
+ const c = o.slice(0, -1).concat(r.slice(0, -1));
50
+ return M(c) < 0 ? c.reverse() : c;
51
+ }
52
+ const w = /* @__PURE__ */ new WeakMap();
53
+ function _(s) {
54
+ let t = w.get(s);
55
+ if (t) return t;
56
+ const n = s.vertices;
57
+ if (n.length < 3 || n.length > 16) throw new Error(`Body: a polygon needs 3–16 corners, got ${n.length}`);
58
+ if (M(n) <= 0) throw new Error("Body: polygon corners must run clockwise on screen (make the shape with polygonShape)");
59
+ const o = [];
60
+ let r = 0, c = 0, e = 0, l = 1 / 0;
61
+ for (let y = 0; y < n.length; y++) {
62
+ const h = n[y], a = n[(y + 1) % n.length], p = a.x - h.x, g = a.y - h.y, x = Math.hypot(p, g);
63
+ if (x < 1e-9) throw new Error("Body: a polygon has two corners in one place");
64
+ const i = { x: g / x, y: -p / x };
65
+ o.push(i);
66
+ const u = n[(y + 2) % n.length];
67
+ if ((u.x - h.x) * i.x + (u.y - h.y) * i.y > 1e-6) throw new Error("Body: a polygon must be convex (make the shape with polygonShape)");
68
+ const f = h.x * a.y - a.x * h.y;
69
+ c += f / 2, r += f * (h.x * h.x + h.x * a.x + a.x * a.x + h.y * h.y + h.y * a.y + a.y * a.y) / 12, e = Math.max(e, Math.hypot(h.x, h.y)), l = Math.min(l, h.x * i.x + h.y * i.y);
70
+ }
71
+ return t = { vertices: n, normals: o, inertiaPerMass: r / c, radius: e, inradius: l }, w.set(s, t), t;
72
+ }
73
+ export {
74
+ O as MAX_POLYGON_VERTICES,
75
+ d as polygonCentroid,
76
+ _ as polygonData,
77
+ m as polygonShape,
78
+ S as regularPolygon
79
+ };
80
+ //# sourceMappingURL=polygon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polygon.js","sources":["../../src/physics/polygon.ts"],"sourcesContent":["import type { BoxShape, PolygonShape, Vec2 } from './types';\n\n/** The most corners a polygon shape may have. */\nexport const MAX_POLYGON_VERTICES = 16;\n\n/** Twice the signed area: positive when the points run clockwise on screen (y down), the order shapes are kept in. */\nfunction doubleArea(points: readonly Vec2[]): number {\n let a = 0;\n for (let i = 0; i < points.length; i++) {\n const p = points[i]!;\n const q = points[(i + 1) % points.length]!;\n a += p.x * q.y - q.x * p.y;\n }\n return a;\n}\n\n/** The centroid of the convex hull of `points`: where to put the body so a `polygonShape(points)` lands on them. */\nexport function polygonCentroid(points: readonly Vec2[]): Vec2 {\n const hull = convexHull(points);\n let cx = 0;\n let cy = 0;\n let a = 0;\n for (let i = 0; i < hull.length; i++) {\n const p = hull[i]!;\n const q = hull[(i + 1) % hull.length]!;\n const cross = p.x * q.y - q.x * p.y;\n a += cross;\n cx += (p.x + q.x) * cross;\n cy += (p.y + q.y) * cross;\n }\n if (Math.abs(a) < 1e-9) throw new Error('polygonShape: the points enclose no area');\n return { x: cx / (3 * a), y: cy / (3 * a) };\n}\n\n/**\n * A convex polygon shape from any points: their convex hull, in the order the solver keeps, moved so its centroid is\n * the body's position. Give points round the origin, or anywhere and place the body at `polygonCentroid(points)`.\n */\nexport function polygonShape(points: readonly Vec2[]): PolygonShape {\n const hull = convexHull(points);\n if (hull.length < 3) throw new Error('polygonShape: needs at least three points not on one line');\n if (hull.length > MAX_POLYGON_VERTICES) throw new Error(`polygonShape: at most ${MAX_POLYGON_VERTICES} corners, got ${hull.length}`);\n const c = polygonCentroid(hull);\n return { kind: 'polygon', vertices: hull.map((p) => ({ x: p.x - c.x, y: p.y - c.y })) };\n}\n\n/** A regular polygon of `sides` corners on a circle of `radius`, its first corner straight up. */\nexport function regularPolygon(sides: number, radius: number): PolygonShape {\n const n = Math.max(3, Math.min(MAX_POLYGON_VERTICES, Math.round(sides)));\n const points: Vec2[] = [];\n for (let i = 0; i < n; i++) {\n const t = -Math.PI / 2 + (i * 2 * Math.PI) / n;\n points.push({ x: Math.cos(t) * radius, y: Math.sin(t) * radius });\n }\n return polygonShape(points);\n}\n\n/** Andrew's monotone chain, returned clockwise on screen (positive `doubleArea`), collinear points dropped. */\nfunction convexHull(points: readonly Vec2[]): Vec2[] {\n const pts = points.map((p) => ({ x: p.x, y: p.y })).sort((a, b) => a.x - b.x || a.y - b.y);\n if (pts.length < 3) return pts;\n const cross = (o: Vec2, a: Vec2, b: Vec2) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);\n const lower: Vec2[] = [];\n for (const p of pts) {\n while (lower.length >= 2 && cross(lower[lower.length - 2]!, lower[lower.length - 1]!, p) <= 1e-9) lower.pop();\n lower.push(p);\n }\n const upper: Vec2[] = [];\n for (let i = pts.length - 1; i >= 0; i--) {\n const p = pts[i]!;\n while (upper.length >= 2 && cross(upper[upper.length - 2]!, upper[upper.length - 1]!, p) <= 1e-9) upper.pop();\n upper.push(p);\n }\n const hull = lower.slice(0, -1).concat(upper.slice(0, -1));\n return doubleArea(hull) < 0 ? hull.reverse() : hull;\n}\n\n/** Local outward normals and the solver's mass terms of a polygon, worked out once per shape object. */\nexport interface PolygonData {\n readonly vertices: readonly Vec2[];\n readonly normals: readonly Vec2[];\n /** Second moment of area about the centroid per unit of area-mass: inertia = mass × this. */\n readonly inertiaPerMass: number;\n /** The furthest corner from the centre. */\n readonly radius: number;\n /** The nearest face to the centre: how far the body may move in one sub-step without passing through anything. */\n readonly inradius: number;\n}\n\nconst cache = new WeakMap<PolygonShape, PolygonData>();\n\n/** The data of a polygon shape, checked (convex, in order) the first time it is asked for. */\nexport function polygonData(shape: PolygonShape): PolygonData {\n let d = cache.get(shape);\n if (d) return d;\n const v = shape.vertices;\n if (v.length < 3 || v.length > MAX_POLYGON_VERTICES) throw new Error(`Body: a polygon needs 3–${MAX_POLYGON_VERTICES} corners, got ${v.length}`);\n if (doubleArea(v) <= 0) throw new Error('Body: polygon corners must run clockwise on screen (make the shape with polygonShape)');\n const normals: Vec2[] = [];\n let inertia = 0;\n let area = 0;\n let radius = 0;\n let inradius = Infinity;\n for (let i = 0; i < v.length; i++) {\n const p = v[i]!;\n const q = v[(i + 1) % v.length]!;\n const ex = q.x - p.x;\n const ey = q.y - p.y;\n const len = Math.hypot(ex, ey);\n if (len < 1e-9) throw new Error('Body: a polygon has two corners in one place');\n const n = { x: ey / len, y: -ex / len };\n normals.push(n);\n const r = v[(i + 2) % v.length]!;\n if ((r.x - p.x) * n.x + (r.y - p.y) * n.y > 1e-6) throw new Error('Body: a polygon must be convex (make the shape with polygonShape)');\n const cross = p.x * q.y - q.x * p.y;\n area += cross / 2;\n inertia += (cross * (p.x * p.x + p.x * q.x + q.x * q.x + p.y * p.y + p.y * q.y + q.y * q.y)) / 12;\n radius = Math.max(radius, Math.hypot(p.x, p.y));\n inradius = Math.min(inradius, p.x * n.x + p.y * n.y);\n }\n d = { vertices: v, normals, inertiaPerMass: inertia / area, radius, inradius };\n cache.set(shape, d);\n return d;\n}\n\n/** A box as the four corners the polygon tests use: top-left first, clockwise on screen, so face i is top, right, bottom, left. */\nexport function boxCorners(s: BoxShape): Vec2[] {\n return [\n { x: -s.halfWidth, y: -s.halfHeight },\n { x: s.halfWidth, y: -s.halfHeight },\n { x: s.halfWidth, y: s.halfHeight },\n { x: -s.halfWidth, y: s.halfHeight },\n ];\n}\n"],"names":["MAX_POLYGON_VERTICES","doubleArea","points","a","i","p","q","polygonCentroid","hull","convexHull","cx","cy","cross","polygonShape","c","regularPolygon","sides","radius","t","pts","b","o","lower","upper","cache","polygonData","shape","d","v","normals","inertia","area","inradius","ex","ey","len","n","r"],"mappings":"AAGO,MAAMA,IAAuB;AAGpC,SAASC,EAAWC,GAAiC;AACnD,MAAIC,IAAI;AACR,WAASC,IAAI,GAAGA,IAAIF,EAAO,QAAQE,KAAK;AACtC,UAAMC,IAAIH,EAAOE,CAAC,GACZE,IAAIJ,GAAQE,IAAI,KAAKF,EAAO,MAAM;AACxC,IAAAC,KAAKE,EAAE,IAAIC,EAAE,IAAIA,EAAE,IAAID,EAAE;AAAA,EAC3B;AACA,SAAOF;AACT;AAGO,SAASI,EAAgBL,GAA+B;AAC7D,QAAMM,IAAOC,EAAWP,CAAM;AAC9B,MAAIQ,IAAK,GACLC,IAAK,GACLR,IAAI;AACR,WAASC,IAAI,GAAGA,IAAII,EAAK,QAAQJ,KAAK;AACpC,UAAMC,IAAIG,EAAKJ,CAAC,GACVE,IAAIE,GAAMJ,IAAI,KAAKI,EAAK,MAAM,GAC9BI,IAAQP,EAAE,IAAIC,EAAE,IAAIA,EAAE,IAAID,EAAE;AAClC,IAAAF,KAAKS,GACLF,MAAOL,EAAE,IAAIC,EAAE,KAAKM,GACpBD,MAAON,EAAE,IAAIC,EAAE,KAAKM;AAAA,EACtB;AACA,MAAI,KAAK,IAAIT,CAAC,IAAI,KAAM,OAAM,IAAI,MAAM,0CAA0C;AAClF,SAAO,EAAE,GAAGO,KAAM,IAAIP,IAAI,GAAGQ,KAAM,IAAIR,GAAA;AACzC;AAMO,SAASU,EAAaX,GAAuC;AAClE,QAAMM,IAAOC,EAAWP,CAAM;AAC9B,MAAIM,EAAK,SAAS,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M,8CAA8C;AAC9E,UAAMC,IAAI,EAAE,GAAGF,IAAKC,GAAK,GAAG,CAACF,IAAKE,EAAA;AAClC,IAAAN,EAAQ,KAAKO,CAAC;AACd,UAAMC,IAAIT,GAAGxB,IAAI,KAAKwB,EAAE,MAAM;AAC9B,SAAKS,EAAE,IAAIhC,EAAE,KAAK+B,EAAE,KAAKC,EAAE,IAAIhC,EAAE,KAAK+B,EAAE,IAAI,KAAM,OAAM,IAAI,MAAM,mEAAmE;AACrI,UAAMxB,IAAQP,EAAE,IAAIC,EAAE,IAAIA,EAAE,IAAID,EAAE;AAClC,IAAA0B,KAAQnB,IAAQ,GAChBkB,KAAYlB,KAASP,EAAE,IAAIA,EAAE,IAAIA,EAAE,IAAIC,EAAE,IAAIA,EAAE,IAAIA,EAAE,IAAID,EAAE,IAAIA,EAAE,IAAIA,EAAE,IAAIC,EAAE,IAAIA,EAAE,IAAIA,EAAE,KAAM,IAC/FW,IAAS,KAAK,IAAIA,GAAQ,KAAK,MAAMZ,EAAE,GAAGA,EAAE,CAAC,CAAC,GAC9C2B,IAAW,KAAK,IAAIA,GAAU3B,EAAE,IAAI+B,EAAE,IAAI/B,EAAE,IAAI+B,EAAE,CAAC;AAAA,EACrD;AACA,SAAAT,IAAI,EAAE,UAAUC,GAAG,SAAAC,GAAS,gBAAgBC,IAAUC,GAAM,QAAAd,GAAQ,UAAAe,EAAA,GACpER,EAAM,IAAIE,GAAOC,CAAC,GACXA;AACT;"}
@@ -0,0 +1,62 @@
1
+ const p = { t: 0, nx: 0, ny: 0 };
2
+ function L(t, r, a, u, m, x, i) {
3
+ const o = t.shape;
4
+ if (o.kind === "circle") {
5
+ const n = r - t.x, e = a - t.y, l = u * u + m * m, X = n * n + e * e - o.radius * o.radius;
6
+ if (X <= 0 || l === 0) return !1;
7
+ const M = n * u + e * m, Y = M * M - l * X;
8
+ if (Y < 0 || M > 0) return !1;
9
+ const w = (-M - Math.sqrt(Y)) / l;
10
+ return w < 0 || w > x ? !1 : (i.t = w, i.nx = (n + u * w) / o.radius, i.ny = (e + m * w) / o.radius, !0);
11
+ }
12
+ if (!t.axisAligned) return P(t, r, a, u, m, x, i);
13
+ if (r > t.minX && r < t.maxX && a > t.minY && a < t.maxY) return !1;
14
+ let c = -1 / 0, s = 1 / 0, h = 0, f = 0;
15
+ if (u !== 0) {
16
+ const n = (t.minX - r) / u, e = (t.maxX - r) / u, l = Math.min(n, e);
17
+ l > c && (c = l, h = u > 0 ? -1 : 1, f = 0), s = Math.min(s, Math.max(n, e));
18
+ } else if (r < t.minX || r > t.maxX) return !1;
19
+ if (m !== 0) {
20
+ const n = (t.minY - a) / m, e = (t.maxY - a) / m, l = Math.min(n, e);
21
+ l > c && (c = l, h = 0, f = m > 0 ? -1 : 1), s = Math.min(s, Math.max(n, e));
22
+ } else if (a < t.minY || a > t.maxY) return !1;
23
+ return c > s || c < 0 || c > x ? !1 : (i.t = c, i.nx = h, i.ny = f, !0);
24
+ }
25
+ function P(t, r, a, u, m, x, i) {
26
+ let o = 0, c = x, s = -1, h = !0;
27
+ for (let f = 0; f < t.corners; f++) {
28
+ const n = t.wnx[f], e = t.wny[f], l = (r - t.wx[f]) * n + (a - t.wy[f]) * e, X = u * n + m * e;
29
+ if (l > 0 && (h = !1), X === 0) {
30
+ if (l > 0) return !1;
31
+ continue;
32
+ }
33
+ const M = -l / X;
34
+ if (X < 0 ? M > o && (o = M, s = f) : M < c && (c = M), o > c) return !1;
35
+ }
36
+ return h || s < 0 ? !1 : (i.t = o, i.nx = t.wnx[s], i.ny = t.wny[s], !0);
37
+ }
38
+ let R = 0;
39
+ function v(t, r, a, u, m, x = {}) {
40
+ const i = t[0];
41
+ if (!i) return null;
42
+ const o = x.mask ?? 4294967295, c = ++R, s = u - r, h = m - a, f = i.cellSize;
43
+ let n = i.cellOf(r), e = i.cellOf(a);
44
+ const l = i.cellOf(u), X = i.cellOf(m), M = s > 0 ? 1 : s < 0 ? -1 : 0, Y = h > 0 ? 1 : h < 0 ? -1 : 0, w = M !== 0 ? f / Math.abs(s) : 1 / 0, q = Y !== 0 ? f / Math.abs(h) : 1 / 0;
45
+ let O = M > 0 ? ((n + 1) * f - r) / s : M < 0 ? (n * f - r) / s : 1 / 0, g = Y > 0 ? ((e + 1) * f - a) / h : Y < 0 ? (e * f - a) / h : 1 / 0, S = null, I = 1, z = 0, D = 0, A = Math.abs(l - n) + Math.abs(X - e) + 1;
46
+ for (; ; ) {
47
+ for (const C of t) {
48
+ const N = C.at(n, e);
49
+ if (N)
50
+ for (const k of N)
51
+ k.rayStamp !== c && (k.rayStamp = c, k.layer & o && (k.sensor && !x.includeSensors || x.filter && !x.filter(k) || L(k, r, a, s, h, I, p) && (!S || p.t < I) && (S = k, I = p.t, z = p.nx, D = p.ny)));
52
+ }
53
+ if (--A <= 0 || Math.min(O, g) > I) break;
54
+ O < g ? (n += M, O += w) : (e += Y, g += q);
55
+ }
56
+ return S ? { body: S, x: r + s * I, y: a + h * I, nx: z, ny: D, fraction: I } : null;
57
+ }
58
+ export {
59
+ v as castRay,
60
+ L as rayShape
61
+ };
62
+ //# sourceMappingURL=raycast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raycast.js","sources":["../../src/physics/raycast.ts"],"sourcesContent":["import type { Body } from './Body';\nimport type { SpatialHash } from './SpatialHash';\nimport type { RayHit, RaycastOptions } from './types';\n\n/** Where a ray from (ox, oy) along (dx, dy) — not normalised, t = 1 at its end — first enters a body. */\ninterface ShapeHit {\n t: number;\n nx: number;\n ny: number;\n}\n\nconst scratch: ShapeHit = { t: 0, nx: 0, ny: 0 };\n\n/** A ray starting inside the shape misses it, so a body can cast from its own centre without hitting itself. */\nexport function rayShape(body: Body, ox: number, oy: number, dx: number, dy: number, maxT: number, out: ShapeHit): boolean {\n const s = body.shape;\n if (s.kind === 'circle') {\n const fx = ox - body.x;\n const fy = oy - body.y;\n const a = dx * dx + dy * dy;\n const c = fx * fx + fy * fy - s.radius * s.radius;\n if (c <= 0 || a === 0) return false;\n const b = fx * dx + fy * dy;\n const disc = b * b - a * c;\n if (disc < 0 || b > 0) return false;\n const t = (-b - Math.sqrt(disc)) / a;\n if (t < 0 || t > maxT) return false;\n out.t = t;\n out.nx = (fx + dx * t) / s.radius;\n out.ny = (fy + dy * t) / s.radius;\n return true;\n }\n if (!body.axisAligned) return rayPolygon(body, ox, oy, dx, dy, maxT, out);\n if (ox > body.minX && ox < body.maxX && oy > body.minY && oy < body.maxY) return false;\n let tmin = -Infinity;\n let tmax = Infinity;\n let nx = 0;\n let ny = 0;\n if (dx !== 0) {\n const t1 = (body.minX - ox) / dx;\n const t2 = (body.maxX - ox) / dx;\n const near = Math.min(t1, t2);\n if (near > tmin) {\n tmin = near;\n nx = dx > 0 ? -1 : 1;\n ny = 0;\n }\n tmax = Math.min(tmax, Math.max(t1, t2));\n } else if (ox < body.minX || ox > body.maxX) return false;\n if (dy !== 0) {\n const t1 = (body.minY - oy) / dy;\n const t2 = (body.maxY - oy) / dy;\n const near = Math.min(t1, t2);\n if (near > tmin) {\n tmin = near;\n nx = 0;\n ny = dy > 0 ? -1 : 1;\n }\n tmax = Math.min(tmax, Math.max(t1, t2));\n } else if (oy < body.minY || oy > body.maxY) return false;\n if (tmin > tmax || tmin < 0 || tmin > maxT) return false;\n out.t = tmin;\n out.nx = nx;\n out.ny = ny;\n return true;\n}\n\n/** Cyrus–Beck: the ray clipped by each face's half plane of a turned box or a polygon (world corners). */\nfunction rayPolygon(body: Body, ox: number, oy: number, dx: number, dy: number, maxT: number, out: ShapeHit): boolean {\n let tmin = 0;\n let tmax = maxT;\n let face = -1;\n let inside = true;\n for (let i = 0; i < body.corners; i++) {\n const nx = body.wnx[i]!;\n const ny = body.wny[i]!;\n // distance of the start outside face i, and how fast the ray closes on it\n const num = (ox - body.wx[i]!) * nx + (oy - body.wy[i]!) * ny;\n const den = dx * nx + dy * ny;\n if (num > 0) inside = false;\n if (den === 0) {\n if (num > 0) return false;\n continue;\n }\n const t = -num / den;\n if (den < 0) {\n if (t > tmin) {\n tmin = t;\n face = i;\n }\n } else if (t < tmax) tmax = t;\n if (tmin > tmax) return false;\n }\n if (inside || face < 0) return false;\n out.t = tmin;\n out.nx = body.wnx[face]!;\n out.ny = body.wny[face]!;\n return true;\n}\n\nlet rayCounter = 0;\n\n/**\n * The first body a segment from (x0, y0) to (x1, y1) meets, walking the broad phase's cells in the ray's order\n * (Amanatides–Woo) and stopping once the next cell lies beyond the best hit so far; a long ray over a large map\n * looks only at the cells it crosses.\n */\nexport function castRay(hashes: readonly SpatialHash[], x0: number, y0: number, x1: number, y1: number, options: RaycastOptions = {}): RayHit | null {\n const grid = hashes[0];\n if (!grid) return null;\n const mask = options.mask ?? 0xffffffff;\n const stamp = ++rayCounter;\n const dx = x1 - x0;\n const dy = y1 - y0;\n const size = grid.cellSize;\n let cx = grid.cellOf(x0);\n let cy = grid.cellOf(y0);\n const ex = grid.cellOf(x1);\n const ey = grid.cellOf(y1);\n const stepX = dx > 0 ? 1 : dx < 0 ? -1 : 0;\n const stepY = dy > 0 ? 1 : dy < 0 ? -1 : 0;\n const tDeltaX = stepX !== 0 ? size / Math.abs(dx) : Infinity;\n const tDeltaY = stepY !== 0 ? size / Math.abs(dy) : Infinity;\n let tMaxX = stepX > 0 ? ((cx + 1) * size - x0) / dx : stepX < 0 ? (cx * size - x0) / dx : Infinity;\n let tMaxY = stepY > 0 ? ((cy + 1) * size - y0) / dy : stepY < 0 ? (cy * size - y0) / dy : Infinity;\n let best: Body | null = null;\n let bestT = 1;\n let bestNx = 0;\n let bestNy = 0;\n // the cell count bounds the walk even if rounding ever kept it from landing on the end cell exactly\n let cellsLeft = Math.abs(ex - cx) + Math.abs(ey - cy) + 1;\n for (;;) {\n for (const hash of hashes) {\n const list = hash.at(cx, cy);\n if (!list) continue;\n for (const body of list) {\n if (body.rayStamp === stamp) continue;\n body.rayStamp = stamp;\n if (!(body.layer & mask)) continue;\n if (body.sensor && !options.includeSensors) continue;\n if (options.filter && !options.filter(body)) continue;\n if (rayShape(body, x0, y0, dx, dy, bestT, scratch) && (!best || scratch.t < bestT)) {\n best = body;\n bestT = scratch.t;\n bestNx = scratch.nx;\n bestNy = scratch.ny;\n }\n }\n }\n if (--cellsLeft <= 0) break;\n const next = Math.min(tMaxX, tMaxY);\n if (next > bestT) break;\n if (tMaxX < tMaxY) {\n cx += stepX;\n tMaxX += tDeltaX;\n } else {\n cy += stepY;\n tMaxY += tDeltaY;\n }\n }\n if (!best) return null;\n return { body: best, x: x0 + dx * bestT, y: y0 + dy * bestT, nx: bestNx, ny: bestNy, fraction: bestT };\n}\n"],"names":["scratch","rayShape","body","ox","oy","dx","dy","maxT","out","s","fx","fy","a","c","b","disc","t","rayPolygon","tmin","tmax","nx","ny","t1","t2","near","face","inside","i","num","den","rayCounter","castRay","hashes","x0","y0","x1","y1","options","grid","mask","stamp","size","cx","cy","ex","ey","stepX","stepY","tDeltaX","tDeltaY","tMaxX","tMaxY","best","bestT","bestNx","bestNy","cellsLeft","hash","list"],"mappings":"AAWA,MAAMA,IAAoB,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,EAAA;AAGtC,SAASC,EAASC,GAAYC,GAAYC,GAAYC,GAAYC,GAAYC,GAAcC,GAAwB;AACzH,QAAMC,IAAIP,EAAK;AACf,MAAIO,EAAE,SAAS,UAAU;AACvB,UAAMC,IAAKP,IAAKD,EAAK,GACfS,IAAKP,IAAKF,EAAK,GACfU,IAAIP,IAAKA,IAAKC,IAAKA,GACnBO,IAAIH,IAAKA,IAAKC,IAAKA,IAAKF,EAAE,SAASA,EAAE;AAC3C,QAAII,KAAK,KAAKD,MAAM,EAAG,QAAO;AAC9B,UAAME,IAAIJ,IAAKL,IAAKM,IAAKL,GACnBS,IAAOD,IAAIA,IAAIF,IAAIC;AACzB,QAAIE,IAAO,KAAKD,IAAI,EAAG,QAAO;AAC9B,UAAME,KAAK,CAACF,IAAI,KAAK,KAAKC,CAAI,KAAKH;AACnC,WAAII,IAAI,KAAKA,IAAIT,IAAa,MAC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GAAM,GAAGnB,IAAK5B,IAAKgD,GAAO,GAAGnB,IAAK5B,IAAK+C,GAAO,IAAIC,GAAQ,IAAIC,GAAQ,UAAUF,EAAA,IAD7E;AAEpB;"}
@@ -0,0 +1,19 @@
1
+ function s(l, n, c, a = 0, e = 0, g = !1) {
2
+ let r = n.prevX + (n.x - n.prevX) * c, M = n.prevY + (n.y - n.prevY) * c;
3
+ if (n.rotates || n.angle !== 0) {
4
+ let t = n.angle - n.prevAngle;
5
+ (t > Math.PI || t < -Math.PI) && (t -= Math.round(t / (2 * Math.PI)) * 2 * Math.PI);
6
+ const h = n.prevAngle + t * c;
7
+ if (a !== 0 || e !== 0) {
8
+ const p = Math.cos(h), i = Math.sin(h);
9
+ r += p * a - i * e, M += i * a + p * e;
10
+ }
11
+ l.rotation = h;
12
+ } else
13
+ r += a, M += e;
14
+ l.x = g ? Math.round(r) : r, l.y = g ? Math.round(M) : M;
15
+ }
16
+ export {
17
+ s as syncToBody
18
+ };
19
+ //# sourceMappingURL=syncToBody.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syncToBody.js","sources":["../../src/physics/syncToBody.ts"],"sourcesContent":["import type { Body } from './Body';\n\n/** Anything with a settable position: a Pixi container, a sprite, a plain object. */\nexport interface Positioned {\n x: number;\n y: number;\n /** Set to the body's angle when the body rotates or stands at an angle; left alone otherwise. */\n rotation?: number;\n}\n\n/**\n * Places `view` where `body` is drawn this frame: between its last two step positions by the loop's `alpha`\n * (`SystemContext.alpha` in a `frame` system), so motion is smooth at any refresh rate even though physics steps\n * at a fixed rate. Pass `round` for pixel art, so the view lands on whole pixels. A body that rotates (or was placed\n * at an angle) turns the view too, by the shorter way between its last two angles; the offset is turned with it.\n */\nexport function syncToBody(view: Positioned, body: Body, alpha: number, offsetX = 0, offsetY = 0, round = false): void {\n let x = body.prevX + (body.x - body.prevX) * alpha;\n let y = body.prevY + (body.y - body.prevY) * alpha;\n if (body.rotates || body.angle !== 0) {\n let d = body.angle - body.prevAngle;\n if (d > Math.PI || d < -Math.PI) d -= Math.round(d / (2 * Math.PI)) * 2 * Math.PI;\n const angle = body.prevAngle + d * alpha;\n if (offsetX !== 0 || offsetY !== 0) {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n x += c * offsetX - s * offsetY;\n y += s * offsetX + c * offsetY;\n }\n view.rotation = angle;\n } else {\n x += offsetX;\n y += offsetY;\n }\n view.x = round ? Math.round(x) : x;\n view.y = round ? Math.round(y) : y;\n}\n"],"names":["syncToBody","view","body","alpha","offsetX","offsetY","round","x","y","d","angle","c","s"],"mappings":"AAgBO,SAASA,EAAWC,GAAkBC,GAAYC,GAAeC,IAAU,GAAGC,IAAU,GAAGC,IAAQ,IAAa;AACrH,MAAIC,IAAIL,EAAK,SAASA,EAAK,IAAIA,EAAK,SAASC,GACzCK,IAAIN,EAAK,SAASA,EAAK,IAAIA,EAAK,SAASC;AAC7C,MAAID,EAAK,WAAWA,EAAK,UAAU,GAAG;AACpC,QAAIO,IAAIP,EAAK,QAAQA,EAAK;AAC1B,KAAIO,IAAI,KAAK,MAAMA,IAAI,CAAC,KAAK,QAAIA,KAAK,KAAK,MAAMA,KAAK,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK;AAC/E,UAAMC,IAAQR,EAAK,YAAYO,IAAIN;AACnC,QAAIC,MAAY,KAAKC,MAAY,GAAG;AAClC,YAAMM,IAAI,KAAK,IAAID,CAAK,GAClBE,IAAI,KAAK,IAAIF,CAAK;AACxB,MAAAH,KAAKI,IAAIP,IAAUQ,IAAIP,GACvBG,KAAKI,IAAIR,IAAUO,IAAIN;AAAA,IACzB;AACA,IAAAJ,EAAK,WAAWS;AAAA,EAClB;AACE,IAAAH,KAAKH,GACLI,KAAKH;AAEP,EAAAJ,EAAK,IAAIK,IAAQ,KAAK,MAAMC,CAAC,IAAIA,GACjCN,EAAK,IAAIK,IAAQ,KAAK,MAAME,CAAC,IAAIA;AACnC;"}
@@ -0,0 +1,59 @@
1
+ import { Body as m } from "./Body.js";
2
+ import { FACE_TOP as d, FACE_BOTTOM as w, FACE_LEFT as F, FACE_RIGHT as T } from "./types.js";
3
+ function p(n, f, i) {
4
+ const s = [];
5
+ let t = /* @__PURE__ */ new Map();
6
+ for (let o = 0; o < f; o++) {
7
+ const l = /* @__PURE__ */ new Map();
8
+ let c = 0;
9
+ for (; c < n; ) {
10
+ if (!i(c, o)) {
11
+ c++;
12
+ continue;
13
+ }
14
+ const e = c;
15
+ for (; c < n && i(c, o); ) c++;
16
+ const u = c - 1, r = e * 1048576 + u, a = t.get(r);
17
+ a ? (a.y1 = o, t.delete(r), l.set(r, a)) : l.set(r, { x0: e, y0: o, x1: u, y1: o });
18
+ }
19
+ for (const e of t.values()) s.push(e);
20
+ t = l;
21
+ }
22
+ for (const o of t.values()) s.push(o);
23
+ return s;
24
+ }
25
+ function E(n, f, i, s, t = {}) {
26
+ const o = (e, u) => e >= 0 && u >= 0 && e < n && u < f && s(e, u), l = t.originX ?? 0, c = t.originY ?? 0;
27
+ return p(n, f, o).map((e) => {
28
+ const u = (e.x1 - e.x0 + 1) * i, r = (e.y1 - e.y0 + 1) * i, a = new m({
29
+ type: "static",
30
+ shape: { kind: "box", halfWidth: u / 2, halfHeight: r / 2 },
31
+ x: l + e.x0 * i + u / 2,
32
+ y: c + e.y0 * i + r / 2,
33
+ friction: t.friction,
34
+ restitution: t.restitution,
35
+ layer: t.layer,
36
+ mask: t.mask,
37
+ userData: t.userData
38
+ });
39
+ let y = 0;
40
+ return x(o, e.x0, e.x1, e.y0 - 1) && (y |= d), x(o, e.x0, e.x1, e.y1 + 1) && (y |= w), h(o, e.x0 - 1, e.y0, e.y1) && (y |= F), h(o, e.x1 + 1, e.y0, e.y1) && (y |= T), a.internalFaces = y, a;
41
+ });
42
+ }
43
+ function B(n, f = {}) {
44
+ return E(n.width, n.height, n.tileSize, (i, s) => n.solid[s * n.width + i] === 1, f);
45
+ }
46
+ function x(n, f, i, s) {
47
+ for (let t = f; t <= i; t++) if (!n(t, s)) return !1;
48
+ return !0;
49
+ }
50
+ function h(n, f, i, s) {
51
+ for (let t = i; t <= s; t++) if (!n(f, t)) return !1;
52
+ return !0;
53
+ }
54
+ export {
55
+ p as mergeTileRects,
56
+ E as tileBodies,
57
+ B as tileBodiesFromGrid
58
+ };
59
+ //# sourceMappingURL=tileBodies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tileBodies.js","sources":["../../src/physics/tileBodies.ts"],"sourcesContent":["import type { CollisionGrid } from '../net/movement';\nimport { Body } from './Body';\nimport { FACE_BOTTOM, FACE_LEFT, FACE_RIGHT, FACE_TOP } from './types';\n\nexport interface TileBodiesOptions {\n /** World position of tile (0, 0)'s top-left corner (default 0, 0). */\n originX?: number;\n originY?: number;\n friction?: number;\n restitution?: number;\n layer?: number;\n mask?: number;\n userData?: unknown;\n}\n\n/** A rectangle of solid tiles, in tiles, both ends inclusive. */\nexport interface TileRect {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n}\n\n/**\n * Covers the solid cells of a tile grid with as few rectangles as a cheap greedy pass finds: runs along each row,\n * then a run is grown downwards while the row below has exactly the same run. A floor becomes one box and a wall\n * one tall box, so a body sliding along either crosses no seam to snag on.\n */\nexport function mergeTileRects(width: number, height: number, solid: (tx: number, ty: number) => boolean): TileRect[] {\n const done: TileRect[] = [];\n /** Rectangles still growing, by the run they end in (\"x0,x1\"). */\n let open = new Map<number, TileRect>();\n for (let ty = 0; ty < height; ty++) {\n const next = new Map<number, TileRect>();\n let tx = 0;\n while (tx < width) {\n if (!solid(tx, ty)) {\n tx++;\n continue;\n }\n const x0 = tx;\n while (tx < width && solid(tx, ty)) tx++;\n const x1 = tx - 1;\n const key = x0 * 0x100000 + x1;\n const above = open.get(key);\n if (above) {\n above.y1 = ty;\n open.delete(key);\n next.set(key, above);\n } else next.set(key, { x0, y0: ty, x1, y1: ty });\n }\n for (const r of open.values()) done.push(r);\n open = next;\n }\n for (const r of open.values()) done.push(r);\n return done;\n}\n\n/**\n * Static boxes for the solid tiles of a grid, ready for `PhysicsWorld.add`. Each box marks the faces that lie\n * wholly against more solid tiles as internal, so a body is never pushed out through a face that is inside the\n * ground (the seam between a floor and the wall standing on it).\n *\n * Outside the grid counts as open, so the edges of the map collide like any other face.\n */\nexport function tileBodies(width: number, height: number, tileSize: number, solid: (tx: number, ty: number) => boolean, options: TileBodiesOptions = {}): Body[] {\n const inside = (tx: number, ty: number): boolean => tx >= 0 && ty >= 0 && tx < width && ty < height && solid(tx, ty);\n const ox = options.originX ?? 0;\n const oy = options.originY ?? 0;\n return mergeTileRects(width, height, inside).map((r) => {\n const w = (r.x1 - r.x0 + 1) * tileSize;\n const h = (r.y1 - r.y0 + 1) * tileSize;\n const body = new Body({\n type: 'static',\n shape: { kind: 'box', halfWidth: w / 2, halfHeight: h / 2 },\n x: ox + r.x0 * tileSize + w / 2,\n y: oy + r.y0 * tileSize + h / 2,\n friction: options.friction,\n restitution: options.restitution,\n layer: options.layer,\n mask: options.mask,\n userData: options.userData,\n });\n let faces = 0;\n if (rowSolid(inside, r.x0, r.x1, r.y0 - 1)) faces |= FACE_TOP;\n if (rowSolid(inside, r.x0, r.x1, r.y1 + 1)) faces |= FACE_BOTTOM;\n if (columnSolid(inside, r.x0 - 1, r.y0, r.y1)) faces |= FACE_LEFT;\n if (columnSolid(inside, r.x1 + 1, r.y0, r.y1)) faces |= FACE_RIGHT;\n body.internalFaces = faces;\n return body;\n });\n}\n\n/** `tileBodies` for the engine's `CollisionGrid` (from `createCollisionGrid` or a Tiled map's `collisionFromTiled`). */\nexport function tileBodiesFromGrid(grid: CollisionGrid, options: TileBodiesOptions = {}): Body[] {\n return tileBodies(grid.width, grid.height, grid.tileSize, (tx, ty) => grid.solid[ty * grid.width + tx] === 1, options);\n}\n\nfunction rowSolid(solid: (tx: number, ty: number) => boolean, x0: number, x1: number, ty: number): boolean {\n for (let tx = x0; tx <= x1; tx++) if (!solid(tx, ty)) return false;\n return true;\n}\n\nfunction columnSolid(solid: (tx: number, ty: number) => boolean, tx: number, y0: number, y1: number): boolean {\n for (let ty = y0; ty <= y1; ty++) if (!solid(tx, ty)) return false;\n return true;\n}\n"],"names":["mergeTileRects","width","height","solid","done","open","ty","next","tx","x0","x1","key","above","r","tileBodies","tileSize","options","inside","ox","oy","w","h","body","Body","faces","rowSolid","FACE_TOP","FACE_BOTTOM","columnSolid","FACE_LEFT","FACE_RIGHT","tileBodiesFromGrid","grid","y0","y1"],"mappings":";;AA4BO,SAASA,EAAeC,GAAeC,GAAgBC,GAAwD;AACpH,QAAMC,IAAmB,CAAA;AAEzB,MAAIC,wBAAW,IAAA;AACf,WAASC,IAAK,GAAGA,IAAKJ,GAAQI,KAAM;AAClC,UAAMC,wBAAW,IAAA;AACjB,QAAIC,IAAK;AACT,WAAOA,IAAKP,KAAO;AACjB,UAAI,CAACE,EAAMK,GAAIF,CAAE,GAAG;AAClB,QAAAE;AACA;AAAA,MACF;AACA,YAAMC,IAAKD;AACX,aAAOA,IAAKP,KAASE,EAAMK,GAAIF,CAAE,IAAG,CAAAE;AACpC,YAAME,IAAKF,IAAK,GACVG,IAAMF,IAAK,UAAWC,GACtBE,IAAQP,EAAK,IAAIM,CAAG;AAC1B,MAAIC,KACFA,EAAM,KAAKN,GACXD,EAAK,OAAOM,CAAG,GACfJ,EAAK,IAAII,GAAKC,CAAK,KACdL,EAAK,IAAII,GAAK,EAAE,IAAAF,GAAI,IAAIH,GAAI,IAAAI,GAAI,IAAIJ,EAAA,CAAI;AAAA,IACjD;AACA,eAAWO,KAAKR,EAAK,OAAA,EAAU,CAAAD,EAAK,KAAKS,CAAC;AAC1C,IAAAR,IAAOE;AAAA,EACT;AACA,aAAWM,KAAKR,EAAK,OAAA,EAAU,CAAAD,EAAK,KAAKS,CAAC;AAC1C,SAAOT;AACT;AASO,SAASU,EAAWb,GAAeC,GAAgBa,GAAkBZ,GAA4Ca,IAA6B,IAAY;AAC/J,QAAMC,IAAS,CAACT,GAAYF,MAAwBE,KAAM,KAAKF,KAAM,KAAK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,CAAO;AACvH;AAEA,SAASS,EAAStB,GAA4CM,GAAYC,GAAYJ,GAAqB;AACzG,WAASE,IAAKC,GAAID,KAAME,GAAIF,IAAM,KAAI,CAACL,EAAMK,GAAIF,CAAE,EAAG,QAAO;AAC7D,SAAO;AACT;AAEA,SAASsB,EAAYzB,GAA4CK,GAAYyB,GAAYC,GAAqB;AAC5G,WAAS5B,IAAK2B,GAAI3B,KAAM4B,GAAI5B,IAAM,KAAI,CAACH,EAAMK,GAAIF,CAAE,EAAG,QAAO;AAC7D,SAAO;AACT;"}
@@ -0,0 +1,8 @@
1
+ const o = 1, t = 2, E = 4, F = 8;
2
+ export {
3
+ F as FACE_BOTTOM,
4
+ o as FACE_LEFT,
5
+ t as FACE_RIGHT,
6
+ E as FACE_TOP
7
+ };
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../src/physics/types.ts"],"sourcesContent":["import type { Body } from './Body';\n\n/**\n * The shapes a body may have, each centred on the body's position. A body turns only when it is made with\n * `rotates: true`; a platformer's bodies need no rotation, and a body that never turns keeps the cheap axis-aligned\n * tests and the steadiest stacks.\n */\nexport type Shape = CircleShape | BoxShape | PolygonShape;\n\nexport interface CircleShape {\n readonly kind: 'circle';\n radius: number;\n}\n\nexport interface BoxShape {\n readonly kind: 'box';\n halfWidth: number;\n halfHeight: number;\n}\n\n/** A point or a vector in world or body pixels, y down. */\nexport interface Vec2 {\n x: number;\n y: number;\n}\n\n/**\n * A convex polygon, its vertices relative to the body's position, which must be the polygon's centroid (make one with\n * `polygonShape`, which orders the points and moves them there). Up to `MAX_POLYGON_VERTICES` corners.\n */\nexport interface PolygonShape {\n readonly kind: 'polygon';\n readonly vertices: readonly Vec2[];\n}\n\n/**\n * - `dynamic`: moved by gravity, forces and contacts;\n * - `static`: never moves (ground, walls); cheapest, kept in a broad phase of its own;\n * - `kinematic`: moved only by its velocity (a moving platform), pushes dynamic bodies and is never pushed.\n */\nexport type BodyType = 'dynamic' | 'static' | 'kinematic';\n\nexport interface BodyOptions {\n type?: BodyType;\n shape: Shape;\n x?: number;\n y?: number;\n vx?: number;\n vy?: number;\n /**\n * Whether contacts and torques turn the body (default false). A body that does not rotate may still be placed at an\n * `angle`, and keeps it.\n */\n rotates?: boolean;\n /** Radians, clockwise on screen (y grows downwards). */\n angle?: number;\n /** Radians per second. */\n angularVelocity?: number;\n /** Turning lost per second, as a share (default 0.05): a rolling ball slows down without rolling friction. */\n angularDamping?: number;\n /** Mass of a dynamic body (default 1). Ignored for static and kinematic bodies, whose mass is infinite. */\n mass?: number;\n /** Bounce, 0–1 (default 0). A pair bounces by the larger of its two. */\n restitution?: number;\n /** Coulomb friction coefficient (default 0.5). A pair uses the geometric mean of its two. */\n friction?: number;\n /** Velocity lost per second, as a share (default 0): air drag. */\n linearDamping?: number;\n /** Multiplies the world's gravity for this body (default 1; 0 floats). */\n gravityScale?: number;\n /** A sensor reports overlaps (contact events) but is never pushed and pushes nothing. */\n sensor?: boolean;\n /** Category bits this body is in (default 1). */\n layer?: number;\n /** Category bits this body collides with (default all). A pair collides when each one's layer is in the other's mask. */\n mask?: number;\n /** Anything the game wants to find again from a contact or a ray hit (an entity id, an object). */\n userData?: unknown;\n}\n\n/** Faces of a box that lie against more solid ground (bits), never used as a contact normal. */\nexport const FACE_LEFT = 1;\nexport const FACE_RIGHT = 2;\nexport const FACE_TOP = 4;\nexport const FACE_BOTTOM = 8;\n\n/** A contact as events and queries report it. The normal points from `a` towards `b`; y grows downwards. */\nexport interface ContactInfo {\n readonly a: Body;\n readonly b: Body;\n readonly nx: number;\n readonly ny: number;\n /** Overlap along the normal, px (slightly negative while resting just apart). */\n readonly depth: number;\n /** Either body is a sensor: reported, never resolved. */\n readonly sensor: boolean;\n /** Where the two touch, world px: one or two points (two where an edge lies along an edge). */\n readonly points: readonly Vec2[];\n}\n\nexport interface PhysicsEvents {\n /** Two bodies started touching (or a sensor started overlapping). Emitted after the step. */\n begin: ContactInfo;\n /** Two bodies stopped touching, or one of them was removed. Emitted after the step. */\n end: ContactInfo;\n}\n\nexport interface RayHit {\n body: Body;\n /** Where the ray met the body. */\n x: number;\n y: number;\n /** Surface normal there, pointing back towards the ray's start. */\n nx: number;\n ny: number;\n /** Share of the ray's length at the hit, 0–1. */\n fraction: number;\n}\n\nexport interface RaycastOptions {\n /** Only bodies whose layer shares a bit with this (default all). */\n mask?: number;\n /** Sensors are skipped unless this is true. */\n includeSensors?: boolean;\n /** Skip bodies this returns false for (the caster itself, say). */\n filter?: (body: Body) => boolean;\n}\n"],"names":["FACE_LEFT","FACE_RIGHT","FACE_TOP","FACE_BOTTOM"],"mappings":"AAiFO,MAAMA,IAAY,GACZC,IAAa,GACbC,IAAW,GACXC,IAAc;"}
@@ -0,0 +1,166 @@
1
+ import { Sprite as g, Texture as v, RenderTexture as S, Container as x } from "pixi.js";
2
+ import { TILE_SIZE as H } from "../net/constants.js";
3
+ import { liveLights as k, lightRadius as R } from "./lights.js";
4
+ import { isTouchUi as D } from "../platform/touch.js";
5
+ const K = 66, W = 33, M = 8, z = (h) => Math.min(1, Math.pow(Math.max(0, 1 - h * h), 1.5) * 1.15), P = (h) => Math.pow(Math.max(0, 1 - h), 2), G = 4, U = 3, Y = 0.3, E = 0.85, $ = 16761466, B = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5].map((h) => (h + 0.5) / 16), _ = (h) => h <= 24 ? Math.max(2, Math.round(h / 2) * 2) : Math.round(h / 8) * 8, F = [...new Set(Array.from({ length: 160 }, (h, t) => _(t + 1)))], N = 33, I = /* @__PURE__ */ new Map();
6
+ let T = !1;
7
+ function O() {
8
+ if (T) return;
9
+ T = !0;
10
+ const h = F.flatMap((s) => [["hole", s], ["wash", s]]), t = () => {
11
+ const s = h.shift();
12
+ s && (y(s[0], s[1]), setTimeout(t, 0));
13
+ };
14
+ setTimeout(t, 0);
15
+ }
16
+ function y(h, t) {
17
+ const s = `${h}${t}`, i = I.get(s);
18
+ if (i) return i;
19
+ const e = t * 2, a = Math.max(2, Math.round(t * 2 * E)), r = h === "hole" ? G : U, p = h === "hole" ? z : P, o = document.createElement("canvas");
20
+ o.width = e, o.height = a;
21
+ const c = o.getContext("2d");
22
+ if (!c) return v.EMPTY;
23
+ const u = c.createImageData(e, a);
24
+ for (let f = 0; f < a; f++)
25
+ for (let l = 0; l < e; l++) {
26
+ const A = Math.hypot((l + 0.5 - e / 2) / t, (f + 0.5 - a / 2) / (t * E));
27
+ if (A >= 1) continue;
28
+ const L = Math.min(r, Math.floor(p(A) * r + B[f % 4 * 4 + l % 4])) / r, d = (f * e + l) * 4;
29
+ u.data[d] = u.data[d + 1] = u.data[d + 2] = 255, u.data[d + 3] = Math.round(L * 255);
30
+ }
31
+ c.putImageData(u, 0, 0);
32
+ const w = v.from(o);
33
+ return w.source.scaleMode = "nearest", I.set(s, w), w;
34
+ }
35
+ class q {
36
+ constructor(t, s, i) {
37
+ this.stage = t, this.color = s, this.alpha = i, this.sheet = new g({ texture: v.WHITE }), this.scratch.addChild(this.sheet, this.holes, this.washes), this.carried = this.light(16773340), this.rt = S.create({ width: 1, height: 1 }), this.view = new g({ texture: this.rt }), this.layer.addChild(this.view), t.screen.addChild(this.layer), t.cameras.main.follow(this.layer), this.unsubscribeResize = t.onResize(() => this.dirty = !0), O();
38
+ }
39
+ stage;
40
+ color;
41
+ alpha;
42
+ scratch = new x();
43
+ sheet;
44
+ /** Every hole is erased before any colour is laid, or a later hole would wipe an earlier light's colour away. */
45
+ holes = new x();
46
+ washes = new x();
47
+ lamps = [];
48
+ /** The transient lights (`lights.ts`), reused frame to frame. */
49
+ flashes = [];
50
+ rt;
51
+ /**
52
+ * On the screen layer, laid over the world with its exact transform by the camera (`Camera.follow`), shake included:
53
+ * the night is drawn in world pixels round the unshaken camera and only this layer moves with a shake, so a shaking
54
+ * screen does not redraw the night every frame.
55
+ */
56
+ layer = new x();
57
+ view;
58
+ /** The light the player carries: the only one that follows them, and the last one they lose. */
59
+ carried;
60
+ unsubscribeResize;
61
+ /** Lamps that flicker: while one does (or the player carries a light) every frame differs. */
62
+ flickering = 0;
63
+ /** Something other than the camera changed what the night looks like (a lamp added, dimmed, the window resized). */
64
+ dirty = !0;
65
+ /** What the last drawn frame was drawn from: the texture, the camera's texel and the shade. */
66
+ drawn = "";
67
+ /** The carried light's place at the last redraw (it follows the body). */
68
+ carriedAt = "";
69
+ /** When the sheet was last redrawn. */
70
+ drawnAt = -1 / 0;
71
+ /** The world pixel the night's top-left texel stands on. */
72
+ ox = 0;
73
+ oy = 0;
74
+ /** The night texture's size in world pixels, and the zoom it was made for. */
75
+ rtKey = "";
76
+ /** The lamps' colour turned down (`setLampsDimmed`). */
77
+ dimLamps = !1;
78
+ /** A phone redraws the night at most `PHONE_MS` apart, whatever moves (`isTouchUi`). */
79
+ phone = D();
80
+ /** A hole and its colour, added to the night's layers. */
81
+ light(t) {
82
+ const s = new g({ texture: y("hole", 8) });
83
+ s.blendMode = "erase", this.holes.addChild(s);
84
+ const i = new g({ texture: y("wash", 8) });
85
+ return i.tint = t, this.washes.addChild(i), { hole: s, wash: i };
86
+ }
87
+ /** A lamp fixed in the world: a torch on a wall, the seep in its chamber, a crystal in a seam, in its own colour. */
88
+ addLamp(t, s, i, e = 0, a = $) {
89
+ this.lamps.push({ sprites: this.light(a), x: t, y: s, r: i, flicker: e }), e && this.flickering++, this.dirty = !0;
90
+ }
91
+ /**
92
+ * Changes how dark and what colour the sheet is (the outdoor night, `NightShade`, deepens and lifts with the
93
+ * world clock). A sheet with no alpha left is neither drawn nor redrawn, so a map at noon pays nothing for its night.
94
+ */
95
+ setShade(t, s) {
96
+ this.color = t, this.alpha = s, this.layer.visible = s > 4e-3;
97
+ }
98
+ /**
99
+ * Dimmed lamps lay only `LAMP_DIM` of their colour on the dark (a "fewer ambient lights" setting). The holes they
100
+ * cut stay as wide, so a dark place is still seen by them.
101
+ */
102
+ setLampsDimmed(t) {
103
+ t !== this.dimLamps && (this.dimLamps = t, this.dirty = !0);
104
+ }
105
+ /**
106
+ * The night's own texture, one texel a world pixel and `MARGIN` to spare on each side (a shake, or a camera that
107
+ * moved while a phone waits for its next redraw, never shows its edge), remade when the window or the zoom changes:
108
+ * at zoom 2 or 3 it is a quarter or a ninth of the screen's pixels. True when it was remade.
109
+ */
110
+ fit(t, s, i) {
111
+ const e = Math.ceil(t / i) + M * 2, a = Math.ceil(s / i) + M * 2, r = `${e},${a},${i}`;
112
+ return r === this.rtKey ? !1 : (this.rtKey = r, this.rt.destroy(!0), this.rt = S.create({ width: e, height: a }), this.rt.source.scaleMode = "nearest", this.view.texture = this.rt, !0);
113
+ }
114
+ /** Redraws the night with this frame's holes in it, when anything in it changed. `px`/`py` is where the player stands. */
115
+ update(t, s, i, e) {
116
+ if (!this.layer.visible) return;
117
+ const a = this.stage.cameras.main, r = a.zoom || 1, p = this.fit(this.stage.width, this.stage.height, r), o = Math.floor(a.scrollX) - M, c = Math.floor(a.scrollY) - M, u = `${o},${c},${this.rtKey},${this.color},${this.alpha}`, w = k(t), f = e > 0 ? `${Math.round(s)},${Math.round(i)},${Math.round(e)}` : "", l = t - this.drawnAt;
118
+ if (!(this.dirty || u !== this.drawn || f !== this.carriedAt || w.length > 0 && l >= N || (e > 0 || this.flickering > 0) && l >= K)) return;
119
+ const L = Math.abs(o - this.ox) >= M - 1 || Math.abs(c - this.oy) >= M - 1;
120
+ if (this.phone && l < W && !p && !L) return;
121
+ this.dirty = !1, this.drawn = u, this.carriedAt = f, this.drawnAt = t, this.ox = o, this.oy = c, this.view.position.set(o, c), this.sheet.width = this.rt.width, this.sheet.height = this.rt.height, this.sheet.position.set(0, 0), this.sheet.tint = this.color, this.sheet.alpha = this.alpha;
122
+ const d = Y * Math.min(1, this.alpha * 1.4);
123
+ e <= 0 ? this.hide(this.carried) : this.place(this.carried, s, i - 6, e * (1 + Math.sin(t / 260) * 0.03 + Math.sin(t / 90) * 0.015), d * 0.5);
124
+ const C = this.dimLamps ? d * V : d;
125
+ for (const n of this.lamps) {
126
+ const m = n.flicker ? 1 + Math.sin(t / 190 + n.flicker) * 0.05 + Math.sin(t / 71 + n.flicker) * 0.03 : 1;
127
+ this.place(n.sprites, n.x, n.y, n.r * m, C * (n.flicker ? 0.9 + (m - 1) * 2 : 1));
128
+ }
129
+ for (; this.flashes.length < w.length; ) this.flashes.push(this.light($));
130
+ for (let n = 0; n < this.flashes.length; n++) {
131
+ const m = w[n], b = this.flashes[n];
132
+ if (!m) {
133
+ this.hide(b);
134
+ continue;
135
+ }
136
+ b.wash.tint = m.color, this.place(b, m.x, m.y, R(m, t), Math.min(0.6, d * 1.6));
137
+ }
138
+ this.stage.app.renderer.render({ container: this.scratch, target: this.rt, clear: !0 });
139
+ }
140
+ hide(t) {
141
+ t.hole.visible = !1, t.wash.visible = !1;
142
+ }
143
+ /** Lays light `l` at world (wx, wy), `r` px across its radius, in the night's world-pixel grid. */
144
+ place(t, s, i, e, a) {
145
+ const r = _(e), p = Math.round(s) - this.ox, o = Math.round(i) - this.oy;
146
+ if (e < 1 || p < -r || o < -r || p > this.rt.width + r || o > this.rt.height + r) {
147
+ this.hide(t);
148
+ return;
149
+ }
150
+ t.hole.texture = y("hole", r), t.wash.texture = y("wash", r);
151
+ for (const c of [t.hole, t.wash])
152
+ c.visible = !0, c.position.set(p - r, o - Math.round(r * E));
153
+ t.wash.alpha = a, t.wash.visible = a > 0.01;
154
+ }
155
+ destroy() {
156
+ this.unsubscribeResize(), this.stage.cameras.main.unfollow(this.layer), this.layer.destroy({ children: !0 }), this.rt.destroy(!0), this.scratch.destroy({ children: !0, context: !0 });
157
+ }
158
+ }
159
+ const V = 0.35, J = H * 5;
160
+ export {
161
+ J as CARRIED_LIGHT,
162
+ q as Darkness,
163
+ V as LAMP_DIM,
164
+ $ as WARM_LIGHT
165
+ };
166
+ //# sourceMappingURL=Darkness.js.map