@needle-tools/engine 4.13.0 → 4.13.1-beta

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 (410) hide show
  1. package/CHANGELOG.md +2 -1
  2. package/README.md +37 -0
  3. package/components.needle.json +1 -1
  4. package/custom-elements.json +138 -4
  5. package/dist/{needle-engine.bundle-CxaKFQVS.min.js → needle-engine.bundle-6774fXoY.min.js} +107 -107
  6. package/dist/{needle-engine.bundle-Dl3TFYyv.js → needle-engine.bundle-CGtsEhyJ.js} +2346 -1844
  7. package/dist/{needle-engine.bundle-J4k4znv8.umd.cjs → needle-engine.bundle-fbFZTOKP.umd.cjs} +108 -108
  8. package/dist/needle-engine.d.ts +3769 -397
  9. package/dist/needle-engine.js +2 -2
  10. package/dist/needle-engine.min.js +1 -1
  11. package/dist/needle-engine.umd.cjs +1 -1
  12. package/lib/engine/engine_context.d.ts +16 -0
  13. package/lib/engine/engine_context.js +16 -0
  14. package/lib/engine/engine_context.js.map +1 -1
  15. package/lib/engine/engine_gameobject.d.ts +72 -0
  16. package/lib/engine/engine_gameobject.js +38 -0
  17. package/lib/engine/engine_gameobject.js.map +1 -1
  18. package/lib/engine/engine_input.d.ts +80 -4
  19. package/lib/engine/engine_input.js +78 -2
  20. package/lib/engine/engine_input.js.map +1 -1
  21. package/lib/engine/engine_math.d.ts +81 -2
  22. package/lib/engine/engine_math.js +68 -2
  23. package/lib/engine/engine_math.js.map +1 -1
  24. package/lib/engine/engine_networking.d.ts +181 -14
  25. package/lib/engine/engine_networking.js +181 -14
  26. package/lib/engine/engine_networking.js.map +1 -1
  27. package/lib/engine/engine_networking_auto.d.ts +35 -8
  28. package/lib/engine/engine_networking_auto.js +35 -8
  29. package/lib/engine/engine_networking_auto.js.map +1 -1
  30. package/lib/engine/engine_physics.d.ts +35 -1
  31. package/lib/engine/engine_physics.js +35 -1
  32. package/lib/engine/engine_physics.js.map +1 -1
  33. package/lib/engine/engine_physics_rapier.d.ts +76 -0
  34. package/lib/engine/engine_physics_rapier.js +76 -0
  35. package/lib/engine/engine_physics_rapier.js.map +1 -1
  36. package/lib/engine/engine_serialization_decorator.d.ts +28 -2
  37. package/lib/engine/engine_serialization_decorator.js +28 -2
  38. package/lib/engine/engine_serialization_decorator.js.map +1 -1
  39. package/lib/engine/engine_time.d.ts +23 -3
  40. package/lib/engine/engine_time.js +23 -3
  41. package/lib/engine/engine_time.js.map +1 -1
  42. package/lib/engine/engine_util_decorator.d.ts +31 -1
  43. package/lib/engine/engine_util_decorator.js +31 -1
  44. package/lib/engine/engine_util_decorator.js.map +1 -1
  45. package/lib/engine/engine_utils.d.ts +21 -5
  46. package/lib/engine/engine_utils.js +21 -5
  47. package/lib/engine/engine_utils.js.map +1 -1
  48. package/lib/engine/extensions/NEEDLE_materialx.d.ts +2 -2
  49. package/lib/engine/extensions/NEEDLE_materialx.js +2 -2
  50. package/lib/engine/extensions/NEEDLE_materialx.js.map +1 -1
  51. package/lib/engine/extensions/index.d.ts +1 -1
  52. package/lib/engine/extensions/index.js +1 -1
  53. package/lib/engine/extensions/index.js.map +1 -1
  54. package/lib/engine-components/AlignmentConstraint.d.ts +23 -3
  55. package/lib/engine-components/AlignmentConstraint.js +23 -3
  56. package/lib/engine-components/AlignmentConstraint.js.map +1 -1
  57. package/lib/engine-components/Animation.d.ts +42 -0
  58. package/lib/engine-components/Animation.js +36 -0
  59. package/lib/engine-components/Animation.js.map +1 -1
  60. package/lib/engine-components/Animator.d.ts +37 -4
  61. package/lib/engine-components/Animator.js +37 -4
  62. package/lib/engine-components/Animator.js.map +1 -1
  63. package/lib/engine-components/AudioListener.d.ts +1 -1
  64. package/lib/engine-components/AudioListener.js +1 -1
  65. package/lib/engine-components/AudioSource.d.ts +32 -10
  66. package/lib/engine-components/AudioSource.js +32 -10
  67. package/lib/engine-components/AudioSource.js.map +1 -1
  68. package/lib/engine-components/AxesHelper.d.ts +22 -3
  69. package/lib/engine-components/AxesHelper.js +22 -3
  70. package/lib/engine-components/AxesHelper.js.map +1 -1
  71. package/lib/engine-components/BasicIKConstraint.d.ts +27 -4
  72. package/lib/engine-components/BasicIKConstraint.js +27 -4
  73. package/lib/engine-components/BasicIKConstraint.js.map +1 -1
  74. package/lib/engine-components/Camera.d.ts +32 -2
  75. package/lib/engine-components/Camera.js +32 -2
  76. package/lib/engine-components/Camera.js.map +1 -1
  77. package/lib/engine-components/CharacterController.d.ts +68 -4
  78. package/lib/engine-components/CharacterController.js +68 -4
  79. package/lib/engine-components/CharacterController.js.map +1 -1
  80. package/lib/engine-components/Collider.d.ts +69 -12
  81. package/lib/engine-components/Collider.js +69 -12
  82. package/lib/engine-components/Collider.js.map +1 -1
  83. package/lib/engine-components/ContactShadows.d.ts +26 -6
  84. package/lib/engine-components/ContactShadows.js +31 -8
  85. package/lib/engine-components/ContactShadows.js.map +1 -1
  86. package/lib/engine-components/DeleteBox.d.ts +43 -2
  87. package/lib/engine-components/DeleteBox.js +43 -2
  88. package/lib/engine-components/DeleteBox.js.map +1 -1
  89. package/lib/engine-components/DeviceFlag.d.ts +21 -2
  90. package/lib/engine-components/DeviceFlag.js +21 -2
  91. package/lib/engine-components/DeviceFlag.js.map +1 -1
  92. package/lib/engine-components/DragControls.d.ts +32 -2
  93. package/lib/engine-components/DragControls.js +32 -2
  94. package/lib/engine-components/DragControls.js.map +1 -1
  95. package/lib/engine-components/DropListener.d.ts +33 -21
  96. package/lib/engine-components/DropListener.js +33 -21
  97. package/lib/engine-components/DropListener.js.map +1 -1
  98. package/lib/engine-components/Duplicatable.d.ts +36 -5
  99. package/lib/engine-components/Duplicatable.js +36 -5
  100. package/lib/engine-components/Duplicatable.js.map +1 -1
  101. package/lib/engine-components/EventList.d.ts +38 -10
  102. package/lib/engine-components/EventList.js +38 -10
  103. package/lib/engine-components/EventList.js.map +1 -1
  104. package/lib/engine-components/EventTrigger.d.ts +1 -1
  105. package/lib/engine-components/EventTrigger.js +1 -1
  106. package/lib/engine-components/Fog.d.ts +23 -1
  107. package/lib/engine-components/Fog.js +23 -1
  108. package/lib/engine-components/Fog.js.map +1 -1
  109. package/lib/engine-components/GridHelper.d.ts +18 -2
  110. package/lib/engine-components/GridHelper.js +18 -2
  111. package/lib/engine-components/GridHelper.js.map +1 -1
  112. package/lib/engine-components/GroundProjection.d.ts +24 -2
  113. package/lib/engine-components/GroundProjection.js +24 -2
  114. package/lib/engine-components/GroundProjection.js.map +1 -1
  115. package/lib/engine-components/Interactable.d.ts +17 -2
  116. package/lib/engine-components/Interactable.js +17 -2
  117. package/lib/engine-components/Interactable.js.map +1 -1
  118. package/lib/engine-components/Joints.d.ts +50 -7
  119. package/lib/engine-components/Joints.js +50 -7
  120. package/lib/engine-components/Joints.js.map +1 -1
  121. package/lib/engine-components/LODGroup.d.ts +36 -14
  122. package/lib/engine-components/LODGroup.js +43 -11
  123. package/lib/engine-components/LODGroup.js.map +1 -1
  124. package/lib/engine-components/Light.d.ts +30 -5
  125. package/lib/engine-components/Light.js +30 -5
  126. package/lib/engine-components/Light.js.map +1 -1
  127. package/lib/engine-components/LookAtConstraint.d.ts +22 -7
  128. package/lib/engine-components/LookAtConstraint.js +22 -7
  129. package/lib/engine-components/LookAtConstraint.js.map +1 -1
  130. package/lib/engine-components/NeedleMenu.d.ts +27 -5
  131. package/lib/engine-components/NeedleMenu.js +27 -5
  132. package/lib/engine-components/NeedleMenu.js.map +1 -1
  133. package/lib/engine-components/NestedGltf.d.ts +39 -4
  134. package/lib/engine-components/NestedGltf.js +42 -4
  135. package/lib/engine-components/NestedGltf.js.map +1 -1
  136. package/lib/engine-components/OffsetConstraint.d.ts +27 -3
  137. package/lib/engine-components/OffsetConstraint.js +27 -3
  138. package/lib/engine-components/OffsetConstraint.js.map +1 -1
  139. package/lib/engine-components/OrbitControls.d.ts +41 -3
  140. package/lib/engine-components/OrbitControls.js +41 -3
  141. package/lib/engine-components/OrbitControls.js.map +1 -1
  142. package/lib/engine-components/PlayerColor.d.ts +1 -1
  143. package/lib/engine-components/PlayerColor.js +1 -1
  144. package/lib/engine-components/ReflectionProbe.d.ts +17 -2
  145. package/lib/engine-components/ReflectionProbe.js +17 -3
  146. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  147. package/lib/engine-components/Renderer.d.ts +34 -0
  148. package/lib/engine-components/Renderer.js +35 -2
  149. package/lib/engine-components/Renderer.js.map +1 -1
  150. package/lib/engine-components/SceneSwitcher.d.ts +11 -0
  151. package/lib/engine-components/SceneSwitcher.js +11 -0
  152. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  153. package/lib/engine-components/ScreenCapture.d.ts +38 -6
  154. package/lib/engine-components/ScreenCapture.js +38 -6
  155. package/lib/engine-components/ScreenCapture.js.map +1 -1
  156. package/lib/engine-components/Skybox.d.ts +1 -1
  157. package/lib/engine-components/Skybox.js +1 -1
  158. package/lib/engine-components/SmoothFollow.d.ts +66 -7
  159. package/lib/engine-components/SmoothFollow.js +66 -7
  160. package/lib/engine-components/SmoothFollow.js.map +1 -1
  161. package/lib/engine-components/SpatialTrigger.d.ts +48 -1
  162. package/lib/engine-components/SpatialTrigger.js +48 -1
  163. package/lib/engine-components/SpatialTrigger.js.map +1 -1
  164. package/lib/engine-components/SpectatorCamera.d.ts +21 -3
  165. package/lib/engine-components/SpectatorCamera.js +21 -3
  166. package/lib/engine-components/SpectatorCamera.js.map +1 -1
  167. package/lib/engine-components/SyncedRoom.d.ts +7 -1
  168. package/lib/engine-components/SyncedRoom.js +7 -1
  169. package/lib/engine-components/SyncedRoom.js.map +1 -1
  170. package/lib/engine-components/SyncedTransform.d.ts +55 -6
  171. package/lib/engine-components/SyncedTransform.js +55 -6
  172. package/lib/engine-components/SyncedTransform.js.map +1 -1
  173. package/lib/engine-components/TransformGizmo.d.ts +30 -3
  174. package/lib/engine-components/TransformGizmo.js +30 -3
  175. package/lib/engine-components/TransformGizmo.js.map +1 -1
  176. package/lib/engine-components/VideoPlayer.d.ts +33 -6
  177. package/lib/engine-components/VideoPlayer.js +45 -6
  178. package/lib/engine-components/VideoPlayer.js.map +1 -1
  179. package/lib/engine-components/Voip.d.ts +33 -2
  180. package/lib/engine-components/Voip.js +33 -2
  181. package/lib/engine-components/Voip.js.map +1 -1
  182. package/lib/engine-components/export/usdz/USDZExporter.d.ts +47 -13
  183. package/lib/engine-components/export/usdz/USDZExporter.js +47 -13
  184. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  185. package/lib/engine-components/particlesystem/ParticleSystem.d.ts +82 -3
  186. package/lib/engine-components/particlesystem/ParticleSystem.js +82 -3
  187. package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
  188. package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +1 -0
  189. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +1 -0
  190. package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
  191. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  192. package/lib/engine-components/postprocessing/Effects/BloomEffect.js +1 -1
  193. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +1 -1
  194. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +1 -1
  195. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +1 -1
  196. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +1 -1
  197. package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +1 -1
  198. package/lib/engine-components/postprocessing/Effects/DepthOfField.js +1 -1
  199. package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +1 -0
  200. package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +1 -0
  201. package/lib/engine-components/postprocessing/Effects/EffectWrapper.js.map +1 -1
  202. package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +1 -1
  203. package/lib/engine-components/postprocessing/Effects/Pixelation.js +1 -1
  204. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +1 -1
  205. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +1 -1
  206. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +1 -1
  207. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
  208. package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -1
  209. package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -1
  210. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +1 -1
  211. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +1 -1
  212. package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +1 -1
  213. package/lib/engine-components/postprocessing/Effects/Tonemapping.js +1 -1
  214. package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +1 -1
  215. package/lib/engine-components/postprocessing/Effects/Vignette.js +1 -1
  216. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +1 -1
  217. package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
  218. package/lib/engine-components/postprocessing/Volume.d.ts +1 -1
  219. package/lib/engine-components/postprocessing/Volume.js +1 -1
  220. package/lib/engine-components/splines/Spline.d.ts +409 -12
  221. package/lib/engine-components/splines/Spline.js +409 -12
  222. package/lib/engine-components/splines/Spline.js.map +1 -1
  223. package/lib/engine-components/splines/SplineUtils.d.ts +1 -0
  224. package/lib/engine-components/splines/SplineUtils.js +1 -0
  225. package/lib/engine-components/splines/SplineUtils.js.map +1 -1
  226. package/lib/engine-components/splines/SplineWalker.d.ts +3 -1
  227. package/lib/engine-components/splines/SplineWalker.js +3 -1
  228. package/lib/engine-components/splines/SplineWalker.js.map +1 -1
  229. package/lib/engine-components/timeline/PlayableDirector.d.ts +99 -14
  230. package/lib/engine-components/timeline/PlayableDirector.js +91 -25
  231. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  232. package/lib/engine-components/ui/Button.d.ts +29 -3
  233. package/lib/engine-components/ui/Button.js +29 -3
  234. package/lib/engine-components/ui/Button.js.map +1 -1
  235. package/lib/engine-components/ui/Canvas.d.ts +29 -4
  236. package/lib/engine-components/ui/Canvas.js +29 -4
  237. package/lib/engine-components/ui/Canvas.js.map +1 -1
  238. package/lib/engine-components/ui/CanvasGroup.d.ts +1 -1
  239. package/lib/engine-components/ui/CanvasGroup.js +1 -1
  240. package/lib/engine-components/ui/EventSystem.d.ts +1 -1
  241. package/lib/engine-components/ui/EventSystem.js +1 -1
  242. package/lib/engine-components/ui/Graphic.d.ts +1 -0
  243. package/lib/engine-components/ui/Graphic.js +1 -0
  244. package/lib/engine-components/ui/Graphic.js.map +1 -1
  245. package/lib/engine-components/ui/Image.d.ts +22 -3
  246. package/lib/engine-components/ui/Image.js +22 -3
  247. package/lib/engine-components/ui/Image.js.map +1 -1
  248. package/lib/engine-components/ui/InputField.d.ts +1 -1
  249. package/lib/engine-components/ui/InputField.js +1 -1
  250. package/lib/engine-components/ui/Layout.d.ts +3 -0
  251. package/lib/engine-components/ui/Layout.js +3 -0
  252. package/lib/engine-components/ui/Layout.js.map +1 -1
  253. package/lib/engine-components/ui/Outline.d.ts +1 -1
  254. package/lib/engine-components/ui/Outline.js +1 -1
  255. package/lib/engine-components/ui/PointerEvents.d.ts +1 -1
  256. package/lib/engine-components/ui/PointerEvents.js +1 -1
  257. package/lib/engine-components/ui/Raycaster.d.ts +55 -6
  258. package/lib/engine-components/ui/Raycaster.js +55 -6
  259. package/lib/engine-components/ui/Raycaster.js.map +1 -1
  260. package/lib/engine-components/ui/RectTransform.d.ts +1 -1
  261. package/lib/engine-components/ui/RectTransform.js +1 -1
  262. package/lib/engine-components/ui/SpatialHtml.d.ts +1 -1
  263. package/lib/engine-components/ui/SpatialHtml.js +1 -1
  264. package/lib/engine-components/ui/Text.d.ts +23 -1
  265. package/lib/engine-components/ui/Text.js +23 -1
  266. package/lib/engine-components/ui/Text.js.map +1 -1
  267. package/lib/engine-components/utils/LookAt.d.ts +1 -1
  268. package/lib/engine-components/utils/LookAt.js +1 -1
  269. package/lib/engine-components/utils/OpenURL.d.ts +1 -1
  270. package/lib/engine-components/utils/OpenURL.js +1 -1
  271. package/lib/engine-components/web/Clickthrough.d.ts +116 -7
  272. package/lib/engine-components/web/Clickthrough.js +116 -7
  273. package/lib/engine-components/web/Clickthrough.js.map +1 -1
  274. package/lib/engine-components/web/CursorFollow.d.ts +171 -7
  275. package/lib/engine-components/web/CursorFollow.js +171 -7
  276. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  277. package/lib/engine-components/web/HoverAnimation.d.ts +140 -11
  278. package/lib/engine-components/web/HoverAnimation.js +140 -11
  279. package/lib/engine-components/web/HoverAnimation.js.map +1 -1
  280. package/lib/engine-components/web/ScrollFollow.d.ts +4 -1
  281. package/lib/engine-components/web/ScrollFollow.js +4 -1
  282. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  283. package/lib/engine-components/web/ViewBox.d.ts +116 -16
  284. package/lib/engine-components/web/ViewBox.js +110 -16
  285. package/lib/engine-components/web/ViewBox.js.map +1 -1
  286. package/lib/engine-components/webxr/TeleportTarget.d.ts +21 -2
  287. package/lib/engine-components/webxr/TeleportTarget.js +21 -2
  288. package/lib/engine-components/webxr/TeleportTarget.js.map +1 -1
  289. package/lib/engine-components/webxr/WebXR.d.ts +10 -2
  290. package/lib/engine-components/webxr/WebXR.js +10 -2
  291. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  292. package/lib/engine-components/webxr/WebXRAvatar.d.ts +39 -2
  293. package/lib/engine-components/webxr/WebXRAvatar.js +35 -3
  294. package/lib/engine-components/webxr/WebXRAvatar.js.map +1 -1
  295. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +266 -30
  296. package/lib/engine-components/webxr/WebXRImageTracking.js +266 -30
  297. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  298. package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +1 -1
  299. package/lib/engine-components/webxr/WebXRPlaneTracking.js +1 -1
  300. package/lib/engine-components/webxr/XRFlag.d.ts +29 -2
  301. package/lib/engine-components/webxr/XRFlag.js +29 -2
  302. package/lib/engine-components/webxr/XRFlag.js.map +1 -1
  303. package/package.json +1 -1
  304. package/plugins/vite/custom-element-data.js +128 -19
  305. package/src/engine/engine_context.ts +16 -0
  306. package/src/engine/engine_gameobject.ts +73 -0
  307. package/src/engine/engine_input.ts +83 -7
  308. package/src/engine/engine_math.ts +81 -2
  309. package/src/engine/engine_networking.ts +186 -17
  310. package/src/engine/engine_networking_auto.ts +36 -9
  311. package/src/engine/engine_physics.ts +37 -1
  312. package/src/engine/engine_physics_rapier.ts +77 -0
  313. package/src/engine/engine_serialization_decorator.ts +28 -2
  314. package/src/engine/engine_time.ts +23 -3
  315. package/src/engine/engine_util_decorator.ts +31 -1
  316. package/src/engine/engine_utils.ts +21 -5
  317. package/src/engine/extensions/NEEDLE_materialx.ts +5 -4
  318. package/src/engine/extensions/index.ts +2 -2
  319. package/src/engine-components/AlignmentConstraint.ts +24 -4
  320. package/src/engine-components/Animation.ts +44 -2
  321. package/src/engine-components/Animator.ts +40 -7
  322. package/src/engine-components/AudioListener.ts +1 -1
  323. package/src/engine-components/AudioSource.ts +37 -15
  324. package/src/engine-components/AxesHelper.ts +23 -4
  325. package/src/engine-components/BasicIKConstraint.ts +28 -5
  326. package/src/engine-components/Camera.ts +33 -3
  327. package/src/engine-components/CharacterController.ts +74 -7
  328. package/src/engine-components/Collider.ts +78 -21
  329. package/src/engine-components/ContactShadows.ts +36 -11
  330. package/src/engine-components/DeleteBox.ts +43 -2
  331. package/src/engine-components/DeviceFlag.ts +22 -3
  332. package/src/engine-components/DragControls.ts +32 -2
  333. package/src/engine-components/DropListener.ts +41 -29
  334. package/src/engine-components/Duplicatable.ts +37 -6
  335. package/src/engine-components/EventList.ts +41 -13
  336. package/src/engine-components/EventTrigger.ts +1 -1
  337. package/src/engine-components/Fog.ts +23 -1
  338. package/src/engine-components/GridHelper.ts +18 -2
  339. package/src/engine-components/GroundProjection.ts +25 -3
  340. package/src/engine-components/Interactable.ts +17 -2
  341. package/src/engine-components/Joints.ts +51 -8
  342. package/src/engine-components/LODGroup.ts +45 -11
  343. package/src/engine-components/Light.ts +35 -13
  344. package/src/engine-components/LookAtConstraint.ts +26 -8
  345. package/src/engine-components/NeedleMenu.ts +29 -7
  346. package/src/engine-components/NestedGltf.ts +40 -4
  347. package/src/engine-components/OffsetConstraint.ts +27 -3
  348. package/src/engine-components/OrbitControls.ts +41 -3
  349. package/src/engine-components/PlayerColor.ts +1 -1
  350. package/src/engine-components/ReflectionProbe.ts +19 -5
  351. package/src/engine-components/Renderer.ts +34 -1
  352. package/src/engine-components/SceneSwitcher.ts +11 -0
  353. package/src/engine-components/ScreenCapture.ts +41 -9
  354. package/src/engine-components/Skybox.ts +1 -1
  355. package/src/engine-components/SmoothFollow.ts +68 -7
  356. package/src/engine-components/SpatialTrigger.ts +51 -4
  357. package/src/engine-components/SpectatorCamera.ts +23 -5
  358. package/src/engine-components/SyncedRoom.ts +8 -2
  359. package/src/engine-components/SyncedTransform.ts +59 -10
  360. package/src/engine-components/TransformGizmo.ts +31 -4
  361. package/src/engine-components/VideoPlayer.ts +48 -6
  362. package/src/engine-components/Voip.ts +33 -2
  363. package/src/engine-components/export/usdz/USDZExporter.ts +47 -13
  364. package/src/engine-components/particlesystem/ParticleSystem.ts +84 -5
  365. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +1 -0
  366. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
  367. package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +1 -1
  368. package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +1 -1
  369. package/src/engine-components/postprocessing/Effects/DepthOfField.ts +1 -1
  370. package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +1 -0
  371. package/src/engine-components/postprocessing/Effects/Pixelation.ts +1 -1
  372. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +1 -1
  373. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
  374. package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -1
  375. package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +1 -1
  376. package/src/engine-components/postprocessing/Effects/Tonemapping.ts +1 -1
  377. package/src/engine-components/postprocessing/Effects/Vignette.ts +1 -1
  378. package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
  379. package/src/engine-components/postprocessing/Volume.ts +1 -1
  380. package/src/engine-components/splines/Spline.ts +412 -14
  381. package/src/engine-components/splines/SplineUtils.ts +1 -0
  382. package/src/engine-components/splines/SplineWalker.ts +4 -2
  383. package/src/engine-components/timeline/PlayableDirector.ts +104 -27
  384. package/src/engine-components/ui/Button.ts +29 -3
  385. package/src/engine-components/ui/Canvas.ts +29 -4
  386. package/src/engine-components/ui/CanvasGroup.ts +2 -2
  387. package/src/engine-components/ui/EventSystem.ts +1 -1
  388. package/src/engine-components/ui/Graphic.ts +1 -0
  389. package/src/engine-components/ui/Image.ts +22 -3
  390. package/src/engine-components/ui/InputField.ts +2 -2
  391. package/src/engine-components/ui/Layout.ts +3 -0
  392. package/src/engine-components/ui/Outline.ts +1 -1
  393. package/src/engine-components/ui/PointerEvents.ts +1 -1
  394. package/src/engine-components/ui/Raycaster.ts +57 -8
  395. package/src/engine-components/ui/RectTransform.ts +2 -2
  396. package/src/engine-components/ui/SpatialHtml.ts +1 -1
  397. package/src/engine-components/ui/Text.ts +24 -2
  398. package/src/engine-components/utils/LookAt.ts +1 -1
  399. package/src/engine-components/utils/OpenURL.ts +1 -1
  400. package/src/engine-components/web/Clickthrough.ts +119 -10
  401. package/src/engine-components/web/CursorFollow.ts +174 -9
  402. package/src/engine-components/web/HoverAnimation.ts +142 -13
  403. package/src/engine-components/web/ScrollFollow.ts +4 -1
  404. package/src/engine-components/web/ViewBox.ts +118 -18
  405. package/src/engine-components/webxr/TeleportTarget.ts +23 -4
  406. package/src/engine-components/webxr/WebXR.ts +11 -3
  407. package/src/engine-components/webxr/WebXRAvatar.ts +41 -4
  408. package/src/engine-components/webxr/WebXRImageTracking.ts +282 -38
  409. package/src/engine-components/webxr/WebXRPlaneTracking.ts +1 -1
  410. package/src/engine-components/webxr/XRFlag.ts +30 -3
