lecodes-sdk 0.19.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 (367) hide show
  1. package/README.md +114 -0
  2. package/dist/global.d.ts +503 -0
  3. package/dist/host.d.ts +61 -0
  4. package/dist/inject.js +4730 -0
  5. package/dist/types/animate/animate.d.ts +20 -0
  6. package/dist/types/animate/bezier.d.ts +2 -0
  7. package/dist/types/animate/easings.d.ts +21 -0
  8. package/dist/types/canvas/Canvas.d.ts +168 -0
  9. package/dist/types/core/Aspect.d.ts +171 -0
  10. package/dist/types/core/InspectorUI.d.ts +88 -0
  11. package/dist/types/core/StateMachine.d.ts +81 -0
  12. package/dist/types/core/color.d.ts +13 -0
  13. package/dist/types/core/compWrite.d.ts +11 -0
  14. package/dist/types/core/events.d.ts +11 -0
  15. package/dist/types/core/fields.d.ts +58 -0
  16. package/dist/types/core/registry.d.ts +7 -0
  17. package/dist/types/core/signals.d.ts +29 -0
  18. package/dist/types/core/time.d.ts +31 -0
  19. package/dist/types/g2/Camera2D.d.ts +19 -0
  20. package/dist/types/g2/CharacterController2D.d.ts +134 -0
  21. package/dist/types/g2/Node2D.d.ts +91 -0
  22. package/dist/types/g2/OneWay2D.d.ts +24 -0
  23. package/dist/types/g2/Physics2D.d.ts +147 -0
  24. package/dist/types/g2/Scene2D.d.ts +72 -0
  25. package/dist/types/g2/Shape2D.d.ts +58 -0
  26. package/dist/types/g2/Sprite.d.ts +51 -0
  27. package/dist/types/g2/SpriteAnimation.d.ts +50 -0
  28. package/dist/types/g2/SpriteSheet.d.ts +69 -0
  29. package/dist/types/g2/Texture2D.d.ts +16 -0
  30. package/dist/types/g2/Tilemap.d.ts +20 -0
  31. package/dist/types/g2/Tileset.d.ts +32 -0
  32. package/dist/types/g2/Trigger2D.d.ts +20 -0
  33. package/dist/types/g2/autotile.d.ts +133 -0
  34. package/dist/types/g2/cells.d.ts +14 -0
  35. package/dist/types/g2/defineScene2d.d.ts +141 -0
  36. package/dist/types/g2/groups2d.d.ts +16 -0
  37. package/dist/types/g2/loop.d.ts +4 -0
  38. package/dist/types/g2/scenarios2d.d.ts +30 -0
  39. package/dist/types/g2/touch.d.ts +2 -0
  40. package/dist/types/gl/Camera.d.ts +79 -0
  41. package/dist/types/gl/CameraPlace.d.ts +26 -0
  42. package/dist/types/gl/CharacterController.d.ts +98 -0
  43. package/dist/types/gl/Gearbox.d.ts +86 -0
  44. package/dist/types/gl/Geometry.d.ts +39 -0
  45. package/dist/types/gl/IK.d.ts +53 -0
  46. package/dist/types/gl/InstancedMesh.d.ts +46 -0
  47. package/dist/types/gl/Light.d.ts +73 -0
  48. package/dist/types/gl/Lightmap.d.ts +85 -0
  49. package/dist/types/gl/Locomotion.d.ts +279 -0
  50. package/dist/types/gl/Material.d.ts +100 -0
  51. package/dist/types/gl/Mesh.d.ts +33 -0
  52. package/dist/types/gl/Model.d.ts +53 -0
  53. package/dist/types/gl/NavAgent.d.ts +99 -0
  54. package/dist/types/gl/NavMesh.d.ts +169 -0
  55. package/dist/types/gl/Node.d.ts +99 -0
  56. package/dist/types/gl/Noise.d.ts +20 -0
  57. package/dist/types/gl/Particles.d.ts +277 -0
  58. package/dist/types/gl/Physics.d.ts +91 -0
  59. package/dist/types/gl/Plane.d.ts +19 -0
  60. package/dist/types/gl/Ragdoll.d.ts +86 -0
  61. package/dist/types/gl/Ray.d.ts +8 -0
  62. package/dist/types/gl/Scene.d.ts +221 -0
  63. package/dist/types/gl/Shape.d.ts +122 -0
  64. package/dist/types/gl/Terrain.d.ts +280 -0
  65. package/dist/types/gl/Texture.d.ts +27 -0
  66. package/dist/types/gl/Trigger.d.ts +10 -0
  67. package/dist/types/gl/Vehicle.d.ts +191 -0
  68. package/dist/types/gl/Wheel.d.ts +95 -0
  69. package/dist/types/gl/animation/AnimationClip.d.ts +60 -0
  70. package/dist/types/gl/animation/Animator.d.ts +219 -0
  71. package/dist/types/gl/animation/Layer.d.ts +31 -0
  72. package/dist/types/gl/animation/Loop.d.ts +17 -0
  73. package/dist/types/gl/animation/Playback.d.ts +36 -0
  74. package/dist/types/gl/animation/core.d.ts +367 -0
  75. package/dist/types/gl/controls.d.ts +19 -0
  76. package/dist/types/gl/physicsEvents.d.ts +1 -0
  77. package/dist/types/gl/scenarios.d.ts +98 -0
  78. package/dist/types/gl/state.d.ts +5 -0
  79. package/dist/types/gl/terrainMesh.d.ts +46 -0
  80. package/dist/types/gl/touch.d.ts +2 -0
  81. package/dist/types/inject.d.ts +123 -0
  82. package/dist/types/math/Mathf.d.ts +39 -0
  83. package/dist/types/math/mat4.d.ts +66 -0
  84. package/dist/types/math/quat.d.ts +53 -0
  85. package/dist/types/math/vec.d.ts +129 -0
  86. package/dist/types/net/codec.d.ts +25 -0
  87. package/dist/types/net/core.d.ts +106 -0
  88. package/dist/types/net/index.d.ts +80 -0
  89. package/dist/types/net/replication.d.ts +101 -0
  90. package/dist/types/plugins/camera.d.ts +25 -0
  91. package/dist/types/plugins/geolocation.d.ts +39 -0
  92. package/dist/types/plugins/oauth.d.ts +25 -0
  93. package/dist/types/plugins/permission.d.ts +1 -0
  94. package/dist/types/plugins/push.d.ts +46 -0
  95. package/dist/types/plugins/qr.d.ts +21 -0
  96. package/dist/types/plugins/service.d.ts +33 -0
  97. package/dist/types/runtime/app.d.ts +67 -0
  98. package/dist/types/runtime/appEvents.d.ts +7 -0
  99. package/dist/types/runtime/channel.d.ts +1 -0
  100. package/dist/types/runtime/clipboard.d.ts +7 -0
  101. package/dist/types/runtime/datetime.d.ts +80 -0
  102. package/dist/types/runtime/device.d.ts +126 -0
  103. package/dist/types/runtime/fetch.d.ts +31 -0
  104. package/dist/types/runtime/files.d.ts +33 -0
  105. package/dist/types/runtime/input.d.ts +121 -0
  106. package/dist/types/runtime/media.d.ts +46 -0
  107. package/dist/types/runtime/misc.d.ts +11 -0
  108. package/dist/types/runtime/net.d.ts +15 -0
  109. package/dist/types/runtime/rpc.d.ts +44 -0
  110. package/dist/types/runtime/service.d.ts +1 -0
  111. package/dist/types/runtime/share.d.ts +2 -0
  112. package/dist/types/runtime/storage.d.ts +5 -0
  113. package/dist/types/runtime/touch.d.ts +56 -0
  114. package/dist/types/scene/defineScene.d.ts +296 -0
  115. package/dist/types/scene/editorPlugins.d.ts +82 -0
  116. package/dist/types/scene/gizmos.d.ts +56 -0
  117. package/dist/types/scene/grammar.d.ts +56 -0
  118. package/dist/types/scene/level.d.ts +98 -0
  119. package/dist/types/scene/material.d.ts +76 -0
  120. package/dist/types/server/auth/appConfig.d.ts +16 -0
  121. package/dist/types/server/auth/global.d.ts +56 -0
  122. package/dist/types/server/auth/models.d.ts +164 -0
  123. package/dist/types/server/auth/types.d.ts +56 -0
  124. package/dist/types/server/channel.d.ts +28 -0
  125. package/dist/types/server/context.d.ts +27 -0
  126. package/dist/types/server/db/defineDb.d.ts +36 -0
  127. package/dist/types/server/db/fields.d.ts +146 -0
  128. package/dist/types/server/db/index.d.ts +6 -0
  129. package/dist/types/server/db/marci/query.d.ts +326 -0
  130. package/dist/types/server/db/types.d.ts +163 -0
  131. package/dist/types/server/errors.d.ts +8 -0
  132. package/dist/types/server/inject.d.ts +5 -0
  133. package/dist/types/ui/NativeView.d.ts +38 -0
  134. package/dist/types/ui/UI.d.ts +27 -0
  135. package/dist/types/ui/UIBottomSheet.d.ts +71 -0
  136. package/dist/types/ui/UIButton.d.ts +30 -0
  137. package/dist/types/ui/UIContainer.d.ts +33 -0
  138. package/dist/types/ui/UIImage.d.ts +35 -0
  139. package/dist/types/ui/UIInput.d.ts +110 -0
  140. package/dist/types/ui/UIModal.d.ts +70 -0
  141. package/dist/types/ui/UINode.d.ts +363 -0
  142. package/dist/types/ui/UIPager.d.ts +123 -0
  143. package/dist/types/ui/UIPopover.d.ts +39 -0
  144. package/dist/types/ui/UIScreen.d.ts +57 -0
  145. package/dist/types/ui/UIScrollable.d.ts +40 -0
  146. package/dist/types/ui/UISpacer.d.ts +9 -0
  147. package/dist/types/ui/UITabs.d.ts +96 -0
  148. package/dist/types/ui/UIText.d.ts +19 -0
  149. package/dist/types/ui/UIVideo.d.ts +28 -0
  150. package/dist/types/ui/UIVirtualizedList.d.ts +97 -0
  151. package/dist/types/ui/UIWidget.d.ts +65 -0
  152. package/dist/types/ui/fonts.d.ts +9 -0
  153. package/dist/types/ui/presentable.d.ts +68 -0
  154. package/dist/types/ui/router.d.ts +40 -0
  155. package/dist/types/ui/theme.d.ts +26 -0
  156. package/dist/types.json +1 -0
  157. package/package.json +46 -0
  158. package/prompts/2d.md +395 -0
  159. package/prompts/3d-scene-files.md +113 -0
  160. package/prompts/3d-scene.md +119 -0
  161. package/prompts/3d.md +303 -0
  162. package/prompts/README.md +142 -0
  163. package/prompts/ar.md +109 -0
  164. package/prompts/canvas.md +27 -0
  165. package/prompts/compose.ts +46 -0
  166. package/prompts/concept.md +49 -0
  167. package/prompts/core-design.md +75 -0
  168. package/prompts/core.md +264 -0
  169. package/prompts/design.md +218 -0
  170. package/prompts/dist/2d-game.md +1530 -0
  171. package/prompts/dist/3d-app.md +1672 -0
  172. package/prompts/dist/ar-app.md +1548 -0
  173. package/prompts/dist/concept.md +49 -0
  174. package/prompts/dist/design.md +498 -0
  175. package/prompts/dist/ui-app.md +1134 -0
  176. package/prompts/index.md +37 -0
  177. package/prompts/intake-prompt.md +33 -0
  178. package/prompts/namer-prompt.md +12 -0
  179. package/prompts/router-prompt.md +50 -0
  180. package/prompts/select.ts +111 -0
  181. package/prompts/ui-design.md +203 -0
  182. package/prompts/ui.md +803 -0
  183. package/src/animate/animate.ts +238 -0
  184. package/src/animate/bezier.ts +138 -0
  185. package/src/animate/easings.ts +126 -0
  186. package/src/bridges.d.ts +1345 -0
  187. package/src/canvas/Canvas.ts +305 -0
  188. package/src/compile/__tests__/assetIconMacro.test.ts +219 -0
  189. package/src/compile/__tests__/assetMacro.test.ts +74 -0
  190. package/src/compile/__tests__/assetName.test.ts +55 -0
  191. package/src/compile/__tests__/compile.test.ts +287 -0
  192. package/src/compile/__tests__/detectEntry.test.ts +132 -0
  193. package/src/compile/__tests__/fontMacro.test.ts +199 -0
  194. package/src/compile/aspectMacro.ts +86 -0
  195. package/src/compile/assetIconMacro.ts +384 -0
  196. package/src/compile/assetMacro.ts +146 -0
  197. package/src/compile/assetName.ts +50 -0
  198. package/src/compile/bundler.ts +287 -0
  199. package/src/compile/compileProject.ts +127 -0
  200. package/src/compile/detectEntry.ts +128 -0
  201. package/src/compile/fontMacro.ts +459 -0
  202. package/src/compile/fontRegistry.ts +78 -0
  203. package/src/compile/header.ts +67 -0
  204. package/src/compile/index.ts +100 -0
  205. package/src/compile/libraryImports.ts +52 -0
  206. package/src/compile/liteMaterial.ts +247 -0
  207. package/src/compile/sceneEditor.ts +88 -0
  208. package/src/compile/serverSplit.ts +233 -0
  209. package/src/compile/serverTypes.ts +227 -0
  210. package/src/compile/sfnt.ts +98 -0
  211. package/src/compile/shaderSchema.ts +202 -0
  212. package/src/compile/shaderTargets.ts +77 -0
  213. package/src/compile/sourcemap.ts +25 -0
  214. package/src/core/Aspect.ts +568 -0
  215. package/src/core/InspectorUI.ts +212 -0
  216. package/src/core/StateMachine.ts +308 -0
  217. package/src/core/__tests__/stateMachine.test.ts +132 -0
  218. package/src/core/color.ts +66 -0
  219. package/src/core/compWrite.ts +42 -0
  220. package/src/core/events.ts +38 -0
  221. package/src/core/fields.ts +120 -0
  222. package/src/core/registry.ts +23 -0
  223. package/src/core/signals.ts +277 -0
  224. package/src/core/time.ts +84 -0
  225. package/src/g2/Camera2D.ts +40 -0
  226. package/src/g2/CharacterController2D.ts +276 -0
  227. package/src/g2/Node2D.ts +267 -0
  228. package/src/g2/OneWay2D.ts +66 -0
  229. package/src/g2/Physics2D.ts +346 -0
  230. package/src/g2/Scene2D.ts +209 -0
  231. package/src/g2/Shape2D.ts +259 -0
  232. package/src/g2/Sprite.ts +89 -0
  233. package/src/g2/SpriteAnimation.ts +171 -0
  234. package/src/g2/SpriteSheet.ts +166 -0
  235. package/src/g2/Texture2D.ts +47 -0
  236. package/src/g2/Tilemap.ts +41 -0
  237. package/src/g2/Tileset.ts +71 -0
  238. package/src/g2/Trigger2D.ts +77 -0
  239. package/src/g2/autotile.ts +433 -0
  240. package/src/g2/cells.ts +91 -0
  241. package/src/g2/defineScene2d.ts +381 -0
  242. package/src/g2/groups2d.ts +106 -0
  243. package/src/g2/loop.ts +50 -0
  244. package/src/g2/scenarios2d.ts +69 -0
  245. package/src/g2/touch.ts +83 -0
  246. package/src/gl/Camera.ts +160 -0
  247. package/src/gl/CameraPlace.ts +52 -0
  248. package/src/gl/CharacterController.ts +238 -0
  249. package/src/gl/Gearbox.ts +212 -0
  250. package/src/gl/Geometry.ts +279 -0
  251. package/src/gl/IK.ts +193 -0
  252. package/src/gl/InstancedMesh.ts +132 -0
  253. package/src/gl/Light.ts +135 -0
  254. package/src/gl/Lightmap.ts +402 -0
  255. package/src/gl/Locomotion.ts +498 -0
  256. package/src/gl/Material.ts +279 -0
  257. package/src/gl/Mesh.ts +83 -0
  258. package/src/gl/Model.ts +124 -0
  259. package/src/gl/NavAgent.ts +337 -0
  260. package/src/gl/NavMesh.ts +397 -0
  261. package/src/gl/Node.ts +350 -0
  262. package/src/gl/Noise.ts +30 -0
  263. package/src/gl/Particles.ts +676 -0
  264. package/src/gl/Physics.ts +222 -0
  265. package/src/gl/Plane.ts +53 -0
  266. package/src/gl/Ragdoll.ts +270 -0
  267. package/src/gl/Ray.ts +16 -0
  268. package/src/gl/Scene.ts +505 -0
  269. package/src/gl/Shape.ts +409 -0
  270. package/src/gl/Terrain.ts +1092 -0
  271. package/src/gl/Texture.ts +63 -0
  272. package/src/gl/Trigger.ts +45 -0
  273. package/src/gl/Vehicle.ts +473 -0
  274. package/src/gl/Wheel.ts +240 -0
  275. package/src/gl/animation/AnimationClip.ts +204 -0
  276. package/src/gl/animation/Animator.ts +329 -0
  277. package/src/gl/animation/Layer.ts +39 -0
  278. package/src/gl/animation/Loop.ts +31 -0
  279. package/src/gl/animation/Playback.ts +52 -0
  280. package/src/gl/animation/core.ts +670 -0
  281. package/src/gl/controls.ts +95 -0
  282. package/src/gl/physicsEvents.ts +20 -0
  283. package/src/gl/scenarios.ts +291 -0
  284. package/src/gl/state.ts +6 -0
  285. package/src/gl/terrainMesh.ts +219 -0
  286. package/src/gl/touch.ts +68 -0
  287. package/src/host.d.ts +61 -0
  288. package/src/inject.ts +203 -0
  289. package/src/math/Mathf.ts +118 -0
  290. package/src/math/mat4.ts +278 -0
  291. package/src/math/quat.ts +232 -0
  292. package/src/math/vec.ts +255 -0
  293. package/src/net/codec.ts +119 -0
  294. package/src/net/core.ts +384 -0
  295. package/src/net/index.ts +181 -0
  296. package/src/net/replication.ts +622 -0
  297. package/src/plugins/camera.ts +81 -0
  298. package/src/plugins/geolocation.ts +123 -0
  299. package/src/plugins/oauth.ts +61 -0
  300. package/src/plugins/permission.ts +7 -0
  301. package/src/plugins/push.ts +132 -0
  302. package/src/plugins/qr.ts +73 -0
  303. package/src/plugins/service.ts +47 -0
  304. package/src/runtime/app.ts +101 -0
  305. package/src/runtime/appEvents.ts +54 -0
  306. package/src/runtime/channel.ts +61 -0
  307. package/src/runtime/clipboard.ts +20 -0
  308. package/src/runtime/datetime.ts +329 -0
  309. package/src/runtime/device.ts +293 -0
  310. package/src/runtime/fetch.ts +77 -0
  311. package/src/runtime/files.ts +108 -0
  312. package/src/runtime/input.ts +175 -0
  313. package/src/runtime/media.ts +111 -0
  314. package/src/runtime/misc.ts +16 -0
  315. package/src/runtime/net.ts +36 -0
  316. package/src/runtime/rpc.ts +218 -0
  317. package/src/runtime/service.ts +83 -0
  318. package/src/runtime/share.ts +9 -0
  319. package/src/runtime/storage.ts +13 -0
  320. package/src/runtime/touch.ts +76 -0
  321. package/src/scene/defineScene.ts +1396 -0
  322. package/src/scene/editorPlugins.ts +110 -0
  323. package/src/scene/gizmos.ts +148 -0
  324. package/src/scene/grammar.ts +120 -0
  325. package/src/scene/level.ts +296 -0
  326. package/src/scene/material.ts +188 -0
  327. package/src/server/auth/appConfig.ts +12 -0
  328. package/src/server/auth/global.ts +80 -0
  329. package/src/server/auth/host.ts +318 -0
  330. package/src/server/auth/models.ts +83 -0
  331. package/src/server/auth/types.ts +50 -0
  332. package/src/server/channel.ts +56 -0
  333. package/src/server/context.ts +36 -0
  334. package/src/server/db/defineDb.ts +237 -0
  335. package/src/server/db/fields.ts +132 -0
  336. package/src/server/db/httpTransport.ts +93 -0
  337. package/src/server/db/index.ts +7 -0
  338. package/src/server/db/marci/query.ts +412 -0
  339. package/src/server/db/types.ts +202 -0
  340. package/src/server/errors.ts +12 -0
  341. package/src/server/host.ts +74 -0
  342. package/src/server/inject.ts +13 -0
  343. package/src/server/runtime.ts +133 -0
  344. package/src/server/validate.ts +87 -0
  345. package/src/ui/NativeView.ts +142 -0
  346. package/src/ui/UI.ts +39 -0
  347. package/src/ui/UIBottomSheet.ts +139 -0
  348. package/src/ui/UIButton.ts +101 -0
  349. package/src/ui/UIContainer.ts +60 -0
  350. package/src/ui/UIImage.ts +83 -0
  351. package/src/ui/UIInput.ts +185 -0
  352. package/src/ui/UIModal.ts +139 -0
  353. package/src/ui/UINode.ts +830 -0
  354. package/src/ui/UIPager.ts +362 -0
  355. package/src/ui/UIPopover.ts +100 -0
  356. package/src/ui/UIScreen.ts +123 -0
  357. package/src/ui/UIScrollable.ts +87 -0
  358. package/src/ui/UISpacer.ts +14 -0
  359. package/src/ui/UITabs.ts +236 -0
  360. package/src/ui/UIText.ts +51 -0
  361. package/src/ui/UIVideo.ts +88 -0
  362. package/src/ui/UIVirtualizedList.ts +241 -0
  363. package/src/ui/UIWidget.ts +127 -0
  364. package/src/ui/fonts.ts +13 -0
  365. package/src/ui/presentable.ts +117 -0
  366. package/src/ui/router.ts +132 -0
  367. package/src/ui/theme.ts +84 -0
