@relu-interactives/spatial-ecs 0.2.2

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 (308) hide show
  1. package/README.md +125 -0
  2. package/dist/System-rXAmagXA.d.cts +659 -0
  3. package/dist/System-rXAmagXA.d.ts +659 -0
  4. package/dist/Video-CDemv74U.d.cts +1261 -0
  5. package/dist/Video-ChKV1UI7.d.ts +1261 -0
  6. package/dist/assets/draco/draco_decoder.js +34 -0
  7. package/dist/assets/draco/draco_decoder.wasm +0 -0
  8. package/dist/assets/draco/draco_wasm_wrapper.js +117 -0
  9. package/dist/chunk-AYEF3X2P.js +223 -0
  10. package/dist/chunk-AYEF3X2P.js.map +1 -0
  11. package/dist/chunk-MAWBTMCG.js +1722 -0
  12. package/dist/chunk-MAWBTMCG.js.map +1 -0
  13. package/dist/chunk-NFDTIYR4.js +248 -0
  14. package/dist/chunk-NFDTIYR4.js.map +1 -0
  15. package/dist/chunk-OY7ZODZP.js +16 -0
  16. package/dist/chunk-OY7ZODZP.js.map +1 -0
  17. package/dist/chunk-P2YDX5DB.js +3304 -0
  18. package/dist/chunk-P2YDX5DB.js.map +1 -0
  19. package/dist/chunk-QHILSPT4.js +3 -0
  20. package/dist/chunk-QHILSPT4.js.map +1 -0
  21. package/dist/chunk-XWIEEJ7Z.js +1315 -0
  22. package/dist/chunk-XWIEEJ7Z.js.map +1 -0
  23. package/dist/components/index.cjs +1745 -0
  24. package/dist/components/index.cjs.map +1 -0
  25. package/dist/components/index.d.cts +4 -0
  26. package/dist/components/index.d.ts +4 -0
  27. package/dist/components/index.js +4 -0
  28. package/dist/components/index.js.map +1 -0
  29. package/dist/docs/api/Behaviour/classes/Behaviour.md +554 -0
  30. package/dist/docs/api/Behaviour/index.md +15 -0
  31. package/dist/docs/api/Component/classes/Component.md +57 -0
  32. package/dist/docs/api/Component/index.md +15 -0
  33. package/dist/docs/api/components/classes/AnimationComponent.md +318 -0
  34. package/dist/docs/api/components/classes/AudioComponent.md +114 -0
  35. package/dist/docs/api/components/classes/CameraComponent.md +59 -0
  36. package/dist/docs/api/components/classes/EntityType.md +48 -0
  37. package/dist/docs/api/components/classes/Environment.md +47 -0
  38. package/dist/docs/api/components/classes/ImageComponent.md +57 -0
  39. package/dist/docs/api/components/classes/ImageTarget.md +60 -0
  40. package/dist/docs/api/components/classes/ImageTargetAnchor.md +48 -0
  41. package/dist/docs/api/components/classes/LightComponent.md +70 -0
  42. package/dist/docs/api/components/classes/MaterialComponent.md +181 -0
  43. package/dist/docs/api/components/classes/MeshComponent.md +48 -0
  44. package/dist/docs/api/components/classes/MeshGeometryComponent.md +64 -0
  45. package/dist/docs/api/components/classes/ModelComponent.md +49 -0
  46. package/dist/docs/api/components/classes/Name.md +46 -0
  47. package/dist/docs/api/components/classes/Object3DRef.md +54 -0
  48. package/dist/docs/api/components/classes/ParentId.md +47 -0
  49. package/dist/docs/api/components/classes/PhysicsComponent.md +82 -0
  50. package/dist/docs/api/components/classes/Postprocessing.md +49 -0
  51. package/dist/docs/api/components/classes/ScriptComponent.md +54 -0
  52. package/dist/docs/api/components/classes/Selectable.md +46 -0
  53. package/dist/docs/api/components/classes/SelectionTransformState.md +54 -0
  54. package/dist/docs/api/components/classes/SpriteComponent.md +55 -0
  55. package/dist/docs/api/components/classes/TransformComponent.md +197 -0
  56. package/dist/docs/api/components/classes/VideoComponent.md +123 -0
  57. package/dist/docs/api/components/functions/normalizePhysicsState.md +23 -0
  58. package/dist/docs/api/components/index.md +94 -0
  59. package/dist/docs/api/components/type-aliases/AnimationComponentOptions.md +42 -0
  60. package/dist/docs/api/components/type-aliases/CameraComponentOptions.md +45 -0
  61. package/dist/docs/api/components/type-aliases/CameraProjection.md +15 -0
  62. package/dist/docs/api/components/type-aliases/CameraRuntimeType.md +15 -0
  63. package/dist/docs/api/components/type-aliases/ColliderShape.md +15 -0
  64. package/dist/docs/api/components/type-aliases/ColliderState.md +62 -0
  65. package/dist/docs/api/components/type-aliases/CubeMeshParameters.md +27 -0
  66. package/dist/docs/api/components/type-aliases/EditableMeshObjectKind.md +15 -0
  67. package/dist/docs/api/components/type-aliases/EnvironmentFogState.md +37 -0
  68. package/dist/docs/api/components/type-aliases/EnvironmentFogType.md +15 -0
  69. package/dist/docs/api/components/type-aliases/EnvironmentGradientEffect.md +15 -0
  70. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxState.md +34 -0
  71. package/dist/docs/api/components/type-aliases/EnvironmentSkyboxType.md +15 -0
  72. package/dist/docs/api/components/type-aliases/EnvironmentState.md +29 -0
  73. package/dist/docs/api/components/type-aliases/ImageTargetAnchorOptions.md +25 -0
  74. package/dist/docs/api/components/type-aliases/ImageTargetReference.md +33 -0
  75. package/dist/docs/api/components/type-aliases/LightValueState.md +41 -0
  76. package/dist/docs/api/components/type-aliases/MaterialTypeValue.md +15 -0
  77. package/dist/docs/api/components/type-aliases/MaterialValueState.md +75 -0
  78. package/dist/docs/api/components/type-aliases/MeshGeometryParameters.md +13 -0
  79. package/dist/docs/api/components/type-aliases/MeshGeometryParametersByKind.md +33 -0
  80. package/dist/docs/api/components/type-aliases/PhysicsState.md +25 -0
  81. package/dist/docs/api/components/type-aliases/PlaneMeshParameters.md +25 -0
  82. package/dist/docs/api/components/type-aliases/PostprocessingState.md +164 -0
  83. package/dist/docs/api/components/type-aliases/RadiusHeightMeshParameters.md +25 -0
  84. package/dist/docs/api/components/type-aliases/RadiusMeshParameters.md +23 -0
  85. package/dist/docs/api/components/type-aliases/RigidbodyState.md +53 -0
  86. package/dist/docs/api/components/type-aliases/RigidbodyType.md +19 -0
  87. package/dist/docs/api/components/type-aliases/ScriptEntry.md +38 -0
  88. package/dist/docs/api/components/type-aliases/TextureFilteringValue.md +15 -0
  89. package/dist/docs/api/components/type-aliases/TransformData.md +27 -0
  90. package/dist/docs/api/components/type-aliases/TransformModeValue.md +15 -0
  91. package/dist/docs/api/components/type-aliases/TransformSpaceValue.md +15 -0
  92. package/dist/docs/api/components/type-aliases/Vec3.md +27 -0
  93. package/dist/docs/api/components/variables/DEFAULT_COLLIDER_STATE.md +13 -0
  94. package/dist/docs/api/components/variables/DEFAULT_ENVIRONMENT_STATE.md +13 -0
  95. package/dist/docs/api/components/variables/DEFAULT_MESH_GEOMETRY_PARAMETERS.md +13 -0
  96. package/dist/docs/api/components/variables/DEFAULT_PHYSICS_STATE.md +13 -0
  97. package/dist/docs/api/components/variables/DEFAULT_POSTPROCESSING_STATE.md +13 -0
  98. package/dist/docs/api/components/variables/DEFAULT_RIGIDBODY_STATE.md +13 -0
  99. package/dist/docs/api/index/classes/AnimationStateMachine.md +201 -0
  100. package/dist/docs/api/index/classes/AnimationStateManager.md +253 -0
  101. package/dist/docs/api/index/classes/AnimationSystem.md +68 -0
  102. package/dist/docs/api/index/classes/AudioSystem.md +98 -0
  103. package/dist/docs/api/index/classes/CameraSyncSystem.md +49 -0
  104. package/dist/docs/api/index/classes/EnvironmentSyncSystem.md +75 -0
  105. package/dist/docs/api/index/classes/InputSystem.md +449 -0
  106. package/dist/docs/api/index/classes/LightSyncSystem.md +49 -0
  107. package/dist/docs/api/index/classes/MaterialSyncSystem.md +67 -0
  108. package/dist/docs/api/index/classes/MeshGeometrySystem.md +49 -0
  109. package/dist/docs/api/index/classes/ObjectManagementSystem.md +298 -0
  110. package/dist/docs/api/index/classes/ObjectVisibilitySystem.md +49 -0
  111. package/dist/docs/api/index/classes/PhysicsSyncSystem.md +83 -0
  112. package/dist/docs/api/index/classes/PostprocessingSyncSystem.md +80 -0
  113. package/dist/docs/api/index/classes/RenderSystem.md +64 -0
  114. package/dist/docs/api/index/classes/ScriptBehaviourSystem.md +83 -0
  115. package/dist/docs/api/index/classes/TransformSyncSystem.md +49 -0
  116. package/dist/docs/api/index/classes/VideoSystem.md +97 -0
  117. package/dist/docs/api/index/classes/World.md +1405 -0
  118. package/dist/docs/api/index/functions/createAnimationComponent.md +28 -0
  119. package/dist/docs/api/index/functions/createAudioComponent.md +32 -0
  120. package/dist/docs/api/index/functions/createCameraComponent.md +28 -0
  121. package/dist/docs/api/index/functions/createEntityTypeComponent.md +28 -0
  122. package/dist/docs/api/index/functions/createEnvironmentComponent.md +28 -0
  123. package/dist/docs/api/index/functions/createImageComponent.md +28 -0
  124. package/dist/docs/api/index/functions/createImageTargetAnchorComponent.md +28 -0
  125. package/dist/docs/api/index/functions/createImageTargetComponent.md +28 -0
  126. package/dist/docs/api/index/functions/createLightComponent.md +28 -0
  127. package/dist/docs/api/index/functions/createMaterialComponent.md +28 -0
  128. package/dist/docs/api/index/functions/createMeshComponent.md +28 -0
  129. package/dist/docs/api/index/functions/createMeshGeometryComponent.md +28 -0
  130. package/dist/docs/api/index/functions/createModelComponent.md +28 -0
  131. package/dist/docs/api/index/functions/createNameComponent.md +28 -0
  132. package/dist/docs/api/index/functions/createObject3DRefComponent.md +28 -0
  133. package/dist/docs/api/index/functions/createParentIdComponent.md +28 -0
  134. package/dist/docs/api/index/functions/createPhysicsComponent.md +30 -0
  135. package/dist/docs/api/index/functions/createPostprocessingComponent.md +28 -0
  136. package/dist/docs/api/index/functions/createScriptComponent.md +28 -0
  137. package/dist/docs/api/index/functions/createSelectableComponent.md +28 -0
  138. package/dist/docs/api/index/functions/createSelectionTransformStateComponent.md +28 -0
  139. package/dist/docs/api/index/functions/createSpriteComponent.md +28 -0
  140. package/dist/docs/api/index/functions/createTransformComponent.md +28 -0
  141. package/dist/docs/api/index/functions/createVideoComponent.md +28 -0
  142. package/dist/docs/api/index/functions/hydrateWorldFromSnapshot.md +28 -0
  143. package/dist/docs/api/index/functions/hydrateWorldFromSnapshotDetailed.md +28 -0
  144. package/dist/docs/api/index/functions/registerDefaultComponentFactories.md +23 -0
  145. package/dist/docs/api/index/functions/registerDefaultFactories.md +23 -0
  146. package/dist/docs/api/index/index.md +249 -0
  147. package/dist/docs/api/index/interfaces/EcsSystem.md +50 -0
  148. package/dist/docs/api/index/interfaces/StateMachine.md +26 -0
  149. package/dist/docs/api/index/type-aliases/AnimationStateCallbacks.md +25 -0
  150. package/dist/docs/api/index/type-aliases/ComponentFactory.md +25 -0
  151. package/dist/docs/api/index/type-aliases/EcsComponentFactoryKind.md +37 -0
  152. package/dist/docs/api/index/type-aliases/EcsWorldComponentSnapshot.md +26 -0
  153. package/dist/docs/api/index/type-aliases/EcsWorldStateSnapshotLike.md +25 -0
  154. package/dist/docs/api/index/type-aliases/HydrateWorldFromSnapshotResult.md +23 -0
  155. package/dist/docs/api/index/type-aliases/KeyboardKey.md +13 -0
  156. package/dist/docs/api/index/type-aliases/MouseButton.md +13 -0
  157. package/dist/docs/api/index/type-aliases/SelectionContext.md +31 -0
  158. package/dist/docs/api/index/variables/HYDRATABLE_ENTITY_KINDS.md +13 -0
  159. package/dist/docs/api/index/variables/KeyboardKeys.md +195 -0
  160. package/dist/docs/api/index.md +15 -0
  161. package/dist/docs/api/typedoc-sidebar.json +1 -0
  162. package/dist/docs/api/types/index.md +34 -0
  163. package/dist/docs/api/types/type-aliases/AssetInput.md +23 -0
  164. package/dist/docs/api/types/type-aliases/CheckboxInput.md +13 -0
  165. package/dist/docs/api/types/type-aliases/ColorInput.md +13 -0
  166. package/dist/docs/api/types/type-aliases/ComponentInput.md +52 -0
  167. package/dist/docs/api/types/type-aliases/ComponentKind.md +37 -0
  168. package/dist/docs/api/types/type-aliases/DropdownInput.md +23 -0
  169. package/dist/docs/api/types/type-aliases/DropdownOption.md +23 -0
  170. package/dist/docs/api/types/type-aliases/EcsEntityEditorKind.md +15 -0
  171. package/dist/docs/api/types/type-aliases/EcsEntityKind.md +35 -0
  172. package/dist/docs/api/types/type-aliases/EntityId.md +16 -0
  173. package/dist/docs/api/types/type-aliases/EntityInput.md +23 -0
  174. package/dist/docs/api/types/type-aliases/FloatInput.md +13 -0
  175. package/dist/docs/api/types/type-aliases/IntersectionResult.md +29 -0
  176. package/dist/docs/api/types/type-aliases/ParentLookup.md +26 -0
  177. package/dist/docs/api/types/type-aliases/SelectionListener.md +25 -0
  178. package/dist/docs/api/types/type-aliases/SliderInput.md +27 -0
  179. package/dist/docs/api/types/type-aliases/TextInput.md +13 -0
  180. package/dist/docs/api/types/type-aliases/ToggleInput.md +13 -0
  181. package/dist/docs/api/types/type-aliases/Vec3.md +23 -0
  182. package/dist/docs/api/types/type-aliases/Vector2Input.md +23 -0
  183. package/dist/docs/api/types/type-aliases/Vector3Input.md +25 -0
  184. package/dist/docs/api/types/type-aliases/WorldEntityView.md +17 -0
  185. package/dist/docs/guide/accessing-components.md +399 -0
  186. package/dist/docs/guide/authoring-a-behaviour.md +166 -0
  187. package/dist/docs/guide/behaviour-lifecycle.md +43 -0
  188. package/dist/docs/guide/component-catalog.md +59 -0
  189. package/dist/docs/guide/components/_sidebar.json +78 -0
  190. package/dist/docs/guide/components/animation.md +171 -0
  191. package/dist/docs/guide/components/audio.md +181 -0
  192. package/dist/docs/guide/components/camera.md +179 -0
  193. package/dist/docs/guide/components/entity-type.md +141 -0
  194. package/dist/docs/guide/components/image-target-anchor.md +103 -0
  195. package/dist/docs/guide/components/image-target.md +122 -0
  196. package/dist/docs/guide/components/image.md +146 -0
  197. package/dist/docs/guide/components/light.md +157 -0
  198. package/dist/docs/guide/components/material.md +161 -0
  199. package/dist/docs/guide/components/mesh-geometry.md +153 -0
  200. package/dist/docs/guide/components/mesh.md +151 -0
  201. package/dist/docs/guide/components/model.md +96 -0
  202. package/dist/docs/guide/components/name.md +121 -0
  203. package/dist/docs/guide/components/object3d-ref.md +115 -0
  204. package/dist/docs/guide/components/parent-id.md +108 -0
  205. package/dist/docs/guide/components/physics.md +163 -0
  206. package/dist/docs/guide/components/script.md +142 -0
  207. package/dist/docs/guide/components/sprite.md +155 -0
  208. package/dist/docs/guide/components/transform.md +155 -0
  209. package/dist/docs/guide/components/video.md +153 -0
  210. package/dist/docs/guide/concepts.md +34 -0
  211. package/dist/docs/guide/getting-started/creating-objects.md +50 -0
  212. package/dist/docs/guide/getting-started/editing-objects.md +62 -0
  213. package/dist/docs/guide/getting-started/editor/assets-browser.md +55 -0
  214. package/dist/docs/guide/getting-started/editor/hierarchy.md +47 -0
  215. package/dist/docs/guide/getting-started/editor/index.md +16 -0
  216. package/dist/docs/guide/getting-started/editor/inspector.md +36 -0
  217. package/dist/docs/guide/getting-started/editor/modules.md +35 -0
  218. package/dist/docs/guide/getting-started/editor/scene-inspector.md +64 -0
  219. package/dist/docs/guide/getting-started/editor/toolbar.md +39 -0
  220. package/dist/docs/guide/getting-started/editor/viewport.md +43 -0
  221. package/dist/docs/guide/getting-started/first-launch.md +17 -0
  222. package/dist/docs/guide/getting-started/index.md +37 -0
  223. package/dist/docs/guide/getting-started/installation.md +59 -0
  224. package/dist/docs/guide/getting-started/preview-and-test.md +55 -0
  225. package/dist/docs/guide/getting-started/project-types/3d.md +30 -0
  226. package/dist/docs/guide/getting-started/project-types/ar.md +6 -0
  227. package/dist/docs/guide/getting-started/project-types/face-tracking.md +6 -0
  228. package/dist/docs/guide/getting-started/project-types/image-tracking.md +42 -0
  229. package/dist/docs/guide/getting-started/project-types/index.md +25 -0
  230. package/dist/docs/guide/getting-started/project-types/vr.md +6 -0
  231. package/dist/docs/guide/getting-started/projects.md +53 -0
  232. package/dist/docs/guide/getting-started/shortcuts.md +43 -0
  233. package/dist/docs/guide/inspector-data-binding.md +367 -0
  234. package/dist/docs/guide/reading-input.md +202 -0
  235. package/dist/docs/guide/scene/environment.md +101 -0
  236. package/dist/docs/guide/scene/index.md +36 -0
  237. package/dist/docs/guide/scene/postprocessing.md +108 -0
  238. package/dist/docs/guide/spawning/ambient-light.md +28 -0
  239. package/dist/docs/guide/spawning/area-light.md +32 -0
  240. package/dist/docs/guide/spawning/audio.md +42 -0
  241. package/dist/docs/guide/spawning/camera.md +50 -0
  242. package/dist/docs/guide/spawning/capsule.md +29 -0
  243. package/dist/docs/guide/spawning/cube.md +31 -0
  244. package/dist/docs/guide/spawning/cylinder.md +29 -0
  245. package/dist/docs/guide/spawning/directional-light.md +32 -0
  246. package/dist/docs/guide/spawning/empty.md +31 -0
  247. package/dist/docs/guide/spawning/image-target.md +48 -0
  248. package/dist/docs/guide/spawning/image.md +33 -0
  249. package/dist/docs/guide/spawning/index.md +79 -0
  250. package/dist/docs/guide/spawning/model.md +31 -0
  251. package/dist/docs/guide/spawning/plane.md +31 -0
  252. package/dist/docs/guide/spawning/point-light.md +32 -0
  253. package/dist/docs/guide/spawning/sphere.md +29 -0
  254. package/dist/docs/guide/spawning/spot-light.md +32 -0
  255. package/dist/docs/guide/spawning/sprite.md +31 -0
  256. package/dist/docs/guide/spawning/video.md +53 -0
  257. package/dist/docs/guide/system-overview.md +73 -0
  258. package/dist/docs/guide/systems/_sidebar.json +66 -0
  259. package/dist/docs/guide/systems/animation-system.md +32 -0
  260. package/dist/docs/guide/systems/audio-system.md +28 -0
  261. package/dist/docs/guide/systems/camera-sync-system.md +31 -0
  262. package/dist/docs/guide/systems/environment-sync-system.md +31 -0
  263. package/dist/docs/guide/systems/input-system.md +217 -0
  264. package/dist/docs/guide/systems/light-sync-system.md +29 -0
  265. package/dist/docs/guide/systems/material-sync-system.md +32 -0
  266. package/dist/docs/guide/systems/mesh-geometry-system.md +40 -0
  267. package/dist/docs/guide/systems/object-management-system.md +38 -0
  268. package/dist/docs/guide/systems/object-visibility-system.md +26 -0
  269. package/dist/docs/guide/systems/physics-sync-system.md +56 -0
  270. package/dist/docs/guide/systems/postprocessing-sync-system.md +43 -0
  271. package/dist/docs/guide/systems/render-system.md +22 -0
  272. package/dist/docs/guide/systems/script-behaviour-system.md +59 -0
  273. package/dist/docs/guide/systems/transform-sync-system.md +29 -0
  274. package/dist/docs/guide/systems/video-system.md +30 -0
  275. package/dist/docs/guide/world-api.md +405 -0
  276. package/dist/factories/index.cjs +3077 -0
  277. package/dist/factories/index.cjs.map +1 -0
  278. package/dist/factories/index.d.cts +69 -0
  279. package/dist/factories/index.d.ts +69 -0
  280. package/dist/factories/index.js +6 -0
  281. package/dist/factories/index.js.map +1 -0
  282. package/dist/index-B4-YyUNR.d.cts +73 -0
  283. package/dist/index-BZUOKeTO.d.ts +73 -0
  284. package/dist/index.cjs +8584 -0
  285. package/dist/index.cjs.map +1 -0
  286. package/dist/index.d.cts +283 -0
  287. package/dist/index.d.ts +283 -0
  288. package/dist/index.js +1729 -0
  289. package/dist/index.js.map +1 -0
  290. package/dist/systems/index.cjs +5119 -0
  291. package/dist/systems/index.cjs.map +1 -0
  292. package/dist/systems/index.d.cts +200 -0
  293. package/dist/systems/index.d.ts +200 -0
  294. package/dist/systems/index.js +6 -0
  295. package/dist/systems/index.js.map +1 -0
  296. package/dist/types.cjs +4 -0
  297. package/dist/types.cjs.map +1 -0
  298. package/dist/types.d.cts +3 -0
  299. package/dist/types.d.ts +3 -0
  300. package/dist/types.js +3 -0
  301. package/dist/types.js.map +1 -0
  302. package/dist/worldSnapshotUtils.cjs +259 -0
  303. package/dist/worldSnapshotUtils.cjs.map +1 -0
  304. package/dist/worldSnapshotUtils.d.cts +3 -0
  305. package/dist/worldSnapshotUtils.d.ts +3 -0
  306. package/dist/worldSnapshotUtils.js +4 -0
  307. package/dist/worldSnapshotUtils.js.map +1 -0
  308. package/package.json +80 -0
