@needle-tools/engine 4.13.0 → 4.13.1

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 (428) hide show
  1. package/CHANGELOG.md +8 -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-BNIUpreS.min.js} +107 -107
  6. package/dist/{needle-engine.bundle-Dl3TFYyv.js → needle-engine.bundle-DauZUYl7.js} +2347 -1845
  7. package/dist/{needle-engine.bundle-J4k4znv8.umd.cjs → needle-engine.bundle-tjI5Fq2c.umd.cjs} +108 -108
  8. package/dist/needle-engine.d.ts +4022 -419
  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 +37 -1
  31. package/lib/engine/engine_physics.js +37 -1
  32. package/lib/engine/engine_physics.js.map +1 -1
  33. package/lib/engine/engine_physics_rapier.d.ts +78 -0
  34. package/lib/engine/engine_physics_rapier.js +78 -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 +28 -6
  84. package/lib/engine-components/ContactShadows.js +33 -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 +40 -12
  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 +35 -0
  148. package/lib/engine-components/Renderer.js +36 -2
  149. package/lib/engine-components/Renderer.js.map +1 -1
  150. package/lib/engine-components/RigidBody.d.ts +57 -5
  151. package/lib/engine-components/RigidBody.js +57 -5
  152. package/lib/engine-components/RigidBody.js.map +1 -1
  153. package/lib/engine-components/SceneSwitcher.d.ts +11 -0
  154. package/lib/engine-components/SceneSwitcher.js +11 -0
  155. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  156. package/lib/engine-components/ScreenCapture.d.ts +39 -6
  157. package/lib/engine-components/ScreenCapture.js +39 -6
  158. package/lib/engine-components/ScreenCapture.js.map +1 -1
  159. package/lib/engine-components/SeeThrough.d.ts +70 -5
  160. package/lib/engine-components/SeeThrough.js +70 -5
  161. package/lib/engine-components/SeeThrough.js.map +1 -1
  162. package/lib/engine-components/ShadowCatcher.d.ts +56 -4
  163. package/lib/engine-components/ShadowCatcher.js +56 -4
  164. package/lib/engine-components/ShadowCatcher.js.map +1 -1
  165. package/lib/engine-components/Skybox.d.ts +43 -7
  166. package/lib/engine-components/Skybox.js +43 -7
  167. package/lib/engine-components/Skybox.js.map +1 -1
  168. package/lib/engine-components/SmoothFollow.d.ts +66 -7
  169. package/lib/engine-components/SmoothFollow.js +66 -7
  170. package/lib/engine-components/SmoothFollow.js.map +1 -1
  171. package/lib/engine-components/SpatialTrigger.d.ts +48 -1
  172. package/lib/engine-components/SpatialTrigger.js +48 -1
  173. package/lib/engine-components/SpatialTrigger.js.map +1 -1
  174. package/lib/engine-components/SpectatorCamera.d.ts +21 -3
  175. package/lib/engine-components/SpectatorCamera.js +21 -3
  176. package/lib/engine-components/SpectatorCamera.js.map +1 -1
  177. package/lib/engine-components/SyncedRoom.d.ts +7 -1
  178. package/lib/engine-components/SyncedRoom.js +7 -1
  179. package/lib/engine-components/SyncedRoom.js.map +1 -1
  180. package/lib/engine-components/SyncedTransform.d.ts +55 -6
  181. package/lib/engine-components/SyncedTransform.js +55 -6
  182. package/lib/engine-components/SyncedTransform.js.map +1 -1
  183. package/lib/engine-components/TransformGizmo.d.ts +30 -3
  184. package/lib/engine-components/TransformGizmo.js +30 -3
  185. package/lib/engine-components/TransformGizmo.js.map +1 -1
  186. package/lib/engine-components/VideoPlayer.d.ts +33 -6
  187. package/lib/engine-components/VideoPlayer.js +45 -6
  188. package/lib/engine-components/VideoPlayer.js.map +1 -1
  189. package/lib/engine-components/Voip.d.ts +33 -2
  190. package/lib/engine-components/Voip.js +33 -2
  191. package/lib/engine-components/Voip.js.map +1 -1
  192. package/lib/engine-components/export/usdz/USDZExporter.d.ts +47 -13
  193. package/lib/engine-components/export/usdz/USDZExporter.js +47 -13
  194. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  195. package/lib/engine-components/particlesystem/ParticleSystem.d.ts +82 -3
  196. package/lib/engine-components/particlesystem/ParticleSystem.js +82 -3
  197. package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
  198. package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +1 -0
  199. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +1 -0
  200. package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
  201. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  202. package/lib/engine-components/postprocessing/Effects/BloomEffect.js +1 -1
  203. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +1 -1
  204. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +1 -1
  205. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +1 -1
  206. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +1 -1
  207. package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +1 -1
  208. package/lib/engine-components/postprocessing/Effects/DepthOfField.js +1 -1
  209. package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +1 -0
  210. package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +1 -0
  211. package/lib/engine-components/postprocessing/Effects/EffectWrapper.js.map +1 -1
  212. package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +1 -1
  213. package/lib/engine-components/postprocessing/Effects/Pixelation.js +1 -1
  214. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +1 -1
  215. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +1 -1
  216. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +1 -1
  217. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
  218. package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -1
  219. package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -1
  220. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +1 -1
  221. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +1 -1
  222. package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +1 -1
  223. package/lib/engine-components/postprocessing/Effects/Tonemapping.js +1 -1
  224. package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +1 -1
  225. package/lib/engine-components/postprocessing/Effects/Vignette.js +1 -1
  226. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +1 -1
  227. package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
  228. package/lib/engine-components/postprocessing/Volume.d.ts +1 -1
  229. package/lib/engine-components/postprocessing/Volume.js +1 -1
  230. package/lib/engine-components/splines/Spline.d.ts +409 -12
  231. package/lib/engine-components/splines/Spline.js +409 -12
  232. package/lib/engine-components/splines/Spline.js.map +1 -1
  233. package/lib/engine-components/splines/SplineUtils.d.ts +1 -0
  234. package/lib/engine-components/splines/SplineUtils.js +1 -0
  235. package/lib/engine-components/splines/SplineUtils.js.map +1 -1
  236. package/lib/engine-components/splines/SplineWalker.d.ts +3 -1
  237. package/lib/engine-components/splines/SplineWalker.js +3 -1
  238. package/lib/engine-components/splines/SplineWalker.js.map +1 -1
  239. package/lib/engine-components/timeline/PlayableDirector.d.ts +103 -14
  240. package/lib/engine-components/timeline/PlayableDirector.js +95 -25
  241. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  242. package/lib/engine-components/timeline/TimelineModels.d.ts +14 -0
  243. package/lib/engine-components/timeline/TimelineModels.js +4 -0
  244. package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
  245. package/lib/engine-components/ui/Button.d.ts +29 -3
  246. package/lib/engine-components/ui/Button.js +29 -3
  247. package/lib/engine-components/ui/Button.js.map +1 -1
  248. package/lib/engine-components/ui/Canvas.d.ts +29 -4
  249. package/lib/engine-components/ui/Canvas.js +29 -4
  250. package/lib/engine-components/ui/Canvas.js.map +1 -1
  251. package/lib/engine-components/ui/CanvasGroup.d.ts +1 -1
  252. package/lib/engine-components/ui/CanvasGroup.js +1 -1
  253. package/lib/engine-components/ui/EventSystem.d.ts +1 -1
  254. package/lib/engine-components/ui/EventSystem.js +1 -1
  255. package/lib/engine-components/ui/Graphic.d.ts +1 -0
  256. package/lib/engine-components/ui/Graphic.js +1 -0
  257. package/lib/engine-components/ui/Graphic.js.map +1 -1
  258. package/lib/engine-components/ui/Image.d.ts +22 -3
  259. package/lib/engine-components/ui/Image.js +22 -3
  260. package/lib/engine-components/ui/Image.js.map +1 -1
  261. package/lib/engine-components/ui/InputField.d.ts +1 -1
  262. package/lib/engine-components/ui/InputField.js +1 -1
  263. package/lib/engine-components/ui/Layout.d.ts +3 -0
  264. package/lib/engine-components/ui/Layout.js +3 -0
  265. package/lib/engine-components/ui/Layout.js.map +1 -1
  266. package/lib/engine-components/ui/Outline.d.ts +1 -1
  267. package/lib/engine-components/ui/Outline.js +1 -1
  268. package/lib/engine-components/ui/PointerEvents.d.ts +1 -1
  269. package/lib/engine-components/ui/PointerEvents.js +1 -1
  270. package/lib/engine-components/ui/Raycaster.d.ts +55 -6
  271. package/lib/engine-components/ui/Raycaster.js +55 -6
  272. package/lib/engine-components/ui/Raycaster.js.map +1 -1
  273. package/lib/engine-components/ui/RectTransform.d.ts +1 -1
  274. package/lib/engine-components/ui/RectTransform.js +1 -1
  275. package/lib/engine-components/ui/SpatialHtml.d.ts +1 -1
  276. package/lib/engine-components/ui/SpatialHtml.js +1 -1
  277. package/lib/engine-components/ui/Text.d.ts +23 -1
  278. package/lib/engine-components/ui/Text.js +23 -1
  279. package/lib/engine-components/ui/Text.js.map +1 -1
  280. package/lib/engine-components/utils/LookAt.d.ts +1 -1
  281. package/lib/engine-components/utils/LookAt.js +1 -1
  282. package/lib/engine-components/utils/OpenURL.d.ts +1 -1
  283. package/lib/engine-components/utils/OpenURL.js +1 -1
  284. package/lib/engine-components/web/Clickthrough.d.ts +116 -7
  285. package/lib/engine-components/web/Clickthrough.js +116 -7
  286. package/lib/engine-components/web/Clickthrough.js.map +1 -1
  287. package/lib/engine-components/web/CursorFollow.d.ts +171 -7
  288. package/lib/engine-components/web/CursorFollow.js +171 -7
  289. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  290. package/lib/engine-components/web/HoverAnimation.d.ts +140 -11
  291. package/lib/engine-components/web/HoverAnimation.js +140 -11
  292. package/lib/engine-components/web/HoverAnimation.js.map +1 -1
  293. package/lib/engine-components/web/ScrollFollow.d.ts +4 -1
  294. package/lib/engine-components/web/ScrollFollow.js +4 -1
  295. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  296. package/lib/engine-components/web/ViewBox.d.ts +116 -16
  297. package/lib/engine-components/web/ViewBox.js +110 -16
  298. package/lib/engine-components/web/ViewBox.js.map +1 -1
  299. package/lib/engine-components/webxr/TeleportTarget.d.ts +21 -2
  300. package/lib/engine-components/webxr/TeleportTarget.js +21 -2
  301. package/lib/engine-components/webxr/TeleportTarget.js.map +1 -1
  302. package/lib/engine-components/webxr/WebXR.d.ts +10 -2
  303. package/lib/engine-components/webxr/WebXR.js +10 -2
  304. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  305. package/lib/engine-components/webxr/WebXRAvatar.d.ts +39 -2
  306. package/lib/engine-components/webxr/WebXRAvatar.js +35 -3
  307. package/lib/engine-components/webxr/WebXRAvatar.js.map +1 -1
  308. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +266 -30
  309. package/lib/engine-components/webxr/WebXRImageTracking.js +266 -30
  310. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  311. package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +1 -1
  312. package/lib/engine-components/webxr/WebXRPlaneTracking.js +1 -1
  313. package/lib/engine-components/webxr/XRFlag.d.ts +29 -2
  314. package/lib/engine-components/webxr/XRFlag.js +29 -2
  315. package/lib/engine-components/webxr/XRFlag.js.map +1 -1
  316. package/package.json +1 -1
  317. package/plugins/vite/custom-element-data.js +128 -19
  318. package/src/engine/engine_context.ts +16 -0
  319. package/src/engine/engine_gameobject.ts +73 -0
  320. package/src/engine/engine_input.ts +83 -7
  321. package/src/engine/engine_math.ts +81 -2
  322. package/src/engine/engine_networking.ts +186 -17
  323. package/src/engine/engine_networking_auto.ts +36 -9
  324. package/src/engine/engine_physics.ts +41 -1
  325. package/src/engine/engine_physics_rapier.ts +81 -0
  326. package/src/engine/engine_serialization_decorator.ts +28 -2
  327. package/src/engine/engine_time.ts +23 -3
  328. package/src/engine/engine_util_decorator.ts +31 -1
  329. package/src/engine/engine_utils.ts +21 -5
  330. package/src/engine/extensions/NEEDLE_materialx.ts +5 -4
  331. package/src/engine/extensions/index.ts +2 -2
  332. package/src/engine-components/AlignmentConstraint.ts +24 -4
  333. package/src/engine-components/Animation.ts +44 -2
  334. package/src/engine-components/Animator.ts +40 -7
  335. package/src/engine-components/AudioListener.ts +1 -1
  336. package/src/engine-components/AudioSource.ts +37 -15
  337. package/src/engine-components/AxesHelper.ts +23 -4
  338. package/src/engine-components/BasicIKConstraint.ts +28 -5
  339. package/src/engine-components/Camera.ts +33 -3
  340. package/src/engine-components/CharacterController.ts +74 -7
  341. package/src/engine-components/Collider.ts +78 -21
  342. package/src/engine-components/ContactShadows.ts +41 -11
  343. package/src/engine-components/DeleteBox.ts +43 -2
  344. package/src/engine-components/DeviceFlag.ts +22 -3
  345. package/src/engine-components/DragControls.ts +32 -2
  346. package/src/engine-components/DropListener.ts +41 -29
  347. package/src/engine-components/Duplicatable.ts +37 -6
  348. package/src/engine-components/EventList.ts +43 -15
  349. package/src/engine-components/EventTrigger.ts +1 -1
  350. package/src/engine-components/Fog.ts +23 -1
  351. package/src/engine-components/GridHelper.ts +18 -2
  352. package/src/engine-components/GroundProjection.ts +25 -3
  353. package/src/engine-components/Interactable.ts +17 -2
  354. package/src/engine-components/Joints.ts +51 -8
  355. package/src/engine-components/LODGroup.ts +45 -11
  356. package/src/engine-components/Light.ts +35 -13
  357. package/src/engine-components/LookAtConstraint.ts +26 -8
  358. package/src/engine-components/NeedleMenu.ts +29 -7
  359. package/src/engine-components/NestedGltf.ts +40 -4
  360. package/src/engine-components/OffsetConstraint.ts +27 -3
  361. package/src/engine-components/OrbitControls.ts +41 -3
  362. package/src/engine-components/PlayerColor.ts +1 -1
  363. package/src/engine-components/ReflectionProbe.ts +19 -5
  364. package/src/engine-components/Renderer.ts +35 -1
  365. package/src/engine-components/RigidBody.ts +64 -8
  366. package/src/engine-components/SceneSwitcher.ts +11 -0
  367. package/src/engine-components/ScreenCapture.ts +42 -9
  368. package/src/engine-components/SeeThrough.ts +76 -9
  369. package/src/engine-components/ShadowCatcher.ts +61 -6
  370. package/src/engine-components/Skybox.ts +48 -12
  371. package/src/engine-components/SmoothFollow.ts +68 -7
  372. package/src/engine-components/SpatialTrigger.ts +51 -4
  373. package/src/engine-components/SpectatorCamera.ts +23 -5
  374. package/src/engine-components/SyncedRoom.ts +8 -2
  375. package/src/engine-components/SyncedTransform.ts +59 -10
  376. package/src/engine-components/TransformGizmo.ts +31 -4
  377. package/src/engine-components/VideoPlayer.ts +48 -6
  378. package/src/engine-components/Voip.ts +33 -2
  379. package/src/engine-components/export/usdz/USDZExporter.ts +47 -13
  380. package/src/engine-components/particlesystem/ParticleSystem.ts +84 -5
  381. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +1 -0
  382. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
  383. package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +1 -1
  384. package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +1 -1
  385. package/src/engine-components/postprocessing/Effects/DepthOfField.ts +1 -1
  386. package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +1 -0
  387. package/src/engine-components/postprocessing/Effects/Pixelation.ts +1 -1
  388. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +1 -1
  389. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
  390. package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -1
  391. package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +1 -1
  392. package/src/engine-components/postprocessing/Effects/Tonemapping.ts +1 -1
  393. package/src/engine-components/postprocessing/Effects/Vignette.ts +1 -1
  394. package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
  395. package/src/engine-components/postprocessing/Volume.ts +1 -1
  396. package/src/engine-components/splines/Spline.ts +412 -14
  397. package/src/engine-components/splines/SplineUtils.ts +1 -0
  398. package/src/engine-components/splines/SplineWalker.ts +4 -2
  399. package/src/engine-components/timeline/PlayableDirector.ts +108 -27
  400. package/src/engine-components/timeline/SignalAsset.ts +1 -1
  401. package/src/engine-components/timeline/TimelineModels.ts +18 -2
  402. package/src/engine-components/ui/Button.ts +29 -3
  403. package/src/engine-components/ui/Canvas.ts +29 -4
  404. package/src/engine-components/ui/CanvasGroup.ts +2 -2
  405. package/src/engine-components/ui/EventSystem.ts +1 -1
  406. package/src/engine-components/ui/Graphic.ts +1 -0
  407. package/src/engine-components/ui/Image.ts +22 -3
  408. package/src/engine-components/ui/InputField.ts +2 -2
  409. package/src/engine-components/ui/Layout.ts +3 -0
  410. package/src/engine-components/ui/Outline.ts +1 -1
  411. package/src/engine-components/ui/PointerEvents.ts +1 -1
  412. package/src/engine-components/ui/Raycaster.ts +57 -8
  413. package/src/engine-components/ui/RectTransform.ts +2 -2
  414. package/src/engine-components/ui/SpatialHtml.ts +1 -1
  415. package/src/engine-components/ui/Text.ts +24 -2
  416. package/src/engine-components/utils/LookAt.ts +1 -1
  417. package/src/engine-components/utils/OpenURL.ts +1 -1
  418. package/src/engine-components/web/Clickthrough.ts +119 -10
  419. package/src/engine-components/web/CursorFollow.ts +174 -9
  420. package/src/engine-components/web/HoverAnimation.ts +142 -13
  421. package/src/engine-components/web/ScrollFollow.ts +4 -1
  422. package/src/engine-components/web/ViewBox.ts +118 -18
  423. package/src/engine-components/webxr/TeleportTarget.ts +23 -4
  424. package/src/engine-components/webxr/WebXR.ts +11 -3
  425. package/src/engine-components/webxr/WebXRAvatar.ts +41 -4
  426. package/src/engine-components/webxr/WebXRImageTracking.ts +282 -38
  427. package/src/engine-components/webxr/WebXRPlaneTracking.ts +1 -1
  428. package/src/engine-components/webxr/XRFlag.ts +30 -3
