@zylem/game-lib 0.3.16 → 0.4.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 (294) hide show
  1. package/README.md +39 -14
  2. package/dist/.vite/manifest.json +140 -64
  3. package/dist/api/actions.d.ts +5 -0
  4. package/dist/api/actions.d.ts.map +1 -0
  5. package/dist/api/behaviors.d.ts +4 -0
  6. package/dist/api/behaviors.d.ts.map +1 -0
  7. package/dist/api/camera.d.ts +4 -0
  8. package/dist/api/camera.d.ts.map +1 -0
  9. package/dist/api/core.d.ts +6 -0
  10. package/dist/api/core.d.ts.map +1 -0
  11. package/dist/api/entities.d.ts +9 -0
  12. package/dist/api/entities.d.ts.map +1 -0
  13. package/dist/api/main.d.ts +32 -0
  14. package/dist/api/main.d.ts.map +1 -0
  15. package/dist/api/stage.d.ts +7 -0
  16. package/dist/api/stage.d.ts.map +1 -0
  17. package/dist/core.js +4 -4
  18. package/dist/lib/actions/behaviors/actions.d.ts +1 -0
  19. package/dist/lib/actions/behaviors/actions.d.ts.map +1 -0
  20. package/dist/lib/actions/behaviors/behavior.d.ts +1 -0
  21. package/dist/lib/actions/behaviors/behavior.d.ts.map +1 -0
  22. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts +1 -0
  23. package/dist/lib/actions/behaviors/boundaries/boundary.d.ts.map +1 -0
  24. package/dist/lib/actions/behaviors/character-controller.d.ts +1 -0
  25. package/dist/lib/actions/behaviors/character-controller.d.ts.map +1 -0
  26. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts +1 -0
  27. package/dist/lib/actions/behaviors/debug/debug-collision.d.ts.map +1 -0
  28. package/dist/lib/actions/behaviors/debug/debug-update.d.ts +1 -0
  29. package/dist/lib/actions/behaviors/debug/debug-update.d.ts.map +1 -0
  30. package/dist/lib/actions/behaviors/debug/debug.d.ts +1 -0
  31. package/dist/lib/actions/behaviors/debug/debug.d.ts.map +1 -0
  32. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts +1 -0
  33. package/dist/lib/actions/behaviors/movement/movement-sequence-2d.d.ts.map +1 -0
  34. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts +1 -0
  35. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-collision.d.ts.map +1 -0
  36. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts +1 -0
  37. package/dist/lib/actions/behaviors/ricochet/ricochet-2d-in-bounds.d.ts.map +1 -0
  38. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts +1 -0
  39. package/dist/lib/actions/behaviors/ricochet/ricochet.d.ts.map +1 -0
  40. package/dist/lib/actions/behaviors/zylem-behavior.d.ts +1 -0
  41. package/dist/lib/actions/behaviors/zylem-behavior.d.ts.map +1 -0
  42. package/dist/lib/actions/capabilities/moveable.d.ts +1 -0
  43. package/dist/lib/actions/capabilities/moveable.d.ts.map +1 -0
  44. package/dist/lib/actions/capabilities/rotatable.d.ts +1 -0
  45. package/dist/lib/actions/capabilities/rotatable.d.ts.map +1 -0
  46. package/dist/lib/actions/capabilities/transformable.d.ts +1 -0
  47. package/dist/lib/actions/capabilities/transformable.d.ts.map +1 -0
  48. package/dist/lib/actions/global-change.d.ts +1 -0
  49. package/dist/lib/actions/global-change.d.ts.map +1 -0
  50. package/dist/lib/camera/camera.d.ts +1 -0
  51. package/dist/lib/camera/camera.d.ts.map +1 -0
  52. package/dist/lib/camera/fixed-2d.d.ts +1 -0
  53. package/dist/lib/camera/fixed-2d.d.ts.map +1 -0
  54. package/dist/lib/camera/perspective.d.ts +1 -0
  55. package/dist/lib/camera/perspective.d.ts.map +1 -0
  56. package/dist/lib/camera/third-person.d.ts +1 -0
  57. package/dist/lib/camera/third-person.d.ts.map +1 -0
  58. package/dist/lib/camera/zylem-camera.d.ts +27 -0
  59. package/dist/lib/camera/zylem-camera.d.ts.map +1 -0
  60. package/dist/lib/camera/zylem-camera.js +100 -37
  61. package/dist/lib/collision/collision-builder.d.ts +1 -0
  62. package/dist/lib/collision/collision-builder.d.ts.map +1 -0
  63. package/dist/lib/collision/collision-delegate.d.ts +1 -0
  64. package/dist/lib/collision/collision-delegate.d.ts.map +1 -0
  65. package/dist/lib/collision/collision-group.d.ts +1 -0
  66. package/dist/lib/collision/collision-group.d.ts.map +1 -0
  67. package/dist/lib/collision/collision-mask.d.ts +1 -0
  68. package/dist/lib/collision/collision-mask.d.ts.map +1 -0
  69. package/dist/lib/collision/collision.d.ts +1 -0
  70. package/dist/lib/collision/collision.d.ts.map +1 -0
  71. package/dist/lib/collision/utils.d.ts +1 -0
  72. package/dist/lib/collision/utils.d.ts.map +1 -0
  73. package/dist/lib/collision/world.d.ts +1 -0
  74. package/dist/lib/collision/world.d.ts.map +1 -0
  75. package/dist/lib/core/asset-manager.d.ts +1 -0
  76. package/dist/lib/core/asset-manager.d.ts.map +1 -0
  77. package/dist/lib/core/base-node-life-cycle.d.ts +15 -0
  78. package/dist/lib/core/base-node-life-cycle.d.ts.map +1 -0
  79. package/dist/lib/core/base-node.d.ts +7 -2
  80. package/dist/lib/core/base-node.d.ts.map +1 -0
  81. package/dist/lib/core/base-node.js +7 -3
  82. package/dist/lib/core/entity-asset-loader.d.ts +1 -0
  83. package/dist/lib/core/entity-asset-loader.d.ts.map +1 -0
  84. package/dist/lib/core/errors.d.ts +1 -0
  85. package/dist/lib/core/errors.d.ts.map +1 -0
  86. package/dist/lib/core/flags.d.ts +1 -0
  87. package/dist/lib/core/flags.d.ts.map +1 -0
  88. package/dist/lib/core/index.d.ts +1 -0
  89. package/dist/lib/core/index.d.ts.map +1 -0
  90. package/dist/lib/core/lazy-loader.d.ts +3 -2
  91. package/dist/lib/core/lazy-loader.d.ts.map +1 -0
  92. package/dist/lib/core/lifecycle-base.d.ts +1 -0
  93. package/dist/lib/core/lifecycle-base.d.ts.map +1 -0
  94. package/dist/lib/core/preset-shader.d.ts +1 -0
  95. package/dist/lib/core/preset-shader.d.ts.map +1 -0
  96. package/dist/lib/core/three-addons/Timer.d.ts +1 -0
  97. package/dist/lib/core/three-addons/Timer.d.ts.map +1 -0
  98. package/dist/lib/core/utility/nodes.d.ts +13 -0
  99. package/dist/lib/core/utility/nodes.d.ts.map +1 -0
  100. package/dist/lib/core/utility/nodes.js +31 -0
  101. package/dist/lib/core/utility/strings.d.ts +3 -0
  102. package/dist/lib/core/utility/strings.d.ts.map +1 -0
  103. package/dist/lib/core/utility/strings.js +14 -0
  104. package/dist/lib/core/{utility.d.ts → utility/vector.d.ts} +1 -2
  105. package/dist/lib/core/utility/vector.d.ts.map +1 -0
  106. package/dist/lib/core/utility/vector.js +8 -0
  107. package/dist/lib/core/vector.d.ts +1 -0
  108. package/dist/lib/core/vector.d.ts.map +1 -0
  109. package/dist/lib/core/vessel.d.ts +4 -1
  110. package/dist/lib/core/vessel.d.ts.map +1 -0
  111. package/dist/lib/core/vessel.js +13 -9
  112. package/dist/lib/debug/console/console-state.d.ts +1 -0
  113. package/dist/lib/debug/console/console-state.d.ts.map +1 -0
  114. package/dist/lib/debug/console/console-store.d.ts +1 -0
  115. package/dist/lib/debug/console/console-store.d.ts.map +1 -0
  116. package/dist/lib/debug/debug-state.d.ts +1 -0
  117. package/dist/lib/debug/debug-state.d.ts.map +1 -0
  118. package/dist/lib/debug/debug-store.d.ts +1 -0
  119. package/dist/lib/debug/debug-store.d.ts.map +1 -0
  120. package/dist/lib/debug/state-based-debug-loader.d.ts +1 -0
  121. package/dist/lib/debug/state-based-debug-loader.d.ts.map +1 -0
  122. package/dist/lib/device/aspect-ratio.d.ts +38 -0
  123. package/dist/lib/device/aspect-ratio.d.ts.map +1 -0
  124. package/dist/lib/device/aspect-ratio.js +44 -0
  125. package/dist/lib/device/desktop.d.ts +1 -0
  126. package/dist/lib/device/desktop.d.ts.map +1 -0
  127. package/dist/lib/device/mobile.d.ts +1 -0
  128. package/dist/lib/device/mobile.d.ts.map +1 -0
  129. package/dist/lib/device/tablet.d.ts +1 -0
  130. package/dist/lib/device/tablet.d.ts.map +1 -0
  131. package/dist/lib/entities/actor.d.ts +1 -0
  132. package/dist/lib/entities/actor.d.ts.map +1 -0
  133. package/dist/lib/entities/box.d.ts +1 -0
  134. package/dist/lib/entities/box.d.ts.map +1 -0
  135. package/dist/lib/entities/builder.d.ts +1 -0
  136. package/dist/lib/entities/builder.d.ts.map +1 -0
  137. package/dist/lib/entities/create.d.ts +1 -0
  138. package/dist/lib/entities/create.d.ts.map +1 -0
  139. package/dist/lib/entities/delegates/animation.d.ts +1 -0
  140. package/dist/lib/entities/delegates/animation.d.ts.map +1 -0
  141. package/dist/lib/entities/delegates/debug.d.ts +1 -0
  142. package/dist/lib/entities/delegates/debug.d.ts.map +1 -0
  143. package/dist/lib/entities/delegates/loader.d.ts +1 -0
  144. package/dist/lib/entities/delegates/loader.d.ts.map +1 -0
  145. package/dist/lib/entities/destroy.d.ts +1 -0
  146. package/dist/lib/entities/destroy.d.ts.map +1 -0
  147. package/dist/lib/entities/entity.d.ts +4 -1
  148. package/dist/lib/entities/entity.d.ts.map +1 -0
  149. package/dist/lib/entities/entity.js +9 -5
  150. package/dist/lib/entities/index.d.ts +1 -0
  151. package/dist/lib/entities/index.d.ts.map +1 -0
  152. package/dist/lib/entities/plane.d.ts +1 -0
  153. package/dist/lib/entities/plane.d.ts.map +1 -0
  154. package/dist/lib/entities/rect.d.ts +1 -0
  155. package/dist/lib/entities/rect.d.ts.map +1 -0
  156. package/dist/lib/entities/sphere.d.ts +1 -0
  157. package/dist/lib/entities/sphere.d.ts.map +1 -0
  158. package/dist/lib/entities/sprite.d.ts +1 -0
  159. package/dist/lib/entities/sprite.d.ts.map +1 -0
  160. package/dist/lib/entities/text.d.ts +8 -0
  161. package/dist/lib/entities/text.d.ts.map +1 -0
  162. package/dist/lib/entities/text.js +77 -48
  163. package/dist/lib/entities/zone.d.ts +1 -0
  164. package/dist/lib/entities/zone.d.ts.map +1 -0
  165. package/dist/lib/game/game-blueprint.d.ts +38 -0
  166. package/dist/lib/game/game-blueprint.d.ts.map +1 -0
  167. package/dist/lib/game/game-canvas.d.ts +35 -0
  168. package/dist/lib/game/game-canvas.d.ts.map +1 -0
  169. package/dist/lib/game/game-canvas.js +57 -0
  170. package/dist/lib/game/game-config.d.ts +63 -0
  171. package/dist/lib/game/game-config.d.ts.map +1 -0
  172. package/dist/lib/game/game-config.js +79 -0
  173. package/dist/lib/game/game-default.d.ts +19 -0
  174. package/dist/lib/game/game-default.d.ts.map +1 -0
  175. package/dist/lib/game/game-default.js +24 -0
  176. package/dist/lib/game/game-interfaces.d.ts +3 -2
  177. package/dist/lib/game/game-interfaces.d.ts.map +1 -0
  178. package/dist/lib/game/game-retro-resolutions.d.ts +24 -0
  179. package/dist/lib/game/game-retro-resolutions.d.ts.map +1 -0
  180. package/dist/lib/game/game-retro-resolutions.js +81 -0
  181. package/dist/lib/game/game-state.d.ts +6 -5
  182. package/dist/lib/game/game-state.d.ts.map +1 -0
  183. package/dist/lib/game/game.d.ts +8 -12
  184. package/dist/lib/game/game.d.ts.map +1 -0
  185. package/dist/lib/game/game.js +44 -92
  186. package/dist/lib/game/zylem-game.d.ts +15 -3
  187. package/dist/lib/game/zylem-game.d.ts.map +1 -0
  188. package/dist/lib/game/zylem-game.js +67 -33
  189. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts +1 -0
  190. package/dist/lib/graphics/geometries/XZPlaneGeometry.d.ts.map +1 -0
  191. package/dist/lib/graphics/material.d.ts +2 -1
  192. package/dist/lib/graphics/material.d.ts.map +1 -0
  193. package/dist/lib/graphics/material.js +1 -1
  194. package/dist/lib/graphics/mesh.d.ts +1 -0
  195. package/dist/lib/graphics/mesh.d.ts.map +1 -0
  196. package/dist/lib/graphics/render-pass.d.ts +1 -0
  197. package/dist/lib/graphics/render-pass.d.ts.map +1 -0
  198. package/dist/lib/graphics/zylem-scene.d.ts +8 -7
  199. package/dist/lib/graphics/zylem-scene.d.ts.map +1 -0
  200. package/dist/lib/graphics/zylem-scene.js +26 -40
  201. package/dist/lib/input/gamepad-provider.d.ts +1 -0
  202. package/dist/lib/input/gamepad-provider.d.ts.map +1 -0
  203. package/dist/lib/input/input-manager.d.ts +1 -0
  204. package/dist/lib/input/input-manager.d.ts.map +1 -0
  205. package/dist/lib/input/input-provider.d.ts +1 -0
  206. package/dist/lib/input/input-provider.d.ts.map +1 -0
  207. package/dist/lib/input/input.d.ts +1 -0
  208. package/dist/lib/input/input.d.ts.map +1 -0
  209. package/dist/lib/input/keyboard-provider.d.ts +1 -0
  210. package/dist/lib/input/keyboard-provider.d.ts.map +1 -0
  211. package/dist/lib/interfaces/entity.d.ts +1 -0
  212. package/dist/lib/interfaces/entity.d.ts.map +1 -0
  213. package/dist/lib/sounds/index.d.ts +1 -0
  214. package/dist/lib/sounds/index.d.ts.map +1 -0
  215. package/dist/lib/sounds/ping-pong-sound.d.ts +1 -0
  216. package/dist/lib/sounds/ping-pong-sound.d.ts.map +1 -0
  217. package/dist/lib/sounds/ricochet-sound.d.ts +1 -0
  218. package/dist/lib/sounds/ricochet-sound.d.ts.map +1 -0
  219. package/dist/lib/stage/debug-entity-cursor.d.ts +1 -0
  220. package/dist/lib/stage/debug-entity-cursor.d.ts.map +1 -0
  221. package/dist/lib/stage/entity-spawner.d.ts +1 -0
  222. package/dist/lib/stage/entity-spawner.d.ts.map +1 -0
  223. package/dist/lib/stage/stage-blueprint.d.ts +45 -0
  224. package/dist/lib/stage/stage-blueprint.d.ts.map +1 -0
  225. package/dist/lib/stage/stage-blueprint.js +56 -0
  226. package/dist/lib/stage/stage-camera-debug-delegate.d.ts +14 -0
  227. package/dist/lib/stage/stage-camera-debug-delegate.d.ts.map +1 -0
  228. package/dist/lib/stage/stage-debug-delegate.d.ts +1 -0
  229. package/dist/lib/stage/stage-debug-delegate.d.ts.map +1 -0
  230. package/dist/lib/stage/stage-default.d.ts +10 -0
  231. package/dist/lib/stage/stage-default.d.ts.map +1 -0
  232. package/dist/lib/stage/stage-default.js +42 -0
  233. package/dist/lib/stage/stage-state.d.ts +1 -0
  234. package/dist/lib/stage/stage-state.d.ts.map +1 -0
  235. package/dist/lib/stage/stage.d.ts +4 -3
  236. package/dist/lib/stage/stage.d.ts.map +1 -0
  237. package/dist/lib/stage/stage.js +27 -25
  238. package/dist/lib/stage/zylem-stage.d.ts +8 -4
  239. package/dist/lib/stage/zylem-stage.d.ts.map +1 -0
  240. package/dist/lib/stage/zylem-stage.js +36 -46
  241. package/dist/lib/systems/test-system.d.ts +1 -0
  242. package/dist/lib/systems/test-system.d.ts.map +1 -0
  243. package/dist/lib/systems/transformable.system.d.ts +1 -0
  244. package/dist/lib/systems/transformable.system.d.ts.map +1 -0
  245. package/dist/lib/types/entity-types.d.ts +1 -0
  246. package/dist/lib/types/entity-types.d.ts.map +1 -0
  247. package/dist/lib/types/index.d.ts +1 -0
  248. package/dist/lib/types/index.d.ts.map +1 -0
  249. package/dist/lib/types/stage-types.d.ts +1 -0
  250. package/dist/lib/types/stage-types.d.ts.map +1 -0
  251. package/dist/lib/ui/Debug.d.ts +1 -0
  252. package/dist/lib/ui/Debug.d.ts.map +1 -0
  253. package/dist/lib/ui/console/Console.d.ts +1 -0
  254. package/dist/lib/ui/console/Console.d.ts.map +1 -0
  255. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts +1 -0
  256. package/dist/lib/ui/debug-panel/AccordionMenu.d.ts.map +1 -0
  257. package/dist/lib/ui/debug-panel/Menu.d.ts +1 -0
  258. package/dist/lib/ui/debug-panel/Menu.d.ts.map +1 -0
  259. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts +1 -0
  260. package/dist/lib/ui/debug-panel/sections/EntitiesSection.d.ts.map +1 -0
  261. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts +1 -0
  262. package/dist/lib/ui/debug-panel/sections/GameSection.d.ts.map +1 -0
  263. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts +1 -0
  264. package/dist/lib/ui/debug-panel/sections/StagesSection.d.ts.map +1 -0
  265. package/dist/lib/ui/debug-panel/sections/all.d.ts +1 -0
  266. package/dist/lib/ui/debug-panel/sections/all.d.ts.map +1 -0
  267. package/dist/lib/ui/toolbar/Toolbar.d.ts +1 -0
  268. package/dist/lib/ui/toolbar/Toolbar.d.ts.map +1 -0
  269. package/dist/main.js +52 -50
  270. package/dist/stage.js +20 -4
  271. package/dist/tests/unit/collision/collision.spec.d.ts +2 -0
  272. package/dist/tests/unit/collision/collision.spec.d.ts.map +1 -0
  273. package/dist/tests/unit/core/game.spec.d.ts +2 -0
  274. package/dist/tests/unit/core/game.spec.d.ts.map +1 -0
  275. package/dist/tests/unit/core/stage.spec.d.ts +2 -0
  276. package/dist/tests/unit/core/stage.spec.d.ts.map +1 -0
  277. package/dist/tests/unit/core/vessel.spec.d.ts +2 -0
  278. package/dist/tests/unit/core/vessel.spec.d.ts.map +1 -0
  279. package/dist/tests/unit/stage/stage-blueprint.spec.d.ts +2 -0
  280. package/dist/tests/unit/stage/stage-blueprint.spec.d.ts.map +1 -0
  281. package/package.json +11 -9
  282. package/dist/actions.d.ts +0 -4
  283. package/dist/behaviors.d.ts +0 -3
  284. package/dist/camera.d.ts +0 -3
  285. package/dist/core.d.ts +0 -5
  286. package/dist/entities.d.ts +0 -8
  287. package/dist/lib/core/game-canvas.d.ts +0 -4
  288. package/dist/lib/core/utility.js +0 -20
  289. package/dist/main.d.ts +0 -30
  290. package/dist/stage.d.ts +0 -3
  291. package/dist/tests/collision/collision.spec.d.ts +0 -1
  292. package/dist/tests/core/game.spec.d.ts +0 -1
  293. package/dist/tests/core/stage.spec.d.ts +0 -1
  294. package/dist/tests/core/vessel.spec.d.ts +0 -1