@@ -0,0 +1,29 @@
1
+ # Sphere
2
+
3
+ A radius `0.5` `THREE.SphereGeometry` (24 width × 24 height segments) with a default white `MeshStandardMaterial`.
4
+
5
+ ```ts
6
+ import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
7
+
8
+ export default class SpawnSphere extends Behaviour {
9
+ init() {
10
+ const objects = this.world.getSystem(ObjectManagementSystem);
11
+ objects?.requestCreate("sphere", {
12
+ name: "Ball",
13
+ transform: { position: { x: 0, y: 0.5, z: 0 } },
14
+ });
15
+ }
16
+ }
17
+ ```
18
+
19
+ ## Payload
20
+
21
+ | Field | Type | Default | Description |
22
+ | --- | --- | --- | --- |
23
+ | `name` | `string` | `"Sphere"` | Display name. |
24
+ | `transform` | `TransformData` | identity | Position / rotation (radians) / scale. |
25
+ | `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
26
+
27
+ ## Components attached
28
+
29
+ `Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Mesh`, `Material`, `MeshGeometry`.
@@ -0,0 +1,32 @@
1
+ # Spot Light
2
+
3
+ A cone-shaped light with adjustable angle, penumbra, and distance falloff.
4
+
5
+ ```ts
6
+ import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
7
+
8
+ export default class SpawnSpot extends Behaviour {
9
+ init() {
10
+ const objects = this.world.getSystem(ObjectManagementSystem);
11
+ objects?.requestCreate("spotLight", {
12
+ name: "Stage",
13
+ transform: { position: { x: 0, y: 5, z: 0 } },
14
+ });
15
+ }
16
+ }
17
+ ```
18
+
19
+ ## Payload
20
+
21
+ | Field | Type | Default | Description |
22
+ | --- | --- | --- | --- |
23
+ | `name` | `string` | `"Spot Light"` | Display name. |
24
+ | `transform.position` | `{ x, y, z }` | `(2, 5, 2)` | Light position (direction is `target − position`). |
25
+ | `transform.rotation` / `scale` | — | identity | Standard transform fields. |
26
+ | `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
27
+
28
+ Default color `#ffffff`, intensity `1`, distance `20`, angle `π/6`, penumbra `0.1`, decay `1`.
29
+
30
+ ## Components attached
31
+
32
+ `Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Light`.
@@ -0,0 +1,31 @@
1
+ # Sprite
2
+
3
+ A camera-facing `THREE.Sprite` textured with an image. Always faces the active camera.
4
+
5
+ ```ts
6
+ import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
7
+
8
+ export default class SpawnIcon extends Behaviour {
9
+ init() {
10
+ const objects = this.world.getSystem(ObjectManagementSystem);
11
+ objects?.requestCreate("sprite", {
12
+ name: "Marker",
13
+ path: "/assets/images/marker.png",
14
+ transform: { position: { x: 0, y: 2, z: 0 } },
15
+ });
16
+ }
17
+ }
18
+ ```
19
+
20
+ ## Payload
21
+
22
+ | Field | Type | Default | Description |
23
+ | --- | --- | --- | --- |
24
+ | `name` | `string` | `"Sprite"` | Display name. |
25
+ | `path` | `string` | `""` | URL or local-asset path to the sprite image. |
26
+ | `transform` | `TransformData` | identity | Position / rotation / scale. |
27
+ | `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
28
+
29
+ ## Components attached
30
+
31
+ `Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Sprite`.
@@ -0,0 +1,53 @@
1
+ # Video
2
+
3
+ A textured plane playing a video file, with optional chroma-keying (green-screen) so you can composite the video over the live scene.
4
+
5
+ ```ts
6
+ import { Behaviour, ObjectManagementSystem } from "@relu-interactives/spatial-ecs";
7
+
8
+ export default class SpawnVideo extends Behaviour {
9
+ init() {
10
+ const objects = this.world.getSystem(ObjectManagementSystem);
11
+ objects?.requestCreate("video", {
12
+ name: "Promo",
13
+ path: "/assets/videos/promo.mp4",
14
+ transform: { position: { x: 0, y: 1.5, z: -3 } },
15
+ options: {
16
+ autoplay: true,
17
+ loop: true,
18
+ volume: 0.8,
19
+ width: 1.6,
20
+ height: 0.9,
21
+ },
22
+ });
23
+ }
24
+ }
25
+ ```
26
+
27
+ ## Payload
28
+
29
+ | Field | Type | Default | Description |
30
+ | --- | --- | --- | --- |
31
+ | `name` | `string` | `"Video"` | Display name. |
32
+ | `path` | `string` | `""` | URL or local-asset path to the video file. |
33
+ | `transform` | `TransformData` | identity | Position / rotation / scale. |
34
+ | `parentId` | `EntityId \| null` | `null` | Optional parent entity. |
35
+
36
+ ### `options`
37
+
38
+ | Option | Type | Default | Description |
39
+ | --- | --- | --- | --- |
40
+ | `autoplay` | `boolean` | `false` | Start playback as soon as the video is ready. |
41
+ | `loop` | `boolean` | `true` | Loop playback. |
42
+ | `volume` | `number` (0–1) | `1` | Playback volume. |
43
+ | `width` | `number` | `1` | Plane width in world units. |
44
+ | `height` | `number` | `1` | Plane height in world units. |
45
+ | `isGreenScreen` | `boolean` | `false` | Enable chroma-key shader. |
46
+ | `backgroundColor` | `string` | `"#00ff00"` | Color to key out (CSS hex). |
47
+ | `similarity` | `number` (0.01–1) | `0.4` | Chroma similarity threshold. |
48
+ | `smoothness` | `number` (0.001–1) | `0.08` | Edge smoothing. |
49
+ | `spill` | `number` (0–1) | `0.12` | Spill-suppression strength. |
50
+
51
+ ## Components attached
52
+
53
+ `Transform`, `Object3DRef`, `Name`, `EntityType`, `ParentId`, `Selectable`, `Video`.
@@ -0,0 +1,73 @@
1
+ # System Overview
2
+
3
+ Every frame in `@relu-interactives/spatial-ecs` is driven by a deterministic sequence of systems. This catalog lists every system shipped in the package, grouped by responsibility. Each entry links to a dedicated page with queried components, behavior notes, and ordering details.
4
+
5
+ > [!TIP]
6
+ > Browsing the API? The auto-generated TypeDoc reference lives under [API Reference → systems](../api/index/index.md).
7
+
8
+ ## Entity lifecycle
9
+
10
+ - [ObjectManagementSystem](./systems/object-management-system) — core entity lifecycle: flushes the creation queue, reconciles the THREE.js scene graph hierarchy, and maintains entity/component factory registries. **Runs first each frame.**
11
+
12
+ ## Transform & visibility
13
+
14
+ - [TransformSyncSystem](./systems/transform-sync-system) — writes `TransformComponent` position, rotation, and scale to the linked THREE.js `Object3D` every frame.
15
+ - [ObjectVisibilitySystem](./systems/object-visibility-system) — syncs the `Object3DRef` `visibility` flag to the THREE.js `Object3D.visible` property.
16
+
17
+ ## Geometry & rendering
18
+
19
+ - [MeshGeometrySystem](./systems/mesh-geometry-system) — creates and updates `BufferGeometry` on primitive mesh entities from their `MeshGeometryComponent` kind and parameters.
20
+ - [MaterialSyncSystem](./systems/material-sync-system) — applies `MaterialComponent` authoring values (type, PBR properties, texture slots) to THREE.js materials.
21
+ - [LightSyncSystem](./systems/light-sync-system) — syncs `LightComponent` values to THREE.js light objects (directional, ambient, point, spot, hemisphere, area).
22
+ - [EnvironmentSyncSystem](./systems/environment-sync-system) — applies the scene-level `Environment` component (background, fog, HDRI) to the THREE.js scene.
23
+ - [PostprocessingSyncSystem](./systems/postprocessing-sync-system) — builds and manages an `EffectComposer` pipeline from the `Postprocessing` component state.
24
+ - [RenderSystem](./systems/render-system) — final system in the loop; submits the frame to the WebGL renderer. **Runs last each frame.**
25
+
26
+ ## Animation
27
+
28
+ - [AnimationSystem](./systems/animation-system) — drives the `AnimationStateMachine` for entities with `AnimationComponent`: advances the THREE.js `AnimationMixer`, loads clip sources, and applies cross-fade transitions.
29
+
30
+ ## Camera
31
+
32
+ - [CameraSyncSystem](./systems/camera-sync-system) — syncs `CameraComponent` authoring values to the live THREE.js camera (perspective and orthographic).
33
+
34
+ ## Physics
35
+
36
+ - [PhysicsSyncSystem](./systems/physics-sync-system) — initializes the Rapier physics world, creates rigid bodies and colliders from `PhysicsComponent` state, steps the simulation, and writes results back to entity transforms.
37
+
38
+ ## Audio & video
39
+
40
+ - [AudioSystem](./systems/audio-system) — reconciles `AudioComponent` state with THREE.js positional audio objects. **Preview mode only.**
41
+ - [VideoSystem](./systems/video-system) — reconciles `VideoComponent` state with the HTML `<video>` element and THREE.js mesh/material. **Preview mode only.**
42
+
43
+ ## Scripting
44
+
45
+ - [ScriptBehaviourSystem](./systems/script-behaviour-system) — dynamically imports user-authored Behaviour scripts, instantiates their classes, and drives the full lifecycle (`init`, `onUpdate`, `onDestroy`) each frame.
46
+
47
+ ## Input
48
+
49
+ - [InputSystem](./systems/input-system) — captures and normalizes keyboard and mouse events, exposing them via direct methods on `this.world` (e.g. `this.world.getKey()`, `this.world.getMouseDown()`) inside Behaviour scripts.
50
+
51
+ ## System execution order
52
+
53
+ Systems run in the following order each frame. You can inspect and extend this ordering via `World.setup`.
54
+
55
+ | Order | System |
56
+ |-------|--------|
57
+ | 1 | `ObjectManagementSystem` |
58
+ | 2 | `MeshGeometrySystem` |
59
+ | 3 | *(custom systems)* |
60
+ | 4 | `TransformSyncSystem` |
61
+ | 5 | `ObjectVisibilitySystem` |
62
+ | 6 | `LightSyncSystem` |
63
+ | 7 | `MaterialSyncSystem` |
64
+ | 8 | `CameraSyncSystem` |
65
+ | 9 | `EnvironmentSyncSystem` |
66
+ | 10 | `PostprocessingSyncSystem` |
67
+ | 11 | `AnimationSystem` |
68
+ | 12 | `PhysicsSyncSystem` |
69
+ | 13 | `AudioSystem` |
70
+ | 14 | `VideoSystem` |
71
+ | 15 | `ScriptBehaviourSystem` |
72
+ | 16 | `InputSystem` |
73
+ | 17 | `RenderSystem` |
@@ -0,0 +1,66 @@
1
+ [
2
+ {
3
+ "text": "AnimationSystem",
4
+ "link": "/guide/systems/animation-system"
5
+ },
6
+ {
7
+ "text": "AudioSystem",
8
+ "link": "/guide/systems/audio-system"
9
+ },
10
+ {
11
+ "text": "CameraSyncSystem",
12
+ "link": "/guide/systems/camera-sync-system"
13
+ },
14
+ {
15
+ "text": "EnvironmentSyncSystem",
16
+ "link": "/guide/systems/environment-sync-system"
17
+ },
18
+ {
19
+ "text": "InputSystem",
20
+ "link": "/guide/systems/input-system"
21
+ },
22
+ {
23
+ "text": "LightSyncSystem",
24
+ "link": "/guide/systems/light-sync-system"
25
+ },
26
+ {
27
+ "text": "MaterialSyncSystem",
28
+ "link": "/guide/systems/material-sync-system"
29
+ },
30
+ {
31
+ "text": "MeshGeometrySystem",
32
+ "link": "/guide/systems/mesh-geometry-system"
33
+ },
34
+ {
35
+ "text": "ObjectManagementSystem",
36
+ "link": "/guide/systems/object-management-system"
37
+ },
38
+ {
39
+ "text": "ObjectVisibilitySystem",
40
+ "link": "/guide/systems/object-visibility-system"
41
+ },
42
+ {
43
+ "text": "PhysicsSyncSystem",
44
+ "link": "/guide/systems/physics-sync-system"
45
+ },
46
+ {
47
+ "text": "PostprocessingSyncSystem",
48
+ "link": "/guide/systems/postprocessing-sync-system"
49
+ },
50
+ {
51
+ "text": "RenderSystem",
52
+ "link": "/guide/systems/render-system"
53
+ },
54
+ {
55
+ "text": "ScriptBehaviourSystem",
56
+ "link": "/guide/systems/script-behaviour-system"
57
+ },
58
+ {
59
+ "text": "TransformSyncSystem",
60
+ "link": "/guide/systems/transform-sync-system"
61
+ },
62
+ {
63
+ "text": "VideoSystem",
64
+ "link": "/guide/systems/video-system"
65
+ }
66
+ ]
@@ -0,0 +1,32 @@
1
+ # AnimationSystem
2
+
3
+ Drives the animation state machine for every entity that has an `AnimationComponent`. Each frame it advances the THREE.js `AnimationMixer`, processes clip source loads (model clips and external GLTF sources), and applies the active state's cross-fade transitions.
4
+
5
+ ## Overview
6
+
7
+ `AnimationSystem` runs every frame and is responsible for:
8
+
9
+ - Loading clips from external GLTF sources on demand and merging them with model-embedded clips.
10
+ - Building and maintaining a `THREE.AnimationMixer` per entity.
11
+ - Playing, pausing, stopping, and reversing clips via `THREE.AnimationAction`.
12
+ - Executing cross-fades between animation states using the state machine configured on `AnimationComponent`.
13
+ - Replaying the last persisted state after hydration (saved `activeState`, `paused`, `reverse`, `timeScale`).
14
+
15
+ ## Queried components
16
+
17
+ | Component | Access |
18
+ | --- | --- |
19
+ | [`AnimationComponent`](../components/animation) | Read + mutate (`clips`, `clipCatalog`, `availableClips`, mixer state) |
20
+ | [`ModelComponent`](../components/model) | Read (source URL, loaded model clips) |
21
+
22
+ ## Behavior notes
23
+
24
+ - **Editor vs preview** — the system runs in both editor and preview runtimes. In the editor it powers the viewport animation preview. In preview it drives live playback.
25
+ - **External clip sources** — if `AnimationComponent.externalClipSources` lists remote URLs, the system loads each via `GLTFLoader` (with optional DRACO support). Loaded clips are merged into the entity's catalog and catalog entries are kept stable across reloads.
26
+ - **State machine** — transitions call `THREE.AnimationAction.crossFadeTo()` using `AnimationComponent.crossFadeDuration`. The active action's time scale is negated automatically when `reverse` is `true`.
27
+ - **Delta time clamping** — the delta time passed to each mixer is clamped to `[0, +∞)` and non-finite values are treated as `0` to prevent unstable playback after tab focus returns.
28
+
29
+ ## API reference
30
+
31
+ - Class: [`AnimationComponent`](../../api/components/classes/AnimationComponent.md)
32
+ - Source: [`core/systems/AnimationSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/AnimationSystem.ts)
@@ -0,0 +1,28 @@
1
+ # AudioSystem
2
+
3
+ Reconciles `AudioComponent` state with the underlying THREE.js positional audio objects each frame. Only active in **preview** mode — editor viewports are unaffected.
4
+
5
+ ## Overview
6
+
7
+ `AudioSystem` runs every frame in preview and is responsible for:
8
+
9
+ - Driving `play()`, `pause()`, and `stop()` on the THREE.js `PositionalAudio` node based on the intent flags set by `AudioComponent.play()`, `.pause()`, and `.stop()`.
10
+ - Detecting when a non-looping clip ends naturally (THREE.js stops on its own) and resetting component state accordingly.
11
+ - Syncing `loop`, `pitch`, `volume`, `refDistance`, `distanceModel`, and `rolloffFactor` to the live audio node whenever they change. Changes take effect on the next frame.
12
+
13
+ ## Queried components
14
+
15
+ | Component | Access |
16
+ | --- | --- |
17
+ | [`AudioComponent`](../components/audio) | Read + mutate (`isPlaying`, `isPaused` flags; option properties) |
18
+
19
+ ## Behavior notes
20
+
21
+ - **Editor skip** — when constructed with `{ isEditor: true }` the `update` method returns immediately, so no audio state is applied in the editor.
22
+ - **Natural end detection** — the system compares the THREE.js `isPlaying` state between frames. If the audio node stopped on its own while the component still believed it was playing (and not paused), the component flags are reset and a warning is suppressed.
23
+ - **Change detection** — option sync uses a per-entity snapshot from the previous frame, so `AudioComponent` options can be mutated freely in scripts without causing redundant THREE.js calls on every frame.
24
+
25
+ ## API reference
26
+
27
+ - Class: [`AudioComponent`](../../api/components/classes/AudioComponent.md)
28
+ - Source: [`core/systems/AudioSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/AudioSystem.ts)
@@ -0,0 +1,31 @@
1
+ # CameraSyncSystem
2
+
3
+ Syncs `CameraComponent` authoring values to the live THREE.js camera object each frame, handling both perspective and orthographic projection modes.
4
+
5
+ ## Overview
6
+
7
+ `CameraSyncSystem` runs every frame and is responsible for:
8
+
9
+ - Updating `fov`, `near`, `far`, and `zoom` on `THREE.PerspectiveCamera` from the component values.
10
+ - Updating `left`, `right`, `top`, `bottom`, `near`, `far`, and `zoom` on `THREE.OrthographicCamera`.
11
+ - Clamping all values to safe ranges (`near ≥ 0.001`, `far > near`, `fov` in `[1, 179]`, `zoom ≥ 0.001`) so an invalid inspector value never breaks the camera projection matrix.
12
+ - Normalizing orthographic bounds so that `right > left` and `top > bottom` are always satisfied.
13
+ - Calling `updateProjectionMatrix()` whenever a change is detected.
14
+
15
+ ## Queried components
16
+
17
+ | Component | Access |
18
+ | --- | --- |
19
+ | [`CameraComponent`](../components/camera) | Read + sanitize (clamps written back to component fields) |
20
+ | [`Object3DRef`](../components/object3d-ref) | Read (the live THREE.js camera object) |
21
+
22
+ ## Behavior notes
23
+
24
+ - **Projection type** — the system checks the concrete type of the object in `Object3DRef` (`instanceof THREE.PerspectiveCamera` / `THREE.OrthographicCamera`) and applies the matching update path. If neither type matches, the entity is skipped.
25
+ - **Aspect ratio** — perspective cameras auto-update aspect from `window.innerWidth / window.innerHeight` each frame when a window is available.
26
+ - **Change detection** — property values are compared before writing to avoid redundant `updateProjectionMatrix()` calls on every frame.
27
+
28
+ ## API reference
29
+
30
+ - Class: [`CameraComponent`](../../api/components/classes/CameraComponent.md)
31
+ - Source: [`core/systems/CameraSyncSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/CameraSyncSystem.ts)
@@ -0,0 +1,31 @@
1
+ # EnvironmentSyncSystem
2
+
3
+ Applies the scene-level `Environment` component to the THREE.js scene each frame — background color, gradient textures, HDRI environment maps, and fog.
4
+
5
+ ## Overview
6
+
7
+ `EnvironmentSyncSystem` runs every frame and is responsible for:
8
+
9
+ - Generating canvas-based gradient textures (`linear`, `radial`, `angular`) from the color stops defined in the `Environment` component and setting them as `scene.background`.
10
+ - Loading HDRI or image URLs via `THREE.TextureLoader` and assigning them as `scene.background` and/or `scene.environment`.
11
+ - Applying solid color backgrounds directly as `THREE.Color`.
12
+ - Configuring `THREE.FogExp2` or `THREE.Fog` from the fog sub-state (`near`, `far`, `density`, `color`).
13
+ - Disposing previous textures when the background changes to prevent GPU memory leaks.
14
+
15
+ ## Queried components
16
+
17
+ | Component | Access |
18
+ | --- | --- |
19
+ | [`Environment`](../scene/environment) | Read (background type, colors, fog state) |
20
+
21
+ ## Behavior notes
22
+
23
+ - **Signature-based change detection** — the system serializes the entire Environment state into a string signature each frame. Texture regeneration and scene assignments only happen when the signature changes, so frequent re-renders don't rebuild the background every frame.
24
+ - **Gradient texture** — generated on a 512×512 `<canvas>` element. In server-side or non-DOM environments a single-pixel `DataTexture` fallback is used instead.
25
+ - **Fog clamping** — fog `near` and `far` values are clamped so `far > near + 0.001` and density is clamped to `≥ 0`. Invalid values are replaced with safe defaults.
26
+ - **Pending image URL** — image/HDRI loads are queued via an internal pending URL field; a stale load result is discarded if the component signature changed again before the load finished.
27
+
28
+ ## API reference
29
+
30
+ - Class: [`Environment`](../../api/components/classes/Environment.md)
31
+ - Source: [`core/systems/EnvironmentSyncSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/EnvironmentSyncSystem.ts)
@@ -0,0 +1,217 @@
1
+ # InputSystem
2
+
3
+ Captures and normalizes keyboard and mouse input events from the browser, then exposes a clean query API accessible directly on `this.world` inside Behaviour scripts.
4
+
5
+ ## Overview
6
+
7
+ `InputSystem` manages input state for the current frame and is responsible for:
8
+
9
+ - Listening to `keydown` / `keyup` DOM events and tracking which keys are currently held, newly pressed (`down`), or just released (`up`) this frame.
10
+ - Listening to `mousedown` / `mouseup` / `mousemove` / `wheel` events for left, middle, and right buttons plus pointer position and scroll deltas.
11
+ - Flushing pending input changes at the start of each frame so `getKeyDown` / `getKeyUp` are only `true` for a single frame.
12
+ - Providing pointer-lock support: when a lock target element is set, mouse position and delta calculations are bounded to that element's rect.
13
+
14
+ ## API exposed to scripts
15
+
16
+ Call these methods directly on `this.world` from any Behaviour script. There is no `world.input` accessor.
17
+
18
+ | Method | Description |
19
+ | --- | --- |
20
+ | `this.world.getKey(key)` | `true` while the key is held this frame. |
21
+ | `this.world.getKeyDown(key)` | `true` only on the first frame the key is pressed. |
22
+ | `this.world.getKeyUp(key)` | `true` only on the frame the key is released. |
23
+ | `this.world.getMouse(button)` | `true` while the mouse button is held. |
24
+ | `this.world.getMouseDown(button)` | `true` only on the first frame the button is pressed. |
25
+ | `this.world.getMouseUp(button)` | `true` only on the frame the button is released. |
26
+ | `this.world.getMousePosition()` | `{ x, y }` in viewport pixels. |
27
+ | `this.world.getMouseDelta()` | `{ x, y }` movement delta since the previous frame. |
28
+ | `this.world.consumeMouseDelta()` | `{ x, y }` movement delta; zeroes after reading. |
29
+ | `this.world.getScrollDelta()` | `{ x, y }` scroll delta since the previous frame. |
30
+
31
+ Mouse buttons can be specified as `"left"`, `"middle"`, or `"right"` (or the numeric indices `0`, `1`, `2`).
32
+
33
+ ## KeyboardKeys reference
34
+
35
+ Import `KeyboardKeys` from `@relu-interactives/spatial-ecs` to access all available key constants with full TypeScript autocomplete.
36
+
37
+ ```ts
38
+ import { KeyboardKeys } from "@relu-interactives/spatial-ecs";
39
+ ```
40
+
41
+ ### Letters
42
+
43
+ | Constant | Value |
44
+ | --- | --- |
45
+ | `KeyboardKeys.A` … `KeyboardKeys.Z` | `"a"` … `"z"` |
46
+
47
+ ### Digits
48
+
49
+ | Constant | Value |
50
+ | --- | --- |
51
+ | `KeyboardKeys.Digit0` … `KeyboardKeys.Digit9` | `"0"` … `"9"` |
52
+
53
+ ### Navigation & editing
54
+
55
+ | Constant | Value |
56
+ | --- | --- |
57
+ | `KeyboardKeys.ArrowUp` | `"arrowup"` |
58
+ | `KeyboardKeys.ArrowDown` | `"arrowdown"` |
59
+ | `KeyboardKeys.ArrowLeft` | `"arrowleft"` |
60
+ | `KeyboardKeys.ArrowRight` | `"arrowright"` |
61
+ | `KeyboardKeys.Space` | `" "` |
62
+ | `KeyboardKeys.Enter` | `"enter"` |
63
+ | `KeyboardKeys.Escape` | `"escape"` |
64
+ | `KeyboardKeys.Tab` | `"tab"` |
65
+ | `KeyboardKeys.Backspace` | `"backspace"` |
66
+ | `KeyboardKeys.Delete` | `"delete"` |
67
+ | `KeyboardKeys.Insert` | `"insert"` |
68
+ | `KeyboardKeys.Home` | `"home"` |
69
+ | `KeyboardKeys.End` | `"end"` |
70
+ | `KeyboardKeys.PageUp` | `"pageup"` |
71
+ | `KeyboardKeys.PageDown` | `"pagedown"` |
72
+
73
+ ### Modifier keys
74
+
75
+ Generic variants match either left or right physical key. Use the specific variants when the side matters.
76
+
77
+ | Constant | Value | Notes |
78
+ | --- | --- | --- |
79
+ | `KeyboardKeys.Shift` | `"shift"` | Either shift key |
80
+ | `KeyboardKeys.ShiftLeft` | `"shiftleft"` | Left Shift only |
81
+ | `KeyboardKeys.ShiftRight` | `"shiftright"` | Right Shift only |
82
+ | `KeyboardKeys.Control` | `"control"` | Either Ctrl key |
83
+ | `KeyboardKeys.ControlLeft` | `"controlleft"` | Left Ctrl only |
84
+ | `KeyboardKeys.ControlRight` | `"controlright"` | Right Ctrl only |
85
+ | `KeyboardKeys.Alt` | `"alt"` | Alt / Option |
86
+ | `KeyboardKeys.Meta` | `"meta"` | Cmd (macOS) / Win (Windows) |
87
+ | `KeyboardKeys.CapsLock` | `"capslock"` | |
88
+
89
+ ### Function keys
90
+
91
+ | Constant | Value |
92
+ | --- | --- |
93
+ | `KeyboardKeys.F1` … `KeyboardKeys.F12` | `"f1"` … `"f12"` |
94
+
95
+ ### Punctuation & symbols
96
+
97
+ | Constant | Value |
98
+ | --- | --- |
99
+ | `KeyboardKeys.Minus` | `"-"` |
100
+ | `KeyboardKeys.Equal` | `"="` |
101
+ | `KeyboardKeys.BracketLeft` | `"["` |
102
+ | `KeyboardKeys.BracketRight` | `"]"` |
103
+ | `KeyboardKeys.Backslash` | `"\\"` |
104
+ | `KeyboardKeys.Semicolon` | `";"` |
105
+ | `KeyboardKeys.Quote` | `"'"` |
106
+ | `KeyboardKeys.Backquote` | `` "`" `` |
107
+ | `KeyboardKeys.Comma` | `","` |
108
+ | `KeyboardKeys.Period` | `"."` |
109
+ | `KeyboardKeys.Slash` | `"/"` |
110
+
111
+ ### Other
112
+
113
+ | Constant | Value |
114
+ | --- | --- |
115
+ | `KeyboardKeys.NumLock` | `"numlock"` |
116
+ | `KeyboardKeys.ScrollLock` | `"scrolllock"` |
117
+ | `KeyboardKeys.Pause` | `"pause"` |
118
+ | `KeyboardKeys.PrintScreen` | `"printscreen"` |
119
+ | `KeyboardKeys.ContextMenu` | `"contextmenu"` |
120
+
121
+ ## Script examples
122
+
123
+ ### Basic movement
124
+
125
+ Move an object along the X/Z plane with WASD and sprint with Shift.
126
+
127
+ ```ts
128
+ import { KeyboardKeys, Behaviour } from "@relu-interactives/spatial-ecs";
129
+
130
+ export default class PlayerMovement extends Behaviour {
131
+ speed = 5;
132
+ sprintMultiplier = 2;
133
+
134
+ protected onUpdate() {
135
+ const sprint = this.world.getKey(KeyboardKeys.Shift) ? this.sprintMultiplier : 1;
136
+ const step = this.speed * sprint * this.deltaTime;
137
+
138
+ if (this.world.getKey(KeyboardKeys.W)) this.transform.position.z -= step;
139
+ if (this.world.getKey(KeyboardKeys.S)) this.transform.position.z += step;
140
+ if (this.world.getKey(KeyboardKeys.A)) this.transform.position.x -= step;
141
+ if (this.world.getKey(KeyboardKeys.D)) this.transform.position.x += step;
142
+ }
143
+ }
144
+ ```
145
+
146
+ ### One-shot action on key press
147
+
148
+ Toggle visibility on Space, fire on left-click.
149
+
150
+ ```ts
151
+ import { KeyboardKeys, Behaviour } from "@relu-interactives/spatial-ecs";
152
+
153
+ export default class ActionHandler extends Behaviour {
154
+ protected onUpdate() {
155
+ // getKeyDown fires only on the first frame the key is pressed.
156
+ if (this.world.getKeyDown(KeyboardKeys.Space)) {
157
+ this.transform.visible = !this.transform.visible;
158
+ }
159
+
160
+ // Left mouse button
161
+ if (this.world.getMouseDown("left")) {
162
+ console.log("Fired!");
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ ### Distinguishing left vs right modifier
169
+
170
+ ```ts
171
+ import { KeyboardKeys, Behaviour } from "@relu-interactives/spatial-ecs";
172
+
173
+ export default class ModifierDemo extends Behaviour {
174
+ protected onUpdate() {
175
+ if (this.world.getKeyDown(KeyboardKeys.ControlLeft)) {
176
+ console.log("Left Ctrl pressed");
177
+ }
178
+
179
+ if (this.world.getKeyDown(KeyboardKeys.ControlRight)) {
180
+ console.log("Right Ctrl pressed");
181
+ }
182
+
183
+ // Generic: matches either left or right Shift
184
+ if (this.world.getKey(KeyboardKeys.Shift)) {
185
+ console.log("A Shift key is held");
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ ### Reading mouse delta (camera look)
192
+
193
+ ```ts
194
+ import { Behaviour } from "@relu-interactives/spatial-ecs";
195
+
196
+ export default class CameraLook extends Behaviour {
197
+ sensitivity = 0.002;
198
+
199
+ protected onUpdate() {
200
+ const { x, y } = this.world.consumeMouseDelta();
201
+ this.transform.rotation.y -= x * this.sensitivity;
202
+ this.transform.rotation.x -= y * this.sensitivity;
203
+ }
204
+ }
205
+ ```
206
+
207
+ ## Behavior notes
208
+
209
+ - **Frame flush** — pending input queued during the previous frame's browser event callbacks is promoted to the current frame's `down`/`up` sets at the start of `update()`. This guarantees `getKeyDown` is never missed even if the frame rate drops.
210
+ - **Key normalization** — key names are lowercased before storage so `"ArrowUp"` and `"arrowup"` are treated identically.
211
+ - **Left/right modifiers** — the system tracks both `event.key` (e.g. `"shift"`) and `event.code` (e.g. `"shiftleft"`) so generic and specific modifier queries both work simultaneously.
212
+ - **Register / unregister** — call `register(element)` to attach all DOM listeners to a specific element, and `unregister()` to remove them. This should be called during world setup and teardown.
213
+
214
+ ## API reference
215
+
216
+ - Source: [`core/systems/InputSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/InputSystem.ts)
217
+ - Related: [`KeyboardKey`](../../api/index/type-aliases/KeyboardKey.md) type alias for valid key string constants.
@@ -0,0 +1,29 @@
1
+ # LightSyncSystem
2
+
3
+ Applies `LightComponent` authoring values to the underlying THREE.js light objects each frame, supporting directional, ambient, point, spot, hemisphere, and area light types.
4
+
5
+ ## Overview
6
+
7
+ `LightSyncSystem` runs every frame and is responsible for:
8
+
9
+ - Writing `color`, `intensity`, `castShadow`, and `frustumCulled` to every light object.
10
+ - Writing `distance` and `decay` for `THREE.PointLight` and `THREE.SpotLight`.
11
+ - Writing `angle` and `penumbra` for `THREE.SpotLight`.
12
+ - Writing `width` and `height` for `THREE.RectAreaLight`.
13
+
14
+ ## Queried components
15
+
16
+ | Component | Access |
17
+ | --- | --- |
18
+ | [`LightComponent`](../components/light) | Read (`values` sub-state) |
19
+
20
+ ## Behavior notes
21
+
22
+ - **Signature-based change detection** — per-entity signatures are computed from the serialized `values` object each frame. Light properties are only written when the signature changes, preventing redundant THREE.js mutations on every frame.
23
+ - **Value clamping** — `intensity` is clamped to `≥ 0`. `distance` is clamped to `≥ 0`. `angle` is clamped to `[0, π/2]`. `penumbra` is clamped to `[0, 1]`. Non-finite values use safe defaults.
24
+ - **Stale entity cleanup** — when an entity is destroyed the system removes its entry from the signature map to prevent unbounded memory growth.
25
+
26
+ ## API reference
27
+
28
+ - Class: [`LightComponent`](../../api/components/classes/LightComponent.md)
29
+ - Source: [`core/systems/LightSyncSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/LightSyncSystem.ts)