@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,32 @@
1
+ # MaterialSyncSystem
2
+
3
+ Applies `MaterialComponent` authoring values to the THREE.js materials on an entity's mesh objects each frame, including material type switching, PBR properties, and texture slot management.
4
+
5
+ ## Overview
6
+
7
+ `MaterialSyncSystem` runs every frame and is responsible for:
8
+
9
+ - Creating or replacing THREE.js materials (`MeshStandardMaterial`, `MeshBasicMaterial`, `MeshPhongMaterial`, `MeshPhysicalMaterial`) when the `type` field changes.
10
+ - Applying scalar and vector properties (color, roughness, metalness, opacity, emissive, etc.) from the `values` array to the matching material slots.
11
+ - Loading textures from URLs and assigning them to the correct texture slot (`map`, `alphaMap`, `normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `emissiveMap`, `bumpMap`, `displacementMap`, `lightMap`, `envMap`).
12
+ - Disposing stale textures and materials when they are replaced to prevent GPU memory leaks.
13
+ - Propagating material changes across multi-material meshes (i.e. objects with a `materials` array).
14
+
15
+ ## Queried components
16
+
17
+ | Component | Access |
18
+ | --- | --- |
19
+ | [`MaterialComponent`](../components/material) | Read (`type`, `values` array) |
20
+ | [`Object3DRef`](../components/object3d-ref) | Read (the live THREE.js mesh) |
21
+
22
+ ## Behavior notes
23
+
24
+ - **Per-slot values** — `MaterialComponent.values` is an array where each entry maps to one material slot. Entities with multiple materials (e.g. a model with distinct material groups) are handled by index.
25
+ - **Texture loading** — textures are loaded via `THREE.TextureLoader` and cached internally. A changed URL triggers a fresh load and the old texture is disposed on replacement.
26
+ - **Change detection** — property values are compared to a previous-frame snapshot before being written to the material, so inspector edits during runtime take effect on the next frame without redundant assignments.
27
+ - **Material type switch** — when `MaterialComponent.type` changes (e.g. from `standard` to `physical`), the old material is disposed and a new one is created and assigned to the mesh.
28
+
29
+ ## API reference
30
+
31
+ - Class: [`MaterialComponent`](../../api/components/classes/MaterialComponent.md)
32
+ - Source: [`core/systems/MaterialSyncSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/MaterialSyncSystem.ts)
@@ -0,0 +1,40 @@
1
+ # MeshGeometrySystem
2
+
3
+ Creates and updates the THREE.js `BufferGeometry` on primitive mesh entities based on their `MeshGeometryComponent` kind and parameter values.
4
+
5
+ ## Overview
6
+
7
+ `MeshGeometrySystem` runs every frame and is responsible for:
8
+
9
+ - Creating `THREE.BoxGeometry`, `THREE.SphereGeometry`, `THREE.PlaneGeometry`, `THREE.CylinderGeometry`, or `THREE.CapsuleGeometry` when an entity's `MeshGeometryComponent` is first seen or its kind changes.
10
+ - Recreating the geometry when parameter values (dimensions, radius, height) change.
11
+ - Assigning the geometry to the `THREE.Mesh` found via `Object3DRef`.
12
+ - Disposing the previous geometry before replacing it to free GPU memory.
13
+
14
+ ## Queried components
15
+
16
+ | Component | Access |
17
+ | --- | --- |
18
+ | [`MeshGeometryComponent`](../components/mesh-geometry) | Read (`kind`, `parameters`) |
19
+ | [`Object3DRef`](../components/object3d-ref) | Read (the live THREE.js mesh) |
20
+
21
+ ## Supported geometry kinds
22
+
23
+ | Kind | Parameters |
24
+ | --- | --- |
25
+ | `cube` | `width`, `height`, `depth` |
26
+ | `plane` | `width`, `height` |
27
+ | `sphere` | `radius` |
28
+ | `cylinder` | `radiusTop`, `radiusBottom`, `height` |
29
+ | `capsule` | `radius`, `height` |
30
+
31
+ ## Behavior notes
32
+
33
+ - **Parameter sanitization** — all dimension values are clamped to a minimum (`0.01` for dimensions, `0.001` for radii). Non-finite values fall back to component defaults so an invalid inspector input never creates a degenerate geometry.
34
+ - **Signature-based change detection** — per-entity signatures are compared each frame; the geometry is only rebuilt when the signature changes.
35
+ - **Geometry disposal** — the previous `BufferGeometry` is disposed before the new one is assigned, preventing accumulated GPU memory usage when parameters change frequently.
36
+
37
+ ## API reference
38
+
39
+ - Class: [`MeshGeometryComponent`](../../api/components/classes/MeshGeometryComponent.md)
40
+ - Source: [`core/systems/MeshGeometrySystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/MeshGeometrySystem.ts)
@@ -0,0 +1,38 @@
1
+ # ObjectManagementSystem
2
+
3
+ Core entity lifecycle system. Manages the entity creation queue, the scene graph parent-child hierarchy, and the registries for entity and component factories.
4
+
5
+ ## Overview
6
+
7
+ `ObjectManagementSystem` runs at the **start of each frame** (before all other systems) and is responsible for:
8
+
9
+ - Flushing the entity creation queue — calling the registered `EntityFactory` for each queued `create` request and invoking the optional `onCreated` callback with the new entity ID.
10
+ - Reconciling parent-child relationships in the THREE.js scene graph each frame by reading `ParentId` components and reparenting `Object3DRef` objects when the hierarchy changes.
11
+ - Maintaining the entity factory registry (`register`) and component factory registry (`registerComponentFactory`) used by higher-level spawn helpers.
12
+
13
+ ## Entity factory registry
14
+
15
+ Object kinds (e.g. `"model"`, `"cube"`, `"image"`) are registered with `register(kind, factory)`. When `world.create(kind, payload)` is called, the system enqueues the request and the factory is invoked on the next frame.
16
+
17
+ ## Component factory registry
18
+
19
+ Component kinds (e.g. `"animation"`, `"physics"`) are registered with `registerComponentFactory(kind, factory)`. These are called by save/hydration flows to restore component state onto existing entities.
20
+
21
+ ## Queried components
22
+
23
+ | Component | Access |
24
+ | --- | --- |
25
+ | [`ParentId`](../components/parent-id) | Read (desired parent entity ID) |
26
+ | [`Object3DRef`](../components/object3d-ref) | Read + mutate (scene graph reparenting) |
27
+ | [`TransformComponent`](../components/transform) | Read (applied to object after reparenting) |
28
+
29
+ ## Behavior notes
30
+
31
+ - **Ordering** — this system must run first in the world's update loop. All other systems assume entities and parent relationships are already resolved when they run.
32
+ - **Parent reconciliation** — if a `ParentId` refers to an entity that does not yet have an `Object3DRef` (e.g. the parent is still loading), reparenting is deferred to the next frame.
33
+ - **Scene root** — entities without a `ParentId` (or with `ParentId.parentId === null`) are kept as direct children of the THREE.js scene root.
34
+ - **Audio listener** — `getOrCreateAudioListener()` lazily creates a single `THREE.AudioListener` on the world camera and is used by audio object factories.
35
+
36
+ ## API reference
37
+
38
+ - Source: [`core/systems/ObjectManagementSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/ObjectManagementSystem.ts)
@@ -0,0 +1,26 @@
1
+ # ObjectVisibilitySystem
2
+
3
+ Synchronizes the `visibility` flag on `Object3DRef` to the `visible` property of the underlying THREE.js `Object3D` each frame.
4
+
5
+ ## Overview
6
+
7
+ `ObjectVisibilitySystem` runs every frame and is responsible for:
8
+
9
+ - Reading `Object3DRef.visibility` for every entity that has an `Object3DRef` component.
10
+ - Setting `object.visible` to `Boolean(visibility)` whenever it differs from the current THREE.js value.
11
+
12
+ ## Queried components
13
+
14
+ | Component | Access |
15
+ | --- | --- |
16
+ | [`Object3DRef`](../components/object3d-ref) | Read + mutate (`visibility` → `object.visible`) |
17
+
18
+ ## Behavior notes
19
+
20
+ - **Change-only writes** — the system only assigns `object.visible` when the value differs from the current state, preventing unnecessary scene graph dirty flags.
21
+ - **Hierarchy inheritance** — THREE.js propagates `visible = false` to all children automatically, so hiding a parent entity hides its entire subtree without additional logic here.
22
+
23
+ ## API reference
24
+
25
+ - Class: [`Object3DRef`](../../api/components/classes/Object3DRef.md)
26
+ - Source: [`core/systems/ObjectVisibilitySystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/ObjectVisibilitySystem.ts)
@@ -0,0 +1,56 @@
1
+ # PhysicsSyncSystem
2
+
3
+ Initializes and manages the Rapier physics world, creates rigid bodies and colliders from `PhysicsComponent` authoring state, steps the simulation each frame, and writes the results back to entity transforms.
4
+
5
+ ## Overview
6
+
7
+ `PhysicsSyncSystem` runs every frame and is responsible for:
8
+
9
+ - Lazy-initializing the Rapier physics engine (loaded asynchronously via `@dimforge/rapier3d-compat`) the first time the system updates.
10
+ - Creating a Rapier `RigidBody` and `Collider` for each entity that has a `PhysicsComponent` and `Object3DRef`.
11
+ - Recreating bodies and colliders when their type, shape, or size changes (detected by per-entity signatures).
12
+ - Stepping the Rapier world each frame with the clamped delta time.
13
+ - Writing the simulation's output (body translation + rotation) back into the entity's `TransformComponent` and THREE.js `Object3D` for dynamic and kinematic bodies.
14
+ - Applying per-axis translation/rotation locks from `PhysicsComponent.values.rigidbody`.
15
+ - Handling `isSensor` colliders that fire collision events without generating a physical response.
16
+
17
+ ## Queried components
18
+
19
+ | Component | Access |
20
+ | --- | --- |
21
+ | [`PhysicsComponent`](../components/physics) | Read + mutate (`rigidBody`, `collider` live refs; `values` for authoring state) |
22
+ | [`Object3DRef`](../components/object3d-ref) | Read (initial world position for body placement) |
23
+ | [`TransformComponent`](../components/transform) | Mutate (position, rotation written from simulation output) |
24
+ | [`Environment`](../scene/environment) | Read (global gravity vector) |
25
+
26
+ ## Supported rigid body types
27
+
28
+ | Type | Description |
29
+ | --- | --- |
30
+ | `dynamic` | Fully simulated; affected by gravity and forces. |
31
+ | `fixed` | Immovable; acts as a static collider. |
32
+ | `kinematicPosition` | Moved by setting position directly; not affected by physics. |
33
+ | `kinematicVelocity` | Moved by setting velocity; interacts with dynamics. |
34
+
35
+ ## Supported collider shapes
36
+
37
+ | Shape | Parameters |
38
+ | --- | --- |
39
+ | `cuboid` | `width`, `height`, `depth` |
40
+ | `ball` | `radius` |
41
+ | `capsule` | `radius`, `height` |
42
+ | `cylinder` | `radius`, `height` |
43
+ | `trimesh` | Auto-extracted from the entity's THREE.js geometry |
44
+
45
+ ## Behavior notes
46
+
47
+ - **Async init** — the Rapier WASM module is loaded once on the first `update()` call. Physics simulation does not start until the module is ready; entities created before init are processed on the first frame after init completes.
48
+ - **Trimesh** — `trimesh` colliders extract vertex/index data from the entity's `THREE.BufferGeometry`. The extracted data is cached per entity by a geometry signature.
49
+ - **Sensor colliders** — setting `values.collider.isSensor = true` creates a Rapier sensor collider. Sensor contacts do not generate forces but can be used for overlap/trigger queries.
50
+ - **Gravity** — the global gravity vector is read from the `Environment` component (`gravity` field, default `{ x: 0, y: -9.81, z: 0 }`) and applied to the Rapier world gravity setting each frame.
51
+ - **Preview only** — the system is typically constructed with `{ isEditor: false }` for preview. In the editor the physics world step is skipped so objects don't fall during authoring.
52
+
53
+ ## API reference
54
+
55
+ - Class: [`PhysicsComponent`](../../api/components/classes/PhysicsComponent.md)
56
+ - Source: [`core/systems/PhysicsSyncSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/PhysicsSyncSystem.ts)
@@ -0,0 +1,43 @@
1
+ # PostprocessingSyncSystem
2
+
3
+ Builds and manages a THREE.js `EffectComposer` pipeline from the `Postprocessing` component's state, enabling full-screen visual effects in the rendered scene.
4
+
5
+ ## Overview
6
+
7
+ `PostprocessingSyncSystem` runs every frame and is responsible for:
8
+
9
+ - Building an `EffectComposer` with a `RenderPass` base and adding post-process passes derived from the enabled effects in `Postprocessing`.
10
+ - Rebuilding the composer pipeline when the effect configuration changes (detected by signature).
11
+ - Handing off the composer to `RenderSystem` via `scene.userData.ecsPostprocessingComposer` so the render pass uses it instead of the default `renderer.render()`.
12
+ - Disposing old composers and passes when the configuration changes or the component is removed.
13
+
14
+ ## Queried components
15
+
16
+ | Component | Access |
17
+ | --- | --- |
18
+ | [`Postprocessing`](../scene/postprocessing) | Read (`effects` array and each effect's enabled/parameter state) |
19
+
20
+ ## Supported effects
21
+
22
+ | Effect | THREE.js pass |
23
+ | --- | --- |
24
+ | `bloom` | `UnrealBloomPass` |
25
+ | `dotScreen` | `DotScreenPass` |
26
+ | `glitch` | `GlitchPass` |
27
+ | `film` | `FilmPass` |
28
+ | `bokeh` | `BokehPass` |
29
+ | `ssao` | `SSAOPass` |
30
+ | `hueSaturation` | `ShaderPass` (HueSaturationShader) |
31
+ | `sepia` | `ShaderPass` (SepiaShader) |
32
+ | `vignette` | `ShaderPass` (VignetteShader) |
33
+
34
+ ## Behavior notes
35
+
36
+ - **Composer handoff** — when the composer is active, `scene.userData.ecsPostprocessingComposerActive` is set to `true` and `scene.userData.ecsPostprocessingComposer` holds the composer reference. `RenderSystem` checks this flag and delegates rendering to the composer instead of calling `renderer.render()` directly.
37
+ - **Signature-based rebuild** — the full effect configuration is serialized each frame. The composer is only rebuilt when the signature changes, so parameter tweaks during runtime (e.g. adjusting bloom strength from the inspector) are applied efficiently.
38
+ - **Cleanup** — when the `Postprocessing` component is removed from the scene, or when the composer is rebuilt, all existing passes are disposed and the composer is torn down.
39
+
40
+ ## API reference
41
+
42
+ - Class: [`Postprocessing`](../../api/components/classes/Postprocessing.md)
43
+ - Source: [`core/systems/PostprocessingSyncSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/PostprocessingSyncSystem.ts)
@@ -0,0 +1,22 @@
1
+ # RenderSystem
2
+
3
+ The final system in the update loop. Submits the frame to the WebGL renderer, delegating to an `EffectComposer` when postprocessing is active.
4
+
5
+ ## Overview
6
+
7
+ `RenderSystem` runs **last** in the world update loop and is responsible for:
8
+
9
+ - Calling `renderer.render(scene, camera)` to produce the final frame.
10
+ - Detecting whether `PostprocessingSyncSystem` has placed an active `EffectComposer` on `scene.userData.ecsPostprocessingComposer`.
11
+ - When a composer is active: resizing it to the current renderer element dimensions and calling `composer.render()` instead of the default render path.
12
+ - Invoking an optional `afterRender` callback after every frame (used by editor overlays or custom render hooks).
13
+
14
+ ## Behavior notes
15
+
16
+ - **Composer precedence** — the system checks `scene.userData.ecsPostprocessingComposerActive` each frame. If `true`, the `EffectComposer` path is used; otherwise the standard `renderer.render()` path is used. This coupling with `PostprocessingSyncSystem` means both systems must be present for postprocessing to work.
17
+ - **Dynamic resize** — before calling `composer.render()`, the system reads `renderer.domElement.clientWidth/Height` (clamped to `≥ 1`) and updates the composer size to match. This ensures the effect pipeline stays correct after window resizes without an explicit resize event handler.
18
+ - **Ordering** — `RenderSystem` must be registered last in `World.setup`. All scene mutations (transform sync, visibility, etc.) must have already run.
19
+
20
+ ## API reference
21
+
22
+ - Source: [`core/systems/RenderSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/RenderSystem.ts)
@@ -0,0 +1,59 @@
1
+ # ScriptBehaviourSystem
2
+
3
+ Loads user-authored Behaviour scripts via dynamic `import()`, instantiates their classes, and drives the full Behaviour lifecycle (`init`, `onUpdate`, `onDestroy`) each frame.
4
+
5
+ ## Overview
6
+
7
+ `ScriptBehaviourSystem` runs every frame and is responsible for:
8
+
9
+ - Discovering entities with a `ScriptComponent` and iterating their `entries` array.
10
+ - Dynamically importing each script's compiled URL the first time it is seen (or when the URL changes).
11
+ - Resolving the exported `Behaviour` subclass by name (or falling back to the default export).
12
+ - Instantiating the class and calling `init()` once.
13
+ - Calling `onUpdate(deltaTime)` on every active script instance each frame.
14
+ - Detecting stale instances (removed entries, changed URLs, destroyed entities) and calling `onDestroy()` before discarding them.
15
+
16
+ ## Queried components
17
+
18
+ | Component | Access |
19
+ | --- | --- |
20
+ | [`ScriptComponent`](../components/script) | Read (`entries`, `defaultData`, `runtimeData`) |
21
+
22
+ ## Behaviour resolution
23
+
24
+ The system resolves the `Behaviour` constructor from the imported module using:
25
+
26
+ 1. Named export matching `ScriptEntry.className`.
27
+ 2. `default` export as a fallback.
28
+ 3. A `__reluBehaviourClass` static marker check to handle cases where esbuild bundles a second copy of `@relu-interactives/spatial-ecs` into the script blob (breaking the `instanceof` identity check).
29
+
30
+ If no valid `Behaviour` subclass is found the entry is skipped and an error is written to the console.
31
+
32
+ ## Behavior notes
33
+
34
+ - **Instance keying** — each script instance is keyed by `entityId + scriptUrl + className`. A new instance is created only when any of these three values changes.
35
+ - **Error isolation** — errors thrown inside `init()` or `onUpdate()` are caught per-instance and logged to the console. A failing script does not crash the frame loop or affect other scripts.
36
+ - **Destroyed entity cleanup** — when an entity is removed from the world, all of its script instances are destroyed and removed from the registry on the next update.
37
+ - **Editor vs preview** — the system is used in both the editor and preview. By default, scripts are **not** executed in the editor. Set `executeInEditor: true` on a `ScriptEntry` to opt a script into full lifecycle execution (including `init()`) while the editor is open. Scripts without this flag stay in `idle` state in editor mode and never call `init()` or `onUpdate()`.
38
+
39
+ ## Editor mode execution
40
+
41
+ When `ScriptEntry.executeInEditor` is `true`:
42
+
43
+ 1. The script module is loaded and the class is instantiated as normal.
44
+ 2. `init()` is called once (same as preview).
45
+ 3. `onUpdate()` is called every frame while the script is enabled.
46
+ 4. Direct Three.js scene access is available via `this.world.getScene()`, `getCamera()`, and `getRenderer()`.
47
+
48
+ This allows scripts to create geometry, shaders, materials, and any other Three.js construct that the editor's object palette does not expose.
49
+
50
+ > [!WARNING]
51
+ > Writing to ECS components (e.g. `TransformComponent`) every frame in editor mode will generate an undo history entry on every tick. Keep per-frame mutations in local Three.js state to avoid flooding the undo stack.
52
+
53
+ See [Running scripts in the editor](../authoring-a-behaviour#running-scripts-in-the-editor) for usage examples.
54
+
55
+ ## API reference
56
+
57
+ - Class: [`ScriptComponent`](../../api/components/classes/ScriptComponent.md)
58
+ - Base class: [`Behaviour`](../../api/Behaviour/classes/Behaviour.md)
59
+ - Source: [`core/systems/ScriptBehaviourSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/ScriptBehaviourSystem.ts)
@@ -0,0 +1,29 @@
1
+ # TransformSyncSystem
2
+
3
+ Applies `TransformComponent` position, rotation, and scale values to the linked THREE.js `Object3D` every frame.
4
+
5
+ ## Overview
6
+
7
+ `TransformSyncSystem` runs every frame (just before `RenderSystem`) and is responsible for:
8
+
9
+ - Querying all entities that have both a `TransformComponent` and an `Object3DRef`.
10
+ - Calling `object.position.set(...)`, `object.rotation.set(...)`, and `object.scale.set(...)` from the component values.
11
+ - Calling `object.updateMatrixWorld(true)` after applying the transform to propagate changes to child objects.
12
+
13
+ ## Queried components
14
+
15
+ | Component | Access |
16
+ | --- | --- |
17
+ | [`TransformComponent`](../components/transform) | Read (`position`, `rotation`, `scale`) |
18
+ | [`Object3DRef`](../components/object3d-ref) | Read (the live THREE.js object) |
19
+
20
+ ## Behavior notes
21
+
22
+ - **Every frame** — transforms are applied unconditionally every frame. Scripts and inspector edits can mutate `TransformComponent` at any point and the result will be visible on the next render.
23
+ - **World matrix propagation** — `updateMatrixWorld(true)` is called with `force = true` so that child objects in the hierarchy receive updated world matrices even if the parent did not mark itself dirty.
24
+ - **Ordering** — `TransformSyncSystem` runs after all custom systems and before `RenderSystem`. This guarantees that script-driven position changes (from `onUpdate`) are reflected in the same frame they are written.
25
+
26
+ ## API reference
27
+
28
+ - Class: [`TransformComponent`](../../api/components/classes/TransformComponent.md)
29
+ - Source: [`core/systems/TransformSyncSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/TransformSyncSystem.ts)
@@ -0,0 +1,30 @@
1
+ # VideoSystem
2
+
3
+ Reconciles `VideoComponent` state with the underlying HTML `<video>` element and THREE.js mesh/material each frame. Only active in **preview** mode — editor viewports are unaffected.
4
+
5
+ ## Overview
6
+
7
+ `VideoSystem` runs every frame in preview and is responsible for:
8
+
9
+ - Driving `play()`, `pause()`, and stop (pause + seek to 0) on the HTML `<video>` element based on the intent flags set by `VideoComponent.play()`, `.pause()`, and `.stop()`.
10
+ - Detecting when a non-looping video ends naturally and resetting the component flags.
11
+ - Syncing `loop`, `volume`, `width`, `height`, `positional`, `refDistance`, `distanceModel`, and `rolloffFactor` to the video element and THREE.js mesh material.
12
+ - Updating the green-screen chroma key shader uniforms (`backgroundColor`, `similarity`, `smoothness`, `spill`) live when they change.
13
+
14
+ ## Queried components
15
+
16
+ | Component | Access |
17
+ | --- | --- |
18
+ | [`VideoComponent`](../components/video) | Read + mutate (`isPlaying`, `isPaused` flags; option properties) |
19
+
20
+ ## Behavior notes
21
+
22
+ - **Editor skip** — when constructed with `{ isEditor: true }` the `update` method returns immediately so no video state is applied in the editor.
23
+ - **Natural end detection** — the system compares `HTMLVideoElement.paused` and `ended` state between frames. If the video ended on its own while the component still believed it was playing, the component flags are reset.
24
+ - **Change detection** — option sync uses a per-entity snapshot from the previous frame. Chroma key shader uniforms and other options are only written when they change, avoiding redundant material updates every frame.
25
+ - **Positional audio** — videos with `options.positional = true` use a `THREE.PositionalAudio` node attached to the mesh; non-positional videos use a standard `THREE.Audio` node. The system respects `refDistance`, `distanceModel`, and `rolloffFactor` for spatial audio falloff.
26
+
27
+ ## API reference
28
+
29
+ - Class: [`VideoComponent`](../../api/components/classes/VideoComponent.md)
30
+ - Source: [`core/systems/VideoSystem.ts`](https://github.com/Relu-Interactives/relu-spatial-ecs-engine/blob/main/core/systems/VideoSystem.ts)