@@ -0,0 +1,51 @@
1
+ import { type ColorInput } from "../core/color";
2
+ import { Vec2, type Vec2Like } from "../math/vec";
3
+ import { Canvas } from "../canvas/Canvas";
4
+ import { Node2D } from "./Node2D";
5
+ import type { Texture2D } from "./Texture2D";
6
+ /** Anything that can back a sprite: a texture, or a Canvas (baked to a texture on assign). */
7
+ export type TextureSource = Texture2D | Canvas;
8
+ export type SpriteOptions = {
9
+ texture?: TextureSource;
10
+ /** Pivot, [0,0] = top-left .. [1,1] = bottom-right. Use [0.5, 1] (feet) for Y-sorted depth. */
11
+ anchor?: Vec2Like;
12
+ /** World size; defaults to the texture's pixel dimensions. */
13
+ size?: Vec2Like;
14
+ /** Normalized UV sub-rect [u0,v0,u1,v1]. */
15
+ frame?: [number, number, number, number];
16
+ /** Tint multiplied with the texture. */
17
+ color?: ColorInput;
18
+ opacity?: number;
19
+ layer?: number;
20
+ position?: Vec2Like;
21
+ };
22
+ export declare class Sprite extends Node2D {
23
+ private _texture?;
24
+ private _anchor;
25
+ private _color;
26
+ private _opacity;
27
+ private _flipX;
28
+ private _flipY;
29
+ private _size;
30
+ constructor(options?: SpriteOptions);
31
+ get texture(): Texture2D | undefined;
32
+ set texture(t: TextureSource | undefined);
33
+ /** Current world size: explicit override if set, else the texture's pixel dimensions (a Canvas-backed
34
+ * sprite defaults to the canvas's LOGICAL size, so pixelRatio is crispness only, not size). */
35
+ get size(): Vec2;
36
+ set size(v: Vec2Like);
37
+ get anchor(): Vec2;
38
+ set anchor(v: Vec2Like);
39
+ /** Set the UV sub-rect (normalized). */
40
+ set frame(uv: [number, number, number, number]);
41
+ /** Set the sub-rect in texture pixels. */
42
+ setFramePx(px: number, py: number, pw: number, ph: number): this;
43
+ get color(): ColorInput;
44
+ set color(c: ColorInput);
45
+ get opacity(): number;
46
+ set opacity(a: number);
47
+ get flipX(): boolean;
48
+ set flipX(v: boolean);
49
+ get flipY(): boolean;
50
+ set flipY(v: boolean);
51
+ }
@@ -0,0 +1,50 @@
1
+ import { Aspect } from "../core/Aspect";
2
+ import { type Vec2Like } from "../math/vec";
3
+ import type { Sprite } from "./Sprite";
4
+ /** Per-clip frame list, or an object for per-clip fps/loop/direction overrides. */
5
+ export type Clip = number[] | {
6
+ frames: number[];
7
+ fps?: number;
8
+ loop?: boolean;
9
+ perDirection?: boolean;
10
+ };
11
+ export declare class SpriteAnimation extends Aspect<"anim", Sprite> {
12
+ static readonly aspect = "anim";
13
+ /** Grid cell size in texture pixels (defaults to the full texture). */
14
+ size?: [number, number];
15
+ /** Grid columns override — for sheets with padding; defaults to floor(texWidth / cellWidth). */
16
+ cols?: number;
17
+ /** Pixel origin of the grid in the texture — cells index from here (a SpriteSheet region). */
18
+ origin?: [number, number];
19
+ /** Default fps for clips that don't override it. */
20
+ fps: number;
21
+ /** Default loop for clips that don't override it. */
22
+ loop: boolean;
23
+ /** Named clips; frame indices are row-major into the grid. Set via the attach opts. */
24
+ clips: Record<string, Clip>;
25
+ /** Facing names in texture-row order (row i = directions[i]) for `perDirection` clips. */
26
+ directions?: string[];
27
+ private _clipIds;
28
+ private _clipNames;
29
+ private _current;
30
+ private _defined;
31
+ private _queued;
32
+ private _dir;
33
+ onAttach(): void;
34
+ /** (Re)build native clips from `this.clips`. Called on attach; call again after changing clips. */
35
+ define(): this;
36
+ private _define;
37
+ /**
38
+ * Play a clip by name. Re-playing the active clip is a no-op (keeps it running smoothly).
39
+ * For a `perDirection` clip, `dir` picks the facing — a direction name or a movement vector
40
+ * (nearest compass row wins); omitted, the last direction (or the first row) is kept.
41
+ */
42
+ play(name: string, dir?: string | Vec2Like): this;
43
+ stop(): this;
44
+ /** Current facing (last direction resolved by play()), or null before the first directional play. */
45
+ get direction(): string | null;
46
+ set speed(value: number);
47
+ get current(): string | null;
48
+ get frame(): number;
49
+ private _resolveDir;
50
+ }
@@ -0,0 +1,69 @@
1
+ import { type Vec2Like } from "../math/vec";
2
+ import { Sprite } from "./Sprite";
3
+ import { SpriteAnimation, type Clip } from "./SpriteAnimation";
4
+ import { Texture2D } from "./Texture2D";
5
+ /**
6
+ * A named region of the image. Just a rect is a static sprite; `slice` subdivides the rect into an
7
+ * animation grid ([cols, rows] — the cell is rect size / counts); `clips` names frame runs over
8
+ * that grid (local, row-major). A sliced entry with NO clips loops all of its cells in order.
9
+ */
10
+ export type SheetSprite = {
11
+ /** Pixel rect [x, y, w, h] in the image. */
12
+ rect?: [number, number, number, number];
13
+ /** Subdivide the rect into an animation grid: [cols, rows]. */
14
+ slice?: [number, number];
15
+ /** Playback fps for this sprite's animation (defaults to the sheet fps, then 12). */
16
+ fps?: number;
17
+ /** Named clips over the local grid (see SpriteAnimation). Omit to loop every cell. */
18
+ clips?: Record<string, Clip>;
19
+ /** Facing names in local-row order for `perDirection` clips (compass tokens: S/SE/E/…). */
20
+ directions?: string[];
21
+ /** Overrides the sheet anchor. */
22
+ anchor?: Vec2Like;
23
+ };
24
+ export type SpriteSheetDef = {
25
+ /** The image URL — write `asset('./sheet.png')`. */
26
+ image: string;
27
+ /** Default pivot for every sprite made from this sheet ([0.5, 1] = feet, for Y-sorted worlds). */
28
+ anchor?: Vec2Like;
29
+ /** Default fps for sliced sprites / clips that don't override it. */
30
+ fps?: number;
31
+ /** The named sprites. */
32
+ sprites?: Record<string, SheetSprite>;
33
+ };
34
+ export type SpriteMakeOptions = {
35
+ position?: Vec2Like;
36
+ layer?: number;
37
+ /** Overrides the sheet/sprite anchor. */
38
+ anchor?: Vec2Like;
39
+ /** Start this clip immediately (sliced sprites with clips). */
40
+ clip?: string;
41
+ /** Initial facing for `perDirection` clips. */
42
+ direction?: string;
43
+ };
44
+ export declare class SpriteSheet {
45
+ private _def;
46
+ private _tex;
47
+ private _loading;
48
+ constructor(def: SpriteSheetDef);
49
+ /** The sheet definition (read-only by convention — the editor owns the file). */
50
+ get def(): SpriteSheetDef;
51
+ /** The loaded texture, or null before load() resolves. */
52
+ get texture(): Texture2D | null;
53
+ /** Load the sheet's texture (idempotent). make() starts this automatically. */
54
+ load(): Promise<Texture2D>;
55
+ /** Names of the sheet's sprites. */
56
+ get spriteNames(): string[];
57
+ /** Build a named sprite; starting a clip hands back the animation handle. */
58
+ make(name: string, opts: SpriteMakeOptions & {
59
+ clip: string;
60
+ }): Sprite & {
61
+ anim: SpriteAnimation;
62
+ };
63
+ make(name: string, opts?: SpriteMakeOptions): Sprite;
64
+ /** The pixel rect [x, y, w, h] of a named sprite's REGION (the whole rect, sliced or not). */
65
+ rectOf(name: string): [number, number, number, number] | null;
66
+ private _applyTexture;
67
+ }
68
+ /** Declare a sprite sheet (the default export of a `.sprite.ts` file). */
69
+ export declare const defineSpriteSheet: (def: SpriteSheetDef) => SpriteSheet;
@@ -0,0 +1,16 @@
1
+ import { type FetchResponse, type File } from "../runtime/fetch";
2
+ export declare class Texture2D {
3
+ /** Native texture handle. */
4
+ readonly id: number;
5
+ readonly width: number;
6
+ readonly height: number;
7
+ constructor(id: number, width: number, height: number);
8
+ static fromCanvas(canvas: {
9
+ _bakeSurface(): number;
10
+ width: number;
11
+ height: number;
12
+ pixelRatio: number;
13
+ }): Texture2D;
14
+ static load(source: string | FetchResponse | File): Promise<Texture2D>;
15
+ destroy(): void;
16
+ }
@@ -0,0 +1,20 @@
1
+ import { Node2D } from "./Node2D";
2
+ import type { Texture2D } from "./Texture2D";
3
+ export type TilemapOptions = {
4
+ texture: Texture2D;
5
+ /** Map grid size (in tiles). */
6
+ cols: number;
7
+ rows: number;
8
+ /** On-screen cell size in world units — a single number (square) or [w, h]. */
9
+ tile: number | [number, number];
10
+ /** Atlas grid: how the texture is sliced into tiles, [atlasCols, atlasRows]. */
11
+ atlas: [number, number];
12
+ /** Row-major tile indices into the atlas (-1 = empty), length cols*rows. Row 0 is the top row. */
13
+ data: number[] | Int32Array;
14
+ };
15
+ export declare class Tilemap extends Node2D {
16
+ readonly cols: number;
17
+ readonly rows: number;
18
+ constructor(options: TilemapOptions);
19
+ setTile(x: number, y: number, index: number): this;
20
+ }
@@ -0,0 +1,32 @@
1
+ import { Aspect } from "../core/Aspect";
2
+ import type { Node2D } from "./Node2D";
3
+ import { type TilesetDef, type TileMaterial } from "./autotile";
4
+ export declare class Tileset {
5
+ private _def;
6
+ constructor(def: TilesetDef);
7
+ /** The tileset definition (read-only by convention — the editor owns the file). */
8
+ get def(): TilesetDef;
9
+ /** Names of the declared materials, in file order. */
10
+ get materialNames(): string[];
11
+ /** A material by name. */
12
+ material(name: string): TileMaterial | undefined;
13
+ /** The cell value maps store for a named material (what you paint / pass in `data`). */
14
+ id(name: string): number | undefined;
15
+ /** Derive display atlas indices from a material-id grid (what Autotile2D does at load). */
16
+ derive(cols: number, rows: number, data: ArrayLike<number>, seed?: number): Int32Array;
17
+ }
18
+ /** Declare a tileset (the default export of a `.tiles.ts` file). */
19
+ export declare const defineTileset: (def: TilesetDef) => Tileset;
20
+ /**
21
+ * Marks a tilemap node's `cells` as MATERIAL ids of a tileset instead of raw atlas indices:
22
+ * `aspects: [use(Autotile2D, { tileset: world })]`. The scene2d loader derives the display
23
+ * indices (neighbor-mask autotile + seeded scatter, deterministic) before building the tilemap;
24
+ * the aspect itself holds no behavior. Change `seed` to reshuffle scatter variants.
25
+ */
26
+ export declare class Autotile2D extends Aspect<"autotile", Node2D> {
27
+ static readonly aspect = "autotile";
28
+ /** The imported `.tiles.ts` handle. */
29
+ tileset: Tileset | null;
30
+ /** Scatter seed — same seed, same map, same result on every platform. */
31
+ seed: number;
32
+ }
@@ -0,0 +1,20 @@
1
+ import { Aspect } from "../core/Aspect";
2
+ import { PhysicsGroup2D } from "./groups2d";
3
+ import type { Node2D } from "./Node2D";
4
+ export declare class Trigger2D extends Aspect<"trigger", Node2D> {
5
+ static readonly aspect = "trigger";
6
+ private _h;
7
+ private _enabled;
8
+ private _group;
9
+ private _repush;
10
+ /** Which collision group this zone belongs to. Live. */
11
+ get group(): PhysicsGroup2D | undefined;
12
+ set group(g: PhysicsGroup2D | undefined);
13
+ /** Native physics body id (0 if no physics support). Mirrors 3D `Trigger.id`. */
14
+ get id(): number;
15
+ onAttach(): void;
16
+ onDetach(): void;
17
+ /** Switch the zone off and on — a spent pickup, a hitbox that is only live during a swing. */
18
+ get enabled(): boolean;
19
+ set enabled(v: boolean);
20
+ }
@@ -0,0 +1,133 @@
1
+ /** A fill entry: an atlas index, or [index, weight] for seeded scatter variants. */
2
+ export type FillEntry = number | [number, number];
3
+ export type Dir4 = [number, number, number, number];
4
+ /** One side's tiles: a single index (used for every cell along that side), or — with `size` > 1 —
5
+ * the `size` indices ALONG it (n/s run left→right, w/e run top→bottom). */
6
+ export type EdgeSlot = number | number[];
7
+ /** A whole `size`×`size` piece: one index (drawn in every cell of the block), or size² indices
8
+ * row-major. Path pieces and parts are blocks — at size 1 they are just a tile. */
9
+ export type TileBlock = number | number[];
10
+ /** `size`² indices, row-major within the block. */
11
+ export type FillBlock = number[];
12
+ /** A named element placed BY HAND (a pedestrian crossing in a road, a gate in a fence). It carries
13
+ * its own `id`, so the map stores it like any material — but it CONNECTS as its parent, so the
14
+ * run continues straight through it. Never picked at random: you paint it from the palette, ONE
15
+ * CELL at a time, and the tile is worked out from where that cell sits. */
16
+ export type TilePart = {
17
+ /** Stable small int, unique across every material and part of the tileset. */
18
+ id: number;
19
+ /** Which run the art is drawn for — 'v' vertical, 'h' horizontal. It also picks the art: the
20
+ * element varies ACROSS the line (a crossing has one tile per lane) and repeats along it, so
21
+ * `tiles` is `size` long, indexed by row for 'h' and by column for 'v'. */
22
+ axis?: "v" | "h";
23
+ /** The tiles — one index, `size` across the run when `axis` is set, else the size² block. */
24
+ tiles?: TileBlock;
25
+ };
26
+ /** A block variant: the block, or [block, weight] for seeded scatter. */
27
+ export type BlockEntry = FillBlock | [FillBlock, number];
28
+ /** One transition set of a patch material — the tiles its border shows against a neighbor. */
29
+ export type PatchSlots = {
30
+ /** Edge line tiles [n, e, s, w] — e.g. `edges[0]` draws where the patch stops toward the top. */
31
+ edges?: [EdgeSlot, EdgeSlot, EdgeSlot, EdgeSlot];
32
+ /** Convex corner tiles [ne, se, sw, nw] — the patch's outside corners. Always one cell. */
33
+ outer?: Dir4;
34
+ /** Concave corner tiles [ne, se, sw, nw] — the notch where two patch arms meet. One cell. */
35
+ inner?: Dir4;
36
+ };
37
+ export type PatchMaterial = {
38
+ /** Stable small int — what `cells('…')` stores when a map carries Autotile2D. */
39
+ id: number;
40
+ kind: "patch";
41
+ /** Editor swatch color ('#4a7c3a'). */
42
+ color?: string;
43
+ /** Block size in cells (default 1). With 2 or 3 the material is classified block-to-block on a
44
+ * lattice anchored at the map origin, `fill` holds size² tiles and each edge `size` tiles. */
45
+ size?: number;
46
+ /** Interior tile — one index, or an ARRAY of scatter variants (each `index` or
47
+ * `[index, weight]`; bare indices weigh 1): `fill: [261, [262, 0.1], [263, 0.05]]`.
48
+ * With `size` > 1 it is instead the row-major BLOCK of size² indices
49
+ * (`fill: [130, 131, 146, 147]`), or a list of such blocks for scatter variants. */
50
+ fill: number | FillEntry[] | BlockEntry[];
51
+ /** Transition sets keyed by the neighboring material's name; '*' = any other neighbor
52
+ * (including empty). Baked packs draw a material fading into a SPECIFIC background. */
53
+ over?: Record<string, PatchSlots>;
54
+ /** Hand-placed elements that connect as this material (see TilePart). */
55
+ parts?: Record<string, TilePart>;
56
+ };
57
+ export type PathMaterial = {
58
+ id: number;
59
+ kind: "path";
60
+ color?: string;
61
+ /** Cells ACROSS the line (default 1). A `size: 2` road is two lanes wide: connectivity runs
62
+ * block to block and every piece below is a 2×2 block instead of one tile. */
63
+ size?: number;
64
+ /** No connections at all. */
65
+ isolated?: TileBlock;
66
+ /** End caps [n, e, s, w] — `ends[0]` connects toward the top only. */
67
+ ends?: [TileBlock, TileBlock, TileBlock, TileBlock];
68
+ /** [vertical (n+s), horizontal (e+w)]. */
69
+ straights?: [TileBlock, TileBlock];
70
+ /** Elbows [ne, se, sw, nw] — `corners[0]` connects top + right. */
71
+ corners?: [TileBlock, TileBlock, TileBlock, TileBlock];
72
+ /** T pieces [n, e, s, w] — `tees[0]` is the tee MISSING the top connection. */
73
+ tees?: [TileBlock, TileBlock, TileBlock, TileBlock];
74
+ /** All four connections. */
75
+ cross?: TileBlock;
76
+ /** Hand-placed elements that connect as this material (see TilePart). */
77
+ parts?: Record<string, TilePart>;
78
+ };
79
+ export type TileMaterial = PatchMaterial | PathMaterial;
80
+ export type TilesetDef = {
81
+ /** The atlas image — write `asset('./TileSet.png')`. */
82
+ image: string;
83
+ /** Atlas cell size in image pixels — a number (square) or [w, h]. */
84
+ tile: number | [number, number];
85
+ /** Named materials; names are the editor/`over:` vocabulary, `id`s are what maps store. */
86
+ materials?: Record<string, TileMaterial>;
87
+ };
88
+ export declare const normalizeFill: (fill: number | FillEntry[]) => [number, number][];
89
+ /** A material's block size — 1 unless it declares `size` (clamped to a positive int). */
90
+ export declare const blockSize: (mat: TileMaterial) => number;
91
+ /** One cell of a block: a scalar covers the whole block, an array reads row-major. Undefined =
92
+ * unassigned (missing, or the negative sentinel the editor writes for a blank slot). */
93
+ export declare const blockTile: (block: TileBlock | undefined, n: number, lx: number, ly: number) => number | undefined;
94
+ /** How many tiles a part holds: `size` across the run when it declares an axis, else the block. */
95
+ export declare const partSlots: (part: TilePart, n: number) => number;
96
+ /** The cell value that draws atlas tile `index` verbatim in a material map. */
97
+ export declare const rawCell: (index: number) => number;
98
+ /** True for a cell holding a raw atlas tile rather than a material id. */
99
+ export declare const isRawCell: (v: number) => boolean;
100
+ /** The atlas index behind a raw cell (garbage in, garbage out — guard with isRawCell). */
101
+ export declare const rawIndex: (v: number) => number;
102
+ export declare const TILE_INDEX_MASK = 268435455;
103
+ /** The atlas index behind a (possibly oriented) tile value. */
104
+ export declare const tileIndex: (v: number) => number;
105
+ /** Clockwise quarter-turns (0–3) of a tile value. */
106
+ export declare const tileTurns: (v: number) => number;
107
+ /** Whether the tile is mirrored horizontally (the mirror applies before the rotation). */
108
+ export declare const tileFlip: (v: number) => boolean;
109
+ /** True when the value carries any orientation (renderers keep the fast path otherwise). */
110
+ export declare const tileOriented: (v: number) => boolean;
111
+ /** Build an oriented tile value: `index`, mirrored when `flip`, then `turns` quarter-turns CW. */
112
+ export declare const packTile: (index: number, turns?: number, flip?: boolean) => number;
113
+ /** The value rotated a further 90° clockwise. */
114
+ export declare const rot90: (v: number) => number;
115
+ /** The value rotated a further 180°. */
116
+ export declare const rot180: (v: number) => number;
117
+ /** The value rotated a further 270° clockwise (90° counter-clockwise). */
118
+ export declare const rot270: (v: number) => number;
119
+ /** The value mirrored horizontally (on screen — existing turns are re-based, group math). */
120
+ export declare const flipX: (v: number) => number;
121
+ /** The tile a part draws in a cell — indexed ACROSS the run ('h' by row, 'v' by column) so one
122
+ * element covers a lane each and repeats along the run; without an axis it is a plain block. */
123
+ export declare const partTile: (part: TilePart, n: number, lx: number, ly: number) => number | undefined;
124
+ /** `fill` as weighted BLOCKS of `size`² indices (row-major). Size 1 keeps the scalar/scatter
125
+ * reading; with size > 1 a flat number array is one positional block, an array of arrays is the
126
+ * variant list, and a bare number fills the whole block. Missing entries read as -1. */
127
+ export declare const fillBlocks: (fill: PatchMaterial["fill"], size?: number) => [number[], number][];
128
+ /**
129
+ * Derive display atlas indices from a material-id grid (row-major, row 0 = top, -1 = empty).
130
+ * Values that match no material id pass through unchanged (so converting maps degrades
131
+ * gracefully); -1 stays -1. Deterministic: same inputs + seed → same output on every platform.
132
+ */
133
+ export declare const deriveCells: (def: TilesetDef, cols: number, rows: number, cells: ArrayLike<number>, seed?: number) => Int32Array;
@@ -0,0 +1,14 @@
1
+ export type CellsData = {
2
+ cols: number;
3
+ rows: number;
4
+ /** Row-major tile values (row 0 = the top row), length cols*rows. */
5
+ data: Int32Array;
6
+ };
7
+ /** Encode a grid into a `cells()` payload (the editor / tools side of the codec). */
8
+ export declare const encodeCells: (cols: number, rows: number, data: ArrayLike<number>) => string;
9
+ /**
10
+ * Decode a `cells('…')` payload into the grid a tilemap block consumes. Scene files call this via
11
+ * the injected global; the value is plain data, so hand-written code may pass any
12
+ * `{ cols, rows, data }` of its own instead (procedural maps).
13
+ */
14
+ export declare const cells: (payload: string) => CellsData;
@@ -0,0 +1,141 @@
1
+ import type { ColorInput } from "../core/color";
2
+ import type { Vec2Like } from "../math/vec";
3
+ import { type AspectEntry, type MakeEntry as SharedMakeEntry } from "../scene/grammar";
4
+ import { Scene2D } from "./Scene2D";
5
+ import { Node2D } from "./Node2D";
6
+ import { Sprite } from "./Sprite";
7
+ import { Tilemap } from "./Tilemap";
8
+ import { SpriteSheet } from "./SpriteSheet";
9
+ import type { SpriteAnimation } from "./SpriteAnimation";
10
+ import type { CellsData } from "./cells";
11
+ import type { With } from "../core/Aspect";
12
+ export type Scene2dEnv = {
13
+ /** Background color — '#5a6b3b', 0x5a6b3b, or [r,g,b] in 0..1. */
14
+ background?: ColorInput;
15
+ /** Texture sampling: 'nearest' (crisp pixel art, engine default) or 'linear'. */
16
+ filter?: "nearest" | "linear";
17
+ /** Pixel-art crispness: snap the camera to whole screen pixels (seeds CameraFollow's
18
+ * `pixelSnap`, and the initial camera position lands on whole world units). */
19
+ pixelPerfect?: boolean;
20
+ /** Physics world gravity (Y-up: down is negative). Presence configures the world before any
21
+ * body is created — `[0, 0]` for top-down worlds. Omit to leave the world unconfigured. */
22
+ gravity?: Vec2Like;
23
+ };
24
+ /** A sprite node: one named entry of an imported `.sprite.ts` sheet. The sheet is ART only —
25
+ * colliders/bodies are scene semantics: put Shape2D / Physics2D / Trigger2D in `aspects`. */
26
+ export type SpriteSourceDef = {
27
+ /** The imported sheet handle: `import props from './props.sprite'` … `sheet: props`. */
28
+ sheet: SpriteSheet;
29
+ /** The entry name; omit when the sheet declares exactly one sprite. */
30
+ name?: string;
31
+ /** Start this clip immediately (sliced entries with clips). */
32
+ clip?: string;
33
+ /** Initial facing for `perDirection` clips. */
34
+ direction?: string;
35
+ };
36
+ export type TilemapSourceDef = {
37
+ /** The tileset image — `asset('./TileSet.png')`. */
38
+ texture: string;
39
+ /** On-screen cell size in world units — a number (square) or [w, h]. */
40
+ tile: number | [number, number];
41
+ /** Atlas grid: how the texture slices into tiles, [atlasCols, atlasRows]. */
42
+ atlas: [number, number];
43
+ /** The map: a `cells('…')` payload — or any `{ cols, rows, data }` of your own. */
44
+ cells: CellsData | {
45
+ cols: number;
46
+ rows: number;
47
+ data: number[] | Int32Array;
48
+ };
49
+ };
50
+ /** A camera marker node: seeds the scene camera's starting position (+ zoom). To MOVE the camera
51
+ * in play, attach `CameraFollow` to the node being followed — not aspects on this marker. */
52
+ export type Camera2dNodeDef = {
53
+ zoom?: number;
54
+ };
55
+ export type Scene2dNodeDef = {
56
+ sprite?: SpriteSourceDef;
57
+ tilemap?: TilemapSourceDef;
58
+ camera?: Camera2dNodeDef;
59
+ /** A code-built subtree — `make(factoryFn, { ...literal args })`, factory returns a Node2D. */
60
+ make?: SharedMakeEntry<any, Node2D>;
61
+ position?: Vec2Like;
62
+ /** Degrees, CCW. */
63
+ rotation?: number;
64
+ scale?: Vec2Like | number;
65
+ /** Draw layer (int) — higher renders on top. */
66
+ layer?: number;
67
+ /** Intra-layer depth for non-Y-sorted layers. */
68
+ z?: number;
69
+ /** Sprite tint (sprite nodes only). */
70
+ color?: ColorInput;
71
+ /** Sprite opacity 0..1 (sprite nodes only). */
72
+ opacity?: number;
73
+ flipX?: boolean;
74
+ flipY?: boolean;
75
+ visible?: boolean;
76
+ /** Editor-only: the move gizmo won't target this node (fields still edit). No runtime effect. */
77
+ locked?: boolean;
78
+ aspects?: readonly AspectEntry<any>[];
79
+ children?: Record<string, Scene2dNodeDef>;
80
+ };
81
+ export type Scene2dCameraDef = {
82
+ position?: Vec2Like;
83
+ zoom?: number;
84
+ };
85
+ export type Scene2dDef = {
86
+ env?: Scene2dEnv;
87
+ /** Per-layer config, keyed by layer number: `layers: { 1: { ySort: true } }`. */
88
+ layers?: Record<number | string, {
89
+ ySort?: boolean;
90
+ }>;
91
+ /** Starting camera when there's no camera NODE (a camera node wins). */
92
+ camera?: Scene2dCameraDef;
93
+ nodes?: Record<string, Scene2dNodeDef>;
94
+ };
95
+ type SourceNodeOf<N extends Scene2dNodeDef> = N extends {
96
+ sprite: {
97
+ clip: string;
98
+ };
99
+ } ? Sprite & {
100
+ anim: SpriteAnimation;
101
+ } : N extends {
102
+ sprite: SpriteSourceDef;
103
+ } ? Sprite : N extends {
104
+ tilemap: TilemapSourceDef;
105
+ } ? Tilemap : Node2D;
106
+ type AspectsOf<N extends Scene2dNodeDef> = N extends {
107
+ aspects: readonly AspectEntry<infer A>[];
108
+ } ? A : never;
109
+ type NodeOf<N extends Scene2dNodeDef> = [
110
+ AspectsOf<N>
111
+ ] extends [never] ? SourceNodeOf<N> : With<SourceNodeOf<N>, AspectsOf<N>>;
112
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
113
+ type ChildMapsOf<T extends Record<string, Scene2dNodeDef>> = {
114
+ [K in keyof T]: T[K] extends {
115
+ children: infer C extends Record<string, Scene2dNodeDef>;
116
+ } ? NodesOf<C> : never;
117
+ }[keyof T];
118
+ type NodesOf<T extends Record<string, Scene2dNodeDef>> = {
119
+ [K in keyof T]: NodeOf<T[K]>;
120
+ } & ([ChildMapsOf<T>] extends [never] ? unknown : UnionToIntersection<ChildMapsOf<T>>);
121
+ export type Scene2dNodes<D extends Scene2dDef> = D["nodes"] extends Record<string, Scene2dNodeDef> ? NodesOf<D["nodes"]> : Record<string, Node2D>;
122
+ export type LoadedScene2d<D extends Scene2dDef> = {
123
+ scene: Scene2D;
124
+ nodes: Scene2dNodes<D>;
125
+ };
126
+ export declare class Scene2dHandle<D extends Scene2dDef = Scene2dDef> {
127
+ readonly def: D;
128
+ private _loading?;
129
+ constructor(def: D);
130
+ /** Instantiate the scene (idempotent — subsequent calls return the same instance). Does not open. */
131
+ load(): Promise<LoadedScene2d<D>>;
132
+ /** Load and make active (only the active 2D scene renders). */
133
+ open(): Promise<LoadedScene2d<D>>;
134
+ }
135
+ /**
136
+ * Define a 2D scene as data — the default export of a `.scene2d.ts` file. Returns a typed handle:
137
+ * `const { scene, nodes } = await handle.open()` gives `nodes.<name>` typed by its source block
138
+ * (Sprite / Tilemap / Node2D) with its `use(...)`d aspects attached.
139
+ */
140
+ export declare const defineScene2d: <const D extends Scene2dDef>(def: D) => Scene2dHandle<D>;
141
+ export {};
@@ -0,0 +1,16 @@
1
+ /** Collides with everything. */
2
+ export declare const ALL_GROUPS = 4294967295;
3
+ export declare class PhysicsGroup2D {
4
+ /** The single category bit this group owns. */
5
+ readonly bit: number;
6
+ /** Optional debug label, so an inspector says "bullets" rather than "group #3". */
7
+ readonly label: string;
8
+ private _ignored;
9
+ /**
10
+ * Stop colliding with these groups — symmetric, so naming it on one side is enough. Safe to call
11
+ * after bodies exist: their filters are re-pushed.
12
+ */
13
+ ignore(...groups: PhysicsGroup2D[]): this;
14
+ /** Members of this group don't collide with EACH OTHER — bullets, debris, a ragdoll's own bones. */
15
+ ignoreSelf(): this;
16
+ }
@@ -0,0 +1,4 @@
1
+ export declare const onUpdate: (callback: (dt: number) => void) => void;
2
+ export declare const offUpdate: (callback: (dt: number) => void) => void;
3
+ export declare const ensureAnimEvents: () => void;
4
+ export declare const ensurePhysicsEvents: () => void;
@@ -0,0 +1,30 @@
1
+ import { Aspect } from "../core/Aspect";
2
+ import type { Node2D } from "./Node2D";
3
+ import type { Scene2D } from "./Scene2D";
4
+ /**
5
+ * Ease the scene camera toward this node every frame (attach it to the player). In a `.scene2d.ts`
6
+ * file the loader wires `scene` automatically; from hand-written code pass it yourself:
7
+ * `hero.aspect(CameraFollow, { scene })`.
8
+ *
9
+ * The eased position accumulates at full precision and only the value PUSHED to the camera is
10
+ * snapped — reading the snapped camera back as the ease-from value would let tiny sub-pixel steps
11
+ * round to zero near settle (the follow would stall a few px off-centre, then jump).
12
+ */
13
+ export declare class CameraFollow extends Aspect<"cameraFollow", Node2D> {
14
+ static readonly aspect = "cameraFollow";
15
+ /** The scene2d loader injects the scene into aspects that declare this. */
16
+ static readonly wantsScene = true;
17
+ /** The scene whose camera follows (wired by the scene file loader). */
18
+ scene: Scene2D | null;
19
+ /** Exponential time constant in seconds; smaller = snappier, 0 = pin the node to centre. */
20
+ smooth: number;
21
+ /** Camera offset from the node, in world units. */
22
+ offset: [number, number];
23
+ /** Quantize the camera to whole screen pixels so eased motion never shimmers pixel art.
24
+ * Defaults to the scene's `env.pixelPerfect` (true when unset). */
25
+ pixelSnap: boolean;
26
+ private _x;
27
+ private _y;
28
+ private readonly _grid;
29
+ update(dt: number): void;
30
+ }
@@ -0,0 +1,2 @@
1
+ /** Register the host pointer callback once, on the first click/touchstart listener (node or scene). */
2
+ export declare const ensurePointerEvents: () => void;