@needle-tools/engine 4.12.5 → 4.13.0-next.1eca7a7

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 (322) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +38 -1
  3. package/components.needle.json +1 -1
  4. package/custom-elements.json +156 -5
  5. package/dist/{gltf-progressive-BqUnxvCx.umd.cjs → gltf-progressive-BURrJW0U.umd.cjs} +1 -1
  6. package/dist/{gltf-progressive-CSaX5HQb.min.js → gltf-progressive-DHLDFNvQ.min.js} +1 -1
  7. package/dist/{gltf-progressive-ChnIhDXx.js → gltf-progressive-eiJCrjLb.js} +3 -3
  8. package/dist/materialx-B9ddsHcF.min.js +90 -0
  9. package/dist/materialx-BF23AVE8.umd.cjs +90 -0
  10. package/dist/materialx-fkoFuRh3.js +4636 -0
  11. package/dist/{needle-engine.bundle-Cnemui9H.umd.cjs → needle-engine.bundle-BfrDWglE.umd.cjs} +124 -124
  12. package/dist/{needle-engine.bundle-B_IGIr6Z.min.js → needle-engine.bundle-Bx_Lq_3v.min.js} +131 -131
  13. package/dist/{needle-engine.bundle-Cj66livk.js → needle-engine.bundle-MQyZGnMF.js} +3754 -3374
  14. package/dist/needle-engine.d.ts +2791 -309
  15. package/dist/needle-engine.js +415 -414
  16. package/dist/needle-engine.min.js +1 -1
  17. package/dist/needle-engine.umd.cjs +1 -1
  18. package/dist/{postprocessing-12-UW7je.min.js → postprocessing-BVNrgYZK.min.js} +1 -1
  19. package/dist/{postprocessing-B3Hu0Ryi.umd.cjs → postprocessing-CI2TjWpu.umd.cjs} +1 -1
  20. package/dist/{postprocessing-R535krvT.js → postprocessing-DdM-tz1j.js} +2 -2
  21. package/dist/{three-BzxwLtUE.umd.cjs → three-BW2s1Yl-.umd.cjs} +25 -25
  22. package/dist/{three-DMvLgxja.min.js → three-I__hSXzr.min.js} +26 -26
  23. package/dist/{three-D9pcFbxc.js → three-VvRoMeIN.js} +22 -0
  24. package/dist/{three-examples-F0MJj0vr.js → three-examples-BhfOE7NG.js} +1 -1
  25. package/dist/{three-examples-CjSwCv_b.umd.cjs → three-examples-Bpfu6ke_.umd.cjs} +1 -1
  26. package/dist/{three-examples-CIv2roOA.min.js → three-examples-D8zAE_7t.min.js} +1 -1
  27. package/dist/{three-mesh-ui-BLnJQzMl.umd.cjs → three-mesh-ui-BU55xDxJ.umd.cjs} +1 -1
  28. package/dist/{three-mesh-ui-BllgajJz.min.js → three-mesh-ui-C3QbemOV.min.js} +1 -1
  29. package/dist/{three-mesh-ui-DYyiRn5Y.js → three-mesh-ui-CcMp-FQm.js} +1 -1
  30. package/dist/{vendor-BIFy-gRe.js → vendor-BiyIZ61v.js} +1 -1
  31. package/dist/{vendor-BFgQSG2m.umd.cjs → vendor-COVQl0b8.umd.cjs} +1 -1
  32. package/dist/{vendor-ChgmXMYr.min.js → vendor-DW7zqjuT.min.js} +1 -1
  33. package/lib/engine/engine_context.d.ts +16 -0
  34. package/lib/engine/engine_context.js +16 -0
  35. package/lib/engine/engine_context.js.map +1 -1
  36. package/lib/engine/engine_gameobject.d.ts +72 -0
  37. package/lib/engine/engine_gameobject.js +38 -0
  38. package/lib/engine/engine_gameobject.js.map +1 -1
  39. package/lib/engine/engine_input.d.ts +80 -4
  40. package/lib/engine/engine_input.js +78 -2
  41. package/lib/engine/engine_input.js.map +1 -1
  42. package/lib/engine/engine_loaders.js +7 -1
  43. package/lib/engine/engine_loaders.js.map +1 -1
  44. package/lib/engine/engine_math.d.ts +81 -2
  45. package/lib/engine/engine_math.js +68 -2
  46. package/lib/engine/engine_math.js.map +1 -1
  47. package/lib/engine/engine_modules.d.ts +9 -0
  48. package/lib/engine/engine_modules.js +25 -0
  49. package/lib/engine/engine_modules.js.map +1 -1
  50. package/lib/engine/engine_networking.d.ts +181 -14
  51. package/lib/engine/engine_networking.js +181 -14
  52. package/lib/engine/engine_networking.js.map +1 -1
  53. package/lib/engine/engine_networking_auto.d.ts +35 -8
  54. package/lib/engine/engine_networking_auto.js +35 -8
  55. package/lib/engine/engine_networking_auto.js.map +1 -1
  56. package/lib/engine/engine_physics.d.ts +35 -1
  57. package/lib/engine/engine_physics.js +35 -1
  58. package/lib/engine/engine_physics.js.map +1 -1
  59. package/lib/engine/engine_physics_rapier.d.ts +76 -0
  60. package/lib/engine/engine_physics_rapier.js +76 -0
  61. package/lib/engine/engine_physics_rapier.js.map +1 -1
  62. package/lib/engine/engine_serialization_decorator.d.ts +28 -2
  63. package/lib/engine/engine_serialization_decorator.js +28 -2
  64. package/lib/engine/engine_serialization_decorator.js.map +1 -1
  65. package/lib/engine/engine_time.d.ts +23 -3
  66. package/lib/engine/engine_time.js +23 -3
  67. package/lib/engine/engine_time.js.map +1 -1
  68. package/lib/engine/engine_util_decorator.d.ts +31 -1
  69. package/lib/engine/engine_util_decorator.js +31 -1
  70. package/lib/engine/engine_util_decorator.js.map +1 -1
  71. package/lib/engine/engine_utils.d.ts +21 -5
  72. package/lib/engine/engine_utils.js +21 -5
  73. package/lib/engine/engine_utils.js.map +1 -1
  74. package/lib/engine/engine_utils_format.d.ts +1 -1
  75. package/lib/engine/engine_utils_format.js +4 -1
  76. package/lib/engine/engine_utils_format.js.map +1 -1
  77. package/lib/engine/extensions/NEEDLE_materialx.d.ts +29 -0
  78. package/lib/engine/extensions/NEEDLE_materialx.js +115 -0
  79. package/lib/engine/extensions/NEEDLE_materialx.js.map +1 -0
  80. package/lib/engine/extensions/extensions.js +2 -0
  81. package/lib/engine/extensions/extensions.js.map +1 -1
  82. package/lib/engine/extensions/index.d.ts +1 -0
  83. package/lib/engine/extensions/index.js +1 -0
  84. package/lib/engine/extensions/index.js.map +1 -1
  85. package/lib/engine-components/AlignmentConstraint.d.ts +23 -3
  86. package/lib/engine-components/AlignmentConstraint.js +23 -3
  87. package/lib/engine-components/AlignmentConstraint.js.map +1 -1
  88. package/lib/engine-components/Animation.d.ts +42 -0
  89. package/lib/engine-components/Animation.js +36 -0
  90. package/lib/engine-components/Animation.js.map +1 -1
  91. package/lib/engine-components/Animator.d.ts +37 -4
  92. package/lib/engine-components/Animator.js +37 -4
  93. package/lib/engine-components/Animator.js.map +1 -1
  94. package/lib/engine-components/AudioSource.d.ts +32 -10
  95. package/lib/engine-components/AudioSource.js +32 -10
  96. package/lib/engine-components/AudioSource.js.map +1 -1
  97. package/lib/engine-components/AxesHelper.d.ts +22 -3
  98. package/lib/engine-components/AxesHelper.js +22 -3
  99. package/lib/engine-components/AxesHelper.js.map +1 -1
  100. package/lib/engine-components/BasicIKConstraint.d.ts +27 -4
  101. package/lib/engine-components/BasicIKConstraint.js +27 -4
  102. package/lib/engine-components/BasicIKConstraint.js.map +1 -1
  103. package/lib/engine-components/Camera.d.ts +31 -1
  104. package/lib/engine-components/Camera.js +31 -1
  105. package/lib/engine-components/Camera.js.map +1 -1
  106. package/lib/engine-components/CharacterController.d.ts +67 -3
  107. package/lib/engine-components/CharacterController.js +67 -3
  108. package/lib/engine-components/CharacterController.js.map +1 -1
  109. package/lib/engine-components/Collider.d.ts +69 -12
  110. package/lib/engine-components/Collider.js +69 -12
  111. package/lib/engine-components/Collider.js.map +1 -1
  112. package/lib/engine-components/ContactShadows.d.ts +26 -6
  113. package/lib/engine-components/ContactShadows.js +46 -8
  114. package/lib/engine-components/ContactShadows.js.map +1 -1
  115. package/lib/engine-components/DeleteBox.d.ts +43 -2
  116. package/lib/engine-components/DeleteBox.js +43 -2
  117. package/lib/engine-components/DeleteBox.js.map +1 -1
  118. package/lib/engine-components/DeviceFlag.d.ts +21 -2
  119. package/lib/engine-components/DeviceFlag.js +21 -2
  120. package/lib/engine-components/DeviceFlag.js.map +1 -1
  121. package/lib/engine-components/DragControls.d.ts +32 -2
  122. package/lib/engine-components/DragControls.js +32 -2
  123. package/lib/engine-components/DragControls.js.map +1 -1
  124. package/lib/engine-components/DropListener.d.ts +33 -21
  125. package/lib/engine-components/DropListener.js +33 -21
  126. package/lib/engine-components/DropListener.js.map +1 -1
  127. package/lib/engine-components/Duplicatable.d.ts +36 -5
  128. package/lib/engine-components/Duplicatable.js +36 -5
  129. package/lib/engine-components/Duplicatable.js.map +1 -1
  130. package/lib/engine-components/EventList.d.ts +38 -10
  131. package/lib/engine-components/EventList.js +38 -10
  132. package/lib/engine-components/EventList.js.map +1 -1
  133. package/lib/engine-components/Fog.d.ts +23 -1
  134. package/lib/engine-components/Fog.js +23 -1
  135. package/lib/engine-components/Fog.js.map +1 -1
  136. package/lib/engine-components/GridHelper.d.ts +18 -2
  137. package/lib/engine-components/GridHelper.js +18 -2
  138. package/lib/engine-components/GridHelper.js.map +1 -1
  139. package/lib/engine-components/GroundProjection.d.ts +24 -2
  140. package/lib/engine-components/GroundProjection.js +24 -2
  141. package/lib/engine-components/GroundProjection.js.map +1 -1
  142. package/lib/engine-components/Interactable.d.ts +17 -2
  143. package/lib/engine-components/Interactable.js +17 -2
  144. package/lib/engine-components/Interactable.js.map +1 -1
  145. package/lib/engine-components/Joints.d.ts +50 -7
  146. package/lib/engine-components/Joints.js +50 -7
  147. package/lib/engine-components/Joints.js.map +1 -1
  148. package/lib/engine-components/LODGroup.d.ts +36 -14
  149. package/lib/engine-components/LODGroup.js +43 -11
  150. package/lib/engine-components/LODGroup.js.map +1 -1
  151. package/lib/engine-components/Light.d.ts +27 -5
  152. package/lib/engine-components/Light.js +27 -5
  153. package/lib/engine-components/Light.js.map +1 -1
  154. package/lib/engine-components/LookAtConstraint.d.ts +22 -7
  155. package/lib/engine-components/LookAtConstraint.js +22 -7
  156. package/lib/engine-components/LookAtConstraint.js.map +1 -1
  157. package/lib/engine-components/NeedleMenu.d.ts +27 -5
  158. package/lib/engine-components/NeedleMenu.js +27 -5
  159. package/lib/engine-components/NeedleMenu.js.map +1 -1
  160. package/lib/engine-components/NestedGltf.d.ts +39 -4
  161. package/lib/engine-components/NestedGltf.js +42 -4
  162. package/lib/engine-components/NestedGltf.js.map +1 -1
  163. package/lib/engine-components/OffsetConstraint.d.ts +27 -3
  164. package/lib/engine-components/OffsetConstraint.js +27 -3
  165. package/lib/engine-components/OffsetConstraint.js.map +1 -1
  166. package/lib/engine-components/OrbitControls.d.ts +41 -3
  167. package/lib/engine-components/OrbitControls.js +41 -3
  168. package/lib/engine-components/OrbitControls.js.map +1 -1
  169. package/lib/engine-components/ReflectionProbe.d.ts +17 -2
  170. package/lib/engine-components/ReflectionProbe.js +28 -10
  171. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  172. package/lib/engine-components/Renderer.d.ts +34 -0
  173. package/lib/engine-components/Renderer.js +35 -2
  174. package/lib/engine-components/Renderer.js.map +1 -1
  175. package/lib/engine-components/SceneSwitcher.d.ts +11 -0
  176. package/lib/engine-components/SceneSwitcher.js +11 -0
  177. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  178. package/lib/engine-components/ScreenCapture.d.ts +38 -6
  179. package/lib/engine-components/ScreenCapture.js +38 -6
  180. package/lib/engine-components/ScreenCapture.js.map +1 -1
  181. package/lib/engine-components/Skybox.js +1 -1
  182. package/lib/engine-components/Skybox.js.map +1 -1
  183. package/lib/engine-components/SmoothFollow.d.ts +66 -7
  184. package/lib/engine-components/SmoothFollow.js +66 -7
  185. package/lib/engine-components/SmoothFollow.js.map +1 -1
  186. package/lib/engine-components/SpatialTrigger.d.ts +48 -1
  187. package/lib/engine-components/SpatialTrigger.js +48 -1
  188. package/lib/engine-components/SpatialTrigger.js.map +1 -1
  189. package/lib/engine-components/SpectatorCamera.d.ts +21 -3
  190. package/lib/engine-components/SpectatorCamera.js +21 -3
  191. package/lib/engine-components/SpectatorCamera.js.map +1 -1
  192. package/lib/engine-components/SyncedRoom.d.ts +6 -0
  193. package/lib/engine-components/SyncedRoom.js +6 -0
  194. package/lib/engine-components/SyncedRoom.js.map +1 -1
  195. package/lib/engine-components/SyncedTransform.d.ts +55 -6
  196. package/lib/engine-components/SyncedTransform.js +55 -6
  197. package/lib/engine-components/SyncedTransform.js.map +1 -1
  198. package/lib/engine-components/TransformGizmo.d.ts +30 -3
  199. package/lib/engine-components/TransformGizmo.js +30 -3
  200. package/lib/engine-components/TransformGizmo.js.map +1 -1
  201. package/lib/engine-components/VideoPlayer.d.ts +33 -6
  202. package/lib/engine-components/VideoPlayer.js +45 -6
  203. package/lib/engine-components/VideoPlayer.js.map +1 -1
  204. package/lib/engine-components/Voip.d.ts +33 -2
  205. package/lib/engine-components/Voip.js +33 -2
  206. package/lib/engine-components/Voip.js.map +1 -1
  207. package/lib/engine-components/export/usdz/USDZExporter.d.ts +47 -13
  208. package/lib/engine-components/export/usdz/USDZExporter.js +47 -13
  209. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  210. package/lib/engine-components/particlesystem/ParticleSystem.d.ts +82 -3
  211. package/lib/engine-components/particlesystem/ParticleSystem.js +82 -3
  212. package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
  213. package/lib/engine-components/timeline/PlayableDirector.d.ts +99 -14
  214. package/lib/engine-components/timeline/PlayableDirector.js +91 -25
  215. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  216. package/lib/engine-components/ui/Button.d.ts +29 -3
  217. package/lib/engine-components/ui/Button.js +29 -3
  218. package/lib/engine-components/ui/Button.js.map +1 -1
  219. package/lib/engine-components/ui/Canvas.d.ts +28 -3
  220. package/lib/engine-components/ui/Canvas.js +28 -3
  221. package/lib/engine-components/ui/Canvas.js.map +1 -1
  222. package/lib/engine-components/ui/Image.d.ts +22 -3
  223. package/lib/engine-components/ui/Image.js +22 -3
  224. package/lib/engine-components/ui/Image.js.map +1 -1
  225. package/lib/engine-components/ui/Raycaster.d.ts +55 -6
  226. package/lib/engine-components/ui/Raycaster.js +55 -6
  227. package/lib/engine-components/ui/Raycaster.js.map +1 -1
  228. package/lib/engine-components/ui/Text.d.ts +23 -1
  229. package/lib/engine-components/ui/Text.js +23 -1
  230. package/lib/engine-components/ui/Text.js.map +1 -1
  231. package/lib/engine-components/webxr/TeleportTarget.d.ts +21 -2
  232. package/lib/engine-components/webxr/TeleportTarget.js +21 -2
  233. package/lib/engine-components/webxr/TeleportTarget.js.map +1 -1
  234. package/lib/engine-components/webxr/WebXR.d.ts +10 -2
  235. package/lib/engine-components/webxr/WebXR.js +10 -2
  236. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  237. package/lib/engine-components/webxr/WebXRAvatar.d.ts +39 -2
  238. package/lib/engine-components/webxr/WebXRAvatar.js +35 -3
  239. package/lib/engine-components/webxr/WebXRAvatar.js.map +1 -1
  240. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +266 -30
  241. package/lib/engine-components/webxr/WebXRImageTracking.js +266 -30
  242. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  243. package/lib/engine-components/webxr/XRFlag.d.ts +29 -2
  244. package/lib/engine-components/webxr/XRFlag.js +29 -2
  245. package/lib/engine-components/webxr/XRFlag.js.map +1 -1
  246. package/package.json +3 -2
  247. package/plugins/vite/custom-element-data.js +128 -19
  248. package/plugins/vite/dependencies.js +9 -4
  249. package/plugins/vite/index.js +0 -2
  250. package/src/engine/engine_context.ts +16 -0
  251. package/src/engine/engine_gameobject.ts +73 -0
  252. package/src/engine/engine_input.ts +83 -7
  253. package/src/engine/engine_loaders.ts +9 -2
  254. package/src/engine/engine_math.ts +81 -2
  255. package/src/engine/engine_modules.ts +24 -0
  256. package/src/engine/engine_networking.ts +187 -17
  257. package/src/engine/engine_networking_auto.ts +36 -9
  258. package/src/engine/engine_physics.ts +37 -1
  259. package/src/engine/engine_physics_rapier.ts +77 -0
  260. package/src/engine/engine_serialization_decorator.ts +28 -2
  261. package/src/engine/engine_time.ts +23 -3
  262. package/src/engine/engine_util_decorator.ts +31 -1
  263. package/src/engine/engine_utils.ts +21 -5
  264. package/src/engine/engine_utils_format.ts +6 -2
  265. package/src/engine/extensions/NEEDLE_materialx.ts +143 -0
  266. package/src/engine/extensions/extensions.ts +2 -0
  267. package/src/engine/extensions/index.ts +1 -0
  268. package/src/engine-components/AlignmentConstraint.ts +24 -4
  269. package/src/engine-components/Animation.ts +44 -2
  270. package/src/engine-components/Animator.ts +40 -7
  271. package/src/engine-components/AudioSource.ts +37 -15
  272. package/src/engine-components/AxesHelper.ts +23 -4
  273. package/src/engine-components/BasicIKConstraint.ts +28 -5
  274. package/src/engine-components/Camera.ts +33 -3
  275. package/src/engine-components/CharacterController.ts +73 -6
  276. package/src/engine-components/Collider.ts +78 -21
  277. package/src/engine-components/ContactShadows.ts +51 -11
  278. package/src/engine-components/DeleteBox.ts +43 -2
  279. package/src/engine-components/DeviceFlag.ts +22 -3
  280. package/src/engine-components/DragControls.ts +32 -2
  281. package/src/engine-components/DropListener.ts +42 -29
  282. package/src/engine-components/Duplicatable.ts +37 -6
  283. package/src/engine-components/EventList.ts +41 -13
  284. package/src/engine-components/Fog.ts +23 -1
  285. package/src/engine-components/GridHelper.ts +18 -2
  286. package/src/engine-components/GroundProjection.ts +25 -3
  287. package/src/engine-components/Interactable.ts +17 -2
  288. package/src/engine-components/Joints.ts +51 -8
  289. package/src/engine-components/LODGroup.ts +45 -11
  290. package/src/engine-components/Light.ts +30 -8
  291. package/src/engine-components/LookAtConstraint.ts +26 -8
  292. package/src/engine-components/NeedleMenu.ts +29 -7
  293. package/src/engine-components/NestedGltf.ts +40 -4
  294. package/src/engine-components/OffsetConstraint.ts +27 -3
  295. package/src/engine-components/OrbitControls.ts +41 -3
  296. package/src/engine-components/ReflectionProbe.ts +31 -13
  297. package/src/engine-components/Renderer.ts +34 -1
  298. package/src/engine-components/SceneSwitcher.ts +11 -0
  299. package/src/engine-components/ScreenCapture.ts +41 -9
  300. package/src/engine-components/Skybox.ts +1 -1
  301. package/src/engine-components/SmoothFollow.ts +69 -7
  302. package/src/engine-components/SpatialTrigger.ts +51 -4
  303. package/src/engine-components/SpectatorCamera.ts +23 -5
  304. package/src/engine-components/SyncedRoom.ts +6 -0
  305. package/src/engine-components/SyncedTransform.ts +59 -10
  306. package/src/engine-components/TransformGizmo.ts +31 -4
  307. package/src/engine-components/VideoPlayer.ts +48 -6
  308. package/src/engine-components/Voip.ts +33 -2
  309. package/src/engine-components/export/usdz/USDZExporter.ts +47 -13
  310. package/src/engine-components/particlesystem/ParticleSystem.ts +84 -5
  311. package/src/engine-components/timeline/PlayableDirector.ts +104 -27
  312. package/src/engine-components/ui/Button.ts +29 -3
  313. package/src/engine-components/ui/Canvas.ts +28 -3
  314. package/src/engine-components/ui/Image.ts +22 -3
  315. package/src/engine-components/ui/Raycaster.ts +57 -8
  316. package/src/engine-components/ui/Text.ts +24 -2
  317. package/src/engine-components/webxr/TeleportTarget.ts +23 -4
  318. package/src/engine-components/webxr/WebXR.ts +11 -3
  319. package/src/engine-components/webxr/WebXRAvatar.ts +41 -4
  320. package/src/engine-components/webxr/WebXRImageTracking.ts +282 -38
  321. package/src/engine-components/webxr/XRFlag.ts +30 -3
  322. package/plugins/vite/materialx.js +0 -32
