@zylem/game-lib 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/README.md +23 -41
  2. package/dist/actions.d.ts +25 -0
  3. package/dist/actions.js +287 -8
  4. package/dist/actions.js.map +1 -0
  5. package/dist/behaviors.d.ts +106 -0
  6. package/dist/behaviors.js +396 -6
  7. package/dist/behaviors.js.map +1 -0
  8. package/dist/blueprints-BOCc3Wve.d.ts +26 -0
  9. package/dist/{src/lib/camera/zylem-camera.d.ts → camera-CpbDr4-V.d.ts} +48 -27
  10. package/dist/camera.d.ts +5 -0
  11. package/dist/camera.js +608 -4
  12. package/dist/camera.js.map +1 -0
  13. package/dist/core-CZhozNRH.d.ts +466 -0
  14. package/dist/core.d.ts +10 -0
  15. package/dist/core.js +5761 -9
  16. package/dist/core.js.map +1 -0
  17. package/dist/entities-BAxfJOkk.d.ts +307 -0
  18. package/dist/entities.d.ts +6 -0
  19. package/dist/entities.js +2284 -17
  20. package/dist/entities.js.map +1 -0
  21. package/dist/{src/lib/interfaces/entity.d.ts → entity-Bq_eNEDI.d.ts} +8 -6
  22. package/dist/entity-COvRtFNG.d.ts +395 -0
  23. package/dist/main.d.ts +211 -0
  24. package/dist/main.js +7600 -56
  25. package/dist/main.js.map +1 -0
  26. package/dist/moveable-B_vyA6cw.d.ts +67 -0
  27. package/dist/stage-types-CD21XoIU.d.ts +338 -0
  28. package/dist/stage.d.ts +46 -0
  29. package/dist/stage.js +2765 -4
  30. package/dist/stage.js.map +1 -0
  31. package/dist/transformable-CUhvyuYO.d.ts +67 -0
  32. package/package.json +11 -47
  33. package/dist/.vite/manifest.json +0 -716
  34. package/dist/assets/zylem-logo.png +0 -0
  35. package/dist/examples/00-readme-example.d.ts +0 -2
  36. package/dist/examples/00-readme-example.d.ts.map +0 -1
  37. package/dist/examples/01-basic.d.ts +0 -2
  38. package/dist/examples/01-basic.d.ts.map +0 -1
  39. package/dist/examples/01.1-basic-ball.d.ts +0 -9
  40. package/dist/examples/01.1-basic-ball.d.ts.map +0 -1
  41. package/dist/examples/01.2-ricochet-test.d.ts +0 -2
  42. package/dist/examples/01.2-ricochet-test.d.ts.map +0 -1
  43. package/dist/examples/01.3-rect.d.ts +0 -2
  44. package/dist/examples/01.3-rect.d.ts.map +0 -1
  45. package/dist/examples/02-input.d.ts +0 -2
  46. package/dist/examples/02-input.d.ts.map +0 -1
  47. package/dist/examples/03-stage-test/03-stage-test.d.ts +0 -2
  48. package/dist/examples/03-stage-test/03-stage-test.d.ts.map +0 -1
  49. package/dist/examples/03-stage-test/stage0.d.ts +0 -2
  50. package/dist/examples/03-stage-test/stage0.d.ts.map +0 -1
  51. package/dist/examples/03-stage-test/stage1.d.ts +0 -2
  52. package/dist/examples/03-stage-test/stage1.d.ts.map +0 -1
  53. package/dist/examples/03-stage-test/stage2.d.ts +0 -2
  54. package/dist/examples/03-stage-test/stage2.d.ts.map +0 -1
  55. package/dist/examples/03-stage-test/stage3.d.ts +0 -2
  56. package/dist/examples/03-stage-test/stage3.d.ts.map +0 -1
  57. package/dist/examples/03.1-stage-variable.d.ts +0 -2
  58. package/dist/examples/03.1-stage-variable.d.ts.map +0 -1
  59. package/dist/examples/04-vessel-test.d.ts +0 -18
  60. package/dist/examples/04-vessel-test.d.ts.map +0 -1
  61. package/dist/examples/05-camera-test.d.ts +0 -2
  62. package/dist/examples/05-camera-test.d.ts.map +0 -1
  63. package/dist/examples/06-entity-test.d.ts +0 -2
  64. package/dist/examples/06-entity-test.d.ts.map +0 -1
  65. package/dist/examples/07-behaviors.d.ts +0 -2
  66. package/dist/examples/07-behaviors.d.ts.map +0 -1
  67. package/dist/examples/07.01-behavior-context.d.ts +0 -2
  68. package/dist/examples/07.01-behavior-context.d.ts.map +0 -1
  69. package/dist/examples/08-pong.d.ts +0 -2
  70. package/dist/examples/08-pong.d.ts.map +0 -1
  71. package/dist/examples/08.01-breakout.d.ts +0 -2
  72. package/dist/examples/08.01-breakout.d.ts.map +0 -1
  73. package/dist/examples/09-space-invaders.d.ts +0 -2
  74. package/dist/examples/09-space-invaders.d.ts.map +0 -1
  75. package/dist/examples/10-asteroids.d.ts +0 -2
  76. package/dist/examples/10-asteroids.d.ts.map +0 -1
  77. package/dist/examples/11-2d-platformer.d.ts +0 -2
  78. package/dist/examples/11-2d-platformer.d.ts.map +0 -1
  79. package/dist/examples/12-3d-platformer.d.ts +0 -2
  80. package/dist/examples/12-3d-platformer.d.ts.map +0 -1
  81. package/dist/examples/13-fps.d.ts +0 -2
  82. package/dist/examples/13-fps.d.ts.map +0 -1
  83. package/dist/examples/14-strategy.d.ts +0 -2
  84. package/dist/examples/14-strategy.d.ts.map +0 -1
  85. package/dist/examples/15-zylem-planet-demo.d.ts +0 -2
  86. package/dist/examples/15-zylem-planet-demo.d.ts.map +0 -1
  87. package/dist/examples/16-timbotron.d.ts +0 -2
  88. package/dist/examples/16-timbotron.d.ts.map +0 -1
  89. package/dist/examples/17-stress-test.d.ts +0 -2
  90. package/dist/examples/17-stress-test.d.ts.map +0 -1
  91. package/dist/examples/architecture-test.d.ts +0 -2
  92. package/dist/examples/architecture-test.d.ts.map +0 -1
  93. package/dist/examples/utils.d.ts +0 -10
  94. package/dist/examples/utils.d.ts.map +0 -1
  95. package/dist/lib/actions/behaviors/actions.js +0 -35
  96. package/dist/lib/actions/behaviors/boundaries/boundary.js +0 -40
  97. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.js +0 -100
  98. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.js +0 -37
  99. package/dist/lib/actions/behaviors/ricochet/ricochet.js +0 -6
  100. package/dist/lib/actions/capabilities/moveable.js +0 -108
  101. package/dist/lib/actions/capabilities/rotatable.js +0 -82
  102. package/dist/lib/actions/capabilities/transformable.js +0 -9
  103. package/dist/lib/actions/global-change.js +0 -40
  104. package/dist/lib/camera/camera.js +0 -19
  105. package/dist/lib/camera/fixed-2d.js +0 -30
  106. package/dist/lib/camera/perspective.js +0 -10
  107. package/dist/lib/camera/third-person.js +0 -42
  108. package/dist/lib/camera/zylem-camera.js +0 -208
  109. package/dist/lib/collision/collision-builder.js +0 -46
  110. package/dist/lib/collision/collision-delegate.js +0 -6
  111. package/dist/lib/collision/utils.js +0 -24
  112. package/dist/lib/collision/world.js +0 -77
  113. package/dist/lib/core/base-node.js +0 -61
  114. package/dist/lib/core/entity-asset-loader.js +0 -54
  115. package/dist/lib/core/lifecycle-base.js +0 -20
  116. package/dist/lib/core/preset-shader.js +0 -26
  117. package/dist/lib/core/three-addons/Timer.js +0 -103
  118. package/dist/lib/core/utility/nodes.js +0 -31
  119. package/dist/lib/core/utility/strings.js +0 -14
  120. package/dist/lib/core/utility/vector.js +0 -8
  121. package/dist/lib/core/vessel.js +0 -26
  122. package/dist/lib/debug/console/console-state.js +0 -11
  123. package/dist/lib/debug/debug-state.js +0 -40
  124. package/dist/lib/device/aspect-ratio.js +0 -44
  125. package/dist/lib/entities/actor.js +0 -122
  126. package/dist/lib/entities/box.js +0 -68
  127. package/dist/lib/entities/builder.js +0 -79
  128. package/dist/lib/entities/create.js +0 -31
  129. package/dist/lib/entities/delegates/animation.js +0 -58
  130. package/dist/lib/entities/delegates/debug.js +0 -71
  131. package/dist/lib/entities/delegates/loader.js +0 -19
  132. package/dist/lib/entities/destroy.js +0 -15
  133. package/dist/lib/entities/entity-factory.js +0 -24
  134. package/dist/lib/entities/entity.js +0 -121
  135. package/dist/lib/entities/plane.js +0 -81
  136. package/dist/lib/entities/rect.js +0 -160
  137. package/dist/lib/entities/sphere.js +0 -68
  138. package/dist/lib/entities/sprite.js +0 -125
  139. package/dist/lib/entities/text.js +0 -140
  140. package/dist/lib/entities/zone.js +0 -103
  141. package/dist/lib/game/game-canvas.js +0 -57
  142. package/dist/lib/game/game-config.js +0 -78
  143. package/dist/lib/game/game-default.js +0 -23
  144. package/dist/lib/game/game-retro-resolutions.js +0 -80
  145. package/dist/lib/game/game-state.js +0 -17
  146. package/dist/lib/game/game.js +0 -131
  147. package/dist/lib/game/zylem-game.js +0 -140
  148. package/dist/lib/graphics/geometries/XZPlaneGeometry.js +0 -34
  149. package/dist/lib/graphics/material.js +0 -64
  150. package/dist/lib/graphics/mesh.js +0 -14
  151. package/dist/lib/graphics/render-pass.js +0 -56
  152. package/dist/lib/graphics/shaders/fragment/debug.glsl.js +0 -23
  153. package/dist/lib/graphics/shaders/fragment/fire.glsl.js +0 -52
  154. package/dist/lib/graphics/shaders/fragment/standard.glsl.js +0 -11
  155. package/dist/lib/graphics/shaders/fragment/stars.glsl.js +0 -44
  156. package/dist/lib/graphics/shaders/vertex/debug.glsl.js +0 -15
  157. package/dist/lib/graphics/shaders/vertex/object-shader.glsl.js +0 -11
  158. package/dist/lib/graphics/shaders/vertex/standard.glsl.js +0 -9
  159. package/dist/lib/graphics/zylem-scene.js +0 -75
  160. package/dist/lib/input/gamepad-provider.js +0 -58
  161. package/dist/lib/input/input-manager.js +0 -70
  162. package/dist/lib/input/keyboard-provider.js +0 -120
  163. package/dist/lib/stage/debug-entity-cursor.js +0 -53
  164. package/dist/lib/stage/entity-spawner.js +0 -27
  165. package/dist/lib/stage/stage-debug-delegate.js +0 -100
  166. package/dist/lib/stage/stage-default.js +0 -32
  167. package/dist/lib/stage/stage-factory.js +0 -22
  168. package/dist/lib/stage/stage-manager.js +0 -49
  169. package/dist/lib/stage/stage-state.js +0 -36
  170. package/dist/lib/stage/stage.js +0 -67
  171. package/dist/lib/stage/zylem-stage.js +0 -268
  172. package/dist/lib/systems/transformable.system.js +0 -43
  173. package/dist/node_modules/.pnpm/idb-keyval@6.2.2/node_modules/idb-keyval/dist/index.js +0 -34
  174. package/dist/node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/pack.js +0 -520
  175. package/dist/node_modules/.pnpm/msgpackr@1.11.5/node_modules/msgpackr/unpack.js +0 -672
  176. package/dist/src/api/actions.d.ts +0 -5
  177. package/dist/src/api/actions.d.ts.map +0 -1
  178. package/dist/src/api/behaviors.d.ts +0 -4
  179. package/dist/src/api/behaviors.d.ts.map +0 -1
  180. package/dist/src/api/camera.d.ts +0 -4
  181. package/dist/src/api/camera.d.ts.map +0 -1
  182. package/dist/src/api/core.d.ts +0 -6
  183. package/dist/src/api/core.d.ts.map +0 -1
  184. package/dist/src/api/entities.d.ts +0 -9
  185. package/dist/src/api/entities.d.ts.map +0 -1
  186. package/dist/src/api/main.d.ts +0 -32
  187. package/dist/src/api/main.d.ts.map +0 -1
  188. package/dist/src/api/stage.d.ts +0 -5
  189. package/dist/src/api/stage.d.ts.map +0 -1
  190. package/dist/src/lib/actions/behaviors/actions.d.ts +0 -11
  191. package/dist/src/lib/actions/behaviors/actions.d.ts.map +0 -1
  192. package/dist/src/lib/actions/behaviors/behavior.d.ts +0 -6
  193. package/dist/src/lib/actions/behaviors/behavior.d.ts.map +0 -1
  194. package/dist/src/lib/actions/behaviors/boundaries/boundary.d.ts +0 -37
  195. package/dist/src/lib/actions/behaviors/boundaries/boundary.d.ts.map +0 -1
  196. package/dist/src/lib/actions/behaviors/character-controller.d.ts +0 -6
  197. package/dist/src/lib/actions/behaviors/character-controller.d.ts.map +0 -1
  198. package/dist/src/lib/actions/behaviors/debug/debug-collision.d.ts +0 -6
  199. package/dist/src/lib/actions/behaviors/debug/debug-collision.d.ts.map +0 -1
  200. package/dist/src/lib/actions/behaviors/debug/debug-update.d.ts +0 -5
  201. package/dist/src/lib/actions/behaviors/debug/debug-update.d.ts.map +0 -1
  202. package/dist/src/lib/actions/behaviors/debug/debug.d.ts +0 -10
  203. package/dist/src/lib/actions/behaviors/debug/debug.d.ts.map +0 -1
  204. package/dist/src/lib/actions/behaviors/movement/movement-sequence-2d.d.ts +0 -24
  205. package/dist/src/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +0 -1
  206. package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +0 -11
  207. package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +0 -1
  208. package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +0 -12
  209. package/dist/src/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +0 -1
  210. package/dist/src/lib/actions/behaviors/ricochet/ricochet.d.ts +0 -44
  211. package/dist/src/lib/actions/behaviors/ricochet/ricochet.d.ts.map +0 -1
  212. package/dist/src/lib/actions/behaviors/zylem-behavior.d.ts +0 -2
  213. package/dist/src/lib/actions/behaviors/zylem-behavior.d.ts.map +0 -1
  214. package/dist/src/lib/actions/capabilities/moveable.d.ts +0 -125
  215. package/dist/src/lib/actions/capabilities/moveable.d.ts.map +0 -1
  216. package/dist/src/lib/actions/capabilities/rotatable.d.ts +0 -111
  217. package/dist/src/lib/actions/capabilities/rotatable.d.ts.map +0 -1
  218. package/dist/src/lib/actions/capabilities/transformable.d.ts +0 -7
  219. package/dist/src/lib/actions/capabilities/transformable.d.ts.map +0 -1
  220. package/dist/src/lib/actions/global-change.d.ts +0 -23
  221. package/dist/src/lib/actions/global-change.d.ts.map +0 -1
  222. package/dist/src/lib/camera/camera.d.ts +0 -16
  223. package/dist/src/lib/camera/camera.d.ts.map +0 -1
  224. package/dist/src/lib/camera/fixed-2d.d.ts +0 -32
  225. package/dist/src/lib/camera/fixed-2d.d.ts.map +0 -1
  226. package/dist/src/lib/camera/perspective.d.ts +0 -9
  227. package/dist/src/lib/camera/perspective.d.ts.map +0 -1
  228. package/dist/src/lib/camera/third-person.d.ts +0 -32
  229. package/dist/src/lib/camera/third-person.d.ts.map +0 -1
  230. package/dist/src/lib/camera/zylem-camera.d.ts.map +0 -1
  231. package/dist/src/lib/collision/collision-builder.d.ts +0 -17
  232. package/dist/src/lib/collision/collision-builder.d.ts.map +0 -1
  233. package/dist/src/lib/collision/collision-delegate.d.ts +0 -6
  234. package/dist/src/lib/collision/collision-delegate.d.ts.map +0 -1
  235. package/dist/src/lib/collision/collision-group.d.ts +0 -11
  236. package/dist/src/lib/collision/collision-group.d.ts.map +0 -1
  237. package/dist/src/lib/collision/collision-mask.d.ts +0 -18
  238. package/dist/src/lib/collision/collision-mask.d.ts.map +0 -1
  239. package/dist/src/lib/collision/collision.d.ts +0 -19
  240. package/dist/src/lib/collision/collision.d.ts.map +0 -1
  241. package/dist/src/lib/collision/utils.d.ts +0 -15
  242. package/dist/src/lib/collision/utils.d.ts.map +0 -1
  243. package/dist/src/lib/collision/world.d.ts +0 -23
  244. package/dist/src/lib/collision/world.d.ts.map +0 -1
  245. package/dist/src/lib/core/asset-manager.d.ts +0 -2
  246. package/dist/src/lib/core/asset-manager.d.ts.map +0 -1
  247. package/dist/src/lib/core/base-node-life-cycle.d.ts +0 -54
  248. package/dist/src/lib/core/base-node-life-cycle.d.ts.map +0 -1
  249. package/dist/src/lib/core/base-node.d.ts +0 -36
  250. package/dist/src/lib/core/base-node.d.ts.map +0 -1
  251. package/dist/src/lib/core/blueprints.d.ts +0 -22
  252. package/dist/src/lib/core/blueprints.d.ts.map +0 -1
  253. package/dist/src/lib/core/entity-asset-loader.d.ts +0 -16
  254. package/dist/src/lib/core/entity-asset-loader.d.ts.map +0 -1
  255. package/dist/src/lib/core/errors.d.ts +0 -5
  256. package/dist/src/lib/core/errors.d.ts.map +0 -1
  257. package/dist/src/lib/core/flags.d.ts +0 -3
  258. package/dist/src/lib/core/flags.d.ts.map +0 -1
  259. package/dist/src/lib/core/index.d.ts +0 -5
  260. package/dist/src/lib/core/index.d.ts.map +0 -1
  261. package/dist/src/lib/core/interfaces.d.ts +0 -25
  262. package/dist/src/lib/core/interfaces.d.ts.map +0 -1
  263. package/dist/src/lib/core/lazy-loader.d.ts +0 -80
  264. package/dist/src/lib/core/lazy-loader.d.ts.map +0 -1
  265. package/dist/src/lib/core/lifecycle-base.d.ts +0 -17
  266. package/dist/src/lib/core/lifecycle-base.d.ts.map +0 -1
  267. package/dist/src/lib/core/node-interface.d.ts +0 -12
  268. package/dist/src/lib/core/node-interface.d.ts.map +0 -1
  269. package/dist/src/lib/core/preset-shader.d.ts +0 -8
  270. package/dist/src/lib/core/preset-shader.d.ts.map +0 -1
  271. package/dist/src/lib/core/three-addons/Timer.d.ts +0 -92
  272. package/dist/src/lib/core/three-addons/Timer.d.ts.map +0 -1
  273. package/dist/src/lib/core/utility/nodes.d.ts +0 -13
  274. package/dist/src/lib/core/utility/nodes.d.ts.map +0 -1
  275. package/dist/src/lib/core/utility/strings.d.ts +0 -3
  276. package/dist/src/lib/core/utility/strings.d.ts.map +0 -1
  277. package/dist/src/lib/core/utility/vector.d.ts +0 -8
  278. package/dist/src/lib/core/utility/vector.d.ts.map +0 -1
  279. package/dist/src/lib/core/vector.d.ts +0 -4
  280. package/dist/src/lib/core/vector.d.ts.map +0 -1
  281. package/dist/src/lib/core/vessel.d.ts +0 -13
  282. package/dist/src/lib/core/vessel.d.ts.map +0 -1
  283. package/dist/src/lib/debug/console/console-state.d.ts +0 -20
  284. package/dist/src/lib/debug/console/console-state.d.ts.map +0 -1
  285. package/dist/src/lib/debug/console/console-store.d.ts +0 -6
  286. package/dist/src/lib/debug/console/console-store.d.ts.map +0 -1
  287. package/dist/src/lib/debug/debug-state.d.ts +0 -38
  288. package/dist/src/lib/debug/debug-state.d.ts.map +0 -1
  289. package/dist/src/lib/debug/debug-store.d.ts +0 -15
  290. package/dist/src/lib/debug/debug-store.d.ts.map +0 -1
  291. package/dist/src/lib/debug/state-based-debug-loader.d.ts +0 -8
  292. package/dist/src/lib/debug/state-based-debug-loader.d.ts.map +0 -1
  293. package/dist/src/lib/device/aspect-ratio.d.ts +0 -38
  294. package/dist/src/lib/device/aspect-ratio.d.ts.map +0 -1
  295. package/dist/src/lib/device/desktop.d.ts +0 -2
  296. package/dist/src/lib/device/desktop.d.ts.map +0 -1
  297. package/dist/src/lib/device/mobile.d.ts +0 -2
  298. package/dist/src/lib/device/mobile.d.ts.map +0 -1
  299. package/dist/src/lib/device/tablet.d.ts +0 -2
  300. package/dist/src/lib/device/tablet.d.ts.map +0 -1
  301. package/dist/src/lib/entities/actor.d.ts +0 -44
  302. package/dist/src/lib/entities/actor.d.ts.map +0 -1
  303. package/dist/src/lib/entities/box.d.ts +0 -27
  304. package/dist/src/lib/entities/box.d.ts.map +0 -1
  305. package/dist/src/lib/entities/builder.d.ts +0 -28
  306. package/dist/src/lib/entities/builder.d.ts.map +0 -1
  307. package/dist/src/lib/entities/create.d.ts +0 -15
  308. package/dist/src/lib/entities/create.d.ts.map +0 -1
  309. package/dist/src/lib/entities/delegates/animation.d.ts +0 -33
  310. package/dist/src/lib/entities/delegates/animation.d.ts.map +0 -1
  311. package/dist/src/lib/entities/delegates/debug.d.ts +0 -29
  312. package/dist/src/lib/entities/delegates/debug.d.ts.map +0 -1
  313. package/dist/src/lib/entities/delegates/loader.d.ts +0 -12
  314. package/dist/src/lib/entities/delegates/loader.d.ts.map +0 -1
  315. package/dist/src/lib/entities/destroy.d.ts +0 -4
  316. package/dist/src/lib/entities/destroy.d.ts.map +0 -1
  317. package/dist/src/lib/entities/entity-factory.d.ts +0 -10
  318. package/dist/src/lib/entities/entity-factory.d.ts.map +0 -1
  319. package/dist/src/lib/entities/entity.d.ts +0 -98
  320. package/dist/src/lib/entities/entity.d.ts.map +0 -1
  321. package/dist/src/lib/entities/index.d.ts +0 -12
  322. package/dist/src/lib/entities/index.d.ts.map +0 -1
  323. package/dist/src/lib/entities/plane.d.ts +0 -36
  324. package/dist/src/lib/entities/plane.d.ts.map +0 -1
  325. package/dist/src/lib/entities/rect.d.ts +0 -63
  326. package/dist/src/lib/entities/rect.d.ts.map +0 -1
  327. package/dist/src/lib/entities/sphere.d.ts +0 -29
  328. package/dist/src/lib/entities/sphere.d.ts.map +0 -1
  329. package/dist/src/lib/entities/sprite.d.ts +0 -54
  330. package/dist/src/lib/entities/sprite.d.ts.map +0 -1
  331. package/dist/src/lib/entities/text.d.ts +0 -49
  332. package/dist/src/lib/entities/text.d.ts.map +0 -1
  333. package/dist/src/lib/entities/zone.d.ts +0 -54
  334. package/dist/src/lib/entities/zone.d.ts.map +0 -1
  335. package/dist/src/lib/game/game-blueprint.d.ts +0 -38
  336. package/dist/src/lib/game/game-blueprint.d.ts.map +0 -1
  337. package/dist/src/lib/game/game-canvas.d.ts +0 -35
  338. package/dist/src/lib/game/game-canvas.d.ts.map +0 -1
  339. package/dist/src/lib/game/game-config.d.ts +0 -59
  340. package/dist/src/lib/game/game-config.d.ts.map +0 -1
  341. package/dist/src/lib/game/game-default.d.ts +0 -14
  342. package/dist/src/lib/game/game-default.d.ts.map +0 -1
  343. package/dist/src/lib/game/game-interfaces.d.ts +0 -29
  344. package/dist/src/lib/game/game-interfaces.d.ts.map +0 -1
  345. package/dist/src/lib/game/game-retro-resolutions.d.ts +0 -25
  346. package/dist/src/lib/game/game-retro-resolutions.d.ts.map +0 -1
  347. package/dist/src/lib/game/game-state.d.ts +0 -11
  348. package/dist/src/lib/game/game-state.d.ts.map +0 -1
  349. package/dist/src/lib/game/game.d.ts +0 -39
  350. package/dist/src/lib/game/game.d.ts.map +0 -1
  351. package/dist/src/lib/game/zylem-game.d.ts +0 -58
  352. package/dist/src/lib/game/zylem-game.d.ts.map +0 -1
  353. package/dist/src/lib/graphics/geometries/XZPlaneGeometry.d.ts +0 -8
  354. package/dist/src/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +0 -1
  355. package/dist/src/lib/graphics/material.d.ts +0 -29
  356. package/dist/src/lib/graphics/material.d.ts.map +0 -1
  357. package/dist/src/lib/graphics/mesh.d.ts +0 -19
  358. package/dist/src/lib/graphics/mesh.d.ts.map +0 -1
  359. package/dist/src/lib/graphics/render-pass.d.ts +0 -17
  360. package/dist/src/lib/graphics/render-pass.d.ts.map +0 -1
  361. package/dist/src/lib/graphics/zylem-scene.d.ts +0 -50
  362. package/dist/src/lib/graphics/zylem-scene.d.ts.map +0 -1
  363. package/dist/src/lib/input/gamepad-provider.d.ts +0 -14
  364. package/dist/src/lib/input/gamepad-provider.d.ts.map +0 -1
  365. package/dist/src/lib/input/input-manager.d.ts +0 -15
  366. package/dist/src/lib/input/input-manager.d.ts.map +0 -1
  367. package/dist/src/lib/input/input-provider.d.ts +0 -7
  368. package/dist/src/lib/input/input-provider.d.ts.map +0 -1
  369. package/dist/src/lib/input/input.d.ts +0 -48
  370. package/dist/src/lib/input/input.d.ts.map +0 -1
  371. package/dist/src/lib/input/keyboard-provider.d.ts +0 -21
  372. package/dist/src/lib/input/keyboard-provider.d.ts.map +0 -1
  373. package/dist/src/lib/interfaces/entity.d.ts.map +0 -1
  374. package/dist/src/lib/sounds/index.d.ts +0 -3
  375. package/dist/src/lib/sounds/index.d.ts.map +0 -1
  376. package/dist/src/lib/sounds/ping-pong-sound.d.ts +0 -5
  377. package/dist/src/lib/sounds/ping-pong-sound.d.ts.map +0 -1
  378. package/dist/src/lib/sounds/ricochet-sound.d.ts +0 -5
  379. package/dist/src/lib/sounds/ricochet-sound.d.ts.map +0 -1
  380. package/dist/src/lib/stage/debug-entity-cursor.d.ts +0 -24
  381. package/dist/src/lib/stage/debug-entity-cursor.d.ts.map +0 -1
  382. package/dist/src/lib/stage/entity-spawner.d.ts +0 -9
  383. package/dist/src/lib/stage/entity-spawner.d.ts.map +0 -1
  384. package/dist/src/lib/stage/stage-camera-debug-delegate.d.ts +0 -14
  385. package/dist/src/lib/stage/stage-camera-debug-delegate.d.ts.map +0 -1
  386. package/dist/src/lib/stage/stage-debug-delegate.d.ts +0 -26
  387. package/dist/src/lib/stage/stage-debug-delegate.d.ts.map +0 -1
  388. package/dist/src/lib/stage/stage-default.d.ts +0 -3
  389. package/dist/src/lib/stage/stage-default.d.ts.map +0 -1
  390. package/dist/src/lib/stage/stage-factory.d.ts +0 -6
  391. package/dist/src/lib/stage/stage-factory.d.ts.map +0 -1
  392. package/dist/src/lib/stage/stage-manager.d.ts +0 -30
  393. package/dist/src/lib/stage/stage-manager.d.ts.map +0 -1
  394. package/dist/src/lib/stage/stage-state.d.ts +0 -14
  395. package/dist/src/lib/stage/stage-state.d.ts.map +0 -1
  396. package/dist/src/lib/stage/stage.d.ts +0 -35
  397. package/dist/src/lib/stage/stage.d.ts.map +0 -1
  398. package/dist/src/lib/stage/zylem-stage.d.ts +0 -128
  399. package/dist/src/lib/stage/zylem-stage.d.ts.map +0 -1
  400. package/dist/src/lib/systems/test-system.d.ts +0 -2
  401. package/dist/src/lib/systems/test-system.d.ts.map +0 -1
  402. package/dist/src/lib/systems/transformable.system.d.ts +0 -25
  403. package/dist/src/lib/systems/transformable.system.d.ts.map +0 -1
  404. package/dist/src/lib/types/entity-types.d.ts +0 -24
  405. package/dist/src/lib/types/entity-types.d.ts.map +0 -1
  406. package/dist/src/lib/types/index.d.ts +0 -3
  407. package/dist/src/lib/types/index.d.ts.map +0 -1
  408. package/dist/src/lib/types/stage-types.d.ts +0 -26
  409. package/dist/src/lib/types/stage-types.d.ts.map +0 -1
  410. package/dist/src/lib/ui/Debug.d.ts +0 -6
  411. package/dist/src/lib/ui/Debug.d.ts.map +0 -1
  412. package/dist/src/lib/ui/console/Console.d.ts +0 -7
  413. package/dist/src/lib/ui/console/Console.d.ts.map +0 -1
  414. package/dist/src/lib/ui/debug-panel/AccordionMenu.d.ts +0 -7
  415. package/dist/src/lib/ui/debug-panel/AccordionMenu.d.ts.map +0 -1
  416. package/dist/src/lib/ui/debug-panel/Menu.d.ts +0 -6
  417. package/dist/src/lib/ui/debug-panel/Menu.d.ts.map +0 -1
  418. package/dist/src/lib/ui/debug-panel/sections/EntitiesSection.d.ts +0 -4
  419. package/dist/src/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +0 -1
  420. package/dist/src/lib/ui/debug-panel/sections/GameSection.d.ts +0 -3
  421. package/dist/src/lib/ui/debug-panel/sections/GameSection.d.ts.map +0 -1
  422. package/dist/src/lib/ui/debug-panel/sections/StagesSection.d.ts +0 -3
  423. package/dist/src/lib/ui/debug-panel/sections/StagesSection.d.ts.map +0 -1
  424. package/dist/src/lib/ui/debug-panel/sections/all.d.ts +0 -4
  425. package/dist/src/lib/ui/debug-panel/sections/all.d.ts.map +0 -1
  426. package/dist/src/lib/ui/toolbar/Toolbar.d.ts +0 -6
  427. package/dist/src/lib/ui/toolbar/Toolbar.d.ts.map +0 -1
  428. package/dist/tests/e2e/basic-game.spec.d.ts +0 -2
  429. package/dist/tests/e2e/basic-game.spec.d.ts.map +0 -1
  430. package/dist/tests/integration/debug.sim.spec.d.ts +0 -2
  431. package/dist/tests/integration/debug.sim.spec.d.ts.map +0 -1
  432. package/dist/tests/unit/collision/collision.spec.d.ts +0 -2
  433. package/dist/tests/unit/collision/collision.spec.d.ts.map +0 -1
  434. package/dist/tests/unit/core/base-node.spec.d.ts +0 -2
  435. package/dist/tests/unit/core/base-node.spec.d.ts.map +0 -1
  436. package/dist/tests/unit/core/game.spec.d.ts +0 -2
  437. package/dist/tests/unit/core/game.spec.d.ts.map +0 -1
  438. package/dist/tests/unit/core/stage.spec.d.ts +0 -2
  439. package/dist/tests/unit/core/stage.spec.d.ts.map +0 -1
  440. package/dist/tests/unit/core/vessel.spec.d.ts +0 -2
  441. package/dist/tests/unit/core/vessel.spec.d.ts.map +0 -1
