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,169 @@
1
+ import { System } from "../core/Aspect";
2
+ import { Vec3, type Vec3Like } from "../math/vec";
3
+ import type { Node } from "./Node";
4
+ import type { Scene } from "./Scene";
5
+ export declare const NAV_AGENT: {
6
+ readonly RADIUS: 0;
7
+ readonly HEIGHT: 1;
8
+ readonly MAX_SPEED: 2;
9
+ readonly MAX_ACCELERATION: 3;
10
+ readonly COLLISION_QUERY_RANGE: 4;
11
+ readonly PATH_OPTIMIZATION_RANGE: 5;
12
+ readonly SEPARATION_WEIGHT: 6;
13
+ readonly AVOIDANCE: 7;
14
+ readonly INCLUDE_FLAGS: 8;
15
+ readonly EXCLUDE_FLAGS: 9;
16
+ readonly ANTICIPATE_TURNS: 10;
17
+ readonly OPTIMIZE_VIS: 11;
18
+ readonly OPTIMIZE_TOPO: 12;
19
+ readonly COUNT: 13;
20
+ };
21
+ export declare const NAV_READ: {
22
+ readonly POS_X: 0;
23
+ readonly POS_Y: 1;
24
+ readonly POS_Z: 2;
25
+ readonly VEL_X: 3;
26
+ readonly VEL_Y: 4;
27
+ readonly VEL_Z: 5;
28
+ readonly DVEL_X: 6;
29
+ readonly DVEL_Y: 7;
30
+ readonly DVEL_Z: 8;
31
+ readonly STATE: 9;
32
+ readonly TARGET_STATE: 10;
33
+ readonly REMAINING: 11;
34
+ readonly PARTIAL: 12;
35
+ readonly STRIDE: 13;
36
+ };
37
+ /** The agent size a navmesh is built for (and the crowd's defaults). */
38
+ export type NavAgentSize = {
39
+ /** metres — polygons are eroded by it. Default 0.4 */
40
+ radius?: number;
41
+ /** metres. Default 1.8 */
42
+ height?: number;
43
+ /** the highest step walked over, metres. Default 0.4 */
44
+ climb?: number;
45
+ /** the steepest walkable slope, degrees. Default 50 */
46
+ slope?: number;
47
+ };
48
+ export type NavMeshLoadOptions = {
49
+ /** `asset('./assets/nav/<scene>.navmesh')` — what `lecodes navmesh bake` writes. */
50
+ data: string;
51
+ /** The agent size the bake uses (the file records it; the crowd reads it back). */
52
+ agent?: NavAgentSize;
53
+ /** Named areas → traversal cost (1 = plain ground). Ids are assigned in this order (1..15); the
54
+ * bake stores the names, queries and agents refer to them (`include` / `exclude`, `cost`). */
55
+ areas?: Record<string, number>;
56
+ };
57
+ /** The file header `lecodes navmesh bake` wrote. */
58
+ export type NavMeshInfo = {
59
+ version: number;
60
+ agent: {
61
+ radius: number;
62
+ height: number;
63
+ climb: number;
64
+ slope: number;
65
+ };
66
+ cell: number;
67
+ cellHeight: number;
68
+ tileSize: number;
69
+ bounds: [[number, number, number], [number, number, number]];
70
+ stats: {
71
+ tiles: number;
72
+ polys: number;
73
+ verts: number;
74
+ triangles: number;
75
+ volumes: number;
76
+ links: number;
77
+ };
78
+ meta: {
79
+ scene?: string;
80
+ areas?: Record<string, number>;
81
+ costs?: Record<string, number>;
82
+ [k: string]: unknown;
83
+ } | null;
84
+ };
85
+ /** A straight path: the corners to walk, plus whether it stops short of the target. */
86
+ export type NavPath = Vec3[] & {
87
+ partial: boolean;
88
+ };
89
+ export type NavQueryOptions = {
90
+ /** Only these areas (names). Default: every area. */
91
+ include?: string[];
92
+ /** Never these areas (names). */
93
+ exclude?: string[];
94
+ /** Search half-extents around each endpoint (how far off the mesh a point may be). Default [2, 4, 2]. */
95
+ extents?: Vec3Like;
96
+ };
97
+ export type NavRaycastHit = {
98
+ hit: boolean;
99
+ point: Vec3;
100
+ normal: Vec3;
101
+ };
102
+ /** The crowd behind a scene's agents — a system `NavMesh.load` attaches to the scene so the whole
103
+ * crowd advances once per fixed step, BEFORE every `NavAgent` applies its slot (`static after`). */
104
+ export declare class NavCrowd extends System<"navCrowd"> {
105
+ static readonly aspect = "navCrowd";
106
+ updateFixed(dt: number): void;
107
+ onDetach(): void;
108
+ }
109
+ export declare class NavMesh {
110
+ /** True while `lecodes navmesh bake` runs the app — skip menus and build the level straight away. */
111
+ static get baking(): boolean;
112
+ /** The navmesh agents bind to (the last one loaded; one per world at a time). */
113
+ static active: NavMesh | null;
114
+ private static byScene;
115
+ private static overrides;
116
+ private static warned;
117
+ private static baked;
118
+ /** Leave a static body out of the bake (`nav: false` in a scene file). */
119
+ static exclude(node: Node): void;
120
+ /** A static body nobody may walk on (`nav: 'unwalkable'`): its footprint is cut out. */
121
+ static unwalkable(node: Node): void;
122
+ /** A static body's surface belongs to a named area (`navArea: 'road'`; names from `load`'s `areas`). */
123
+ static area(node: Node, name: string): void;
124
+ /** Forget every override (a scene rebuild). */
125
+ static clear(): void;
126
+ static of(scene: Scene): NavMesh | null;
127
+ /** Load the level's navmesh — or, under `lecodes navmesh bake`, dump the collision geometry for
128
+ * it. Resolves null when nothing was loaded (no bake yet, a host without navigation, bake mode). */
129
+ static load(scene: Scene, opts: NavMeshLoadOptions): Promise<NavMesh | null>;
130
+ readonly scene: Scene;
131
+ readonly info: NavMeshInfo;
132
+ /** The agent size the mesh was built for. */
133
+ readonly agent: {
134
+ radius: number;
135
+ height: number;
136
+ climb: number;
137
+ slope: number;
138
+ };
139
+ /** Named areas → ids (from the bake; `load`'s `areas` when the file has none). */
140
+ readonly areas: Record<string, number>;
141
+ private _debug;
142
+ private _seed;
143
+ private _disposed;
144
+ private constructor();
145
+ private static areaIds;
146
+ /** The include/exclude flag mask for a list of area names (undefined = every area). */
147
+ flags(names?: string[]): number;
148
+ private masks;
149
+ /** Traversal cost of a named area (1 = plain ground; > 1 = avoided when a cheaper way exists). */
150
+ cost(area: string, cost: number): void;
151
+ /** The straight (string-pulled) path from → to. Empty when an endpoint is off the mesh;
152
+ * `.partial` when the target is unreachable (the path ends at the closest polygon). */
153
+ findPath(from: Vec3Like, to: Vec3Like, opts?: NavQueryOptions & {
154
+ maxCorners?: number;
155
+ }): NavPath;
156
+ /** The closest point on the mesh (within `extents` of `p`), or null. */
157
+ nearest(p: Vec3Like, opts?: NavQueryOptions): Vec3 | null;
158
+ /** Can an agent walk straight from → to? `hit` = a wall in between (at `point`, facing `normal`). */
159
+ raycast(from: Vec3Like, to: Vec3Like, opts?: NavQueryOptions): NavRaycastHit;
160
+ /** A random reachable point — within walking distance `radius` of `center`, or anywhere on the
161
+ * mesh. Deterministic: the sequence depends only on the calls made (a seeded generator). */
162
+ randomPoint(center?: Vec3Like, radius?: number, opts?: NavQueryOptions): Vec3 | null;
163
+ /** Draw the polygon mesh (a flat unlit surface 3 cm above the walkable area). */
164
+ get debug(): boolean;
165
+ set debug(on: boolean);
166
+ /** Release the host handles (a scene teardown). Agents fall back to inert. */
167
+ dispose(): void;
168
+ private static bake;
169
+ }
@@ -0,0 +1,99 @@
1
+ import { AspectHost } from "../core/Aspect";
2
+ import { Registry } from "../core/registry";
3
+ import { Vec3, type Vec3Like } from "../math/vec";
4
+ import { Quat, type QuatLike } from "../math/quat";
5
+ import { Mat4, type Mat4Like } from "../math/mat4";
6
+ import type { Geometry } from "./Geometry";
7
+ import { Material } from "./Material";
8
+ import type { CompAxis, CompWriter } from "../core/compWrite";
9
+ import type { ClickEvent, TouchStartEvent } from "../runtime/touch";
10
+ /** id → Node, so host callbacks (touch hits, animation events) route back to the owning object. */
11
+ export declare const nodeRegistry: Registry<Node>;
12
+ export type NodeEvents = {
13
+ click: (ev: ClickEvent<Node | null>) => void;
14
+ touchstart: (ev: TouchStartEvent<Node | null>) => void;
15
+ /** AR anchors only (`scene.root` / `scene.createAnchor()`): the anchor began tracking. */
16
+ track: () => void;
17
+ /** AR anchors only: the anchor lost tracking. */
18
+ untrack: () => void;
19
+ /** A physics contact/trigger overlap began (the other body's node). Needs a Shape + Physics/Trigger. */
20
+ enter: (other: Node) => void;
21
+ /** A physics contact/trigger overlap ended. */
22
+ exit: (other: Node) => void;
23
+ };
24
+ export declare class Node extends AspectHost<NodeEvents> implements CompWriter {
25
+ /** Native entity handle. */
26
+ readonly id: number;
27
+ /** AR anchors only — whether the anchor is currently being tracked. Kept in step with the
28
+ * 'track' / 'untrack' events; `false` for any non-anchor node. */
29
+ isTracked: boolean;
30
+ private _matrix?;
31
+ private _worldMatrix?;
32
+ private _boneCache?;
33
+ /** Materials assigned through setMaterial, by primitive slot (a Mesh fills slot 0 itself). */
34
+ protected _materials?: Material[];
35
+ constructor(internalId?: number);
36
+ /** Geometry, if this node is a Mesh (used by physics auto-shape). Overridden by Mesh. */
37
+ get geometry(): Geometry | undefined;
38
+ get name(): string;
39
+ set name(value: string);
40
+ get visible(): boolean;
41
+ set visible(value: boolean);
42
+ private _sync;
43
+ get matrix(): Mat4;
44
+ set matrix(m: Mat4Like);
45
+ get worldMatrix(): Mat4;
46
+ set worldMatrix(m: Mat4Like);
47
+ private _setOwnedPosition;
48
+ private _setOwnedRotation;
49
+ get position(): Vec3;
50
+ set position(v: Vec3Like);
51
+ get x(): number;
52
+ set x(v: number);
53
+ get y(): number;
54
+ set y(v: number);
55
+ get z(): number;
56
+ set z(v: number);
57
+ _writeComp(_prop: string, axis: CompAxis, v: number): void;
58
+ get scale(): Vec3;
59
+ set scale(v: Vec3Like | number);
60
+ get quaternion(): Quat;
61
+ set quaternion(v: QuatLike);
62
+ get eulerAngles(): Vec3;
63
+ set eulerAngles(v: Vec3Like);
64
+ get forward(): Vec3;
65
+ get worldPosition(): Vec3;
66
+ get worldScale(): Vec3;
67
+ get worldQuaternion(): Quat;
68
+ get worldEulerAngles(): Vec3;
69
+ get parent(): Node | null;
70
+ get children(): Node[];
71
+ get childCount(): number;
72
+ getChild(index: number): Node | null;
73
+ /** Parent the given nodes under this one. */
74
+ add(...children: Node[]): this;
75
+ setParent(parent: Node | null, worldPositionStays?: boolean): this;
76
+ traverse(callback: (node: Node) => void): void;
77
+ /** The material assigned to slot 0 through this API (null before one is set — a GLB part's own
78
+ * glTF material stays native-side). */
79
+ get material(): Material | null;
80
+ set material(m: Material);
81
+ /** Replace the material of one primitive slot (`index` = the primitive's order in the glTF
82
+ * mesh; a primitive-shape Mesh has one slot). */
83
+ setMaterial(material: Material, index?: number): this;
84
+ /** The material previously assigned to `index` (null when none was — see Mesh for the probe). */
85
+ getMaterial(index?: number): Material | null;
86
+ /** Find a descendant by name — bones of a loaded Model included (`hero.bone('RightHand').add(sword)`).
87
+ * Same rule the Animator binds clips with: exact name first, then the part after the last `:` / `|`
88
+ * (Mixamo `mixamorig:Hips` matches `Hips`); a skinned joint beats a plain node of the same name.
89
+ * Cached per name; null if absent. */
90
+ bone(name: string): Node | null;
91
+ /** Orient the node so the given axis (default "-z", "forward") points at a world point. */
92
+ lookAt(point: Vec3Like, mode?: "z" | "-z" | "x" | "-x" | "y" | "-y", ortho?: Vec3Like): this;
93
+ addEventListener<K extends keyof NodeEvents>(channel: K, callback: NodeEvents[K]): void;
94
+ /** Destroy this node and its whole subtree. Every aspect in the subtree is detached first (its
95
+ * `onDetach` runs: physics bodies released, updaters unregistered, listeners dropped) — native
96
+ * `destroyEntity` frees the entity tree but knows nothing about JS-side aspects, and a destroyed
97
+ * node's `update()` must not keep ticking. Deepest nodes go first, then this one. */
98
+ destroy(): void;
99
+ }
@@ -0,0 +1,20 @@
1
+ export declare class Noise {
2
+ private readonly _id;
3
+ constructor();
4
+ /** Sample 2D noise. */
5
+ get(x: number, y: number): number;
6
+ /** Sample 3D noise. */
7
+ get3d(x: number, y: number, z: number): number;
8
+ private _frequency;
9
+ get frequency(): number;
10
+ set frequency(v: number);
11
+ private _octaves;
12
+ get octaves(): number;
13
+ set octaves(v: number);
14
+ private _fractalLacunarity;
15
+ get fractalLacunarity(): number;
16
+ set fractalLacunarity(v: number);
17
+ private _fractalGain;
18
+ get fractalGain(): number;
19
+ set fractalGain(v: number);
20
+ }
@@ -0,0 +1,277 @@
1
+ import { type ColorInput } from "../core/color";
2
+ import { type Vec3Like } from "../math/vec";
3
+ import type { Geometry } from "./Geometry";
4
+ import { Material, type ParticlesMaterialOptions } from "./Material";
5
+ import { Node } from "./Node";
6
+ type Range<T> = T | {
7
+ min: T;
8
+ max: T;
9
+ };
10
+ export declare class CurveBuilder {
11
+ private _kind;
12
+ private _lo;
13
+ private _hi;
14
+ private _stops;
15
+ constructor(base: Range<number>, mode: "multiply" | "add");
16
+ /** Curve value at birth (t = 0). Must come before any other stop. */
17
+ from(v: Range<number>): this;
18
+ /** Curve value at `t` (0..1 of the particle's life). Stops must be added in ascending t order. */
19
+ via(t: number, v: Range<number>): this;
20
+ /** Curve value at death (t = 1). */
21
+ to(v: Range<number>): this;
22
+ /** The classic opacity envelope: rise over the first `fadeIn`, fall over the last `fadeOut`. */
23
+ fade(fadeIn?: number, fadeOut?: number): this;
24
+ /** The PARAM_CURVE record payload (sans slot): [kind, baseLo, baseHi, n, (t, lo, hi)×n]. */
25
+ get _data(): Float32Array;
26
+ }
27
+ export declare class ColorCurveBuilder {
28
+ private _lo;
29
+ private _hi;
30
+ private _stops;
31
+ constructor(base: Range<ColorInput>);
32
+ /** Curve color at birth (t = 0). Must come first. The curve multiplies the base color. */
33
+ from(c: Range<ColorInput>): this;
34
+ /** Curve color at `t` (0..1 of the particle's life), in ascending t order. */
35
+ via(t: number, c: Range<ColorInput>): this;
36
+ /** Curve color at death (t = 1). */
37
+ to(c: Range<ColorInput>): this;
38
+ /** The COLOR_CURVE record payload: [baseLo rgba, baseHi rgba, n, (t, lo rgba, hi rgba)×n]. */
39
+ get _data(): Float32Array;
40
+ }
41
+ /** A value curve over each particle's lifetime. Default mode `multiply` (the curve scales the
42
+ * base); `add` offsets it instead. */
43
+ export declare const curve: (base?: Range<number>, mode?: "multiply" | "add") => CurveBuilder;
44
+ /** A color curve over each particle's lifetime — always multiplies the base color. */
45
+ export declare const colorCurve: (base?: Range<ColorInput>) => ColorCurveBuilder;
46
+ export type ParticleValue = Range<number> | CurveBuilder | {
47
+ _data: Float32Array;
48
+ };
49
+ export type ParticleColor = ColorInput | {
50
+ min: ColorInput;
51
+ max: ColorInput;
52
+ } | ColorCurveBuilder | {
53
+ _data: Float32Array;
54
+ };
55
+ type VelocityValue = {
56
+ speed?: Range<number>;
57
+ /** Cone half-angle in radians — jitter the launch direction uniformly within it. */
58
+ spread?: number;
59
+ /** Asymmetric jitter: two angles (u, v — the x/y components) in radians. */
60
+ randomizeAngle?: {
61
+ min: Vec3Like;
62
+ max: Vec3Like;
63
+ };
64
+ } & ({
65
+ from: Vec3Like;
66
+ } | {
67
+ to: Vec3Like;
68
+ } | {
69
+ dir: Vec3Like;
70
+ } | {});
71
+ /** Where particles are born, in emitter space. Sphere / hemisphere / cone have an axis of +Y (the
72
+ * hemisphere is the +Y half, the cone opens along +Y from its base disc at `center`) — aim the
73
+ * node with `lookAt(target, 'y')`. `thickness` 0 emits from the surface only, 1 (default) from the
74
+ * whole volume. A sphere or cone also sets the LAUNCH DIRECTION (outward / from the cone's apex)
75
+ * when `startVelocity` gives a speed but no direction, like Unity's shapes. */
76
+ type Shape = {
77
+ type: "point";
78
+ v: Vec3Like;
79
+ } | {
80
+ type: "box";
81
+ min: Vec3Like;
82
+ max: Vec3Like;
83
+ } | {
84
+ type: "circle";
85
+ center: Vec3Like;
86
+ radius: number;
87
+ } | {
88
+ type: "sphere";
89
+ center?: Vec3Like;
90
+ radius: number;
91
+ thickness?: number;
92
+ } | {
93
+ type: "hemisphere";
94
+ center?: Vec3Like;
95
+ radius: number;
96
+ thickness?: number;
97
+ } | {
98
+ type: "cone";
99
+ center?: Vec3Like;
100
+ radius: number; /** half-angle, radians */
101
+ angle?: number; /** emit this far up the axis too */
102
+ length?: number;
103
+ thickness?: number;
104
+ };
105
+ /** Extra velocity over each particle's life — evaluated from the curves every frame and ADDED as a
106
+ * displacement (not accumulated like `acceleration`): `radial` pushes outward along the particle's
107
+ * birth direction (a burst that decays: `curve(4).to(0)`), `x`/`y`/`z` drift in the simulation
108
+ * space (rising smoke: `y: curve(2).from(0).to(1)`). Unity's velocityOverLifetime. */
109
+ export type VelocityOverLife = {
110
+ radial?: ParticleValue;
111
+ x?: ParticleValue;
112
+ y?: ParticleValue;
113
+ z?: ParticleValue;
114
+ };
115
+ type Noise = {
116
+ strength?: number;
117
+ frequency?: number;
118
+ speed?: number;
119
+ };
120
+ /** Ground plane for bouncing particles (all render modes). `height` is in the simulation space:
121
+ * world y with `space: 'world'`, emitter-local y otherwise. */
122
+ export type ParticleGround = {
123
+ /** Plane height (default 0). */
124
+ height?: number;
125
+ /** Contact radius — particles stop `radius` above the plane (a mesh's half-extent; default 0). */
126
+ radius?: number;
127
+ /** Fraction of the vertical speed kept on impact, 0..1 (default 0.3). */
128
+ bounce?: number;
129
+ /** Tangential damping while in contact, per second — like `drag` (default 8). */
130
+ friction?: number;
131
+ };
132
+ export type ParticlesOptions = ParticlesMaterialOptions & {
133
+ /** Draw every particle as this mesh — lit, tumbling 3D debris (shell casings, rubble, leaves,
134
+ * shrapnel) in one draw call. The system switches to the mesh render mode; the default
135
+ * material becomes `Material.lit()` (pass `material` for color/roughness/metallic — the
136
+ * sprite look options are ignored). `size` scales the mesh (default 1); `rotation`/`opacity`/
137
+ * `frame` don't apply. See `angularVelocity` and `ground`. */
138
+ mesh?: Geometry;
139
+ /** (mesh) Spin, radians per second about the particle's own axes — a vector, or a per-component
140
+ * `{ min, max }` range randomized at spawn. Particles are born in the emitter's orientation. */
141
+ angularVelocity?: Vec3Like | {
142
+ min: Vec3Like;
143
+ max: Vec3Like;
144
+ };
145
+ /** A ground plane the particles bounce on and come to rest on (any render mode); `null`
146
+ * disables it. */
147
+ ground?: ParticleGround | null;
148
+ /** Custom draw material. Unset = the default point-sprite material, configured by the
149
+ * `ParticlesMaterialOptions` sugar (map/sheet/emissive/blend/soft) — which is ignored
150
+ * when an explicit material is passed. */
151
+ material?: Material;
152
+ /** Particle pool capacity (default 1000). */
153
+ maxParticles?: number;
154
+ /** Particles emitted per second. */
155
+ rate?: number;
156
+ /** Simulation space. `'local'` (default) — particles ride the node's transform; `'world'` —
157
+ * each particle stays where it was born as the emitter moves on (trails: drift smoke, mud,
158
+ * wake). Switching at runtime resets live particles. */
159
+ space?: "local" | "world";
160
+ /** Fraction (usually 0..1) of the emitter's own velocity added to each particle at spawn —
161
+ * smoke "thrown" off a moving car. Takes effect with `space: 'world'`. */
162
+ inheritVelocity?: number;
163
+ /** Particles emitted per world unit the emitter MOVES, on top of `rate`, with spawn points
164
+ * spread evenly along the path — trail density independent of speed, no per-frame clumps.
165
+ * Meant for `space: 'world'`. */
166
+ rateOverDistance?: number;
167
+ /** Draw order among blended systems at the same depth — higher draws later, i.e. on top (Unity's
168
+ * sortingOrder). Systems are depth-sorted by their node, so the emitters of one effect tie and
169
+ * without this the engine picks who covers whom per frame (smoke popping over a fireball).
170
+ * Default 0; a fireball wants 2, its smoke 1, a smoke trail -1. */
171
+ order?: number;
172
+ shape?: Shape;
173
+ /** Extra velocity over life (radial burst that decays, axis drift) — see `VelocityOverLife`. */
174
+ velocityOverLife?: VelocityOverLife;
175
+ startVelocity?: Vec3Like | VelocityValue;
176
+ /** Downward acceleration, world units/s² — positive pulls particles DOWN (sugar for
177
+ * `acceleration: [0, -g, 0]`). */
178
+ gravity?: number;
179
+ /** Constant acceleration vector (gravity, wind, …). Wins over `gravity` when both are set. */
180
+ acceleration?: Vec3Like;
181
+ drag?: number;
182
+ lifetime?: Range<number>;
183
+ color?: ParticleColor;
184
+ /** World-unit diameter (alias of custom[0]). Default 1. */
185
+ size?: ParticleValue;
186
+ /** Radians (alias of custom[1]). */
187
+ rotation?: ParticleValue;
188
+ /** Per-particle opacity 0..1 (alias of custom[2]). Default 1. */
189
+ opacity?: ParticleValue;
190
+ /** Flipbook frame index (alias of custom[3]). With `sheet` set and no explicit frame, the
191
+ * default is one full sheet cycle over each particle's lifetime, starting at `startFrame`. */
192
+ frame?: ParticleValue;
193
+ /** Where the default flipbook cycle begins: `'random'` (default — desynchronized loops like
194
+ * fire/smoke) or a frame index (`0` plays the sheet in order — explosions, one-shot bursts).
195
+ * Only shapes the default; an explicit `frame` wins. */
196
+ startFrame?: number | "random";
197
+ noise?: Noise | null;
198
+ /** Fixed random seed for deterministic tests. */
199
+ seed?: number;
200
+ };
201
+ export declare class Particles extends Node {
202
+ private _material;
203
+ /** Custom curve-param slots (0..3); size/rotation/opacity/frame alias slots 0-3. */
204
+ readonly custom: ParticleValue[];
205
+ constructor(options?: ParticlesOptions);
206
+ /** Emit `count` particles immediately (a burst). */
207
+ spawn(count: number): this;
208
+ private _send;
209
+ set rate(val: number);
210
+ /** `'world'` leaves particles behind where they were born (trails). Switching resets live ones. */
211
+ set space(val: "local" | "world");
212
+ set inheritVelocity(val: number);
213
+ set rateOverDistance(val: number);
214
+ set order(val: number);
215
+ set velocityOverLife(v: VelocityOverLife);
216
+ set shape(shape: Shape);
217
+ /** (mesh mode) Replace the particle mesh; live particles keep flying as the new shape. */
218
+ set mesh(g: Geometry);
219
+ set angularVelocity(v: Vec3Like | {
220
+ min: Vec3Like;
221
+ max: Vec3Like;
222
+ });
223
+ set ground(g: ParticleGround | null);
224
+ set startVelocity(val: Vec3Like | VelocityValue);
225
+ /** Positive pulls particles down — sugar for `acceleration = [0, -g, 0]`. */
226
+ set gravity(val: number);
227
+ set acceleration(a: Vec3Like);
228
+ set drag(val: number);
229
+ set seed(val: number);
230
+ set lifetime(val: Range<number>);
231
+ set size(val: ParticleValue);
232
+ set rotation(val: ParticleValue);
233
+ set opacity(val: ParticleValue);
234
+ set frame(val: ParticleValue);
235
+ set color(value: ParticleColor);
236
+ get material(): Material;
237
+ set material(material: Material);
238
+ set noise(noise: Noise | null);
239
+ }
240
+ /** `Trail` options. The look options (map/sheet/emissive/blend/soft) come from
241
+ * `ParticlesMaterialOptions`, same as `Particles`. */
242
+ export type TrailOptions = Omit<ParticlesMaterialOptions, "render" | "stretch"> & {
243
+ /** Seconds each trail point lives — the trail's length in time. Default 0.5. */
244
+ time?: number;
245
+ /** Strip width in world units; a curve tapers it over each point's life (head → tail).
246
+ * Default 0.1. */
247
+ width?: ParticleValue;
248
+ /** Minimum emitter movement (world units) between recorded points. Default 0.05. */
249
+ minDistance?: number;
250
+ /** Point capacity (default 128). */
251
+ maxPoints?: number;
252
+ color?: ParticleColor;
253
+ /** Opacity along the trail. Defaults to fading the tail out (`curve().to(0)`). */
254
+ opacity?: ParticleValue;
255
+ };
256
+ /** A ribbon strip that follows this node through the world — sword swings, skid marks, missile
257
+ * trails. Attach it to (or under) the moving node and just move; points are laid down per
258
+ * `minDistance` of movement, live for `time` seconds, and the strip stays glued to the node at
259
+ * its head. Width/opacity/color accept the same curves as `Particles`, evaluated over each
260
+ * point's life — i.e. along the trail from head (fresh) to tail (dying). */
261
+ export declare class Trail extends Node {
262
+ private _material;
263
+ private _rateDistance;
264
+ constructor(options?: TrailOptions);
265
+ private _send;
266
+ /** Trail length in seconds — how long each laid-down point lives. */
267
+ set time(val: number);
268
+ set width(val: ParticleValue);
269
+ set opacity(val: ParticleValue);
270
+ set color(value: ParticleColor);
271
+ set minDistance(val: number);
272
+ /** Pause/resume laying down points — existing ones still age out, so the trail fades naturally
273
+ * after e.g. a sword swing ends. */
274
+ set emitting(val: boolean);
275
+ get material(): Material;
276
+ }
277
+ export {};
@@ -0,0 +1,91 @@
1
+ import { Aspect } from "../core/Aspect";
2
+ import type { FieldMeta } from "../core/fields";
3
+ import type { CompAxis, CompWriter } from "../core/compWrite";
4
+ import { Vec3, type Vec3Like } from "../math/vec";
5
+ import { type Node } from "./Node";
6
+ export type MotionType = "static" | "dynamic" | "kinematic";
7
+ export interface PhysicsConfig {
8
+ /** Gravity in world units/s² (Y-up: down is negative). Default [0, -9.81, 0]. */
9
+ gravity?: Vec3Like;
10
+ /** Max simultaneous bodies (resizes the world; only before any body exists). Default 4096. */
11
+ maxBodies?: number;
12
+ }
13
+ /** Closest raycast hit. */
14
+ export interface RayHit {
15
+ node: Node | null;
16
+ point: Vec3;
17
+ normal: Vec3;
18
+ fraction: number;
19
+ }
20
+ /**
21
+ * What a body's friction already is the moment the host creates it. This is part of the ABI, not an
22
+ * assumption: bridges.d.ts states it, so every host owes us this value. Knowing it lets attach skip
23
+ * a bridge call per body whenever nobody named a surface.
24
+ */
25
+ export declare const DEFAULT_FRICTION = 0.6;
26
+ export declare class Physics extends Aspect<"physics", Node> implements CompWriter {
27
+ static readonly aspect = "physics";
28
+ /** Render interpolation of body transforms between the fixed 60 Hz steps (global; default on). Turn
29
+ * off to save per-frame transform writes when you have many moving bodies / don't need >60 Hz
30
+ * smoothness — bodies then advance in discrete steps. */
31
+ private static _interpolation;
32
+ static get interpolation(): boolean;
33
+ static set interpolation(on: boolean);
34
+ /** Default "dynamic". */
35
+ motion: MotionType;
36
+ /** Mass in kg for dynamic bodies (default 1). Ignored for static/kinematic. */
37
+ mass: number;
38
+ /**
39
+ * Surface friction: 0 = ice, ~1 = grippy asphalt, and values above 1 are allowed (rubber on
40
+ * tarmac).
41
+ *
42
+ * The engine COMBINES the two touching bodies as `sqrt(a * b)`, so the LOWER value dominates and
43
+ * the floor caps everything standing on it. The default **0.6** is a neutral solid surface (the
44
+ * raw Jolt default of 0.2 is ice by game standards); dry tarmac a car should corner on wants a
45
+ * `1`, ice `0.02`. A Vehicle's tires read the GROUND body's value, so this is the single number
46
+ * that decides how well a car corners.
47
+ *
48
+ * Change it at runtime by re-configuring — `floor.aspect(Physics, { friction: 0.02 })` (an ice
49
+ * patch) — or by assigning `floor.physics.friction = 0.02`; either way the setter pushes the new
50
+ * surface to the live body at once. (chisel keeps an instance setter whose name appears as an
51
+ * object-literal key anywhere in the bundle, so the config-object route survives tree-shaking
52
+ * even when no code reads `.friction`.)
53
+ */
54
+ get friction(): number;
55
+ set friction(v: number);
56
+ private _friction;
57
+ /** Scene-editor inspector: `motion` as a dropdown (a string default alone infers a text box). */
58
+ static fields: FieldMeta<Physics>;
59
+ private _bodyId;
60
+ onAttach(): void;
61
+ onDetach(): void;
62
+ /** Native Jolt body id. 0 until attached, or if the build has no physics support. */
63
+ get id(): number;
64
+ /** Linear velocity in world units/second (fresh Vec3 on read; `velocity.y = 5` written directly on
65
+ * the aspect is compiled to a component write — see `_writeComp`). */
66
+ get velocity(): Vec3;
67
+ set velocity(v: Vec3Like);
68
+ /**
69
+ * Angular velocity — **degrees/second about each world axis** (the SDK's angle unit everywhere;
70
+ * the engine works in radians and converts here). Fresh Vec3 on read.
71
+ *
72
+ * This is the only handle on a body's spin, and placing an object usually needs it: a `position`
73
+ * write is a pure teleport, so a crate that was tumbling keeps tumbling at its new home. Putting
74
+ * something down is `body.velocity = [0,0,0]; body.angularVelocity = [0,0,0]; node.position = p`.
75
+ */
76
+ get angularVelocity(): Vec3;
77
+ set angularVelocity(v: Vec3Like);
78
+ _writeComp(prop: string, axis: CompAxis, v: number): void;
79
+ /** Apply an instantaneous impulse (kg·m/s) and wake the body. */
80
+ applyImpulse(v: Vec3Like): this;
81
+ /** The same impulse applied at a WORLD-SPACE point instead of the centre of mass: the lever arm
82
+ * becomes angular impulse, so the body spins as well as moves (a bullet hitting a crate off
83
+ * centre, a blast lifting it by its base). Falls back to the central impulse on an older host. */
84
+ applyImpulseAt(v: Vec3Like, point: Vec3Like): this;
85
+ /** Configure gravity / limits. Call once before creating bodies. */
86
+ static configure(config?: PhysicsConfig): void;
87
+ /** Whether this build has physics support (CREATOR_GL_PHYSICS). */
88
+ static get supported(): boolean;
89
+ /** Closest pickable body hit by the ray from `origin` along `dir` (up to `maxDist`), or null. */
90
+ static raycast(origin: Vec3Like, dir: Vec3Like, maxDist?: number): RayHit | null;
91
+ }
@@ -0,0 +1,19 @@
1
+ import { Vec3, type Vec3Like } from "../math/vec";
2
+ import type { Ray } from "./Ray";
3
+ export declare class Plane {
4
+ /** Unit normal. */
5
+ readonly normal: Vec3;
6
+ /** Scalar offset: dot(normal, point). */
7
+ readonly d: number;
8
+ constructor(normal: Vec3Like, point: Vec3Like);
9
+ static fromPoints(a: Vec3Like, b: Vec3Like, c: Vec3Like): Plane;
10
+ static fromCoefficients(a: number, b: number, c: number, d: number): Plane;
11
+ /** Ray-plane parameter t (≥0), or null on a miss (parallel / behind origin). */
12
+ intersectRay(ray: Ray): number | null;
13
+ /** Like intersectRay but allows hits behind the origin (line-plane). */
14
+ intersectLine(ray: Ray): number | null;
15
+ /** Signed distance from a point (positive on the normal's side). */
16
+ signedDistance(point: Vec3Like): number;
17
+ /** Project a point onto the plane. */
18
+ projectPoint(point: Vec3Like): Vec3;
19
+ }