@@ -4,6 +4,8 @@ let networkingServerUrl: string | undefined = "wss://networking.needle.tools/soc
4
4
  import * as flatbuffers from 'flatbuffers';
5
5
  import { type Websocket } from 'websocket-ts';
6
6
 
7
+ import type { Networking } from "../engine-components/Networking.js";
8
+ import type { SyncedRoom } from "../engine-components/SyncedRoom.js";
7
9
  import * as schemes from "../engine-schemes/schemes.js";
8
10
  import { isDevEnvironment } from './debug/index.js';
9
11
  import { Telemetry } from './engine_license.js';
@@ -116,27 +118,95 @@ declare type OwnershipResponse = {
116
118
 
117
119
  declare type WebsocketSendType = IModel | object | boolean | null | string | number;
118
120
 
119
- /** Class for abstracting the concept of ownership regarding a networked object or component.
120
- * A component that is owned by another user can not be modified through networking (the server will reject changes) */
121
+ /**
122
+ * Manages ownership of networked objects or components.
123
+ *
124
+ * In multiplayer scenarios, ownership determines which client has authority to modify an object.
125
+ * The networking server rejects changes from clients that don't own an object. This prevents conflicts
126
+ * when multiple users try to manipulate the same object simultaneously.
127
+ *
128
+ * **Ownership states:**
129
+ * - `hasOwnership`: This client owns the object and can modify it
130
+ * - `isOwned`: Some client (could be local or remote) owns the object
131
+ * - `undefined`: Ownership state is unknown (not yet queried)
132
+ *
133
+ * **Typical workflow:**
134
+ * 1. Request ownership before modifying an object
135
+ * 2. Make your changes while you have ownership
136
+ * 3. Free ownership when done (or keep it if still interacting)
137
+ *
138
+ * @example Basic usage
139
+ * ```ts
140
+ * export class MyComponent extends Behaviour {
141
+ * private ownership?: OwnershipModel;
142
+ *
143
+ * awake() {
144
+ * this.ownership = new OwnershipModel(this.context.connection, this.guid);
145
+ * }
146
+ *
147
+ * onClick() {
148
+ * // Request ownership before modifying the object
149
+ * this.ownership.requestOwnership();
150
+ * }
151
+ *
152
+ * update() {
153
+ * if (this.ownership.hasOwnership) {
154
+ * // Safe to modify and sync the object
155
+ * this.gameObject.position.y += 0.01;
156
+ * }
157
+ * }
158
+ *
159
+ * onDisable() {
160
+ * // Release ownership when done
161
+ * this.ownership.freeOwnership();
162
+ * this.ownership.destroy();
163
+ * }
164
+ * }
165
+ * ```
166
+ *
167
+ * @example Async ownership
168
+ * ```ts
169
+ * async modifyObject() {
170
+ * try {
171
+ * await this.ownership.requestOwnershipAsync();
172
+ * // Now guaranteed to have ownership
173
+ * this.transform.position.x = 5;
174
+ * } catch(e) {
175
+ * console.log("Failed to gain ownership");
176
+ * }
177
+ * }
178
+ * ```
179
+ *
180
+ * @see {@link SyncedTransform} for a complete example of ownership in action
181
+ * @link https://engine.needle.tools/docs/networking.html
182
+ */
121
183
  export class OwnershipModel {
122
184
 
185
+ /** The unique identifier (GUID) of the object this ownership model manages */
123
186
  public guid: string;
124
187
  private connection: NetworkConnection;
125
188
 
189
+ /**
190
+ * Checks if the local client has ownership of this object.
191
+ * @returns `true` if this client owns the object and can modify it, `false` otherwise
192
+ */
126
193
  public get hasOwnership(): boolean {
127
194
  return this._hasOwnership;
128
195
  }
129
196
 
130
197
  // TODO: server should just send id to everyone
131
198
 
132
- /** @returns true of anyone has ownership */
199
+ /**
200
+ * Checks if anyone (local or remote client) has ownership of this object.
201
+ * @returns `true` if someone owns the object, `false` if no one owns it, `undefined` if unknown
202
+ */
133
203
  public get isOwned(): boolean | undefined {
134
204
  return this._isOwned;
135
205
  }
136
206
 
137
- /**
207
+ /**
138
208
  * Checks if Needle Engine networking is connected to a websocket. Note that this is **not equal** to being connected to a *room*. If you want to check if Needle Engine is connected to a networking room use the `isInRoom` property.
139
- * @returns true if connected to the websocket.
209
+ * @returns true if connected to the websocket.
140
210
  */
141
211
  public get isConnected(): boolean {
142
212
  return this.connection.isConnected;
@@ -162,6 +232,10 @@ export class OwnershipModel {
162
232
 
163
233
  private _isWaitingForOwnershipResponseCallback: Function | null = null;
164
234
 
235
+ /**
236
+ * Queries the server to update the `isOwned` state.
237
+ * Call this to check if anyone currently has ownership.
238
+ */
165
239
  public updateIsOwned() {
166
240
  this.connection.send(OwnershipEvent.RequestHasOwner, { guid: this.guid });
167
241
  }
@@ -172,6 +246,11 @@ export class OwnershipModel {
172
246
  }
173
247
  }
174
248
 
249
+ /**
250
+ * Requests ownership only if the object is not currently owned by anyone.
251
+ * Internally checks ownership state first, then requests ownership if free.
252
+ * @returns this OwnershipModel instance for method chaining
253
+ */
175
254
  public requestOwnershipIfNotOwned(): OwnershipModel {
176
255
  if (this._isWaitingForOwnershipResponseCallback !== null) return this;
177
256
  this._isWaitingForOwnershipResponseCallback = this.waitForHasOwnershipRequestResponse.bind(this);
@@ -197,6 +276,20 @@ export class OwnershipModel {
197
276
  }
198
277
 
199
278
 
279
+ /**
280
+ * Requests ownership and waits asynchronously until ownership is granted or timeout occurs.
281
+ * @returns Promise that resolves with this OwnershipModel when ownership is gained
282
+ * @throws Rejects with "Timeout" if ownership is not gained within ~1 second
283
+ * @example
284
+ * ```ts
285
+ * try {
286
+ * await ownership.requestOwnershipAsync();
287
+ * // Ownership granted, safe to modify object
288
+ * } catch(e) {
289
+ * console.warn("Could not gain ownership:", e);
290
+ * }
291
+ * ```
292
+ */
200
293
  public requestOwnershipAsync(): Promise<OwnershipModel> {
201
294
  return new Promise((resolve, reject) => {
202
295
  this.requestOwnership();
@@ -212,12 +305,22 @@ export class OwnershipModel {
212
305
  });
213
306
  }
214
307
 
308
+ /**
309
+ * Requests ownership of this object from the networking server.
310
+ * Ownership may not be granted immediately - check `hasOwnership` property or use `requestOwnershipAsync()`.
311
+ * @returns this OwnershipModel instance for method chaining
312
+ */
215
313
  public requestOwnership(): OwnershipModel {
216
314
  if (debugOwner) console.log("Request ownership", this.guid);
217
315
  this.connection.send(OwnershipEvent.RequestOwnership, { guid: this.guid });
218
316
  return this;
219
317
  }
220
318
 
319
+ /**
320
+ * Releases ownership of this object, allowing others to take control.
321
+ * Call this when you're done modifying an object to allow other users to interact with it.
322
+ * @returns this OwnershipModel instance for method chaining
323
+ */
221
324
  public freeOwnership(): OwnershipModel {
222
325
  // TODO: abort "requestOwnershipIfNotOwned"
223
326
  this.connection.send(OwnershipEvent.RemoveOwnership, { guid: this.guid });
@@ -228,6 +331,10 @@ export class OwnershipModel {
228
331
  return this;
229
332
  }
230
333
 
334
+ /**
335
+ * Cleans up event listeners and resources.
336
+ * Call this when the OwnershipModel is no longer needed (e.g., in `onDestroy()`).
337
+ */
231
338
  public destroy() {
232
339
  this.connection.stopListen(OwnershipEvent.GainedOwnership, this._gainSubscription);
233
340
  this.connection.stopListen(OwnershipEvent.LostOwnership, this._lostSubscription);
@@ -265,10 +372,46 @@ export declare type BinaryCallback = {
265
372
  (data: any | flatbuffers.ByteBuffer): void;
266
373
  }
267
374
 
268
- /** Main class to communicate with the networking backend
269
- * @link https://engine.needle.tools/docs/networking.html
270
- *
271
- */
375
+ /**
376
+ * Main class for multiuser networking. Access via `this.context.connection` from any component.
377
+ *
378
+ * **About GUIDs:**
379
+ * In Needle Engine networking, GUIDs (Globally Unique Identifiers) are used to identify objects and components across the network.
380
+ * Every GameObject and Component has a unique `guid` property that remains consistent across all clients.
381
+ * GUIDs are automatically assigned (e.g. during export from Unity/Blender) and are essential for:
382
+ * - Object ownership management (see {@link OwnershipModel})
383
+ * - State synchronization (storing and retrieving object state)
384
+ * - Identifying which object received a network message
385
+ *
386
+ * When working with networking, you'll typically use `this.guid` to identify your component or `this.gameObject.guid` for the GameObject.
387
+ *
388
+ * @example Joining a room
389
+ * ```ts
390
+ * this.context.connection.connect();
391
+ * this.context.connection.joinRoom("my-room");
392
+ * ```
393
+ * @example Listening to events
394
+ * ```ts
395
+ * this.context.connection.beginListen("my-event", (data) => {
396
+ * console.log("Received:", data);
397
+ * });
398
+ * ```
399
+ * @example Sending data
400
+ * ```ts
401
+ * this.context.connection.send("my-event", { message: "Hello" });
402
+ * ```
403
+ * @example Using GUIDs for object identification
404
+ * ```ts
405
+ * // Get state for a specific object by its GUID
406
+ * const state = this.context.connection.tryGetState(this.guid);
407
+ *
408
+ * // Delete remote state for an object
409
+ * this.context.connection.sendDeleteRemoteState(this.guid);
410
+ * ```
411
+ * @see {@link RoomEvents} for room lifecycle events
412
+ * @see {@link OwnershipModel} for object ownership
413
+ * @link https://engine.needle.tools/docs/how-to-guides/networking/
414
+ */
272
415
  export class NetworkConnection implements INetworkConnection {
273
416
 
274
417
  private context: Context;
@@ -287,7 +430,18 @@ export class NetworkConnection implements INetworkConnection {
287
430
  }
288
431
 
289
432
  /**
290
- * Returns the state of a given guid.
433
+ * Returns the cached network state for a given GUID.
434
+ * The state is stored locally whenever network updates are received for that object.
435
+ * @param guid The unique identifier of the object whose state you want to retrieve
436
+ * @returns The cached state object, or `null` if no state exists for this GUID
437
+ * @example
438
+ * ```ts
439
+ * // Get the last known state for this component
440
+ * const myState = this.context.connection.tryGetState(this.guid);
441
+ * if (myState) {
442
+ * console.log("Found cached state:", myState);
443
+ * }
444
+ * ```
291
445
  */
292
446
  public tryGetState(guid: string): IModel | null {
293
447
  if (guid === "invalid") return null;
@@ -307,7 +461,7 @@ export class NetworkConnection implements INetworkConnection {
307
461
  }
308
462
 
309
463
  /**
310
- * Checks if Needle Engine networking is connected to a websocket. Note that this is **not equal** to being connected to a *room*. If you want to check if Needle Engine is connected to a networking room use the `isInRoom` property.
464
+ * Checks if Needle Engine networking is connected to a websocket. Note that this is **not equal** to being connected to a *room*. If you want to check if Needle Engine is connected to a networking room use the `{@link isInRoom}` property.
311
465
  * @returns true if connected to the websocket.
312
466
  */
313
467
  public get isConnected(): boolean {
@@ -372,7 +526,7 @@ export class NetworkConnection implements INetworkConnection {
372
526
  return target;
373
527
  }
374
528
 
375
- /** Joins a networked room. If you don't want to manage a connection yourself you can use a `SyncedRoom` component as well */
529
+ /** Joins a networked room. If you don't want to manage a connection yourself you can use a `{@link SyncedRoom}` component as well */
376
530
  public joinRoom(room: string, viewOnly: boolean = false): boolean {
377
531
  if (!room) {
378
532
  console.error("Missing room name, can not join: \"" + room + "\"");
@@ -426,7 +580,18 @@ export class NetworkConnection implements INetworkConnection {
426
580
  return this.sendWithWebsocket(key, data, queue);
427
581
  }
428
582
 
429
- /** Use to delete state for a given guid on the server */
583
+ /**
584
+ * Deletes the network state for a specific object on the server.
585
+ * This removes the object's state from the room, preventing it from being sent to newly joining users.
586
+ * @param guid The unique identifier of the object whose state should be deleted
587
+ * @example
588
+ * ```ts
589
+ * // When destroying a networked object, clean up its server state
590
+ * onDestroy() {
591
+ * this.context.connection.sendDeleteRemoteState(this.guid);
592
+ * }
593
+ * ```
594
+ */
430
595
  public sendDeleteRemoteState(guid: string) {
431
596
  this.send("delete-state", { guid: guid, dontSave: true });
432
597
  delete this._state[guid];
@@ -469,7 +634,7 @@ export class NetworkConnection implements INetworkConnection {
469
634
  }
470
635
 
471
636
  /** Use to start listening to networking events.
472
- * To unsubscribe from events use the `stopListen` method.
637
+ * To unsubscribe from events use the `{@link stopListen}` method.
473
638
  * See the example below for typical usage:
474
639
  *
475
640
  * ### Component Example
@@ -501,7 +666,7 @@ export class NetworkConnection implements INetworkConnection {
501
666
  public stopListening(key: (string & {}) | OwnershipEvent | OwnershipEventNamesIncoming | RoomEventsIncoming | RoomEvents, callback: Function | null) { return this.stopListen(key, callback); }
502
667
 
503
668
  /** Use to stop listening to networking events
504
- * To subscribe to events use the `beginListen` method.
669
+ * To subscribe to events use the `{@link beginListen}` method.
505
670
  * See the example below for typical usage:
506
671
  *
507
672
  * ### Component Example
@@ -548,12 +713,16 @@ export class NetworkConnection implements INetworkConnection {
548
713
 
549
714
  private netWebSocketUrlProvider?: INetworkingWebsocketUrlProvider;
550
715
 
551
- /** Use to override the networking server backend url. This is what the `Networking` component uses to modify the backend url */
716
+ /** Use to override the networking server backend url.
717
+ * This is what the `{@link Networking}` component uses to modify the backend url.
718
+ **/
552
719
  public registerProvider(prov: INetworkingWebsocketUrlProvider) {
553
720
  this.netWebSocketUrlProvider = prov;
554
721
  }
555
722
 
556
- /** Used to connect to the networking server */
723
+ /** Used to connect to the networking server
724
+ * @param url Optional url to connect to. If not provided, it will use the url from the registered `INetworkingWebsocketUrlProvider` or the default backend networking url. If you want to change the url after connecting, you need to disconnect first and then connect again with the new url.
725
+ */
557
726
  public async connect(url?: string) {
558
727
  if (this.connected && url && url !== networkingServerUrl) {
559
728
  return Promise.reject("Can not connect to different server url. Please disconnect first.");
@@ -176,15 +176,42 @@ export declare type SyncFieldOptions = {
176
176
  export declare type FieldChangedCallbackFn = (newValue: any, previousValue: any) => void | boolean | any;
177
177
 
178
178
  /**
179
- * **Decorate a field to be automatically networked synced**
180
- * *Primitive* values are all automatically synced (like string, boolean, number).
181
- * For *arrays or objects* make sure to re-assign them (e.g. `this.mySyncField = this.mySyncField`) to trigger an update
182
- *
183
- * @param onFieldChanged name of a callback function that will be called when the field is changed.
184
- * You can also pass in a function like so: syncField(myClass.prototype.myFunctionToBeCalled)
185
- * Note: if you return `false` from this function you'll prevent the field from being synced with other clients
186
- * (for example a networked color is sent as a number and may be converted to a color in the receiver again)
187
- * Parameters: (newValue, previousValue)
179
+ * Marks a field for automatic network synchronization across connected clients.
180
+ * When a synced field changes, the new value is automatically broadcast to all users in the room.
181
+ *
182
+ * Primitives (string, number, boolean) sync automatically.
183
+ * For arrays/objects, reassign to trigger sync: `this.myArray = this.myArray`
184
+ *
185
+ * @param onFieldChanged Optional callback when the field changes (locally or from network).
186
+ * Return `false` to prevent syncing this change to others.
187
+ *
188
+ * @example Basic sync
189
+ * ```ts
190
+ * class MyComponent extends Behaviour {
191
+ * @syncField() playerScore: number = 0;
192
+ * }
193
+ * ```
194
+ * @example With change callback
195
+ * ```ts
196
+ * class MyComponent extends Behaviour {
197
+ * @syncField("onHealthChanged") health: number = 100;
198
+ *
199
+ * onHealthChanged(newValue: number, oldValue: number) {
200
+ * console.log(`Health: ${oldValue} → ${newValue}`);
201
+ * }
202
+ * }
203
+ * ```
204
+ * @example Preventing sync (one-way)
205
+ * ```ts
206
+ * class MyComponent extends Behaviour {
207
+ * @syncField(function(newVal, oldVal) {
208
+ * // Process incoming value but don't sync our changes
209
+ * return false;
210
+ * }) serverControlled: string = "";
211
+ * }
212
+ * ```
213
+ * @see {@link serializable} for editor serialization
214
+ * @link https://engine.needle.tools/docs/how-to-guides/networking/
188
215
  */
189
216
  export const syncField = function (onFieldChanged: string | FieldChangedCallbackFn | undefined | null = null) {
190
217
 
@@ -6,12 +6,14 @@ import type { GenerateMeshBVHWorker } from 'three-mesh-bvh/src/workers/GenerateM
6
6
 
7
7
  import { isDevEnvironment } from './debug/index.js';
8
8
  import { Gizmos } from './engine_gizmos.js';
9
+ import type { RapierPhysics } from './engine_physics_rapier.js';
9
10
  import { Context } from './engine_setup.js';
10
11
  import { getTempVector, getWorldPosition } from "./engine_three_utils.js"
11
12
  import type { ConstructorConcrete, Vec2, Vec3, } from './engine_types.js';
12
13
  import type { IPhysicsEngine } from './engine_types.js';
13
14
  import { getParam } from "./engine_utils.js"
14
15
 
16
+
15
17
  const debugPhysics = getParam("debugphysics");
16
18
  const debugWorker = getParam("debugworker");
17
19
  const layerMaskHelper: Layers = new Layers();
@@ -133,11 +135,45 @@ export class SphereIntersection implements Intersection {
133
135
  }
134
136
  }
135
137
 
138
+ /**
139
+ * Provides physics utilities including raycasting and overlap detection.
140
+ * Access via `this.context.physics` from any component.
141
+ *
142
+ * For physics engine features (rigidbodies, colliders, forces, etc.), use `this.context.physics.engine`.
143
+ * The physics engine is {@link RapierPhysics}, which uses the Rapier physics library for realistic simulation.
144
+ *
145
+ * **Performance - Automatic MeshBVH:**
146
+ * Needle Engine automatically uses [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh) to accelerate raycasting.
147
+ * MeshBVH structures are generated automatically on web workers in the background, making raycasts significantly faster
148
+ * without blocking the main thread. This happens transparently - you don't need to do anything to enable it.
149
+ * While the BVH is being generated, raycasts fall back to standard three.js raycasting (configurable via `allowSlowRaycastFallback`).
150
+ *
151
+ * @example Raycasting from mouse position
152
+ * ```ts
153
+ * const hits = this.context.physics.raycast();
154
+ * if (hits.length > 0) {
155
+ * console.log("Hit:", hits[0].object.name);
156
+ * }
157
+ * ```
158
+ * @example Raycasting with inline options
159
+ * ```ts
160
+ * const hits = this.context.physics.raycast({
161
+ * maxDistance: 100, // Only hit objects within 100 units
162
+ * layerMask: 1, // Only layer 0
163
+ * ignore: [this.gameObject] // Ignore self
164
+ * });
165
+ * ```
166
+ * @example Physics engine raycast (against colliders only)
167
+ * ```ts
168
+ * const hit = this.context.physics.engine?.raycast(origin, direction);
169
+ * ```
170
+ * @see {@link RapierPhysics} for physics engine implementation details
171
+ */
136
172
  export class Physics {
137
173
 
138
174
  private static _raycasting: number = 0;
139
175
  /**
140
- * Returns true if raycasting is currently happening
176
+ * Returns true if raycasting is currently in progress
141
177
  */
142
178
  public static get raycasting() {
143
179
  return this._raycasting > 0;
@@ -10,6 +10,7 @@ import { foreachComponent } from './engine_gameobject.js';
10
10
  import { Gizmos } from './engine_gizmos.js';
11
11
  import { Mathf } from './engine_math.js';
12
12
  import { MODULES } from './engine_modules.js';
13
+ import type { Physics } from './engine_physics.js';
13
14
  import { getWorldPosition, getWorldQuaternion, getWorldScale, setWorldPositionXYZ, setWorldQuaternionXYZW } from "./engine_three_utils.js"
14
15
  import type {
15
16
  IBoxCollider,
@@ -61,6 +62,82 @@ declare type PhysicsBody = {
61
62
  rotation(): { x: number, y: number, z: number, w: number }
62
63
  }
63
64
 
65
+ /**
66
+ * Rapier physics engine implementation for Needle Engine.
67
+ *
68
+ * Rapier is a fast, cross-platform physics engine that provides realistic physics simulation
69
+ * for rigidbodies, colliders, joints, and collision detection. It runs entirely in WebAssembly
70
+ * for high performance.
71
+ *
72
+ * **Features:**
73
+ * - Rigidbody simulation (dynamic, kinematic, static)
74
+ * - Multiple collider shapes (box, sphere, capsule, mesh, convex hull)
75
+ * - Raycasting and shape overlap queries against physics colliders
76
+ * - Collision and trigger events
77
+ * - Joints (fixed, hinge, etc.)
78
+ * - Continuous collision detection (CCD)
79
+ * - Physics materials (friction, bounciness)
80
+ *
81
+ * **Access:**
82
+ * The Rapier physics engine is accessible via `this.context.physics.engine` from any component.
83
+ * Rapier is automatically initialized when physics components are used.
84
+ *
85
+ * **Using the Rapier Module Directly:**
86
+ * Rapier is lazy-loaded for performance. You can access the raw Rapier module via {@link MODULES.RAPIER_PHYSICS}.
87
+ * Use `MODULES.RAPIER_PHYSICS.load()` to load the module, or `MODULES.RAPIER_PHYSICS.ready()` to wait for it without triggering a load.
88
+ * Once loaded, the module is available at `MODULES.RAPIER_PHYSICS.MODULE`.
89
+ *
90
+ * **Note:**
91
+ * This is the low-level physics engine implementation. For general raycasting (against all scene objects),
92
+ * use {@link Physics.raycast} instead. Use this class for physics-specific operations like applying forces,
93
+ * raycasting against colliders only, or accessing the Rapier world directly.
94
+ *
95
+ * @example Applying forces to a rigidbody
96
+ * ```ts
97
+ * const rb = this.gameObject.getComponent(Rigidbody);
98
+ * if (rb) {
99
+ * this.context.physics.engine?.addForce(rb, { x: 0, y: 10, z: 0 }, true);
100
+ * }
101
+ * ```
102
+ * @example Raycasting against physics colliders only
103
+ * ```ts
104
+ * const origin = { x: 0, y: 5, z: 0 };
105
+ * const direction = { x: 0, y: -1, z: 0 };
106
+ * const hit = this.context.physics.engine?.raycast(origin, direction);
107
+ * if (hit) {
108
+ * console.log("Hit collider:", hit.collider.name);
109
+ * }
110
+ * ```
111
+ * @example Accessing Rapier world directly
112
+ * ```ts
113
+ * const rapierWorld = this.context.physics.engine?.world;
114
+ * if (rapierWorld) {
115
+ * // Direct access to Rapier API
116
+ * console.log("Gravity:", rapierWorld.gravity);
117
+ * }
118
+ * ```
119
+ * @example Using the Rapier module directly
120
+ * ```ts
121
+ * import { MODULES } from "@needle-tools/engine";
122
+ *
123
+ * // Load the Rapier module
124
+ * const RAPIER = await MODULES.RAPIER_PHYSICS.load();
125
+ *
126
+ * // Now you can use Rapier types and create custom physics objects
127
+ * const rigidBodyDesc = RAPIER.RigidBodyDesc.dynamic()
128
+ * .setTranslation(0, 10, 0);
129
+ *
130
+ * // Or access the already-loaded module
131
+ * if (MODULES.RAPIER_PHYSICS.MODULE) {
132
+ * const colliderDesc = MODULES.RAPIER_PHYSICS.MODULE.ColliderDesc.ball(1.0);
133
+ * }
134
+ * ```
135
+ * @see {@link Physics} for general raycasting and physics utilities
136
+ * @see {@link MODULES.RAPIER_PHYSICS} for direct access to the Rapier module
137
+ * @link https://rapier.rs/docs/ for Rapier documentation
138
+ * @link https://engine.needle.tools/docs/reference/components.html#physics
139
+ * @link https://engine.needle.tools/docs/how-to-guides/scripting/use-physics.html
140
+ */
64
141
  export class RapierPhysics implements IPhysicsEngine {
65
142
 
66
143
  debugRenderColliders: boolean = false;
@@ -8,8 +8,34 @@ export const serializeable = function <T>(type?: Constructor<T> | null | Array<C
8
8
  }
9
9
 
10
10
  /**
11
- * The serializable attribute should be used to annotate all serialized fields / fields and members that should be serialized and exposed in an editor
12
- * @param type The type of the field. If not provided the type will be inferred from the constructor of the field. If the field is a primitive type (string, number, boolean) the type should be null.
11
+ * Marks a field for serialization and editor exposure. Required for fields that reference
12
+ * other objects, components, or assets. Primitive types (string, number, boolean) work without a type argument.
13
+ *
14
+ * @param type The constructor type for complex objects. Omit for primitives.
15
+ *
16
+ * @example Primitive types (no type needed)
17
+ * ```ts
18
+ * @serializable()
19
+ * speed: number = 1;
20
+ *
21
+ * @serializable()
22
+ * label: string = "Hello";
23
+ * ```
24
+ * @example Object references
25
+ * ```ts
26
+ * @serializable(Object3D)
27
+ * target: Object3D | null = null;
28
+ *
29
+ * @serializable(Renderer)
30
+ * myRenderer: Renderer | null = null;
31
+ * ```
32
+ * @example Arrays
33
+ * ```ts
34
+ * @serializable([Object3D])
35
+ * waypoints: Object3D[] = [];
36
+ * ```
37
+ * @see {@link syncField} for automatic network synchronization
38
+ * @link https://engine.needle.tools/docs/reference/typescript-decorators.html#serializable
13
39
  */
14
40
  export const serializable = function <T>(type?: Constructor<T> | null | Array<Constructor<any> | TypeResolver<T>> | TypeResolver<T>) {
15
41
  if (type === undefined) type = null;
@@ -8,8 +8,23 @@ let timeScale = 1;
8
8
  if (typeof timescaleUrl === "number") timeScale = timescaleUrl;
9
9
 
10
10
  /**
11
- * Time is a class that provides time-related information.
12
- * It is created and used within the Needle Engine Context.
11
+ * Provides time-related information for frame-based game logic.
12
+ * Access via `this.context.time` from any component.
13
+ *
14
+ * @example Using deltaTime for frame-rate independent movement
15
+ * ```ts
16
+ * update() {
17
+ * // Move 1 unit per second regardless of frame rate
18
+ * this.gameObject.position.x += 1 * this.context.time.deltaTime;
19
+ * }
20
+ * ```
21
+ * @example Checking elapsed time
22
+ * ```ts
23
+ * start() {
24
+ * console.log(`Time since start: ${this.context.time.time}s`);
25
+ * console.log(`Current frame: ${this.context.time.frameCount}`);
26
+ * }
27
+ * ```
13
28
  */
14
29
  export class Time implements ITime {
15
30
 
@@ -27,7 +42,12 @@ export class Time implements ITime {
27
42
  get deltaTimeUnscaled() { return this._deltaTimeUnscaled; }
28
43
  private _deltaTimeUnscaled = 0;
29
44
 
30
- /** The scale at which time passes. This can be used for slow motion effects or to speed up time. */
45
+ /**
46
+ * The scale at which time passes. Default is 1.
47
+ * - Values < 1 create slow motion (e.g. 0.5 = half speed)
48
+ * - Values > 1 speed up time (e.g. 2 = double speed)
49
+ * - Value of 0 effectively pauses time-dependent logic
50
+ */
31
51
  timeScale = 1;
32
52
 
33
53
  /** same as frameCount */
@@ -9,7 +9,37 @@ import { watchWrite } from "./engine_utils.js";
9
9
  declare type setter = (v: any) => void;
10
10
  declare type getter = () => any;
11
11
 
12
- /** create accessor callbacks for a field */
12
+ /**
13
+ * Marks a field to trigger the `onValidate` callback when its value changes.
14
+ * Useful for reacting to property changes from the editor or at runtime.
15
+ *
16
+ * Your component must implement `onValidate(property?: string)` to receive notifications.
17
+ *
18
+ * @param set Optional custom setter called before the value is assigned
19
+ * @param get Optional custom getter called when the value is read
20
+ *
21
+ * @example Basic usage
22
+ * ```ts
23
+ * export class MyComponent extends Behaviour {
24
+ * @serializable()
25
+ * @validate()
26
+ * color: Color = new Color(1, 0, 0);
27
+ *
28
+ * onValidate(property?: string) {
29
+ * if (property === "color") {
30
+ * console.log("Color changed to:", this.color);
31
+ * }
32
+ * }
33
+ * }
34
+ * ```
35
+ * @example With custom setter
36
+ * ```ts
37
+ * @validate(function(value) {
38
+ * console.log("Setting speed to", value);
39
+ * })
40
+ * speed: number = 1;
41
+ * ```
42
+ */
13
43
  export const validate = function (set?: setter, get?: getter) {
14
44
  // "descriptor : undefined" prevents @validate() to be added to property getters or setters
15
45
  return function (target: IComponent | any, propertyKey: string, descriptor?: undefined) {