@@ -17,20 +17,15 @@ import * as Tracks from "./TimelineTracks.js";
17
17
  const debug = getParam("debugtimeline");
18
18
 
19
19
  /**
20
- * The wrap mode of the {@link PlayableDirector}.
20
+ * Controls how the {@link PlayableDirector} behaves when playback reaches the end.
21
+ * @see {@link PlayableDirector.extrapolationMode}
21
22
  */
22
23
  export enum DirectorWrapMode {
23
- /// <summary>
24
- /// <para>Hold the last frame when the playable time reaches it's duration.</para>
25
- /// </summary>
24
+ /** Hold the last frame when playback reaches the end of the timeline. */
26
25
  Hold = 0,
27
- /// <summary>
28
- /// <para>Loop back to zero time and continue playing.</para>
29
- /// </summary>
26
+ /** Loop back to the start and continue playing indefinitely. */
30
27
  Loop = 1,
31
- /// <summary>
32
- /// <para>Do not keep playing when the time reaches the duration.</para>
33
- /// </summary>
28
+ /** Stop playback when the end is reached. The timeline will not loop. */
34
29
  None = 2,
35
30
  }
36
31
 
@@ -53,26 +48,76 @@ export enum ClipExtrapolation {
53
48
  export type CreateTrackFunction = (director: PlayableDirector, track: Models.TrackModel) => Tracks.TrackHandler | undefined | null;
54
49
 
55
50
  /**
56
- * The PlayableDirector component is the main component to control timelines in needle engine.
57
- * It is used to play, pause, stop and evaluate timelines.
58
- * Assign a TimelineAsset to the `playableAsset` property to start playing a timeline.
51
+ * PlayableDirector is the main component for controlling timelines in Needle Engine.
52
+ * It orchestrates playback of TimelineAssets containing animation, audio, signal,
53
+ * control, and activation tracks.
54
+ *
55
+ * **Supported track types:**
56
+ * - Animation tracks - animate objects using AnimationClips
57
+ * - Audio tracks - play synchronized audio
58
+ * - Activation tracks - show/hide objects at specific times
59
+ * - Signal tracks - trigger events at specific points
60
+ * - Control tracks - control nested timelines or prefab instances
61
+ * - Marker tracks - add metadata and navigation points
62
+ *
63
+ * [![](https://cloud.needle.tools/-/media/HFudFwl8J8D-Kt_VPu7pRw.gif)](https://engine.needle.tools/samples/bike-scrollytelling-responsive-3d)
64
+ *
65
+ * [![](https://cloud.needle.tools/-/media/xJ1rI3STbZRnOoWJrSzqlQ.gif)](https://app.songsofcultures.com/?scene=little-brother)
66
+ *
67
+ * **Playback control:**
68
+ * Use `play()`, `pause()`, `stop()` for basic control.
69
+ * Set `time` directly and call `evaluate()` for scrubbing.
70
+ * Adjust `speed` for playback rate and `weight` for blending.
71
+ *
72
+ * @example Basic timeline playback
73
+ * ```ts
74
+ * const director = myObject.getComponent(PlayableDirector);
75
+ * director.play();
76
+ * // Jump to specific time
77
+ * director.time = 2.5;
78
+ * director.evaluate();
79
+ * ```
80
+ *
81
+ * @example Control playback speed
82
+ * ```ts
83
+ * director.speed = 0.5; // Half speed
84
+ * director.speed = -1; // Reverse playback
85
+ * ```
86
+ *
87
+ * - Example: https://engine.needle.tools/samples-uploads/product-flyover/
88
+ *
59
89
  * @summary Controls and plays TimelineAssets
60
90
  * @category Animation and Sequencing
61
91
  * @group Components
92
+ * @see {@link Animator} for playing individual AnimationClips
93
+ * @see {@link AudioSource} for standalone audio playback
94
+ * @see {@link SignalReceiver} for handling timeline signals
95
+ * @link https://engine.needle.tools/samples/?overlay=samples&tag=animation
96
+ * @link https://app.songsofcultures.com/
62
97
  */
63
98
  export class PlayableDirector extends Behaviour {
64
99
 
65
100
  private static createTrackFunctions: { [key: string]: CreateTrackFunction } = {};
101
+
102
+ /**
103
+ * Register a function to create a track handler for a custom track type.
104
+ * This allows you to extend the timeline system with your own track types and handlers.
105
+ */
66
106
  static registerCreateTrack(type: string, fn: CreateTrackFunction) {
67
107
  this.createTrackFunctions[type] = fn;
68
108
  }
69
109
 
70
110
  /**
71
- * The timeline asset that is played by this director.
111
+ * The timeline asset containing tracks, clips, and markers that this director will play.
112
+ * Assign a timeline asset exported from Unity or Blender to enable playback.
72
113
  */
73
114
  playableAsset?: Models.TimelineAssetModel;
74
115
 
75
- /** Set to true to start playing the timeline when the scene starts */
116
+ /**
117
+ * When true, the timeline starts playing automatically when the component awakens.
118
+ * Set to false to control playback manually via `play()`.
119
+ * @default false
120
+ */
76
121
  @serializable()
77
122
  playOnAwake?: boolean;
78
123
 
@@ -83,11 +128,18 @@ export class PlayableDirector extends Behaviour {
83
128
  @serializable()
84
129
  extrapolationMode: DirectorWrapMode = DirectorWrapMode.Loop;
85
130
 
86
- /** @returns true if the timeline is currently playing */
131
+ /** Returns true if the timeline is currently playing (not paused or stopped). */
87
132
  get isPlaying(): boolean { return this._isPlaying; }
88
- /** @returns true if the timeline is currently paused */
133
+ /** Returns true if the timeline is currently paused. */
89
134
  get isPaused(): boolean { return this._isPaused; }
90
- /** the current time of the timeline */
135
+ /**
136
+ * The current playback time in seconds. Set this and call `evaluate()` to scrub.
137
+ * @example Scrub to a specific time
138
+ * ```ts
139
+ * director.time = 5.0;
140
+ * director.evaluate();
141
+ * ```
142
+ */
91
143
  get time(): number { return this._time; }
92
144
  set time(value: number) {
93
145
  if (typeof value === "number" && !Number.isNaN(value))
@@ -96,17 +148,32 @@ export class PlayableDirector extends Behaviour {
96
148
  console.error("INVALID TIMELINE.TIME VALUE", value, this.name)
97
149
  };
98
150
  }
99
- /** the duration of the timeline */
151
+ /** The total duration of the timeline in seconds (read from the longest track/clip). */
100
152
  get duration(): number { return this._duration; }
101
153
  set duration(value: number) { this._duration = value; }
102
- /** the weight of the timeline. Set to a value below 1 to blend with other timelines */
154
+ /**
155
+ * The blend weight of the timeline (0-1). Use values below 1 to blend
156
+ * timeline animations with other animations like those from an Animator.
157
+ */
103
158
  get weight(): number { return this._weight; };
104
159
  set weight(value: number) { this._weight = value; }
105
- /** the playback speed of the timeline */
160
+ /**
161
+ * The playback speed multiplier. Set to negative values for reverse playback.
162
+ * @example Reverse playback at double speed
163
+ * ```ts
164
+ * director.speed = -2;
165
+ * ```
166
+ */
106
167
  get speed(): number { return this._speed; }
107
168
  set speed(value: number) { this._speed = value; }
108
169
 
109
- /** When enabled the timeline will wait for audio tracks to load at the current time before starting to play */
170
+ /**
171
+ * When true, `play()` will wait for audio tracks to load and for user interaction
172
+ * before starting playback. Web browsers require user interaction (click/tap) before
173
+ * allowing audio to play - this ensures audio is synchronized with the timeline.
174
+ * Set to false if you need immediate visual playback and can tolerate audio delay.
175
+ * @default true
176
+ */
110
177
  waitForAudio: boolean = true;
111
178
 
112
179
  private _visibilityChangeEvt?: any;
@@ -223,9 +290,9 @@ export class PlayableDirector extends Behaviour {
223
290
  await delay(200);
224
291
  }
225
292
  this.invokeStateChangedMethodsOnTracks();
226
- // Update timeline in LateUpdate to give other scripts time to react to the updated state
227
- // e.g. if we animate OrbitControls look at target we want those changes to be applied in onBeforeRender
228
- // if we use onBeforeRender here it will be called *after* the regular onBeforeRender events
293
+ // Update timeline in LateUpdate to give other scripts time to react to the updated state
294
+ // e.g. if we animate OrbitControls look at target we want those changes to be applied in onBeforeRender
295
+ // if we use onBeforeRender here it will be called *after* the regular onBeforeRender events
229
296
  // which is too late
230
297
  this._internalUpdateRoutine = this.startCoroutine(this.internalUpdate(), FrameEvent.LateUpdate);
231
298
  }
@@ -762,8 +829,18 @@ export class PlayableDirector extends Behaviour {
762
829
  }
763
830
  }
764
831
 
765
- /**
766
- * Experimental interface for receiving timeline animation callbacks. Register at the PlayableDirector
832
+ /**
833
+ * Interface for receiving callbacks during timeline animation evaluation.
834
+ * Allows modification of position/rotation values before they are applied.
835
+ *
836
+ * **Registration:**
837
+ * ```ts
838
+ * director.registerAnimationCallback(this);
839
+ * // Later: director.unregisterAnimationCallback(this);
840
+ * ```
841
+ *
842
+ * @experimental This interface may change in future versions
843
+ * @see {@link PlayableDirector.registerAnimationCallback}
767
844
  */
768
845
  export interface ITimelineAnimationCallbacks {
769
846
  /**
@@ -61,12 +61,38 @@ class AnimationTriggers {
61
61
  }
62
62
 
63
63
  /**
64
- * Button is a UI component that can be clicked by the user to perform an action.
65
- * It supports different visual states such as normal, highlighted, pressed, and disabled.
66
- * You can customize the button's appearance using colors or animations for each state.
64
+ * Button is a UI component that can be clicked to trigger actions.
65
+ * Supports visual states (normal, highlighted, pressed, disabled) with
66
+ * color tints or animation transitions.
67
+ *
68
+ * **Visual transitions:**
69
+ * - `ColorTint` - Tint the button image with state colors
70
+ * - `Animation` - Trigger animator states for each button state
71
+ * - `SpriteSwap` - Swap sprites for each state (not fully supported)
72
+ *
73
+ * **Requirements:**
74
+ * - Typically paired with an {@link Image} component for visuals or any 3D object
75
+ *
76
+ * @example Listen to button clicks
77
+ * ```ts
78
+ * const button = myButton.getComponent(Button);
79
+ * button.onClick.addEventListener(() => {
80
+ * console.log("Button clicked!");
81
+ * });
82
+ * ```
83
+ *
84
+ * @example Programmatically click a button
85
+ * ```ts
86
+ * button.click(); // Triggers onClick event
87
+ * ```
88
+ *
67
89
  * @summary UI Button that can be clicked to perform actions
68
90
  * @category User Interface
69
91
  * @group Components
92
+ * @see {@link EventList} for onClick callback handling
93
+ * @see {@link Image} for button visuals
94
+ * @see {@link GraphicRaycaster} for UI interaction
95
+ * @see {@link Transition} for visual state options
70
96
  */
71
97
  export class Button extends Behaviour implements IPointerEventHandler {
72
98
 
@@ -26,12 +26,37 @@ const debugLayout = getParam("debuguilayout");
26
26
 
27
27
  /**
28
28
  * Canvas is the root component for all UI elements in a scene.
29
- * It defines the area where UI elements are rendered and manages their layout and rendering settings.
30
- * Canvases can be set to render in world space or screen space (overlay or camera).
31
- * Multiple canvases can exist in a scene, each with its own settings and hierarchy of UI elements.
29
+ * Defines the rendering area and manages layout for child UI elements.
30
+ *
31
+ * **Render modes:**
32
+ * - `WorldSpace` - UI exists in 3D space, can be viewed from any angle
33
+ * - `ScreenSpaceOverlay` - UI rendered on top of everything (HUD)
34
+ * - `ScreenSpaceCamera` - UI rendered at a distance from a specific camera
35
+ *
36
+ * **Usage:**
37
+ * All UI components ({@link Button}, {@link Text}, {@link Image}) must be
38
+ * children of a Canvas to render correctly. Multiple canvases can exist
39
+ * in a scene with different settings.
40
+ *
41
+ * **Rendering options:**
42
+ * - `renderOnTop` - Always render above other objects
43
+ * - `depthWrite` - Write to depth buffer (affects occlusion)
44
+ * - `doubleSided` - Render both sides of UI elements
45
+ *
46
+ * @example Create a world-space UI panel
47
+ * ```ts
48
+ * const canvas = panel.getComponent(Canvas);
49
+ * canvas.renderMode = RenderMode.WorldSpace;
50
+ * canvas.doubleSided = true;
51
+ * ```
52
+ *
32
53
  * @summary Root component for UI elements, managing layout and rendering settings
33
54
  * @category User Interface
34
55
  * @group Components
56
+ * @see {@link RenderMode} for rendering options
57
+ * @see {@link RectTransform} for UI layout
58
+ * @see {@link Button} for clickable UI elements
59
+ * @see {@link Text} for UI text rendering
35
60
  */
36
61
  export class Canvas extends UIRootComponent implements ICanvas {
37
62
 
@@ -12,12 +12,31 @@ class Sprite {
12
12
  }
13
13
 
14
14
  /**
15
- * Image is a UI component that displays a sprite (2D image) in the user interface.
16
- * You can set the image property to assign a texture to be displayed.
17
- * The sprite can be customized with various properties such as color tinting and pixel density.
15
+ * Image displays a sprite (2D texture) in the UI. Can be used for icons,
16
+ * backgrounds, or any visual element that needs a texture.
17
+ *
18
+ * **Properties:**
19
+ * - `image` - Direct texture assignment (convenience property)
20
+ * - `sprite` - Sprite object containing texture and rect info
21
+ * - `color` - Tint color applied to the image (inherited from Graphic)
22
+ *
23
+ * **Usage with Button:**
24
+ * Image is commonly paired with {@link Button} to create clickable
25
+ * UI elements with visual feedback via color tinting.
26
+ *
27
+ * @example Set an image texture
28
+ * ```ts
29
+ * const img = myIcon.getComponent(Image);
30
+ * img.image = myTexture;
31
+ * img.color = new RGBAColor(1, 0.5, 0.5, 1); // Red tint
32
+ * ```
33
+ *
18
34
  * @summary Display a 2D image in the UI
19
35
  * @category User Interface
20
36
  * @group Components
37
+ * @see {@link Canvas} for the UI root
38
+ * @see {@link Button} for clickable images
39
+ * @see {@link RawImage} for non-UI image display
21
40
  */
22
41
  export class Image extends MaskableGraphic {
23
42
 
@@ -7,9 +7,21 @@ import { Behaviour } from "../Component.js";
7
7
  import { EventSystem } from "./EventSystem.js";
8
8
 
9
9
 
10
- /** Derive from this class to create your own custom Raycaster
11
- * If you override awake, onEnable or onDisable, be sure to call the base class methods
12
- * Implement `performRaycast` to perform your custom raycasting logic
10
+ /**
11
+ * Base class for raycasters that detect pointer interactions.
12
+ * Derive from this class to create custom raycasting logic.
13
+ *
14
+ * **Built-in raycasters:**
15
+ * - {@link ObjectRaycaster} - Raycasts against 3D objects
16
+ * - {@link GraphicRaycaster} - Raycasts against UI elements
17
+ * - {@link SpatialGrabRaycaster} - Sphere overlap for XR grab
18
+ *
19
+ * **Important:** If you override `awake`, `onEnable`, or `onDisable`,
20
+ * call the base class methods to ensure proper registration with {@link EventSystem}.
21
+ *
22
+ * @category Interactivity
23
+ * @group Components
24
+ * @see {@link EventSystem} for the event dispatch system
13
25
  */
14
26
  export abstract class Raycaster extends Behaviour {
15
27
  awake(): void {
@@ -29,10 +41,22 @@ export abstract class Raycaster extends Behaviour {
29
41
 
30
42
 
31
43
  /**
32
- * A Raycaster that performs raycasting against its own GameObject.
44
+ * ObjectRaycaster enables pointer interactions with 3D objects.
45
+ * Add this component to any object that needs click/hover detection.
46
+ *
47
+ * **Usage:**
48
+ * Objects with ObjectRaycaster will receive pointer events when
49
+ * they implement interfaces like {@link IPointerClickHandler}.
33
50
  *
51
+ * **Note:**
52
+ * In older Needle Engine versions the ObjectRaycaster was required to be added to the Scene.
53
+ * This is no longer the case - the EventSystem will automatically handle raycasts.
54
+ *
55
+ *
34
56
  * @category Interactivity
35
57
  * @group Components
58
+ * @see {@link IPointerClickHandler} for click events
59
+ * @see {@link DragControls} for drag interactions
36
60
  */
37
61
  export class ObjectRaycaster extends Raycaster {
38
62
  private targets: Object3D[] | null = null;
@@ -73,11 +97,27 @@ export class ObjectRaycaster extends Raycaster {
73
97
 
74
98
 
75
99
  /**
76
- * A Raycaster that performs raycasting against UI elements (objects with a CanvasRenderer component).
77
- *
100
+ * GraphicRaycaster enables pointer interactions with UI elements.
101
+ * Add this to a {@link Canvas} or UI hierarchy to enable button clicks,
102
+ * hover effects, and other UI interactions.
103
+ *
104
+ * **Requirements:**
105
+ * - Must be on the same object as a Canvas or on a parent
106
+ * - UI elements need proper RectTransform setup
107
+ *
108
+ * @example Enable UI interaction
109
+ * ```ts
110
+ * // Add to Canvas object
111
+ * canvas.addComponent(GraphicRaycaster);
112
+ * // Now buttons and other UI elements will respond to clicks
113
+ * ```
114
+ *
78
115
  * @summary Raycaster for UI elements
79
116
  * @category User Interface
80
117
  * @group Components
118
+ * @see {@link Canvas} for UI root
119
+ * @see {@link Button} for clickable UI
120
+ * @see {@link EventSystem} for event handling
81
121
  */
82
122
  export class GraphicRaycaster extends ObjectRaycaster {
83
123
  // eventCamera: Camera | null = null;
@@ -91,10 +131,19 @@ export class GraphicRaycaster extends ObjectRaycaster {
91
131
  }
92
132
 
93
133
  /**
94
- * A Raycaster that performs sphere overlap raycasting for spatial grab interactions in XR.
95
- *
134
+ * SpatialGrabRaycaster enables direct grab interactions in VR/AR.
135
+ * Uses sphere overlap detection around the controller/hand position
136
+ * to allow grabbing objects by reaching into them.
137
+ *
138
+ * **Features:**
139
+ * - Active only during XR sessions
140
+ * - Can be globally disabled via `SpatialGrabRaycaster.allow`
141
+ * - Works alongside ray-based interaction
142
+ *
96
143
  * @category XR
97
144
  * @group Components
145
+ * @see {@link WebXR} for XR session management
146
+ * @see {@link DragControls} for object manipulation
98
147
  */
99
148
  export class SpatialGrabRaycaster extends Raycaster {
100
149
 
@@ -40,11 +40,33 @@ export enum FontStyle {
40
40
  }
41
41
 
42
42
  /**
43
- * Text is a UI component that displays text in the user interface.
44
- *
43
+ * Text displays text content in the UI. Supports custom fonts, colors,
44
+ * alignment, and basic rich text formatting.
45
+ *
46
+ * **Text properties:**
47
+ * - `text` - The string content to display
48
+ * - `fontSize` - Size of the text in pixels
49
+ * - `color` - Text color (inherited from Graphic)
50
+ * - `alignment` - Text anchor position (UpperLeft, MiddleCenter, etc.)
51
+ *
52
+ * **Fonts:**
53
+ * Set the `font` property to a URL pointing to a font file.
54
+ * Supports MSDF (Multi-channel Signed Distance Field) fonts for crisp rendering.
55
+ *
56
+ * @example Update text at runtime
57
+ * ```ts
58
+ * const text = myLabel.getComponent(Text);
59
+ * text.text = "Score: " + score;
60
+ * text.fontSize = 24;
61
+ * text.color = new RGBAColor(1, 1, 1, 1);
62
+ * ```
63
+ *
45
64
  * @summary Display text in the UI
46
65
  * @category User Interface
47
66
  * @group Components
67
+ * @see {@link Canvas} for the UI root
68
+ * @see {@link TextAnchor} for alignment options
69
+ * @see {@link FontStyle} for bold/italic styles
48
70
  */
49
71
  export class Text extends Graphic implements IHasAlphaFactor, ICanvasEventReceiver {
50
72
 
@@ -1,12 +1,31 @@
1
1
  import { Behaviour } from "../Component.js";
2
2
  import type { XRControllerMovement } from "./controllers/XRControllerMovement.js";
3
3
 
4
- /**
5
- * This component is just used as a marker on objects for WebXR teleportation
6
- * The {@link XRControllerMovement} component can be configured to check if the TeleportTarget component is present on an object to allow teleporting to that object.
7
- *
4
+ /**
5
+ * Marks a GameObject as a valid teleportation target for VR locomotion.
6
+ * Add this component to objects or surfaces where users should be able to teleport.
7
+ *
8
+ * **Usage:**
9
+ * - Add to floor surfaces, platforms, or designated teleport spots
10
+ * - Works with {@link XRControllerMovement} component's teleport system
11
+ * - Can be used to restrict teleportation to specific areas
12
+ *
13
+ * **Setup:**
14
+ * 1. Add this component to GameObjects that should be teleport destinations
15
+ * 2. Configure {@link XRControllerMovement} to use teleport targets (optional)
16
+ * 3. Test teleportation in VR mode
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * // Make a platform teleportable
21
+ * const platform = myPlatform.addComponent(TeleportTarget);
22
+ * ```
23
+ *
24
+ * @summary Marker component for valid VR teleportation destinations
8
25
  * @category XR
9
26
  * @group Components
27
+ * @see {@link XRControllerMovement} for VR locomotion and teleport configuration
28
+ * @see {@link WebXR} for general WebXR setup
10
29
  */
11
30
  export class TeleportTarget extends Behaviour {
12
31
 
@@ -23,12 +23,13 @@ const debug = getParam("debugwebxr");
23
23
  const debugQuicklook = getParam("debugusdz");
24
24
 
25
25
  /**
26
- * Use the WebXR component to enable VR and AR on iOS and Android in your scene. VisionOS support is also provided via QuickLook USDZ export.
26
+ * Use the WebXR component to enable VR and AR on **iOS and Android** in your scene. VisionOS support is also provided via QuickLook USDZ export.
27
27
  *
28
- * The WebXR component is a simple to use wrapper around the {@link NeedleXRSession} API and adds some additional features like creating buttons for AR, VR, enabling default movement behaviour ({@link XRControllerMovement}) and controller rendering ({@link XRControllerModel}), as well as handling AR placement and Quicklook USDZ export.
28
+ * The WebXR component is a simple to use wrapper around the {@link NeedleXRSession} API and adds some additional features like creating buttons for AR, VR, enabling default movement behaviour ({@link XRControllerMovement}) and controller rendering ({@link XRControllerModel}), as well as handling AR placement and Quicklook USDZ export.
29
29
  *
30
- * - Example: https://samples.needle.tools/collaborative-sandbox
30
+ * ![](https://cloud.needle.tools/-/media/gcj_YoSns8FivafQRiCiOQ.gif)
31
31
  *
32
+ *
32
33
  * @example Enable VR and AR support using code
33
34
  * ```ts
34
35
  * import { onStart, WebXR } from "@needle-tools/engine";
@@ -54,6 +55,13 @@ const debugQuicklook = getParam("debugusdz");
54
55
  * @summary WebXR Component for VR and AR support
55
56
  * @category XR
56
57
  * @group Components
58
+ * @see {@link NeedleXRSession} for low-level XR API
59
+ * @see {@link XRControllerMovement} for VR locomotion
60
+ * @see {@link WebARSessionRoot} for AR session configuration
61
+ * @see {@link Avatar} for networked user avatars
62
+ * @link https://engine.needle.tools/docs/xr.html
63
+ * @link https://engine.needle.tools/samples/?overlay=samples&tag=xr
64
+ * @link https://engine.needle.tools/samples/collaborative-sandbox
57
65
  */
58
66
  export class WebXR extends Behaviour {
59
67
 
@@ -6,32 +6,61 @@ import { XRFlag } from "./XRFlag.js";
6
6
 
7
7
  export const debug = getParam("debugavatar");
8
8
 
9
+ /**
10
+ * Event arguments for avatar marker creation and destruction events
11
+ */
9
12
  export type AvatarMarkerEventArgs = {
13
+ /** The AvatarMarker component instance */
10
14
  avatarMarker: AvatarMarker;
15
+ /** The GameObject that contains the avatar marker */
11
16
  gameObject: Object3D;
12
17
  }
13
18
 
14
- /**
15
- * This is used to mark an object being controlled / owned by a player
16
- * This system might be refactored and moved to a more centralized place in a future version
19
+ /**
20
+ * Marks a GameObject as being controlled or owned by a player in networked XR sessions.
21
+ * This is used internally by the networking system to identify player-controlled objects.
22
+ *
23
+ * **Note:** This is an internal marker class. For most use cases, use the {@link Avatar} component instead.
24
+ *
25
+ * @summary Internal marker for player-controlled objects in networked sessions
26
+ * @category XR
27
+ * @category Networking
28
+ * @group Components
29
+ * @see {@link Avatar} for avatar setup and configuration
17
30
  */
18
- // We might be updating this system in the future to a centralized API (PlayerView)
31
+ // We might be updating this system in the future to a centralized API (PlayerView)
19
32
  // but since currently quite a few core components rely on it, we're keeping it for now
20
33
  export class AvatarMarker extends Behaviour {
21
34
 
35
+ /**
36
+ * Get an avatar marker by index from the global list of avatar markers.
37
+ * @param index The index in the instances array
38
+ * @returns The AvatarMarker at the specified index, or null if index is out of bounds
39
+ */
22
40
  public static getAvatar(index: number): AvatarMarker | null {
23
41
  if (index >= 0 && index < AvatarMarker.instances.length)
24
42
  return AvatarMarker.instances[index];
25
43
  return null;
26
44
  }
27
45
 
46
+ /** Global list of all active AvatarMarker instances */
28
47
  public static instances: AvatarMarker[] = [];
29
48
 
49
+ /**
50
+ * Subscribe to avatar marker creation events.
51
+ * @param cb Callback function called when a new avatar marker is created
52
+ * @returns The callback function (for removal)
53
+ */
30
54
  public static onAvatarMarkerCreated(cb: (args: AvatarMarkerEventArgs) => void): Function {
31
55
  AvatarMarker._onNewAvatarMarkerAdded.push(cb);
32
56
  return cb;
33
57
  }
34
58
 
59
+ /**
60
+ * Subscribe to avatar marker destruction events.
61
+ * @param cb Callback function called when an avatar marker is destroyed
62
+ * @returns The callback function (for removal)
63
+ */
35
64
  public static onAvatarMarkerDestroyed(cb: (args: AvatarMarkerEventArgs) => void): Function {
36
65
  AvatarMarker._onAvatarMarkerDestroyed.push(cb);
37
66
  return cb;
@@ -41,9 +70,12 @@ export class AvatarMarker extends Behaviour {
41
70
  private static _onAvatarMarkerDestroyed: Array<(args: AvatarMarkerEventArgs) => void> = [];
42
71
 
43
72
 
73
+ /** The network connection ID of the player who owns this avatar */
44
74
  public connectionId!: string;
75
+ /** Reference to the avatar GameObject with optional XR flags */
45
76
  public avatar?: Object3D & { flags?: XRFlag[] }
46
77
 
78
+ /** @internal */
47
79
  awake() {
48
80
  AvatarMarker.instances.push(this);
49
81
  if (debug)
@@ -53,6 +85,7 @@ export class AvatarMarker extends Behaviour {
53
85
  cb({ avatarMarker: this, gameObject: this.gameObject });
54
86
  }
55
87
 
88
+ /** @internal */
56
89
  onDestroy() {
57
90
  AvatarMarker.instances.splice(AvatarMarker.instances.indexOf(this), 1);
58
91
 
@@ -60,6 +93,10 @@ export class AvatarMarker extends Behaviour {
60
93
  cb({ avatarMarker: this, gameObject: this.gameObject });
61
94
  }
62
95
 
96
+ /**
97
+ * Check if this avatar marker represents the local player.
98
+ * @returns True if this avatar belongs to the local player, false otherwise
99
+ */
63
100
  isLocalAvatar() {
64
101
  return this.connectionId === this.context.connection.connectionId;
65
102
  }