@@ -0,0 +1,24 @@
1
+ export type RetroResolution = {
2
+ key: string;
3
+ width: number;
4
+ height: number;
5
+ notes?: string;
6
+ };
7
+ export type RetroPreset = {
8
+ displayAspect: number;
9
+ resolutions: RetroResolution[];
10
+ };
11
+ /**
12
+ * Retro and console display presets.
13
+ * displayAspect represents the intended display aspect (letterboxing target),
14
+ * not necessarily the raw pixel aspect of internal buffers.
15
+ */
16
+ export declare const RetroPresets: Record<string, RetroPreset>;
17
+ export type RetroPresetKey = keyof typeof RetroPresets;
18
+ export declare function getDisplayAspect(preset: RetroPresetKey): number;
19
+ export declare function getPresetResolution(preset: RetroPresetKey, key?: string): RetroResolution | undefined;
20
+ export declare function parseResolution(text: string): {
21
+ width: number;
22
+ height: number;
23
+ } | null;
24
+ //# sourceMappingURL=game-retro-resolutions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-retro-resolutions.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-retro-resolutions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7F,MAAM,MAAM,WAAW,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAuDpD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,YAAY,CAAC;AAEvD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAE/D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAKrG;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAStF"}
@@ -0,0 +1,81 @@
1
+ const n = {
2
+ NES: {
3
+ displayAspect: 1.3333333333333333,
4
+ resolutions: [
5
+ { key: "256x240", width: 256, height: 240, notes: "Standard NTSC; effective 240p." }
6
+ ]
7
+ },
8
+ SNES: {
9
+ displayAspect: 1.3333333333333333,
10
+ resolutions: [
11
+ { key: "256x224", width: 256, height: 224, notes: "Common 240p-equivalent mode." },
12
+ { key: "512x448", width: 512, height: 448, notes: "Hi-res interlaced (480i)." }
13
+ ]
14
+ },
15
+ N64: {
16
+ displayAspect: 1.3333333333333333,
17
+ resolutions: [
18
+ { key: "320x240", width: 320, height: 240, notes: "Common 240p mode." },
19
+ { key: "640x480", width: 640, height: 480, notes: "Higher resolution (480i)." }
20
+ ]
21
+ },
22
+ PS1: {
23
+ displayAspect: 1.3333333333333333,
24
+ resolutions: [
25
+ { key: "320x240", width: 320, height: 240, notes: "Progressive 240p common." },
26
+ { key: "640x480", width: 640, height: 480, notes: "Interlaced 480i for higher detail." }
27
+ ]
28
+ },
29
+ PS2: {
30
+ displayAspect: 1.3333333333333333,
31
+ resolutions: [
32
+ { key: "640x480", width: 640, height: 480, notes: "480i/480p baseline." },
33
+ { key: "720x480", width: 720, height: 480, notes: "480p (widescreen capable in some titles)." },
34
+ { key: "1280x720", width: 1280, height: 720, notes: "720p (select titles)." }
35
+ ]
36
+ },
37
+ PS5: {
38
+ displayAspect: 1.7777777777777777,
39
+ resolutions: [
40
+ { key: "720x480", width: 720, height: 480, notes: "Legacy compatibility." },
41
+ { key: "1280x720", width: 1280, height: 720, notes: "720p." },
42
+ { key: "1920x1080", width: 1920, height: 1080, notes: "1080p." },
43
+ { key: "2560x1440", width: 2560, height: 1440, notes: "1440p." },
44
+ { key: "3840x2160", width: 3840, height: 2160, notes: "4K (up to 120Hz)." },
45
+ { key: "7680x4320", width: 7680, height: 4320, notes: "8K (limited)." }
46
+ ]
47
+ },
48
+ XboxOne: {
49
+ displayAspect: 1.7777777777777777,
50
+ resolutions: [
51
+ { key: "1280x720", width: 1280, height: 720, notes: "720p (original)." },
52
+ { key: "1920x1080", width: 1920, height: 1080, notes: "1080p (original)." },
53
+ { key: "3840x2160", width: 3840, height: 2160, notes: "4K UHD (S/X models)." }
54
+ ]
55
+ }
56
+ };
57
+ function h(e) {
58
+ return n[e].displayAspect;
59
+ }
60
+ function r(e, o) {
61
+ const t = n[e]?.resolutions || [];
62
+ if (!o)
63
+ return t[0];
64
+ const i = o.toLowerCase().replace(/\s+/g, "").replace("×", "x");
65
+ return t.find((s) => s.key.toLowerCase() === i);
66
+ }
67
+ function l(e) {
68
+ if (!e)
69
+ return null;
70
+ const t = String(e).toLowerCase().trim().replace(/\s+/g, "").replace("×", "x").match(/^(\d+)x(\d+)$/);
71
+ if (!t)
72
+ return null;
73
+ const i = parseInt(t[1], 10), s = parseInt(t[2], 10);
74
+ return !Number.isFinite(i) || !Number.isFinite(s) ? null : { width: i, height: s };
75
+ }
76
+ export {
77
+ n as RetroPresets,
78
+ h as getDisplayAspect,
79
+ r as getPresetResolution,
80
+ l as parseResolution
81
+ };
@@ -1,10 +1,11 @@
1
- import { BasicTypes, GlobalVariablesType } from './game-interfaces';
1
+ import { BaseGlobals } from './game-interfaces';
2
2
  declare const state: {
3
3
  id: string;
4
- globals: GlobalVariablesType;
4
+ globals: BaseGlobals;
5
5
  time: number;
6
6
  };