@@ -74,13 +74,81 @@ export declare enum OwnershipEvent {
74
74
  }
75
75
  type OwnershipEventNamesIncoming = Exclude<`${OwnershipEvent}`, "request-has-owner" | "request-is-owner" | "request-ownership" | "remove-ownership">;
76
76
  declare type WebsocketSendType = IModel | object | boolean | null | string | number;
77
- /** Class for abstracting the concept of ownership regarding a networked object or component.
78
- * A component that is owned by another user can not be modified through networking (the server will reject changes) */
77
+ /**
78
+ * Manages ownership of networked objects or components.
79
+ *
80
+ * In multiplayer scenarios, ownership determines which client has authority to modify an object.
81
+ * The networking server rejects changes from clients that don't own an object. This prevents conflicts
82
+ * when multiple users try to manipulate the same object simultaneously.
83
+ *
84
+ * **Ownership states:**
85
+ * - `hasOwnership`: This client owns the object and can modify it
86
+ * - `isOwned`: Some client (could be local or remote) owns the object
87
+ * - `undefined`: Ownership state is unknown (not yet queried)
88
+ *
89
+ * **Typical workflow:**
90
+ * 1. Request ownership before modifying an object
91
+ * 2. Make your changes while you have ownership
92
+ * 3. Free ownership when done (or keep it if still interacting)
93
+ *
94
+ * @example Basic usage
95
+ * ```ts
96
+ * export class MyComponent extends Behaviour {
97
+ * private ownership?: OwnershipModel;
98
+ *
99
+ * awake() {
100
+ * this.ownership = new OwnershipModel(this.context.connection, this.guid);
101
+ * }
102
+ *
103
+ * onClick() {
104
+ * // Request ownership before modifying the object
105
+ * this.ownership.requestOwnership();
106
+ * }
107
+ *
108
+ * update() {
109
+ * if (this.ownership.hasOwnership) {
110
+ * // Safe to modify and sync the object
111
+ * this.gameObject.position.y += 0.01;
112
+ * }
113
+ * }
114
+ *
115
+ * onDisable() {
116
+ * // Release ownership when done
117
+ * this.ownership.freeOwnership();
118
+ * this.ownership.destroy();
119
+ * }
120
+ * }
121
+ * ```
122
+ *
123
+ * @example Async ownership
124
+ * ```ts
125
+ * async modifyObject() {
126
+ * try {
127
+ * await this.ownership.requestOwnershipAsync();
128
+ * // Now guaranteed to have ownership
129
+ * this.transform.position.x = 5;
130
+ * } catch(e) {
131
+ * console.log("Failed to gain ownership");
132
+ * }
133
+ * }
134
+ * ```
135
+ *
136
+ * @see {@link SyncedTransform} for a complete example of ownership in action
137
+ * @link https://engine.needle.tools/docs/networking.html
138
+ */
79
139
  export declare class OwnershipModel {
140
+ /** The unique identifier (GUID) of the object this ownership model manages */
80
141
  guid: string;
81
142
  private connection;
143
+ /**
144
+ * Checks if the local client has ownership of this object.
145
+ * @returns `true` if this client owns the object and can modify it, `false` otherwise
146
+ */
82
147
  get hasOwnership(): boolean;
83
- /** @returns true of anyone has ownership */
148
+ /**
149
+ * Checks if anyone (local or remote client) has ownership of this object.
150
+ * @returns `true` if someone owns the object, `false` if no one owns it, `undefined` if unknown
151
+ */
84
152
  get isOwned(): boolean | undefined;
85
153
  /**
86
154
  * 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.
@@ -94,13 +162,50 @@ export declare class OwnershipModel {
94
162
  private _hasOwnerResponse;
95
163
  constructor(connection: NetworkConnection, guid: string);
96
164
  private _isWaitingForOwnershipResponseCallback;
165
+ /**
166
+ * Queries the server to update the `isOwned` state.
167
+ * Call this to check if anyone currently has ownership.
168
+ */
97
169
  updateIsOwned(): void;
98
170
  private onHasOwnerResponse;
171
+ /**
172
+ * Requests ownership only if the object is not currently owned by anyone.
173
+ * Internally checks ownership state first, then requests ownership if free.
174
+ * @returns this OwnershipModel instance for method chaining
175
+ */
99
176
  requestOwnershipIfNotOwned(): OwnershipModel;
100
177
  private waitForHasOwnershipRequestResponse;
178
+ /**
179
+ * Requests ownership and waits asynchronously until ownership is granted or timeout occurs.
180
+ * @returns Promise that resolves with this OwnershipModel when ownership is gained
181
+ * @throws Rejects with "Timeout" if ownership is not gained within ~1 second
182
+ * @example
183
+ * ```ts
184
+ * try {
185
+ * await ownership.requestOwnershipAsync();
186
+ * // Ownership granted, safe to modify object
187
+ * } catch(e) {
188
+ * console.warn("Could not gain ownership:", e);
189
+ * }
190
+ * ```
191
+ */
101
192
  requestOwnershipAsync(): Promise<OwnershipModel>;
193
+ /**
194
+ * Requests ownership of this object from the networking server.
195
+ * Ownership may not be granted immediately - check `hasOwnership` property or use `requestOwnershipAsync()`.
196
+ * @returns this OwnershipModel instance for method chaining
197
+ */
102
198
  requestOwnership(): OwnershipModel;
199
+ /**
200
+ * Releases ownership of this object, allowing others to take control.
201
+ * Call this when you're done modifying an object to allow other users to interact with it.
202
+ * @returns this OwnershipModel instance for method chaining
203
+ */
103
204
  freeOwnership(): OwnershipModel;
205
+ /**
206
+ * Cleans up event listeners and resources.
207
+ * Call this when the OwnershipModel is no longer needed (e.g., in `onDestroy()`).
208
+ */
104
209
  destroy(): void;
105
210
  private onGainedOwnership;
106
211
  private onLostOwnership;
@@ -108,10 +213,46 @@ export declare class OwnershipModel {
108
213
  export declare type BinaryCallback = {
109
214
  (data: any | flatbuffers.ByteBuffer): void;
110
215
  };
111
- /** Main class to communicate with the networking backend
112
- * @link https://engine.needle.tools/docs/networking.html
216
+ /**
217
+ * Main class for multiuser networking. Access via `this.context.connection` from any component.
218
+ *
219
+ * **About GUIDs:**
220
+ * In Needle Engine networking, GUIDs (Globally Unique Identifiers) are used to identify objects and components across the network.
221
+ * Every GameObject and Component has a unique `guid` property that remains consistent across all clients.
222
+ * GUIDs are automatically assigned (e.g. during export from Unity/Blender) and are essential for:
223
+ * - Object ownership management (see {@link OwnershipModel})
224
+ * - State synchronization (storing and retrieving object state)
225
+ * - Identifying which object received a network message
226
+ *
227
+ * When working with networking, you'll typically use `this.guid` to identify your component or `this.gameObject.guid` for the GameObject.
113
228
  *
114
- */
229
+ * @example Joining a room
230
+ * ```ts
231
+ * this.context.connection.connect();
232
+ * this.context.connection.joinRoom("my-room");
233
+ * ```
234
+ * @example Listening to events
235
+ * ```ts
236
+ * this.context.connection.beginListen("my-event", (data) => {
237
+ * console.log("Received:", data);
238
+ * });
239
+ * ```
240
+ * @example Sending data
241
+ * ```ts
242
+ * this.context.connection.send("my-event", { message: "Hello" });
243
+ * ```
244
+ * @example Using GUIDs for object identification
245
+ * ```ts
246
+ * // Get state for a specific object by its GUID
247
+ * const state = this.context.connection.tryGetState(this.guid);
248
+ *
249
+ * // Delete remote state for an object
250
+ * this.context.connection.sendDeleteRemoteState(this.guid);
251
+ * ```
252
+ * @see {@link RoomEvents} for room lifecycle events
253
+ * @see {@link OwnershipModel} for object ownership
254
+ * @link https://engine.needle.tools/docs/how-to-guides/networking/
255
+ */
115
256
  export declare class NetworkConnection implements INetworkConnection {
116
257
  private context;
117
258
  private _peer;
@@ -119,7 +260,18 @@ export declare class NetworkConnection implements INetworkConnection {
119
260
  /** Experimental: networking via peerjs */
120
261
  get peer(): PeerNetworking;
121
262
  /**
122
- * Returns the state of a given guid.
263
+ * Returns the cached network state for a given GUID.
264
+ * The state is stored locally whenever network updates are received for that object.
265
+ * @param guid The unique identifier of the object whose state you want to retrieve
266
+ * @returns The cached state object, or `null` if no state exists for this GUID
267
+ * @example
268
+ * ```ts
269
+ * // Get the last known state for this component
270
+ * const myState = this.context.connection.tryGetState(this.guid);
271
+ * if (myState) {
272
+ * console.log("Found cached state:", myState);
273
+ * }
274
+ * ```
123
275
  */
124
276
  tryGetState(guid: string): IModel | null;
125
277
  /** The connection id of the local user - it is given by the networking backend and can not be changed */
@@ -129,7 +281,7 @@ export declare class NetworkConnection implements INetworkConnection {
129
281
  */
130
282
  get isDebugEnabled(): boolean;
131
283
  /**
132
- * 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.
284
+ * 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.
133
285
  * @returns true if connected to the websocket.
134
286
  */
135
287
  get isConnected(): boolean;
@@ -162,13 +314,24 @@ export declare class NetworkConnection implements INetworkConnection {
162
314
  private _usersInRoomCopy;
163
315
  /** Returns a list of all user ids in the current room */
164
316
  usersInRoom(target?: string[] | null): string[];
165
- /** Joins a networked room. If you don't want to manage a connection yourself you can use a `SyncedRoom` component as well */
317
+ /** Joins a networked room. If you don't want to manage a connection yourself you can use a `{@link SyncedRoom}` component as well */
166
318
  joinRoom(room: string, viewOnly?: boolean): boolean;
167
319
  /** Use to leave a room that you are currently connected to (use `leaveRoom()` to disconnect from the currently active room but you can also specify a room name) */
168
320
  leaveRoom(room?: string | null): boolean;
169
321
  /** Send a message to the networking backend - it will broadcasted to all connected users in the same room by default */
170
322
  send<T extends WebsocketSendType>(key: string | OwnershipEvent, data?: T | null, queue?: SendQueue): void;
171
- /** Use to delete state for a given guid on the server */
323
+ /**
324
+ * Deletes the network state for a specific object on the server.
325
+ * This removes the object's state from the room, preventing it from being sent to newly joining users.
326
+ * @param guid The unique identifier of the object whose state should be deleted
327
+ * @example
328
+ * ```ts
329
+ * // When destroying a networked object, clean up its server state
330
+ * onDestroy() {
331
+ * this.context.connection.sendDeleteRemoteState(this.guid);
332
+ * }
333
+ * ```
334
+ */
172
335
  sendDeleteRemoteState(guid: string): void;
173
336
  /** Use to delete all state in the currently connected room on the server */
174
337
  sendDeleteRemoteStateAll(): void;
@@ -178,7 +341,7 @@ export declare class NetworkConnection implements INetworkConnection {
178
341
  private _defaultMessagesBufferArray;
179
342
  sendBufferedMessagesNow(): void;
180
343
  /** Use to start listening to networking events.
181
- * To unsubscribe from events use the `stopListen` method.
344
+ * To unsubscribe from events use the `{@link stopListen}` method.
182
345
  * See the example below for typical usage:
183
346
  *
184
347
  * ### Component Example
@@ -203,7 +366,7 @@ export declare class NetworkConnection implements INetworkConnection {
203
366
  /**@deprecated please use stopListen instead (2.65.2-pre) */
204
367
  stopListening(key: (string & {}) | OwnershipEvent | OwnershipEventNamesIncoming | RoomEventsIncoming | RoomEvents, callback: Function | null): void;
205
368
  /** Use to stop listening to networking events
206
- * To subscribe to events use the `beginListen` method.
369
+ * To subscribe to events use the `{@link beginListen}` method.
207
370
  * See the example below for typical usage:
208
371
  *
209
372
  * ### Component Example
@@ -228,9 +391,13 @@ export declare class NetworkConnection implements INetworkConnection {
228
391
  /** Use to stop listening to networking binary events */
229
392
  stopListenBinary(identifier: string, callback: any): void;
230
393
  private netWebSocketUrlProvider?;
231
- /** Use to override the networking server backend url. This is what the `Networking` component uses to modify the backend url */
394
+ /** Use to override the networking server backend url.
395
+ * This is what the `{@link Networking}` component uses to modify the backend url.
396
+ **/
232
397
  registerProvider(prov: INetworkingWebsocketUrlProvider): void;
233
- /** Used to connect to the networking server */
398
+ /** Used to connect to the networking server
399
+ * @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.
400
+ */
234
401
  connect(url?: string): Promise<boolean>;
235
402
  /** Disconnect from the networking backend + reset internal state */
236
403
  disconnect(): void;
@@ -67,16 +67,84 @@ export var OwnershipEvent;
67
67
  OwnershipEvent["GainedOwnershipBroadcast"] = "gained-ownership-broadcast";
68
68
  OwnershipEvent["LostOwnershipBroadcast"] = "lost-ownership-broadcast";
69
69
  })(OwnershipEvent || (OwnershipEvent = {}));
70
- /** Class for abstracting the concept of ownership regarding a networked object or component.
71
- * A component that is owned by another user can not be modified through networking (the server will reject changes) */
70
+ /**
71
+ * Manages ownership of networked objects or components.
72
+ *
73
+ * In multiplayer scenarios, ownership determines which client has authority to modify an object.
74
+ * The networking server rejects changes from clients that don't own an object. This prevents conflicts
75
+ * when multiple users try to manipulate the same object simultaneously.
76
+ *
77
+ * **Ownership states:**
78
+ * - `hasOwnership`: This client owns the object and can modify it
79
+ * - `isOwned`: Some client (could be local or remote) owns the object
80
+ * - `undefined`: Ownership state is unknown (not yet queried)
81
+ *
82
+ * **Typical workflow:**
83
+ * 1. Request ownership before modifying an object
84
+ * 2. Make your changes while you have ownership
85
+ * 3. Free ownership when done (or keep it if still interacting)
86
+ *
87
+ * @example Basic usage
88
+ * ```ts
89
+ * export class MyComponent extends Behaviour {
90
+ * private ownership?: OwnershipModel;
91
+ *
92
+ * awake() {
93
+ * this.ownership = new OwnershipModel(this.context.connection, this.guid);
94
+ * }
95
+ *
96
+ * onClick() {
97
+ * // Request ownership before modifying the object
98
+ * this.ownership.requestOwnership();
99
+ * }
100
+ *
101
+ * update() {
102
+ * if (this.ownership.hasOwnership) {
103
+ * // Safe to modify and sync the object
104
+ * this.gameObject.position.y += 0.01;
105
+ * }
106
+ * }
107
+ *
108
+ * onDisable() {
109
+ * // Release ownership when done
110
+ * this.ownership.freeOwnership();
111
+ * this.ownership.destroy();
112
+ * }
113
+ * }
114
+ * ```
115
+ *
116
+ * @example Async ownership
117
+ * ```ts
118
+ * async modifyObject() {
119
+ * try {
120
+ * await this.ownership.requestOwnershipAsync();
121
+ * // Now guaranteed to have ownership
122
+ * this.transform.position.x = 5;
123
+ * } catch(e) {
124
+ * console.log("Failed to gain ownership");
125
+ * }
126
+ * }
127
+ * ```
128
+ *
129
+ * @see {@link SyncedTransform} for a complete example of ownership in action
130
+ * @link https://engine.needle.tools/docs/networking.html
131
+ */
72
132
  export class OwnershipModel {
133
+ /** The unique identifier (GUID) of the object this ownership model manages */
73
134
  guid;
74
135
  connection;
136
+ /**
137
+ * Checks if the local client has ownership of this object.
138
+ * @returns `true` if this client owns the object and can modify it, `false` otherwise
139
+ */
75
140
  get hasOwnership() {
76
141
  return this._hasOwnership;
77
142
  }
78
143
  // TODO: server should just send id to everyone
79
- /** @returns true of anyone has ownership */
144
+ /**
145
+ * Checks if anyone (local or remote client) has ownership of this object.
146
+ * @returns `true` if someone owns the object, `false` if no one owns it, `undefined` if unknown
147
+ */
80
148
  get isOwned() {
81
149
  return this._isOwned;
82
150
  }
@@ -103,6 +171,10 @@ export class OwnershipModel {
103
171
  connection.beginListen(OwnershipEvent.ResponseHasOwner, this._hasOwnerResponse);
104
172
  }
105
173
  _isWaitingForOwnershipResponseCallback = null;
174
+ /**
175
+ * Queries the server to update the `isOwned` state.
176
+ * Call this to check if anyone currently has ownership.
177
+ */
106
178
  updateIsOwned() {
107
179
  this.connection.send(OwnershipEvent.RequestHasOwner, { guid: this.guid });
108
180
  }
@@ -111,6 +183,11 @@ export class OwnershipModel {
111
183
  this._isOwned = res.value;
112
184
  }
113
185
  }
186
+ /**
187
+ * Requests ownership only if the object is not currently owned by anyone.
188
+ * Internally checks ownership state first, then requests ownership if free.
189
+ * @returns this OwnershipModel instance for method chaining
190
+ */
114
191
  requestOwnershipIfNotOwned() {
115
192
  if (this._isWaitingForOwnershipResponseCallback !== null)
116
193
  return this;
@@ -134,6 +211,20 @@ export class OwnershipModel {
134
211
  }
135
212
  }
136
213
  }
214
+ /**
215
+ * Requests ownership and waits asynchronously until ownership is granted or timeout occurs.
216
+ * @returns Promise that resolves with this OwnershipModel when ownership is gained
217
+ * @throws Rejects with "Timeout" if ownership is not gained within ~1 second
218
+ * @example
219
+ * ```ts
220
+ * try {
221
+ * await ownership.requestOwnershipAsync();
222
+ * // Ownership granted, safe to modify object
223
+ * } catch(e) {
224
+ * console.warn("Could not gain ownership:", e);
225
+ * }
226
+ * ```
227
+ */
137
228
  requestOwnershipAsync() {
138
229
  return new Promise((resolve, reject) => {
139
230
  this.requestOwnership();
@@ -151,12 +242,22 @@ export class OwnershipModel {
151
242
  waitForOwnership();
152
243
  });
153
244
  }
245
+ /**
246
+ * Requests ownership of this object from the networking server.
247
+ * Ownership may not be granted immediately - check `hasOwnership` property or use `requestOwnershipAsync()`.
248
+ * @returns this OwnershipModel instance for method chaining
249
+ */
154
250
  requestOwnership() {
155
251
  if (debugOwner)
156
252
  console.log("Request ownership", this.guid);
157
253
  this.connection.send(OwnershipEvent.RequestOwnership, { guid: this.guid });
158
254
  return this;
159
255
  }
256
+ /**
257
+ * Releases ownership of this object, allowing others to take control.
258
+ * Call this when you're done modifying an object to allow other users to interact with it.
259
+ * @returns this OwnershipModel instance for method chaining
260
+ */
160
261
  freeOwnership() {
161
262
  // TODO: abort "requestOwnershipIfNotOwned"
162
263
  this.connection.send(OwnershipEvent.RemoveOwnership, { guid: this.guid });
@@ -166,6 +267,10 @@ export class OwnershipModel {
166
267
  }
167
268
  return this;
168
269
  }
270
+ /**
271
+ * Cleans up event listeners and resources.
272
+ * Call this when the OwnershipModel is no longer needed (e.g., in `onDestroy()`).
273
+ */
169
274
  destroy() {
170
275
  this.connection.stopListen(OwnershipEvent.GainedOwnership, this._gainSubscription);
171
276
  this.connection.stopListen(OwnershipEvent.LostOwnership, this._lostSubscription);
@@ -197,10 +302,46 @@ export class OwnershipModel {
197
302
  }
198
303
  }
199
304
  }
200
- /** Main class to communicate with the networking backend
201
- * @link https://engine.needle.tools/docs/networking.html
305
+ /**
306
+ * Main class for multiuser networking. Access via `this.context.connection` from any component.
307
+ *
308
+ * **About GUIDs:**
309
+ * In Needle Engine networking, GUIDs (Globally Unique Identifiers) are used to identify objects and components across the network.
310
+ * Every GameObject and Component has a unique `guid` property that remains consistent across all clients.
311
+ * GUIDs are automatically assigned (e.g. during export from Unity/Blender) and are essential for:
312
+ * - Object ownership management (see {@link OwnershipModel})
313
+ * - State synchronization (storing and retrieving object state)
314
+ * - Identifying which object received a network message
315
+ *
316
+ * When working with networking, you'll typically use `this.guid` to identify your component or `this.gameObject.guid` for the GameObject.
202
317
  *
203
- */
318
+ * @example Joining a room
319
+ * ```ts
320
+ * this.context.connection.connect();
321
+ * this.context.connection.joinRoom("my-room");
322
+ * ```
323
+ * @example Listening to events
324
+ * ```ts
325
+ * this.context.connection.beginListen("my-event", (data) => {
326
+ * console.log("Received:", data);
327
+ * });
328
+ * ```
329
+ * @example Sending data
330
+ * ```ts
331
+ * this.context.connection.send("my-event", { message: "Hello" });
332
+ * ```
333
+ * @example Using GUIDs for object identification
334
+ * ```ts
335
+ * // Get state for a specific object by its GUID
336
+ * const state = this.context.connection.tryGetState(this.guid);
337
+ *
338
+ * // Delete remote state for an object
339
+ * this.context.connection.sendDeleteRemoteState(this.guid);
340
+ * ```
341
+ * @see {@link RoomEvents} for room lifecycle events
342
+ * @see {@link OwnershipModel} for object ownership
343
+ * @link https://engine.needle.tools/docs/how-to-guides/networking/
344
+ */
204
345
  export class NetworkConnection {
205
346
  context;
206
347
  _peer = null;
@@ -215,7 +356,18 @@ export class NetworkConnection {
215
356
  return this._peer;
216
357
  }
217
358
  /**
218
- * Returns the state of a given guid.
359
+ * Returns the cached network state for a given GUID.
360
+ * The state is stored locally whenever network updates are received for that object.
361
+ * @param guid The unique identifier of the object whose state you want to retrieve
362
+ * @returns The cached state object, or `null` if no state exists for this GUID
363
+ * @example
364
+ * ```ts
365
+ * // Get the last known state for this component
366
+ * const myState = this.context.connection.tryGetState(this.guid);
367
+ * if (myState) {
368
+ * console.log("Found cached state:", myState);
369
+ * }
370
+ * ```
219
371
  */
220
372
  tryGetState(guid) {
221
373
  if (guid === "invalid")
@@ -233,7 +385,7 @@ export class NetworkConnection {
233
385
  return debugNet;
234
386
  }
235
387
  /**
236
- * 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.
388
+ * 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.
237
389
  * @returns true if connected to the websocket.
238
390
  */
239
391
  get isConnected() {
@@ -292,7 +444,7 @@ export class NetworkConnection {
292
444
  target.push(user);
293
445
  return target;
294
446
  }
295
- /** Joins a networked room. If you don't want to manage a connection yourself you can use a `SyncedRoom` component as well */
447
+ /** Joins a networked room. If you don't want to manage a connection yourself you can use a `{@link SyncedRoom}` component as well */
296
448
  joinRoom(room, viewOnly = false) {
297
449
  if (!room) {
298
450
  console.error("Missing room name, can not join: \"" + room + "\"");
@@ -340,7 +492,18 @@ export class NetworkConnection {
340
492
  // this.sendGeckosIo(key, data);
341
493
  return this.sendWithWebsocket(key, data, queue);
342
494
  }
343
- /** Use to delete state for a given guid on the server */
495
+ /**
496
+ * Deletes the network state for a specific object on the server.
497
+ * This removes the object's state from the room, preventing it from being sent to newly joining users.
498
+ * @param guid The unique identifier of the object whose state should be deleted
499
+ * @example
500
+ * ```ts
501
+ * // When destroying a networked object, clean up its server state
502
+ * onDestroy() {
503
+ * this.context.connection.sendDeleteRemoteState(this.guid);
504
+ * }
505
+ * ```
506
+ */
344
507
  sendDeleteRemoteState(guid) {
345
508
  this.send("delete-state", { guid: guid, dontSave: true });
346
509
  delete this._state[guid];
@@ -382,7 +545,7 @@ export class NetworkConnection {
382
545
  this._ws?.send(message);
383
546
  }
384
547
  /** Use to start listening to networking events.
385
- * To unsubscribe from events use the `stopListen` method.
548
+ * To unsubscribe from events use the `{@link stopListen}` method.
386
549
  * See the example below for typical usage:
387
550
  *
388
551
  * ### Component Example
@@ -412,7 +575,7 @@ export class NetworkConnection {
412
575
  /**@deprecated please use stopListen instead (2.65.2-pre) */
413
576
  stopListening(key, callback) { return this.stopListen(key, callback); }
414
577
  /** Use to stop listening to networking events
415
- * To subscribe to events use the `beginListen` method.
578
+ * To subscribe to events use the `{@link beginListen}` method.
416
579
  * See the example below for typical usage:
417
580
  *
418
581
  * ### Component Example
@@ -458,11 +621,15 @@ export class NetworkConnection {
458
621
  }
459
622
  }
460
623
  netWebSocketUrlProvider;
461
- /** Use to override the networking server backend url. This is what the `Networking` component uses to modify the backend url */
624
+ /** Use to override the networking server backend url.
625
+ * This is what the `{@link Networking}` component uses to modify the backend url.
626
+ **/
462
627
  registerProvider(prov) {
463
628
  this.netWebSocketUrlProvider = prov;
464
629
  }
465
- /** Used to connect to the networking server */
630
+ /** Used to connect to the networking server
631
+ * @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.
632
+ */
466
633
  async connect(url) {
467
634
  if (this.connected && url && url !== networkingServerUrl) {
468
635
  return Promise.reject("Can not connect to different server url. Please disconnect first.");