@@ -1,58 +0,0 @@
1
- import { AnimationMixer as u, LoopOnce as c, LoopRepeat as h } from "three";
2
- import { EntityAssetLoader as _ } from "../../core/entity-asset-loader.js";
3
- class d {
4
- target;
5
- _mixer = null;
6
- _actions = {};
7
- _animations = [];
8
- _currentAction = null;
9
- _pauseAtPercentage = 0;
10
- _isPaused = !1;
11
- _queuedKey = null;
12
- _fadeDuration = 0.5;
13
- _currentKey = "";
14
- _assetLoader = new _();
15
- constructor(e) {
16
- this.target = e;
17
- }
18
- async loadAnimations(e) {
19
- if (!e.length)
20
- return;
21
- const i = await Promise.all(e.map((t) => this._assetLoader.loadFile(t.path)));
22
- this._animations = i.filter((t) => !!t.animation).map((t) => t.animation), this._animations.length && (this._mixer = new u(this.target), this._animations.forEach((t, n) => {
23
- const a = e[n].key || n.toString();
24
- this._actions[a] = this._mixer.clipAction(t);
25
- }), this.playAnimation({ key: Object.keys(this._actions)[0] }));
26
- }
27
- update(e) {
28
- if (!this._mixer || !this._currentAction)
29
- return;
30
- this._mixer.update(e);
31
- const i = this._currentAction.getClip().duration * (this._pauseAtPercentage / 100);
32
- if (!this._isPaused && this._pauseAtPercentage > 0 && this._currentAction.time >= i && (this._currentAction.time = i, this._currentAction.paused = !0, this._isPaused = !0, this._queuedKey !== null)) {
33
- const t = this._actions[this._queuedKey];
34
- t.reset().play(), this._currentAction.crossFadeTo(t, this._fadeDuration, !1), this._currentAction = t, this._currentKey = this._queuedKey, this._queuedKey = null;
35
- }
36
- }
37
- playAnimation(e) {
38
- if (!this._mixer)
39
- return;
40
- const { key: i, pauseAtPercentage: t = 0, pauseAtEnd: n = !1, fadeToKey: a, fadeDuration: o = 0.5 } = e;
41
- if (i === this._currentKey)
42
- return;
43
- this._queuedKey = a || null, this._fadeDuration = o, this._pauseAtPercentage = n ? 100 : t, this._isPaused = !1;
44
- const r = this._currentAction;
45
- r && r.stop();
46
- const s = this._actions[i];
47
- s && (this._pauseAtPercentage > 0 ? (s.setLoop(c, 1 / 0), s.clampWhenFinished = !0) : (s.setLoop(h, 1 / 0), s.clampWhenFinished = !1), r && r.crossFadeTo(s, o, !1), s.reset().play(), this._currentAction = s, this._currentKey = i);
48
- }
49
- get currentAnimationKey() {
50
- return this._currentKey;
51
- }
52
- get animations() {
53
- return this._animations;
54
- }
55
- }
56
- export {
57
- d as AnimationDelegate
58
- };
@@ -1,71 +0,0 @@
1
- import { MeshStandardMaterial as c, MeshBasicMaterial as u, MeshPhongMaterial as f } from "three";
2
- function g(o) {
3
- return o && typeof o.getDebugInfo == "function";
4
- }
5
- class d {
6
- entity;
7
- constructor(t) {
8
- this.entity = t;
9
- }
10
- /**
11
- * Get formatted position string
12
- */
13
- getPositionString() {
14
- if (this.entity.mesh) {
15
- const { x: n, y: s, z: r } = this.entity.mesh.position;
16
- return `${n.toFixed(2)}, ${s.toFixed(2)}, ${r.toFixed(2)}`;
17
- }
18
- const { x: t, y: i, z: e } = this.entity.options.position || { x: 0, y: 0, z: 0 };
19
- return `${t.toFixed(2)}, ${i.toFixed(2)}, ${e.toFixed(2)}`;
20
- }
21
- /**
22
- * Get formatted rotation string (in degrees)
23
- */
24
- getRotationString() {
25
- if (this.entity.mesh) {
26
- const { x: s, y: r, z: y } = this.entity.mesh.rotation, a = (h) => (h * 180 / Math.PI).toFixed(1);
27
- return `${a(s)}°, ${a(r)}°, ${a(y)}°`;
28
- }
29
- const { x: t, y: i, z: e } = this.entity.options.rotation || { x: 0, y: 0, z: 0 }, n = (s) => (s * 180 / Math.PI).toFixed(1);
30
- return `${n(t)}°, ${n(i)}°, ${n(e)}°`;
31
- }
32
- /**
33
- * Get material information
34
- */
35
- getMaterialInfo() {
36
- if (!this.entity.mesh || !this.entity.mesh.material)
37
- return { type: "none" };
38
- const t = Array.isArray(this.entity.mesh.material) ? this.entity.mesh.material[0] : this.entity.mesh.material, i = {
39
- type: t.type
40
- };
41
- return (t instanceof c || t instanceof u || t instanceof f) && (i.color = `#${t.color.getHexString()}`, i.opacity = t.opacity, i.transparent = t.transparent), "roughness" in t && (i.roughness = t.roughness), "metalness" in t && (i.metalness = t.metalness), i;
42
- }
43
- getPhysicsInfo() {
44
- if (!this.entity.body)
45
- return null;
46
- const t = {
47
- type: this.entity.body.bodyType(),
48
- mass: this.entity.body.mass(),
49
- isEnabled: this.entity.body.isEnabled(),
50
- isSleeping: this.entity.body.isSleeping()
51
- }, i = this.entity.body.linvel();
52
- return t.velocity = `${i.x.toFixed(2)}, ${i.y.toFixed(2)}, ${i.z.toFixed(2)}`, t;
53
- }
54
- buildDebugInfo() {
55
- const t = {
56
- name: this.entity.name || this.entity.uuid,
57
- uuid: this.entity.uuid,
58
- position: this.getPositionString(),
59
- rotation: this.getRotationString(),
60
- material: this.getMaterialInfo()
61
- }, i = this.getPhysicsInfo();
62
- if (i && (t.physics = i), this.entity.behaviors.length > 0 && (t.behaviors = this.entity.behaviors.map((e) => e.constructor.name)), g(this.entity)) {
63
- const e = this.entity.getDebugInfo();
64
- return { ...t, ...e };
65
- }
66
- return t;
67
- }
68
- }
69
- export {
70
- d as DebugDelegate
71
- };
@@ -1,19 +0,0 @@
1
- function n(e) {
2
- return typeof e?.load == "function" && typeof e?.data == "function";
3
- }
4
- class a {
5
- entityReference;
6
- constructor(t) {
7
- this.entityReference = t;
8
- }
9
- async load() {
10
- this.entityReference.load && await this.entityReference.load();
11
- }
12
- async data() {
13
- return this.entityReference.data ? this.entityReference.data() : null;
14
- }
15
- }
16
- export {
17
- a as EntityLoader,
18
- n as isLoadable
19
- };
@@ -1,15 +0,0 @@
1
- import { getGlobalState as n } from "../game/game-state.js";
2
- function r(o, t, e) {
3
- e({
4
- me: o,
5
- globals: t
6
- });
7
- }
8
- function d(o, t) {
9
- const e = t ?? n();
10
- r(o, e, o.nodeDestroy.bind(o));
11
- }
12
- export {
13
- d as destroy,
14
- r as destroyEntity
15
- };
@@ -1,24 +0,0 @@
1
- import { text as e } from "./text.js";
2
- import { sprite as s } from "./sprite.js";
3
- const o = {
4
- registry: /* @__PURE__ */ new Map(),
5
- register(t, i) {
6
- this.registry.set(t, i);
7
- },
8
- async createFromBlueprint(t) {
9
- const i = this.registry.get(t.type);
10
- if (!i)
11
- throw new Error(`Unknown entity type: ${t.type}`);
12
- const r = {
13
- ...t.data,
14
- position: t.position ? { x: t.position[0], y: t.position[1], z: 0 } : void 0,
15
- name: t.id
16
- };
17
- return await i(r);
18
- }
19
- };
20
- o.register("text", async (t) => await e(t));
21
- o.register("sprite", async (t) => await s(t));
22
- export {
23
- o as EntityFactory
24
- };
@@ -1,121 +0,0 @@
1
- import { ShaderMaterial as s } from "three";
2
- import { position as a, scale as o, rotation as n } from "../systems/transformable.system.js";
3
- import { BaseNode as c } from "../core/base-node.js";
4
- class f extends c {
5
- behaviors = [];
6
- group;
7
- mesh;
8
- materials;
9
- bodyDesc = null;
10
- body = null;
11
- colliderDesc;
12
- collider;
13
- custom = {};
14
- debugInfo = {};
15
- debugMaterial;
16
- lifeCycleDelegate = {
17
- setup: [],
18
- update: [],
19
- destroy: []
20
- };
21
- collisionDelegate = {
22
- collision: []
23
- };
24
- collisionType;
25
- behaviorCallbackMap = {
26
- setup: [],
27
- update: [],
28
- destroy: [],
29
- collision: []
30
- };
31
- constructor() {
32
- super();
33
- }
34
- create() {
35
- const { position: e } = this.options, { x: t, y: i, z: l } = e || { x: 0, y: 0, z: 0 };
36
- return this.behaviors = [
37
- { component: a, values: { x: t, y: i, z: l } },
38
- { component: o, values: { x: 0, y: 0, z: 0 } },
39
- { component: n, values: { x: 0, y: 0, z: 0, w: 0 } }
40
- ], this.name = this.options.name || "", this;
41
- }
42
- onSetup(...e) {
43
- const t = [...this.lifeCycleDelegate.setup ?? [], ...e];
44
- return this.lifeCycleDelegate = {
45
- ...this.lifeCycleDelegate,
46
- setup: t
47
- }, this;
48
- }
49
- onUpdate(...e) {
50
- const t = [...this.lifeCycleDelegate.update ?? [], ...e];
51
- return this.lifeCycleDelegate = {
52
- ...this.lifeCycleDelegate,
53
- update: t
54
- }, this;
55
- }
56
- onDestroy(...e) {
57
- return this.lifeCycleDelegate = {
58
- ...this.lifeCycleDelegate,
59
- destroy: e.length > 0 ? e : void 0
60
- }, this;
61
- }
62
- onCollision(...e) {
63
- return this.collisionDelegate = {
64
- collision: e.length > 0 ? e : void 0
65
- }, this;
66
- }
67
- _setup(e) {
68
- this.behaviorCallbackMap.setup.forEach((t) => {
69
- t({ ...e, me: this });
70
- }), this.lifeCycleDelegate.setup?.length && this.lifeCycleDelegate.setup.forEach((i) => {
71
- i({ ...e, me: this });
72
- });
73
- }
74
- async _loaded(e) {
75
- }
76
- _update(e) {
77
- this.updateMaterials(e), this.lifeCycleDelegate.update?.length && this.lifeCycleDelegate.update.forEach((i) => {
78
- i({ ...e, me: this });
79
- }), this.behaviorCallbackMap.update.forEach((t) => {
80
- t({ ...e, me: this });
81
- });
82
- }
83
- _destroy(e) {
84
- this.lifeCycleDelegate.destroy?.length && this.lifeCycleDelegate.destroy.forEach((i) => {
85
- i({ ...e, me: this });
86
- }), this.behaviorCallbackMap.destroy.forEach((t) => {
87
- t({ ...e, me: this });
88
- });
89
- }
90
- async _cleanup(e) {
91
- }
92
- _collision(e, t) {
93
- this.collisionDelegate.collision?.length && this.collisionDelegate.collision.forEach((l) => {
94
- l({ entity: this, other: e, globals: t });
95
- }), this.behaviorCallbackMap.collision.forEach((i) => {
96
- i({ entity: this, other: e, globals: t });
97
- });
98
- }
99
- addBehavior(e) {
100
- const t = e.handler;
101
- return t && this.behaviorCallbackMap[e.type].push(t), this;
102
- }
103
- addBehaviors(e) {
104
- return e.forEach((t) => {
105
- const i = t.handler;
106
- i && this.behaviorCallbackMap[t.type].push(i);
107
- }), this;
108
- }
109
- updateMaterials(e) {
110
- if (this.materials?.length)
111
- for (const t of this.materials)
112
- t instanceof s && t.uniforms && t.uniforms.iTime && (t.uniforms.iTime.value += e.delta);
113
- }
114
- buildInfo() {
115
- const e = {};
116
- return e.name = this.name, e.uuid = this.uuid, e.eid = this.eid.toString(), e;
117
- }
118
- }
119
- export {
120
- f as GameEntity
121
- };
@@ -1,81 +0,0 @@
1
- import { ColliderDesc as B } from "@dimforge/rapier3d-compat";
2
- import { Color as M, Vector3 as u, Vector2 as d, PlaneGeometry as C } from "three";
3
- import { GameEntity as D } from "./entity.js";
4
- import { EntityCollisionBuilder as E, EntityBuilder as P, EntityMeshBuilder as v } from "./builder.js";
5
- import { XZPlaneGeometry as z } from "../graphics/geometries/XZPlaneGeometry.js";
6
- import { createEntity as A } from "./create.js";
7
- const r = 4, p = {
8
- tile: new d(10, 10),
9
- repeat: new d(1, 1),
10
- position: new u(0, 0, 0),
11
- collision: {
12
- static: !0
13
- },
14
- material: {
15
- color: new M("#ffffff"),
16
- shader: "standard"
17
- },
18
- subdivisions: r
19
- };
20
- class G extends E {
21
- collider(e) {
22
- const o = e.tile ?? new d(1, 1), s = e.subdivisions ?? r, t = new u(o.x, 1, o.y), i = e._builders?.meshBuilder?.heightData, h = new u(t.x, 1, t.z);
23
- return B.heightfield(s, s, i, h);
24
- }
25
- }
26
- class R extends v {
27
- heightData = new Float32Array();
28
- columnsRows = /* @__PURE__ */ new Map();
29
- build(e) {
30
- const o = e.tile ?? new d(1, 1), s = e.subdivisions ?? r, t = new u(o.x, 1, o.y), i = new z(t.x, t.z, s, s), h = new C(t.x, t.z, s, s), w = t.x / s, g = t.z / s, x = i.attributes.position.array, a = h.attributes.position.array, c = /* @__PURE__ */ new Map();
31
- for (let n = 0; n < a.length; n += 3) {
32
- let b = Math.floor(Math.abs(a[n] + t.x / 2) / w), m = Math.floor(Math.abs(a[n + 1] - t.z / 2) / g);
33
- const y = Math.random() * 4;
34
- a[n + 2] = y, x[n + 1] = y, c.get(m) || c.set(m, /* @__PURE__ */ new Map()), c.get(m).set(b, y);
35
- }
36
- return this.columnsRows = c, i;
37
- }
38
- postBuild() {
39
- const e = [];
40
- for (let o = 0; o <= r; ++o)
41
- for (let s = 0; s <= r; ++s) {
42
- const t = this.columnsRows.get(s);
43
- if (!t)
44
- continue;
45
- const i = t.get(o);
46
- e.push(i);
47
- }
48
- this.heightData = new Float32Array(e);
49
- }
50
- }
51
- class S extends P {
52
- createEntity(e) {
53
- return new f(e);
54
- }
55
- }
56
- const V = Symbol("Plane");
57
- class f extends D {
58
- static type = V;
59
- constructor(e) {
60
- super(), this.options = { ...p, ...e };
61
- }
62
- }
63
- async function U(...l) {
64
- return A({
65
- args: l,
66
- defaultConfig: p,
67
- EntityClass: f,
68
- BuilderClass: S,
69
- MeshBuilderClass: R,
70
- CollisionBuilderClass: G,
71
- entityType: f.type
72
- });
73
- }
74
- export {
75
- V as PLANE_TYPE,
76
- S as PlaneBuilder,
77
- G as PlaneCollisionBuilder,
78
- R as PlaneMeshBuilder,
79
- f as ZylemPlane,
80
- U as plane
81
- };
@@ -1,160 +0,0 @@
1
- import { Vector2 as f, Group as D, CanvasTexture as R, LinearFilter as x, SpriteMaterial as V, Sprite as Y, ClampToEdgeWrapping as T, ShaderMaterial as y, Color as S, Mesh as z, PlaneGeometry as B, Vector3 as W } from "three";
2
- import { GameEntity as I } from "./entity.js";
3
- import { EntityBuilder as X } from "./builder.js";
4
- import { createEntity as q } from "./create.js";
5
- import { DebugDelegate as U } from "./delegates/debug.js";
6
- const k = {
7
- position: void 0,
8
- width: 120,
9
- height: 48,
10
- fillColor: "#FFFFFF",
11
- strokeColor: null,
12
- strokeWidth: 0,
13
- radius: 0,
14
- padding: 0,
15
- stickToViewport: !0,
16
- screenPosition: new f(24, 24),
17
- zDistance: 1,
18
- anchor: new f(0, 0)
19
- };
20
- class G extends X {
21
- createEntity(t) {
22
- return new _(t);
23
- }
24
- }
25
- const O = Symbol("Rect");
26
- class _ extends I {
27
- static type = O;
28
- _sprite = null;
29
- _mesh = null;
30
- _texture = null;
31
- _canvas = null;
32
- _ctx = null;
33
- _cameraRef = null;
34
- _lastCanvasW = 0;
35
- _lastCanvasH = 0;
36
- constructor(t) {
37
- super(), this.options = { ...k, ...t }, this.group = new D(), this.createSprite(), this.lifeCycleDelegate = {
38
- setup: [this.rectSetup.bind(this)],
39
- update: [this.rectUpdate.bind(this)]
40
- };
41
- }
42
- createSprite() {
43
- this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), this._texture = new R(this._canvas), this._texture.minFilter = x, this._texture.magFilter = x;
44
- const t = new V({
45
- map: this._texture,
46
- transparent: !0,
47
- depthTest: !1,
48
- depthWrite: !1,
49
- alphaTest: 0.5
50
- });
51
- this._sprite = new Y(t), this.group?.add(this._sprite), this.redrawRect();
52
- }
53
- redrawRect() {
54
- if (!this._canvas || !this._ctx)
55
- return;
56
- const t = Math.max(2, Math.floor(this.options.width ?? 120)), e = Math.max(2, Math.floor(this.options.height ?? 48)), s = this.options.padding ?? 0, i = this.options.strokeWidth ?? 0, a = t + s * 2 + i, r = e + s * 2 + i, o = Math.max(2, a), n = Math.max(2, r), h = o !== this._lastCanvasW || n !== this._lastCanvasH;
57
- this._canvas.width = o, this._canvas.height = n, this._lastCanvasW = o, this._lastCanvasH = n, this._ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
58
- const u = Math.max(0, this.options.radius ?? 0), d = Math.floor(s + i / 2), m = Math.floor(s + i / 2), g = Math.floor(t), p = Math.floor(e);
59
- if (this._ctx.beginPath(), u > 0 ? this.roundedRectPath(this._ctx, d, m, g, p, u) : this._ctx.rect(d, m, g, p), this.options.fillColor && (this._ctx.fillStyle = this.toCssColor(this.options.fillColor), this._ctx.fill()), this.options.strokeColor && i > 0 && (this._ctx.lineWidth = i, this._ctx.strokeStyle = this.toCssColor(this.options.strokeColor), this._ctx.stroke()), this._texture) {
60
- if (h && (this._texture.dispose(), this._texture = new R(this._canvas), this._texture.minFilter = x, this._texture.magFilter = x, this._texture.wrapS = T, this._texture.wrapT = T, this._sprite && this._sprite.material instanceof y)) {
61
- const c = this._sprite.material;
62
- c.uniforms?.tDiffuse && (c.uniforms.tDiffuse.value = this._texture), c.uniforms?.iResolution && c.uniforms.iResolution.value.set(this._canvas.width, this._canvas.height, 1);
63
- }
64
- this._texture.image = this._canvas, this._texture.needsUpdate = !0, this._sprite && this._sprite.material && (this._sprite.material.map = this._texture, this._sprite.material.needsUpdate = !0);
65
- }
66
- }
67
- roundedRectPath(t, e, s, i, a, r) {
68
- const o = Math.min(r, Math.floor(Math.min(i, a) / 2));
69
- t.moveTo(e + o, s), t.lineTo(e + i - o, s), t.quadraticCurveTo(e + i, s, e + i, s + o), t.lineTo(e + i, s + a - o), t.quadraticCurveTo(e + i, s + a, e + i - o, s + a), t.lineTo(e + o, s + a), t.quadraticCurveTo(e, s + a, e, s + a - o), t.lineTo(e, s + o), t.quadraticCurveTo(e, s, e + o, s);
70
- }
71
- toCssColor(t) {
72
- return typeof t == "string" ? t : `#${(t instanceof S ? t : new S(t)).getHexString()}`;
73
- }
74
- rectSetup(t) {
75
- if (this._cameraRef = t.camera, this.options.stickToViewport && this._cameraRef && this._cameraRef.camera.add(this.group), this.materials?.length && this._sprite) {
76
- const e = this.materials[0];
77
- e instanceof y && (e.transparent = !0, e.depthTest = !1, e.depthWrite = !1, this._texture && (e.uniforms?.tDiffuse && (e.uniforms.tDiffuse.value = this._texture), e.uniforms?.iResolution && this._canvas && e.uniforms.iResolution.value.set(this._canvas.width, this._canvas.height, 1)), this._mesh = new z(new B(1, 1), e), this.group?.add(this._mesh), this._sprite.visible = !1);
78
- }
79
- }
80
- rectUpdate(t) {
81
- if (this._sprite) {
82
- if (this._cameraRef && this.options.bounds) {
83
- this._cameraRef.renderer.domElement;
84
- const e = this.computeScreenBoundsFromOptions(this.options.bounds);
85
- if (e) {
86
- const { x: s, y: i, width: a, height: r } = e, o = Math.max(2, Math.floor(a)), n = Math.max(2, Math.floor(r)), h = o !== (this.options.width ?? 0) || n !== (this.options.height ?? 0);
87
- this.options.screenPosition = new f(Math.floor(s), Math.floor(i)), this.options.width = o, this.options.height = n, this.options.anchor = new f(0, 0), h && this.redrawRect();
88
- }
89
- }
90
- this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
91
- }
92
- }
93
- updateStickyTransform() {
94
- if (!this._sprite || !this._cameraRef)
95
- return;
96
- const t = this._cameraRef.camera, e = this._cameraRef.renderer.domElement, s = e.clientWidth, i = e.clientHeight, a = (this.options.screenPosition ?? new f(24, 24)).x, r = (this.options.screenPosition ?? new f(24, 24)).y, o = Math.max(1e-3, this.options.zDistance ?? 1);
97
- let n = 1, h = 1;
98
- if (t.isPerspectiveCamera) {
99
- const l = t, w = Math.tan(l.fov * Math.PI / 180 / 2) * o;
100
- n = w * l.aspect, h = w;
101
- } else if (t.isOrthographicCamera) {
102
- const l = t;
103
- n = (l.right - l.left) / 2, h = (l.top - l.bottom) / 2;
104
- }
105
- const u = a / s * 2 - 1, d = 1 - r / i * 2, m = u * n, g = d * h;
106
- let p = 1, c = 1;
107
- if (this._canvas) {
108
- const w = h * 2 / i, C = this._canvas.height;
109
- c = Math.max(1e-4, C * w);
110
- const P = this._canvas.width / this._canvas.height;
111
- p = c * P, this._sprite.scale.set(p, c, 1), this._mesh && this._mesh.scale.set(p, c, 1);
112
- }
113
- const M = this.options.anchor ?? new f(0, 0), H = Math.min(100, Math.max(0, M.x)) / 100, b = Math.min(100, Math.max(0, M.y)) / 100, E = (0.5 - H) * p, F = (b - 0.5) * c;
114
- this.group?.position.set(m + E, g + F, -o);
115
- }
116
- worldToScreen(t) {
117
- if (!this._cameraRef)
118
- return { x: 0, y: 0 };
119
- const e = this._cameraRef.camera, s = this._cameraRef.renderer.domElement, i = t.clone().project(e), a = (i.x + 1) / 2 * s.clientWidth, r = (1 - i.y) / 2 * s.clientHeight;
120
- return { x: a, y: r };
121
- }
122
- computeScreenBoundsFromOptions(t) {
123
- if (!this._cameraRef)
124
- return null;
125
- if (this._cameraRef.renderer.domElement, t.screen)
126
- return { ...t.screen };
127
- if (t.world) {
128
- const { left: e, right: s, top: i, bottom: a, z: r = 0 } = t.world, o = this.worldToScreen(new W(e, i, r)), n = this.worldToScreen(new W(s, a, r)), h = Math.min(o.x, n.x), u = Math.min(o.y, n.y), d = Math.abs(n.x - o.x), m = Math.abs(n.y - o.y);
129
- return { x: h, y: u, width: d, height: m };
130
- }
131
- return null;
132
- }
133
- updateRect(t) {
134
- this.options = { ...this.options, ...t }, this.redrawRect(), this.options.stickToViewport && this._cameraRef && this.updateStickyTransform();
135
- }
136
- buildInfo() {
137
- return {
138
- ...new U(this).buildDebugInfo(),
139
- type: String(_.type),
140
- width: this.options.width ?? 0,
141
- height: this.options.height ?? 0,
142
- sticky: this.options.stickToViewport
143
- };
144
- }
145
- }
146
- async function K(...v) {
147
- return q({
148
- args: v,
149
- defaultConfig: { ...k },
150
- EntityClass: _,
151
- BuilderClass: G,
152
- entityType: _.type
153
- });
154
- }
155
- export {
156
- O as RECT_TYPE,
157
- G as RectBuilder,
158
- _ as ZylemRect,
159
- K as rect
160
- };
@@ -1,68 +0,0 @@
1
- import { ColliderDesc as l } from "@dimforge/rapier3d-compat";
2
- import { Color as n, Vector3 as a, SphereGeometry as d } from "three";
3
- import { GameEntity as u } from "./entity.js";
4
- import { EntityCollisionBuilder as c, EntityBuilder as p, EntityMeshBuilder as f } from "./builder.js";
5
- import { DebugDelegate as m } from "./delegates/debug.js";
6
- import { createEntity as y } from "./create.js";
7
- const o = {
8
- radius: 1,
9
- position: new a(0, 0, 0),
10
- collision: {
11
- static: !1
12
- },
13
- material: {
14
- color: new n("#ffffff"),
15
- shader: "standard"
16
- }
17
- };
18
- class h extends c {
19
- collider(e) {
20
- const t = e.radius ?? 1;
21
- return l.ball(t);
22
- }
23
- }
24
- class C extends f {
25
- build(e) {
26
- const t = e.radius ?? 1;
27
- return new d(t);
28
- }
29
- }
30
- class E extends p {
31
- createEntity(e) {
32
- return new r(e);
33
- }
34
- }
35
- const B = Symbol("Sphere");
36
- class r extends u {
37
- static type = B;
38
- constructor(e) {
39
- super(), this.options = { ...o, ...e };
40
- }
41
- buildInfo() {
42
- const t = new m(this).buildDebugInfo(), i = this.options.radius ?? 1;
43
- return {
44
- ...t,
45
- type: String(r.type),
46
- radius: i.toFixed(2)
47
- };
48
- }
49
- }
50
- async function I(...s) {
51
- return y({
52
- args: s,
53
- defaultConfig: o,
54
- EntityClass: r,
55
- BuilderClass: E,
56
- MeshBuilderClass: C,
57
- CollisionBuilderClass: h,
58
- entityType: r.type
59
- });
60
- }
61
- export {
62
- B as SPHERE_TYPE,
63
- E as SphereBuilder,
64
- h as SphereCollisionBuilder,
65
- C as SphereMeshBuilder,
66
- r as ZylemSphere,
67
- I as sphere
68
- };