7
- export declare function setGlobalState<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType, K extends keyof TGlobals = keyof TGlobals>(key: K, value: TGlobals[K]): void;
8
- export declare function getGlobalState<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType>(): TGlobals;
9
- export declare function getGlobalState<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType, K extends keyof TGlobals = keyof TGlobals>(key: K): TGlobals[K];
7
+ export declare function setGlobalState<TGlobals extends BaseGlobals, K extends keyof TGlobals = keyof TGlobals>(key: K, value: TGlobals[K]): void;
8
+ export declare function getGlobalState<TGlobals extends BaseGlobals>(): TGlobals;
9
+ export declare function getGlobalState<TGlobals extends BaseGlobals, K extends keyof TGlobals = keyof TGlobals>(key: K): TGlobals[K];
10
10
  export { state };
11
+ //# sourceMappingURL=game-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game-state.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game-state.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAE5D,QAAA,MAAM,KAAK;;aAEK,WAAW;;CAEzB,CAAC;AAEH,wBAAgB,cAAc,CAC7B,QAAQ,SAAS,WAAW,EAC5B,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,QAAQ,EACxC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAMpC,wBAAgB,cAAc,CAAC,QAAQ,SAAS,WAAW,KAAK,QAAQ,CAAC;AAEzE,wBAAgB,cAAc,CAC7B,QAAQ,SAAS,WAAW,EAC5B,CAAC,SAAS,MAAM,QAAQ,GAAG,MAAM,QAAQ,EACxC,GAAG,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AASvB,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -1,20 +1,18 @@
1
- import { BaseNode } from '../core/base-node';
2
1
  import { ZylemGame } from './zylem-game';
