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,86 @@
1
+ import { Aspect } from "../core/Aspect";
2
+ import type { FieldMeta } from "../core/fields";
3
+ import { type Vec3Like } from "../math/vec";
4
+ import { Node } from "./Node";
5
+ export interface RagdollHinge {
6
+ /** The hinge axis in the MODEL's space (its rest pose: +Z forward, +Y up, +X the model's left in
7
+ * glTF). Perpendicular to the bone; the engine drops any component along it. */
8
+ axis: Vec3Like;
9
+ /** The bend range about `axis` in degrees, relative to the pose the ragdoll was built in — a knee
10
+ * is `{ axis: [1, 0, 0], min: 0, max: 140 }`: it folds one way only. */
11
+ min: number;
12
+ max: number;
13
+ }
14
+ export interface RagdollPart {
15
+ /** The bone the body sits on — its origin is the joint. */
16
+ bone: string;
17
+ /** The bone the capsule points at (the next joint down). Omitted = a leaf: `length` along the line
18
+ * from the parent part's origin (a head, a hand, a foot without toes). */
19
+ to?: string;
20
+ /** The bone of the part this one hangs from (default: the previous part in the list). The root
21
+ * has none. */
22
+ parent?: string;
23
+ /** Capsule radius in metres (default 0.05). */
24
+ radius?: number;
25
+ /** Length in metres: a leaf's, or an override of the distance to `to`. */
26
+ length?: number;
27
+ /** This part's share of the ragdoll's `mass` (relative weight, default 1). */
28
+ mass?: number;
29
+ /** Cone half-angle in degrees the part may swing off its parent (default 30). Ignored with `hinge`. */
30
+ swing?: number;
31
+ /** Twist half-angle in degrees about its own axis (default 20). */
32
+ twist?: number;
33
+ /** A one-way joint instead of the cone. */
34
+ hinge?: RagdollHinge;
35
+ }
36
+ export declare class Ragdoll extends Aspect<"ragdoll", Node> {
37
+ static readonly aspect = "ragdoll";
38
+ /** The parts: `'humanoid'` (default) finds the standard bones by name; a list places bodies on any
39
+ * bones — parents before children. */
40
+ parts: RagdollPart[] | "humanoid";
41
+ /** Total mass in kg (default 70), split between the parts by their `mass` shares. */
42
+ mass: number;
43
+ /** Friction of every part (default 0.6 — the physics default). */
44
+ friction: number;
45
+ /** Linear / angular damping of every part; 0 = Jolt's own 0.05. More angular damping settles a
46
+ * flailing body sooner. */
47
+ linearDamping: number;
48
+ angularDamping: number;
49
+ /** What the parts collide with. `'static'` (default): the static geometry and other such ragdolls
50
+ * only — dynamic bodies, character controllers and vehicles pass through a fallen body, which then
51
+ * never shoves or blocks anything and costs nothing when they meet. `'all'`: a regular dynamic
52
+ * body that bumps into everything (and gets kicked awake by everything). */
53
+ collide: "static" | "all";
54
+ /** Once every part has come to rest the parts turn static where they lie (default true): the pose
55
+ * holds, nothing can wake a settled body and it costs the solver nothing — `deactivate()` /
56
+ * `activate()` still work (activate makes it dynamic again). */
57
+ freeze: boolean;
58
+ /** Seconds after `activate()` at which the body freezes whatever it is doing — a twitch on a slope
59
+ * or a pile never sleeps on its own. 0 (default) = no cap. */
60
+ freezeAfter: number;
61
+ static fields: FieldMeta<Ragdoll>;
62
+ private _id;
63
+ private _active;
64
+ private _bones;
65
+ onAttach(): void;
66
+ onDetach(): void;
67
+ /** Hand the bones to physics from the pose they are in right now. `velocity` (world m/s) is given
68
+ * to every part — pass the character's, so a running body keeps travelling. */
69
+ activate(opts?: {
70
+ velocity?: Vec3Like;
71
+ }): boolean;
72
+ /** Take the bones back: the animator's pose shows again from the next frame. */
73
+ deactivate(): void;
74
+ /** Physics owns the bones right now. */
75
+ get active(): boolean;
76
+ /** Active and every part asleep (or frozen) — the body has come to rest. */
77
+ get settled(): boolean;
78
+ /** The root part's bone (the hips): where the body is. */
79
+ get root(): Node | null;
80
+ /** The bones that carry a part, in order. */
81
+ get bones(): string[];
82
+ /** The rigid-body id of a part (0 if none) — for the plain body calls. */
83
+ bodyOf(bone: string): number;
84
+ /** Push one part: an impulse in N·s, at a world point (a hit) or through its centre. Wakes the body. */
85
+ impulse(bone: string, v: Vec3Like, at?: Vec3Like): boolean;
86
+ }
@@ -0,0 +1,8 @@
1
+ import { Vec3, type Vec3Like } from "../math/vec";
2
+ export declare class Ray {
3
+ readonly origin: Vec3;
4
+ readonly dir: Vec3;
5
+ constructor(origin: Vec3Like, dir: Vec3Like);
6
+ /** The world-space point origin + t·dir. */
7
+ getPoint(t: number): Vec3;
8
+ }
@@ -0,0 +1,221 @@
1
+ import { type ColorInput } from "../core/color";
2
+ import { type Aspect, type AspectCtor, type FieldOf, type TargetOf } from "../core/Aspect";
3
+ import { Presentable, type PresentOptions } from "../ui/presentable";
4
+ import type { ClickEvent, TouchStartEvent } from "../runtime/touch";
5
+ import type { FetchResponse } from "../runtime/fetch";
6
+ import { Camera } from "./Camera";
7
+ import { type ControlsHandle, type ControlsOptions } from "./controls";
8
+ import { Material } from "./Material";
9
+ import { Node } from "./Node";
10
+ export type AmbientOcclusionOptions = {
11
+ /** Strength of the darkening (default 1). */
12
+ intensity?: number;
13
+ /** How far the occlusion reaches, in metres (default 0.3). */
14
+ radius?: number;
15
+ /** Falloff contrast; >1 tightens it into the crease (default 1). */
16
+ power?: number;
17
+ /** Sample count + filtering (default 'medium'). Not the buffer resolution — that stays half. */
18
+ quality?: "low" | "medium" | "high" | "ultra";
19
+ };
20
+ export type FogOptions = {
21
+ /** A TINT on the in-scattered ambient, not an absolute colour: the engine multiplies it by the
22
+ * environment luminance, so white (the default) means "fog as bright as the ambient" and the fog
23
+ * brightens with `environmentIntensity`. Do NOT expect the same hex to look like it does in
24
+ * `skybox` — that one IS an absolute radiance and reads roughly an order of magnitude brighter.
25
+ * Tint towards the sky's hue; leave it white to sit at the ambient level. */
26
+ color?: ColorInput;
27
+ /** Metres from the camera before the fog starts (default 0). */
28
+ start?: number;
29
+ /** Extinction per metre at `height`; 0.01 ≈ clearly visible over ~100 m (default 0.01). */
30
+ density?: number;
31
+ /** The fog's "sea level" in world Y (default 0). */
32
+ height?: number;
33
+ /** How fast it thins with altitude, 1/m. 0 = uniform everywhere; higher = a ground-hugging layer
34
+ * you can see over (default 0). */
35
+ heightFalloff?: number;
36
+ /** Cap on how opaque it can get, 0–1 — keeps far shapes readable (default 1). */
37
+ maxOpacity?: number;
38
+ /** Metres after which fog stops applying; 0 = everywhere (default 0). */
39
+ cutoff?: number;
40
+ /** Take the colour from the environment in the view direction, tinted by `color`, instead of a
41
+ * flat `color`. Convincing when the IBL is a real sky (default false). */
42
+ fromEnvironment?: boolean;
43
+ };
44
+ export type SceneOptions = {
45
+ /** Image-based ambient lighting (default on). `false` turns it off; a STRING is the scene's own
46
+ * probe - `ibl: asset('../assets/ibl-interior.ktx')` - and is how two levels in one project get
47
+ * different environments. Without it the host looks for a project-wide `ibl.ktx`, which is one
48
+ * probe for every scene: swapping that file to suit an interior level silently relights the
49
+ * outdoor one. A named probe also travels through `asset()`, so a build only carries the
50
+ * environments its own entry point reaches. */
51
+ ibl?: boolean | string;
52
+ /** IBL intensity (default 20000). */
53
+ environmentIntensity?: number;
54
+ /** Camera exposure compensation in stops (default 0) - the same knob as
55
+ * `scene.camera.exposureCompensation`, next to the rest of the scene's lighting so a LEVEL can
56
+ * carry its own. The camera is a physical one at EV100 15 (f/16 - 1/125 - ISO 100), i.e. metered
57
+ * for bright sun; an interior lit at real levels needs +7..+9 to read at all. Expose the camera
58
+ * rather than inflating the lights: scaling lamps past what they physically emit gives bright
59
+ * fixtures in a black room, because it changes the RATIO, not the level. */
60
+ exposureCompensation?: number;
61
+ /** Bloom post-processing. */
62
+ bloom?: boolean;
63
+ bloomIntensity?: number;
64
+ /** Tone mapping operator. `'aces'` (default, filament's ACES legacy) desaturates bright colours
65
+ * towards white — HDR fire reads pale; `'neutral'` (Khronos PBR Neutral) keeps hue and
66
+ * saturation until very bright; `'linear'` clips each channel (what an engine without a
67
+ * tonemapper shows — saturated, Unity-without-post-processing look); `'filmic'` (Uncharted). */
68
+ toneMapping?: "aces" | "neutral" | "linear" | "filmic";
69
+ /** The sky. Three forms:
70
+ * - a colour — a flat clear colour;
71
+ * - `{ texture }` — a KTX1 **cubemap**, the sharp `<name>_skybox.ktx` that filament's `cmgen`
72
+ * produces from an equirectangular .hdr/.exr. This is the one to use for a real sky. Pass an
73
+ * `asset('../assets/sky.ktx')` handle or a bare staged filename;
74
+ * - `'environment'` — reuse the scene's IBL cubemap. Cheapest (no second texture) but that file
75
+ * is prefiltered for roughness, so the sky comes out soft; fine as a fallback, not as the goal.
76
+ *
77
+ * Either texture form draws through filament's own skybox pass: a full-screen pass in device
78
+ * space after the opaque queue. No geometry, no meridian seam, no pole distortion — do NOT build
79
+ * a sky dome or a fullscreen equirect material by hand, both are strictly worse. */
80
+ skybox?: ColorInput | "environment" | {
81
+ texture: string;
82
+ };
83
+ /** Screen-space ambient occlusion — the contact darkening in creases and where props meet the
84
+ * ground. Without it an IBL lights a crease exactly as brightly as an open face, so everything
85
+ * reads as pasted onto the floor rather than standing on it. `true` takes defaults tuned for
86
+ * human-scale props; `radius` is world-space metres and is the one knob that must follow the
87
+ * scene's scale (~0.3 for objects on a table, ~0.6-1 for a yard of crates and containers). */
88
+ ambientOcclusion?: boolean | AmbientOcclusionOptions;
89
+ /** Distance fog / aerial perspective: distant geometry loses contrast so the eye reads depth, and
90
+ * the hard edge where a finite level ends against the skybox goes away. By default the fog applies
91
+ * at every distance — the skybox included — so the sky itself takes the fog colour and the horizon
92
+ * blends on its own; `cutoff` opts geometry beyond a distance back out. */
93
+ fog?: FogOptions;
94
+ /** Multisample anti-aliasing: `true` = 4×, `2`/`4` = that many samples, `false` = off (FXAA
95
+ * takes over). Unset keeps the host default (desktop 4×, mobile/web off). The biggest single
96
+ * fill-rate cost after resolution — turn it down on big screens before anything else. */
97
+ antialias?: boolean | 2 | 4;
98
+ /** Render the 3D at this fraction of the viewport (0.25–1) and upscale; the UI stays at native
99
+ * resolution. A fixed, predictable cut of per-pixel GPU work — `0.75` is ~45 % cheaper and
100
+ * barely visible in motion, `0.5` quarters it. Headless renders ignore it. */
101
+ renderScale?: number;
102
+ /** Let the engine shrink the 3D buffers under `renderScale` only when frames run over budget
103
+ * (Filament dynamic resolution, sharpened upscale) down to `min` (default 0.5). Off by default:
104
+ * it makes the output frame-time dependent, so flow tests / headless renders never enable it. */
105
+ dynamicResolution?: boolean | {
106
+ min?: number;
107
+ };
108
+ /** Anisotropic filtering, 1 (off) … 16. Default 2. What it buys is detail on surfaces seen at a
109
+ * GRAZING angle — a first-person weapon, a floor, a wall — where the sample footprint is far
110
+ * longer in one axis than the other and isotropic filtering has to pick a mip for the long one,
111
+ * several levels coarser than the short axis deserves. Measured on a weapon seen from the side
112
+ * (local contrast): 8.18 at 1× → 10.02 at 2× → 10.84 at 4× → 11.29 at 8×. The default is 2
113
+ * because it is where the curve is steepest per unit of memory bandwidth; raise it if you have
114
+ * the headroom.
115
+ *
116
+ * It is an ENGINE-WIDE default, not a property of this scene: a sampler is baked when its
117
+ * texture is bound, so this reaches the models a scene loads AFTER it (which is every model in a
118
+ * scene file — `env` is applied before the nodes build) and leaves already-loaded ones alone.
119
+ * On the desktop host `CREATOR_TEXTURE_ANISOTROPY` overrides it, for tuning without a rebuild. */
120
+ anisotropy?: number;
121
+ /** The look on an HDR display (a screen with headroom above SDR white — Apple XDR panels, the
122
+ * macOS host today); ignored on SDR. `strength` 0..1 is how much of the picture reaches for the
123
+ * display's headroom (0 only what SDR clipped, 1 nearly everything; default 0.35). `paperWhite`
124
+ * 1..8 is where white lands as a multiple of SDR white — the "HDR brightness" of a console
125
+ * calibration screen, where 1.5–2 is the norm; default 1 keeps a white wall at the UI's white,
126
+ * faithful but dim next to what "HDR on" is expected to look like. Engine-wide like `anisotropy`;
127
+ * `device.hdr` is the runtime form and tells you whether the display has any headroom at all. */
128
+ hdr?: {
129
+ strength?: number;
130
+ paperWhite?: number;
131
+ };
132
+ };
133
+ export declare class Scene implements Presentable {
134
+ readonly camera: Camera;
135
+ readonly _touchStartListeners: Array<(ev: TouchStartEvent<Node | null>) => void>;
136
+ private _material?;
137
+ private static _active;
138
+ static get active(): Scene | null;
139
+ constructor(options?: SceneOptions);
140
+ /** Runtime form of `renderScale` / `dynamicResolution` (a graphics-settings menu). `renderScale`
141
+ * 0.25–1; older hosts without the method ignore it. */
142
+ setRenderOptions(renderScale: number, dynamicResolution?: boolean | {
143
+ min?: number;
144
+ }): void;
145
+ /** Scene occlusion material. */
146
+ get occlusionMaterial(): Material;
147
+ set skybox(sky: ColorInput | "environment" | {
148
+ texture: string;
149
+ });
150
+ /** Runtime form of `ambientOcclusion` (a graphics-settings menu). `false` turns it off. */
151
+ setAmbientOcclusion(options: boolean | AmbientOcclusionOptions): void;
152
+ /** Runtime form of `fog` (weather, entering a building). `false` turns it off. */
153
+ setFog(options: FogOptions | false): void;
154
+ setMaterialGlobalParameter(i: number, x: number, y: number, z: number, w: number): void;
155
+ setAntialias(enabled: boolean, scale?: number): void;
156
+ add(...nodes: Node[]): this;
157
+ remove(...nodes: Node[]): this;
158
+ /** Attach (and configure) a system, or reconfigure it if already present. Returns the scene typed
159
+ * as now-having it (`scene.system(Hud).hud`). A `System<'x', Scene2D>` is rejected here. */
160
+ system<Self extends TargetOf<A>, A extends Aspect<any, any, any>>(this: Self, ctor: AspectCtor<A>, opts?: Partial<A>): Self & FieldOf<A>;
161
+ /** Safe access — undefined if the system isn't attached. */
162
+ get<A extends Aspect<any, any, any>>(ctor: AspectCtor<A>): A | undefined;
163
+ /** Existence check AND type guard: inside `if (scene.has(Hud))`, `scene.hud` is present. */
164
+ has<A extends Aspect<any, any, any>>(ctor: AspectCtor<A>): this is this & FieldOf<A>;
165
+ /** Detach a system (runs its onDetach). Chainable. */
166
+ removeSystem<A extends Aspect<any, any, any>>(ctor: AspectCtor<A>): this;
167
+ /** Tear the scene down: every system detaches (last-attached first) and the scene closes. Nodes
168
+ * are yours — destroy the ones you own; the native scene object itself is not released. */
169
+ destroy(): void;
170
+ createOverlay(options?: SceneOptions): Scene;
171
+ warmRender(): Promise<void>;
172
+ readonly cl: (() => void)[];
173
+ _backButtonCallback?: () => void;
174
+ private _vd?;
175
+ /** Fires when the scene becomes the visible destination (incl. a pop revealing it). */
176
+ onOpen(callback: () => void): this;
177
+ /** Fires when the scene stops being visible (closed, replaced, or covered by a push). */
178
+ onClose(callback: () => void): this;
179
+ onBackPressed(callback: () => void): this;
180
+ /** Make this the active scene — shows it as the current destination (replaces a screen /
181
+ * another scene; only the active scene renders). */
182
+ open(options?: PresentOptions): void | Promise<void>;
183
+ close(): void;
184
+ addEventListener(channel: "click", callback: (ev: ClickEvent<Node | null>) => void): void;
185
+ addEventListener(channel: "touchstart", callback: (ev: TouchStartEvent<Node | null>) => void): void;
186
+ removeEventListener(channel: "click" | "touchstart", callback: (ev: any) => void): void;
187
+ }
188
+ export type ARMode = "default" | "markers" | "arcore" | "detached";
189
+ export declare class ARScene<T extends ARMode = "default"> extends Scene {
190
+ readonly mode: T;
191
+ useWarmRender: boolean;
192
+ private _root?;
193
+ constructor(options?: SceneOptions & {
194
+ mode?: T;
195
+ });
196
+ /** Root anchor node (not available in marker mode). */
197
+ get root(): Node;
198
+ /** Create an anchor from a tracking source (e.g. an image target). */
199
+ createAnchor(source: FetchResponse, physicalWidth?: number): Node;
200
+ /**
201
+ * Let the user place & manipulate a node with touch gestures — the staple AR object-placement
202
+ * interaction: ONE finger drags it across the floor (relative to where the camera looks), TWO fingers
203
+ * pinch to scale and twist to rotate. Returns a handle; call `.remove()` to detach. Tunable via
204
+ * options (min/max scale, and toggles for `pan` / `pinch` / `twist`).
205
+ */
206
+ addControls(target: Node, options?: ControlsOptions): ControlsHandle;
207
+ open(options?: PresentOptions): Promise<void>;
208
+ close(): void;
209
+ }
210
+ /**
211
+ * A 3D scene rendered in a VR headset (OpenXR — e.g. Meta Quest). The headset drives the camera:
212
+ * every frame both eyes are rendered from the tracked head pose, so `scene.camera` position/lookAt
213
+ * have no effect while the scene is open. The world origin is at floor level (stage space) —
214
+ * author content with the ground at y = 0 and the user standing at the origin.
215
+ *
216
+ * `open()` rejects on hosts without a VR runtime ("VR is not supported on this device").
217
+ */
218
+ export declare class VRScene extends Scene {
219
+ open(options?: PresentOptions): Promise<void>;
220
+ close(): void;
221
+ }
@@ -0,0 +1,122 @@
1
+ import { Aspect } from "../core/Aspect";
2
+ import { type Vec3Like } from "../math/vec";
3
+ import type { Node } from "./Node";
4
+ /** Which geometry a Shape uses — the one-of the fields below encode (see `_build`'s order). */
5
+ export type ShapeKind = "auto" | "box" | "sphere" | "cylinder" | "capsule" | "mesh" | "convex" | "heightfield";
6
+ /** A node-local AABB, in the node's OWN frame (its own transform excluded), before world scale. */
7
+ export type ShapeBounds = {
8
+ min: [number, number, number];
9
+ max: [number, number, number];
10
+ };
11
+ /** Dimensions measured from a node's rendered geometry — what `Shape.fit` writes, and the numbers
12
+ * the scene editor's "Fit to mesh" button puts in the file. Exactly one dimension key is set (none
13
+ * for a mesh/convex kind, whose geometry is the mesh itself); `origin` centres it on the art. */
14
+ export type ShapeFit = {
15
+ box?: [number, number, number];
16
+ sphere?: number;
17
+ cylinder?: {
18
+ halfHeight: number;
19
+ radius: number;
20
+ };
21
+ capsule?: {
22
+ halfHeight: number;
23
+ radius: number;
24
+ };
25
+ origin: [number, number, number];
26
+ };
27
+ export declare class Shape extends Aspect<"shape", Node> {
28
+ static readonly aspect = "shape";
29
+ /** Box half-extents [hx, hy, hz] (world units). */
30
+ box?: Vec3Like;
31
+ /** Sphere radius. */
32
+ sphere?: number;
33
+ /** Cylinder aligned on Y: half-height + radius. */
34
+ cylinder?: {
35
+ halfHeight: number;
36
+ radius: number;
37
+ };
38
+ /** Capsule aligned on Y: half-height of the cylinder section + radius. */
39
+ capsule?: {
40
+ halfHeight: number;
41
+ radius: number;
42
+ };
43
+ /** The node's own triangles (a Mesh's geometry or a Model's GLB, world scale applied).
44
+ * `true` = exact triangle mesh — static/kinematic bodies, triggers, characters' ground and picking
45
+ * only (a dynamic body can't be a triangle mesh; Physics throws). `'convex'` = convex hull of the
46
+ * vertices, works for dynamic bodies too. A Model uses its bind pose (skinned parts skipped). */
47
+ mesh?: boolean | "convex";
48
+ /** The node's terrain (`Terrain.create(...).node`) as a Jolt height field — the exact drawn grid,
49
+ * holes included (docs/terrain-plan.md). Static / kinematic / picking / character ground only,
50
+ * like `mesh: true`. `terrain.commit()` pushes edits into the live shape. */
51
+ heightfield?: boolean;
52
+ /**
53
+ * The shape's centre, relative to the node's origin — world units in the node's ROTATED frame
54
+ * (the node's scale is ignored, exactly like the explicit dimensions above). Default [0, 0, 0].
55
+ *
56
+ * A model's pivot is rarely its centre of volume (a character stands ON its origin, a wheel hangs
57
+ * off its axle), so a collider centred on the pivot is half sunk into the floor. `origin` lifts it
58
+ * without moving the node: `{ capsule: { halfHeight: 0.6, radius: 0.3 }, origin: [0, 0.9, 0] }`.
59
+ * `fit()` and the scene editor's "Fit to mesh" fill it in from the rendered bounds.
60
+ *
61
+ * On a DYNAMIC body the offset also moves the centre of mass, so a lopsided collider tips the way
62
+ * you would expect. With no `origin` an auto shape (`{}`) still centres itself on the node's own
63
+ * mesh bounds — only explicit dimensions sit on the pivot by default.
64
+ */
65
+ origin?: Vec3Like;
66
+ /** Whether pointer rays can hit this shape (click / touchstart). Default true. */
67
+ raycast: boolean;
68
+ private _shapeId;
69
+ private _bodyId;
70
+ /** Centre the "auto" box measured for itself — used when `origin` isn't set explicitly. */
71
+ private _autoOrigin;
72
+ /** Geometry props as of the last build (see onReconfigure). */
73
+ private _sig;
74
+ onAttach(): void;
75
+ onDetach(): void;
76
+ /** Re-configuring (`node.aspect(Shape, { origin })`) rebuilds the geometry when a dimension, the
77
+ * kind or the origin changed, and re-applies pickability. The body keeps its id and velocity. */
78
+ onReconfigure(): void;
79
+ /**
80
+ * Measure the node's rendered geometry and size the collider to it — the code half of the scene
81
+ * editor's "Fit to mesh". Keeps the current kind unless one is passed; `auto` becomes an explicit
82
+ * box, and a mesh/convex shape only has its `origin` cleared (its geometry IS the mesh).
83
+ *
84
+ * crate.aspect(Shape, {}).shape.fit() // box around what the model actually draws
85
+ * hero.aspect(Shape, {}).shape.fit('capsule') // capsule of the same height + girth
86
+ *
87
+ * A model loads asynchronously, so fit AFTER its `load()` resolves — an empty subtree measures as
88
+ * nothing and the call is a no-op (it warns). Rebuilds the live shape, keeping the body.
89
+ */
90
+ fit(kind?: ShapeKind): this;
91
+ /** Which geometry this shape currently uses (the `_build` dispatch, as a name). */
92
+ get kind(): ShapeKind;
93
+ /**
94
+ * The node's subtree AABB in its OWN local frame (its own transform excluded), or null when there
95
+ * is nothing to measure. Reads the engine's bounds — which cover a loaded GLB and every child —
96
+ * and falls back to a Mesh node's own CPU geometry on hosts without them.
97
+ */
98
+ static boundsOf(node: Node): ShapeBounds | null;
99
+ /**
100
+ * Dimensions + origin that make `kind` hug what `node` renders — world units, so the node's world
101
+ * scale is baked in exactly as the Shape fields expect. Null when the node has no geometry (a
102
+ * model that hasn't loaded, an empty).
103
+ */
104
+ static fitTo(node: Node, kind?: ShapeKind): ShapeFit | null;
105
+ /**
106
+ * The measuring itself, over plain numbers: a node-local AABB + the node's world scale in, shape
107
+ * dimensions out. Separate from `fitTo` so the scene-editor harness can measure a node from
108
+ * ANOTHER bundle without touching accessors the bundler may have shaken out of it.
109
+ *
110
+ * A sphere takes the LARGEST half-extent and a cylinder/capsule the larger of X/Z, so the fit
111
+ * reads as the object's silhouette rather than as an enclosing ball; adjust from there.
112
+ */
113
+ static fitBounds(bounds: ShapeBounds, scale: Vec3Like, kind?: ShapeKind): ShapeFit;
114
+ private _createPickBody;
115
+ private _rebuild;
116
+ private _build;
117
+ private _applyOrigin;
118
+ private _signature;
119
+ private _buildHeightField;
120
+ private _buildMesh;
121
+ private _buildAutoBox;
122
+ }