3
- import { Stage } from '../stage/stage';
4
2
  import { DestroyFunction, IGame, SetupFunction, UpdateFunction } from '../core/base-node-life-cycle';
5
- import { GameEntityLifeCycle } from '../entities/entity';
6
- import { BasicTypes, GlobalVariablesType, ZylemGameConfig } from './game-interfaces';
7
- export declare class Game<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType> implements IGame<TGlobals> {
8
- gameRef: ZylemGame<TGlobals> | null;
9
- options: GameOptions<TGlobals>;
3
+ import { BaseGlobals } from './game-interfaces';
4
+ import { GameOptions } from '../core/utility/nodes';
5
+ export declare class Game<TGlobals extends BaseGlobals> implements IGame<TGlobals> {
6
+ private wrappedGame;
10
7
  private pendingGlobalChangeHandlers;
8
+ options: GameOptions<TGlobals>;
11
9
  update: UpdateFunction<ZylemGame<TGlobals>, TGlobals>;
12
10
  setup: SetupFunction<ZylemGame<TGlobals>, TGlobals>;
13
11
  destroy: DestroyFunction<ZylemGame<TGlobals>, TGlobals>;
14
12
  refErrorMessage: string;
15
13
  constructor(options: GameOptions<TGlobals>);
16
14
  start(): Promise<this>;
17
- load(): Promise<ZylemGame<TGlobals>>;
15
+ private load;
18
16
  setOverrides(): void;
19
17
  pause(): Promise<void>;
20
18
  resume(): Promise<void>;
@@ -23,12 +21,10 @@ export declare class Game<TGlobals extends Record<string, BasicTypes> = GlobalVa
23
21
  previousStage(): Promise<void>;
24
22
  goToStage(): Promise<void>;
25
23
  end(): Promise<void>;
26
- add(...inputs: Array<Stage | Promise<any> | (() => Stage | Promise<any>)>): this;
27
24
  getGlobal<K extends keyof TGlobals>(key: K): TGlobals[K];
28
25
  setGlobal<K extends keyof TGlobals>(key: K, value: TGlobals[K]): void;
29
26
  onGlobalChange<K extends keyof TGlobals>(key: K, callback: (value: TGlobals[K]) => void): void;
30
27
  }
31
- type GameOptions<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType> = Array<ZylemGameConfig<Stage, Game<TGlobals>, TGlobals> | Stage | GameEntityLifeCycle | BaseNode>;
32
28
  /**
33
29
  * create a new game
34
30
  * @param options GameOptions - Array of IGameOptions, Stage, GameEntity, or BaseNode objects
@@ -37,5 +33,5 @@ type GameOptions<TGlobals extends Record<string, BasicTypes> = GlobalVariablesTy
37
33
  * @param options.stages Array of stage objects (when using IGameOptions)
38
34
  * @returns Game
39
35
  */
40
- export declare function game<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType>(...options: GameOptions<TGlobals>): Game<TGlobals>;
41
- export {};
36
+ export declare function createGame<TGlobals extends BaseGlobals>(...options: GameOptions<TGlobals>): Game<TGlobals>;
37
+ //# sourceMappingURL=game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../../src/lib/game/game.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,C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Q,SAAS,WAAW,EAAE,GAAG,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAE1G"}
@@ -1,40 +1,13 @@
1
- import { BaseNode as h } from "../core/base-node.js";
2
- import { ZylemGame as c } from "./zylem-game.js";
3
- import { Stage as o, stage as l } from "../stage/stage.js";
4
- import { setPaused as r } from "../debug/debug-state.js";
5
- import { GameEntity as u } from "../entities/entity.js";
6
- import { getGlobalState as m, setGlobalState as p } from "./game-state.js";
7
- const f = {
8
- id: "zylem",
9
- globals: {},
10
- stages: [
11
- l()
12
- ]
13
- };
14
- function d(n) {
15
- let e = { ...f };
16
- const t = [], s = [], a = [];
17
- return Object.values(n).forEach((i) => {
18
- if (i instanceof o)
19
- s.push(i);
20
- else if (i instanceof u)
21
- a.push(i);
22
- else if (i instanceof h)
23
- a.push(i);
24
- else if (i.constructor.name === "Object" && typeof i == "object") {
25
- const g = Object.assign(f, { ...i });
26
- t.push(g);
27
- }
28
- }), t.forEach((i) => {
29
- e = Object.assign(e, { ...i });
30
- }), s.forEach((i) => {
31
- i.addEntities(a);
32
- }), s.length ? e.stages = s : e.stages[0].addEntities(a), e;
33
- }
34
- class R {
35
- gameRef = null;
36
- options;
1
+ import { ZylemGame as n } from "./zylem-game.js";
2
+ import { setPaused as o } from "../debug/debug-state.js";
3
+ import { getGlobalState as i, setGlobalState as p } from "./game-state.js";
4
+ import { hasStages as d, convertNodes as l } from "../core/utility/nodes.js";
5
+ import { resolveGameConfig as h } from "./game-config.js";
6
+ import { stage as g } from "../stage/stage.js";
7
+ class m {
8
+ wrappedGame = null;
37
9
  pendingGlobalChangeHandlers = [];
10
+ options;
38
11
  update = () => {
39
12
  };
40
13
  setup = () => {
@@ -43,115 +16,94 @@ class R {
43
16
  };
44
17
  refErrorMessage = "lost reference to game";
45
18
  constructor(e) {
46
- this.options = e;
19
+ this.options = e, d(e) || this.options.push(g());
47
20
  }
48
21
  async start() {
49
22
  const e = await this.load();
50
- return this.gameRef = e, this.setOverrides(), e.start(), this;
23
+ return this.wrappedGame = e, this.setOverrides(), e.start(), this;
51
24
  }
52
25
  async load() {
53
26
  console.log("loading game", this.options);
54
- const e = d(this.options), t = new c(e, this);
27
+ const e = await l(this.options), a = h(e), t = new n({
28
+ ...e,
29
+ ...a
30
+ }, this);
55
31
  return await t.loadStage(e.stages[0]), t;
56
32
  }
57
33
  setOverrides() {
58
- if (!this.gameRef) {
34
+ if (!this.wrappedGame) {
59
35
  console.error(this.refErrorMessage);
60
36
  return;
61
37
  }
62
- if (this.gameRef.customSetup = this.setup, this.gameRef.customUpdate = this.update, this.gameRef.customDestroy = this.destroy, this.pendingGlobalChangeHandlers.length) {
63
- for (const { key: e, callback: t } of this.pendingGlobalChangeHandlers)
64
- this.gameRef.onGlobalChange(e, t);
38
+ if (this.wrappedGame.customSetup = this.setup, this.wrappedGame.customUpdate = this.update, this.wrappedGame.customDestroy = this.destroy, this.pendingGlobalChangeHandlers.length) {
39
+ for (const { key: e, callback: a } of this.pendingGlobalChangeHandlers)
40
+ this.wrappedGame.onGlobalChange(e, a);
65
41
  this.pendingGlobalChangeHandlers = [];
66
42
  }
67
43
  }
68
44
  async pause() {
69
- r(!0);
45
+ o(!0);
70
46
  }
71
47
  async resume() {
72
- r(!1), this.gameRef && (this.gameRef.previousTimeStamp = 0, this.gameRef.timer.reset());
48
+ o(!1), this.wrappedGame && (this.wrappedGame.previousTimeStamp = 0, this.wrappedGame.timer.reset());
73
49
  }
74
50
  async reset() {
75
- if (!this.gameRef) {
51
+ if (!this.wrappedGame) {
76
52
  console.error(this.refErrorMessage);
77
53
  return;
78
54
  }
79
- await this.gameRef.loadStage(this.gameRef.stages[0]);
55
+ await this.wrappedGame.loadStage(this.wrappedGame.stages[0]);
80
56
  }
81
57
  async nextStage() {
82
- if (!this.gameRef) {
58
+ if (!this.wrappedGame) {
83
59
  console.error(this.refErrorMessage);
84
60
  return;
85
61
  }
86
- const e = this.gameRef.currentStageId, t = this.gameRef.stages.findIndex((a) => a.stageRef.uuid === e), s = this.gameRef.stages[t + 1];
87
- if (!s) {
62
+ const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a + 1];
63
+ if (!t) {
88
64
  console.error("next stage called on last stage");
89
65
  return;
90
66
  }
91
- await this.gameRef.loadStage(s);
67
+ await this.wrappedGame.loadStage(t);
92
68
  }
93
69
  async previousStage() {
94
- if (!this.gameRef) {
70
+ if (!this.wrappedGame) {
95
71
  console.error(this.refErrorMessage);
96
72
  return;
97
73
  }
98
- const e = this.gameRef.currentStageId, t = this.gameRef.stages.findIndex((a) => a.stageRef.uuid === e), s = this.gameRef.stages[t - 1];
99
- if (!s) {
74
+ const e = this.wrappedGame.currentStageId, a = this.wrappedGame.stages.findIndex((r) => r.wrappedStage.uuid === e), t = this.wrappedGame.stages[a - 1];
75
+ if (!t) {
100
76
  console.error("previous stage called on first stage");
101
77
  return;
102
78
  }
103
- await this.gameRef.loadStage(s);
79
+ await this.wrappedGame.loadStage(t);
104
80
  }
105
81
  async goToStage() {
106
82
  }
107
83
  async end() {
108
84
  }
109
- add(...e) {
110
- for (const t of e)
111
- if (t) {
112
- if (t instanceof o) {
113
- this.gameRef ? (this.gameRef.stages.push(t), this.gameRef.stageMap.set(t.stageRef.uuid, t)) : this.options.push(t);
114
- continue;
115
- }
116
- if (typeof t == "function") {
117
- try {
118
- const s = t();
119
- s instanceof o ? this.gameRef ? (this.gameRef.stages.push(s), this.gameRef.stageMap.set(s.stageRef.uuid, s)) : this.options.push(s) : s && typeof s.then == "function" && s.then((a) => {
120
- a instanceof o && (this.gameRef ? (this.gameRef.stages.push(a), this.gameRef.stageMap.set(a.stageRef.uuid, a)) : this.options.push(a));
121
- }).catch((a) => console.error("Failed to add async stage", a));
122
- } catch (s) {
123
- console.error("Error executing stage factory", s);
124
- }
125
- continue;
126
- }
127
- t && typeof t.then == "function" && t.then((s) => {
128
- s instanceof o && (this.gameRef ? (this.gameRef.stages.push(s), this.gameRef.stageMap.set(s.stageRef.uuid, s)) : this.options.push(s));
129
- }).catch((s) => console.error("Failed to add async stage", s));
130
- }
131
- return this;
132
- }
133
85
  getGlobal(e) {
134
- return this.gameRef ? this.gameRef.getGlobal(e) : m(e);
86
+ return this.wrappedGame ? this.wrappedGame.getGlobal(e) : i(e);
135
87
  }
136
- setGlobal(e, t) {
137
- if (this.gameRef) {
138
- this.gameRef.setGlobal(e, t);
88
+ setGlobal(e, a) {
89
+ if (this.wrappedGame) {
90
+ this.wrappedGame.setGlobal(e, a);
139
91
  return;
140
92
  }
141
- p(e, t);
93
+ p(e, a);
142
94
  }
143
- onGlobalChange(e, t) {
144
- if (this.gameRef) {
145
- this.gameRef.onGlobalChange(e, t);
95
+ onGlobalChange(e, a) {
96
+ if (this.wrappedGame) {
97
+ this.wrappedGame.onGlobalChange(e, a);
146
98
  return;
147
99
  }
148
- this.pendingGlobalChangeHandlers.push({ key: e, callback: t });
100
+ this.pendingGlobalChangeHandlers.push({ key: e, callback: a });
149
101
  }
150
102
  }
151
- function M(...n) {
152
- return new R(n);
103
+ function b(...s) {
104
+ return new m(s);
153
105
  }
154
106
  export {
155
- R as Game,
156
- M as game
107
+ m as Game,
108
+ b as createGame
157
109
  };
@@ -4,8 +4,12 @@ import { InputManager } from '../input/input-manager';
4
4
  import { Timer } from '../core/three-addons/Timer';
5
5
  import { ZylemCamera } from '~/lib/camera/zylem-camera';
6
6
  import { Stage } from '../stage/stage';
7
- import { BasicTypes, GlobalVariablesType, ZylemGameConfig } from './game-interfaces';
8
- export declare class ZylemGame<TGlobals extends Record<string, BasicTypes> = GlobalVariablesType> {
7
+ import { BaseGlobals, ZylemGameConfig } from './game-interfaces';
8
+ import { GameConfig } from './game-config';
9
+ import { AspectRatioDelegate } from '../device/aspect-ratio';
10
+ import { GameCanvas } from './game-canvas';
11
+ type ZylemGameOptions<TGlobals extends BaseGlobals> = ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals> & Partial<GameConfig>;
12
+ export declare class ZylemGame<TGlobals extends BaseGlobals> {
9
13
  id: string;
10
14
  initialGlobals: TGlobals;
11
15
  customSetup: ((params: SetupContext<ZylemGame<TGlobals>, TGlobals>) => void) | null;
@@ -26,10 +30,17 @@ export declare class ZylemGame<TGlobals extends Record<string, BasicTypes> = Glo
26
30
  dom: HTMLElement;
27
31
  } | null;
28
32
  defaultCamera: ZylemCamera | null;
33
+ container: HTMLElement | null;
34
+ canvas: HTMLCanvasElement | null;
35
+ aspectRatioDelegate: AspectRatioDelegate | null;
36
+ resolvedConfig: GameConfig | null;
37
+ gameCanvas: GameCanvas | null;
29
38
  static FRAME_LIMIT: number;
30
39
  static FRAME_DURATION: number;
31
40
  static MAX_DELTA_SECONDS: number;
32
- constructor(options: ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals>, wrapperRef: Game<TGlobals>);
41
+ constructor(options: ZylemGameOptions<TGlobals>, wrapperRef: Game<TGlobals>);
42
+ loadGameCanvas(config: GameConfig): void;
43
+ loadDebugOptions(options: ZylemGameOptions<TGlobals>): void;
33
44
  loadStage(stage: Stage): Promise<void>;
34
45
  unloadCurrentStage(): void;
35
46
  setGlobals(options: ZylemGameConfig<Stage, ZylemGame<TGlobals>, TGlobals>): void;
@@ -44,3 +55,4 @@ export declare class ZylemGame<TGlobals extends Record<string, BasicTypes> = Glo
44
55
  onGlobalChange<K extends keyof TGlobals>(key: K, callback: (value: TGlobals[K]) => void): void;
45
56
  }
46
57
  export default ZylemGame;
58
+ //# sourceMappingURL=zylem-game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zylem-game.d.ts","sourceRoot":"","sources":["../../../src/lib/game/zylem-game.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,YA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,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,GAAG,EAAE,CAAC;IAI1C,SAAS,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAI9D,cAAc,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;CAUvF;AAED,eAAe,SAAS,CAAC"}
@@ -1,10 +1,12 @@
1
- import { state as i, getGlobalState as r, setGlobalState as n } from "./game-state.js";
2
- import { setDebugFlag as u, isPaused as h } from "../debug/debug-state.js";
3
- import { InputManager as g } from "../input/input-manager.js";
4
- import { Timer as c } from "../core/three-addons/Timer.js";
5
- import { subscribe as m } from "valtio/vanilla";
6
- import f from "stats.js";
7
- class l {
1
+ import { state as o, getGlobalState as r, setGlobalState as d } from "./game-state.js";
2
+ import { setDebugFlag as h, isPaused as m } from "../debug/debug-state.js";
3
+ import { InputManager as c } from "../input/input-manager.js";
4
+ import { Timer as p } from "../core/three-addons/Timer.js";
5
+ import { resolveGameConfig as g } from "./game-config.js";
6
+ import { GameCanvas as f } from "./game-canvas.js";
7
+ import { subscribe as S } from "valtio/vanilla";
8
+ import b from "stats.js";
9
+ class n {
8
10
  id;
9
11
  initialGlobals = {};
10
12
  customSetup = null;
@@ -20,27 +22,59 @@ class l {
20
22
  wrapperRef;
21
23
  statsRef = null;
22
24
  defaultCamera = null;
25
+ container = null;
26
+ canvas = null;
27
+ aspectRatioDelegate = null;
28
+ resolvedConfig = null;
29
+ gameCanvas = null;
23
30
  static FRAME_LIMIT = 120;
24
- static FRAME_DURATION = 1e3 / l.FRAME_LIMIT;
31
+ static FRAME_DURATION = 1e3 / n.FRAME_LIMIT;
25
32
  static MAX_DELTA_SECONDS = 1 / 30;
26
33
  constructor(t, e) {
27
- this.wrapperRef = e, this.inputManager = new g(t.input), this.timer = new c(), this.timer.connect(document), this.id = t.id, this.stages = t.stages || [], this.setGlobals(t), t.debug && (this.statsRef = new f(), this.statsRef.showPanel(0), this.statsRef.dom.style.position = "absolute", this.statsRef.dom.style.bottom = "0", this.statsRef.dom.style.right = "0", this.statsRef.dom.style.top = "auto", this.statsRef.dom.style.left = "auto", document.body.appendChild(this.statsRef.dom));
34
+ this.wrapperRef = e, this.inputManager = new c(t.input), this.timer = new p(), this.timer.connect(document);
35
+ const a = g(t);
36
+ this.id = a.id, this.stages = a.stages || [], this.container = a.container, this.canvas = a.canvas ?? null, this.resolvedConfig = a, this.loadGameCanvas(a), this.loadDebugOptions(t), this.setGlobals(t);
37
+ }
38
+ loadGameCanvas(t) {
39
+ this.gameCanvas = new f({
40
+ id: t.id,
41
+ container: t.container,
42
+ containerId: t.containerId,
43
+ canvas: this.canvas ?? void 0,
44
+ bodyBackground: t.bodyBackground,
45
+ fullscreen: t.fullscreen,
46
+ aspectRatio: t.aspectRatio
47
+ }), this.gameCanvas.applyBodyBackground(), this.gameCanvas.mountCanvas(), this.gameCanvas.centerIfFullscreen();
48
+ }
49
+ loadDebugOptions(t) {
50
+ h(!!t.debug), t.debug && (this.statsRef = new b(), this.statsRef.showPanel(0), this.statsRef.dom.style.position = "absolute", this.statsRef.dom.style.bottom = "0", this.statsRef.dom.style.right = "0", this.statsRef.dom.style.top = "auto", this.statsRef.dom.style.left = "auto", document.body.appendChild(this.statsRef.dom));
28
51
  }
29
52
  async loadStage(t) {
30
53
  this.unloadCurrentStage();
31
54
  const e = t.options[0];
32
- await t.load(this.id, e?.camera), this.stageMap.set(t.stageRef.uuid, t), this.currentStageId = t.stageRef.uuid, this.defaultCamera = t.stageRef.cameraRef;
55
+ if (await t.load(this.id, e?.camera), this.stageMap.set(t.wrappedStage.uuid, t), this.currentStageId = t.wrappedStage.uuid, this.defaultCamera = t.wrappedStage.cameraRef, this.container && this.defaultCamera) {
56
+ const a = this.defaultCamera.getDomElement(), s = this.resolvedConfig?.internalResolution;
57
+ this.gameCanvas?.mountRenderer(a, (i, l) => {
58
+ if (this.defaultCamera)
59
+ if (s)
60
+ this.defaultCamera.setPixelRatio(1), this.defaultCamera.resize(s.width, s.height);
61
+ else {
62
+ const u = window.devicePixelRatio || 1;
63
+ this.defaultCamera.setPixelRatio(u), this.defaultCamera.resize(i, l);
64
+ }
65
+ });
66
+ }
33
67
  }
34
68
  unloadCurrentStage() {
35
69
  if (!this.currentStageId)
36
70
  return;
37
71
  const t = this.getStage(this.currentStageId);
38
72
  if (t) {
39
- if (t?.stageRef)
73
+ if (t?.wrappedStage)
40
74
  try {
41
- t.stageRef.nodeDestroy({
42
- me: t.stageRef,
43
- globals: i.globals
75
+ t.wrappedStage.nodeDestroy({
76
+ me: t.wrappedStage,
77
+ globals: o.globals
44
78
  });
45
79
  } catch (e) {
46
80
  console.error("Failed to destroy previous stage", e);
@@ -49,37 +83,37 @@ class l {
49
83
  }
50
84
  }
51
85
  setGlobals(t) {
52
- u(t.debug), this.initialGlobals = { ...t.globals };
86
+ this.initialGlobals = { ...t.globals };
53
87
  for (const e in this.initialGlobals) {
54
- const s = this.initialGlobals[e];
55
- s === void 0 && console.error(`global ${e} is undefined`), this.setGlobal(e, s);
88
+ const a = this.initialGlobals[e];
89
+ a === void 0 && console.error(`global ${e} is undefined`), this.setGlobal(e, a);
56
90
  }
57
91
  }
58
92
  params() {
59
- const t = this.currentStage(), e = this.timer.getDelta(), s = this.inputManager.getInputs(e), a = t?.stageRef?.cameraRef || this.defaultCamera;
93
+ const t = this.currentStage(), e = this.timer.getDelta(), a = this.inputManager.getInputs(e), s = t?.wrappedStage?.cameraRef || this.defaultCamera;
60
94
  return {
61
95
  delta: e,
62
- inputs: s,
63
- globals: i.globals,
96
+ inputs: a,
97
+ globals: o.globals,
64
98
  me: this,
65
- camera: a
99
+ camera: s
66
100
  };
67
101
  }
68
102
  start() {
69
103
  const t = this.currentStage(), e = this.params();
70
- t.start({ ...e, me: t.stageRef }), this.customSetup && this.customSetup(e), this.loop(0);
104
+ t.start({ ...e, me: t.wrappedStage }), this.customSetup && this.customSetup(e), this.loop(0);
71
105
  }
72
106
  loop(t) {
73
- if (this.statsRef && this.statsRef.begin(), !h()) {
107
+ if (this.statsRef && this.statsRef.begin(), !m()) {
74
108
  this.timer.update(t);
75
- const e = this.currentStage(), s = this.params(), a = Math.min(s.delta, l.MAX_DELTA_SECONDS), o = { ...s, delta: a };
76
- this.customUpdate && this.customUpdate(o), e && e.stageRef.nodeUpdate({ ...o, me: e.stageRef }), this.totalTime += o.delta, i.time = this.totalTime, this.previousTimeStamp = t;
109
+ const e = this.currentStage(), a = this.params(), s = Math.min(a.delta, n.MAX_DELTA_SECONDS), i = { ...a, delta: s };
110
+ this.customUpdate && this.customUpdate(i), e && e.wrappedStage.nodeUpdate({ ...i, me: e.wrappedStage }), this.totalTime += i.delta, o.time = this.totalTime, this.previousTimeStamp = t;
77
111
  }
78
112
  this.statsRef && this.statsRef.end(), this.outOfLoop(), requestAnimationFrame(this.loop.bind(this));
79
113
  }
80
114
  outOfLoop() {
81
115
  const t = this.currentStage();
82
- t && t.stageRef.outOfLoop();
116
+ t && t.wrappedStage.outOfLoop();
83
117
  }
84
118
  getStage(t) {
85
119
  return this.stageMap.get(t);
@@ -91,17 +125,17 @@ class l {
91
125
  return r(t);
92
126
  }
93
127
  setGlobal(t, e) {
94
- n(t, e);
128
+ d(t, e);
95
129
  }
96
130
  onGlobalChange(t, e) {
97
- let s = r(t);
98
- m(i, () => {
99
- const a = r(t);
100
- a !== s && (s = a, e(a));
131
+ let a = r(t);
132
+ S(o, () => {
133
+ const s = r(t);
134
+ s !== a && (a = s, e(s));
101
135
  });
102
136
  }
103
137
  }
104
138
  export {
105
- l as ZylemGame,
106
- l as default
139
+ n as ZylemGame,
140
+ n as default
107
141
  };
@@ -5,3 +5,4 @@ declare class XZPlaneGeometry extends BufferGeometry {
5
5
  static fromJSON(data: any): XZPlaneGeometry;
6
6
  }
7
7
  export { XZPlaneGeometry };
8
+ //# sourceMappingURL=XZPlaneGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XZPlaneGeometry.d.ts","sourceRoot":"","sources":["../../../../src/lib/graphics/geometries/XZPlaneGeometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAA0B,MAAM,OAAO,CAAC;AAE/D,cAAM,eAAgB,SAAQ,cAAc;gBAE/B,KAAK,SAAI,EAAE,MAAM,SAAI,EAAE,aAAa,SAAI,EAAE,cAAc,SAAI;IAwExE,IAAI,CAAC,MAAM,KAAA;IASX,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAA;CAIpB;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { Color, Material, Vector2 } from 'three';
2
- import { shortHash } from '../core/utility';
2
+ import { shortHash } from '../core/utility/strings';
3
3
  import { ZylemShaderType } from '../core/preset-shader';
4
4
  export interface MaterialOptions {
5
5
  path?: string;
@@ -26,3 +26,4 @@ export declare class MaterialBuilder {
26
26
  setShader(customShader: ZylemShaderType): void;
27
27
  }
28
28
  export {};
29
+ //# sourceMappingURL=material.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../../../src/lib/graphics/material.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,EACL,QAAQ,EAMR,OAAO,EAEP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAmB,MAAM,yBAAyB,CAAC;AACrE,OAAkB,EAAqB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEtF,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;CACd;AAED,KAAK,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,UAAU,sBAAsB;IAC/B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAE7C,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;AAExC,qBAAa,eAAe;IAC3B,MAAM,CAAC,gBAAgB,EAAE,GAAG,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAa;IAE3E,SAAS,EAAE,QAAQ,EAAE,CAAM;IAE3B,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM;IAmB7D,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,UAAU,EAAE,MAAM;IAWjE,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAK7B,UAAU,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI;IAKvC,UAAU,CAAC,WAAW,GAAE,WAAkB,EAAE,MAAM,GAAE,OAA2B;IAerF,QAAQ,CAAC,KAAK,EAAE,KAAK;IAWrB,SAAS,CAAC,YAAY,EAAE,eAAe;CAgBvC"}
@@ -1,5 +1,5 @@
1
1
  import { Color as n, Vector2 as m, TextureLoader as c, RepeatWrapping as o, MeshPhongMaterial as p, MeshStandardMaterial as u, ShaderMaterial as f, Vector3 as d } from "three";
2
- import { shortHash as M, sortedStringify as w } from "../core/utility.js";
2
+ import { shortHash as M, sortedStringify as w } from "../core/utility/strings.js";
3
3
  import h from "../core/preset-shader.js";
4
4
  class i {
5
5
  static batchMaterialMap = /* @__PURE__ */ new Map();
@@ -16,3 +16,4 @@ export declare class MeshBuilder {
16
16
  _build(meshOptions: MeshBuilderOptions, geometry: BufferGeometry, materials: Material[]): Mesh;
17
17
  _postBuild(): void;
18
18
  }
19
+ //# sourceMappingURL=mesh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../../src/lib/graphics/mesh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;AAE1F,qBAAa,WAAW;IAEvB,MAAM,CAAC,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI;IAY9F,UAAU,IAAI,IAAI;CAGlB"}