@needle-tools/engine 4.13.0 → 4.13.1-next.6cb1b73

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 (452) 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/gltf-progressive-BTd714P0.min.js +9 -0
  6. package/dist/gltf-progressive-CrHduHPm.umd.cjs +9 -0
  7. package/dist/{gltf-progressive-eiJCrjLb.js → gltf-progressive-CsyU_5lc.js} +364 -287
  8. package/dist/{needle-engine.bundle-CxaKFQVS.min.js → needle-engine.bundle-DRSn34Va.min.js} +109 -109
  9. package/dist/{needle-engine.bundle-J4k4znv8.umd.cjs → needle-engine.bundle-qTjHpin6.umd.cjs} +110 -110
  10. package/dist/{needle-engine.bundle-Dl3TFYyv.js → needle-engine.bundle-wB3o8RB6.js} +2655 -2130
  11. package/dist/needle-engine.d.ts +4202 -423
  12. package/dist/needle-engine.js +3 -3
  13. package/dist/needle-engine.min.js +1 -1
  14. package/dist/needle-engine.umd.cjs +1 -1
  15. package/lib/engine/engine_context.d.ts +16 -0
  16. package/lib/engine/engine_context.js +28 -2
  17. package/lib/engine/engine_context.js.map +1 -1
  18. package/lib/engine/engine_gameobject.d.ts +72 -0
  19. package/lib/engine/engine_gameobject.js +38 -0
  20. package/lib/engine/engine_gameobject.js.map +1 -1
  21. package/lib/engine/engine_input.d.ts +80 -4
  22. package/lib/engine/engine_input.js +78 -2
  23. package/lib/engine/engine_input.js.map +1 -1
  24. package/lib/engine/engine_math.d.ts +81 -2
  25. package/lib/engine/engine_math.js +68 -2
  26. package/lib/engine/engine_math.js.map +1 -1
  27. package/lib/engine/engine_networking.d.ts +181 -14
  28. package/lib/engine/engine_networking.js +181 -14
  29. package/lib/engine/engine_networking.js.map +1 -1
  30. package/lib/engine/engine_networking_auto.d.ts +35 -8
  31. package/lib/engine/engine_networking_auto.js +35 -8
  32. package/lib/engine/engine_networking_auto.js.map +1 -1
  33. package/lib/engine/engine_physics.d.ts +37 -1
  34. package/lib/engine/engine_physics.js +37 -1
  35. package/lib/engine/engine_physics.js.map +1 -1
  36. package/lib/engine/engine_physics_rapier.d.ts +78 -0
  37. package/lib/engine/engine_physics_rapier.js +78 -0
  38. package/lib/engine/engine_physics_rapier.js.map +1 -1
  39. package/lib/engine/engine_serialization_decorator.d.ts +28 -2
  40. package/lib/engine/engine_serialization_decorator.js +28 -2
  41. package/lib/engine/engine_serialization_decorator.js.map +1 -1
  42. package/lib/engine/engine_time.d.ts +23 -3
  43. package/lib/engine/engine_time.js +23 -3
  44. package/lib/engine/engine_time.js.map +1 -1
  45. package/lib/engine/engine_util_decorator.d.ts +31 -1
  46. package/lib/engine/engine_util_decorator.js +31 -1
  47. package/lib/engine/engine_util_decorator.js.map +1 -1
  48. package/lib/engine/engine_utils.d.ts +22 -5
  49. package/lib/engine/engine_utils.js +22 -5
  50. package/lib/engine/engine_utils.js.map +1 -1
  51. package/lib/engine/engine_utils_screenshot.d.ts +171 -14
  52. package/lib/engine/engine_utils_screenshot.js +65 -0
  53. package/lib/engine/engine_utils_screenshot.js.map +1 -1
  54. package/lib/engine/engine_utils_screenshot.xr.d.ts +1 -1
  55. package/lib/engine/engine_utils_screenshot.xr.js +1 -1
  56. package/lib/engine/extensions/NEEDLE_materialx.d.ts +2 -2
  57. package/lib/engine/extensions/NEEDLE_materialx.js +2 -2
  58. package/lib/engine/extensions/NEEDLE_materialx.js.map +1 -1
  59. package/lib/engine/extensions/NEEDLE_techniques_webgl.js +3 -0
  60. package/lib/engine/extensions/NEEDLE_techniques_webgl.js.map +1 -1
  61. package/lib/engine/extensions/index.d.ts +1 -1
  62. package/lib/engine/extensions/index.js +1 -1
  63. package/lib/engine/extensions/index.js.map +1 -1
  64. package/lib/engine/xr/NeedleXRSession.d.ts +5 -0
  65. package/lib/engine/xr/NeedleXRSession.js +5 -0
  66. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  67. package/lib/engine-components/AlignmentConstraint.d.ts +23 -3
  68. package/lib/engine-components/AlignmentConstraint.js +23 -3
  69. package/lib/engine-components/AlignmentConstraint.js.map +1 -1
  70. package/lib/engine-components/Animation.d.ts +42 -0
  71. package/lib/engine-components/Animation.js +36 -0
  72. package/lib/engine-components/Animation.js.map +1 -1
  73. package/lib/engine-components/Animator.d.ts +37 -4
  74. package/lib/engine-components/Animator.js +37 -4
  75. package/lib/engine-components/Animator.js.map +1 -1
  76. package/lib/engine-components/AudioListener.d.ts +1 -1
  77. package/lib/engine-components/AudioListener.js +1 -1
  78. package/lib/engine-components/AudioSource.d.ts +32 -10
  79. package/lib/engine-components/AudioSource.js +32 -10
  80. package/lib/engine-components/AudioSource.js.map +1 -1
  81. package/lib/engine-components/AxesHelper.d.ts +22 -3
  82. package/lib/engine-components/AxesHelper.js +22 -3
  83. package/lib/engine-components/AxesHelper.js.map +1 -1
  84. package/lib/engine-components/BasicIKConstraint.d.ts +27 -4
  85. package/lib/engine-components/BasicIKConstraint.js +27 -4
  86. package/lib/engine-components/BasicIKConstraint.js.map +1 -1
  87. package/lib/engine-components/Camera.d.ts +32 -2
  88. package/lib/engine-components/Camera.js +32 -2
  89. package/lib/engine-components/Camera.js.map +1 -1
  90. package/lib/engine-components/CharacterController.d.ts +68 -4
  91. package/lib/engine-components/CharacterController.js +68 -4
  92. package/lib/engine-components/CharacterController.js.map +1 -1
  93. package/lib/engine-components/Collider.d.ts +69 -12
  94. package/lib/engine-components/Collider.js +69 -12
  95. package/lib/engine-components/Collider.js.map +1 -1
  96. package/lib/engine-components/ContactShadows.d.ts +28 -6
  97. package/lib/engine-components/ContactShadows.js +33 -8
  98. package/lib/engine-components/ContactShadows.js.map +1 -1
  99. package/lib/engine-components/DeleteBox.d.ts +43 -2
  100. package/lib/engine-components/DeleteBox.js +43 -2
  101. package/lib/engine-components/DeleteBox.js.map +1 -1
  102. package/lib/engine-components/DeviceFlag.d.ts +21 -2
  103. package/lib/engine-components/DeviceFlag.js +21 -2
  104. package/lib/engine-components/DeviceFlag.js.map +1 -1
  105. package/lib/engine-components/DragControls.d.ts +32 -2
  106. package/lib/engine-components/DragControls.js +32 -2
  107. package/lib/engine-components/DragControls.js.map +1 -1
  108. package/lib/engine-components/DropListener.d.ts +33 -21
  109. package/lib/engine-components/DropListener.js +33 -21
  110. package/lib/engine-components/DropListener.js.map +1 -1
  111. package/lib/engine-components/Duplicatable.d.ts +36 -5
  112. package/lib/engine-components/Duplicatable.js +36 -5
  113. package/lib/engine-components/Duplicatable.js.map +1 -1
  114. package/lib/engine-components/EventList.d.ts +38 -10
  115. package/lib/engine-components/EventList.js +40 -12
  116. package/lib/engine-components/EventList.js.map +1 -1
  117. package/lib/engine-components/EventTrigger.d.ts +1 -1
  118. package/lib/engine-components/EventTrigger.js +1 -1
  119. package/lib/engine-components/Fog.d.ts +23 -1
  120. package/lib/engine-components/Fog.js +23 -1
  121. package/lib/engine-components/Fog.js.map +1 -1
  122. package/lib/engine-components/GridHelper.d.ts +18 -2
  123. package/lib/engine-components/GridHelper.js +18 -2
  124. package/lib/engine-components/GridHelper.js.map +1 -1
  125. package/lib/engine-components/GroundProjection.d.ts +24 -2
  126. package/lib/engine-components/GroundProjection.js +24 -2
  127. package/lib/engine-components/GroundProjection.js.map +1 -1
  128. package/lib/engine-components/Interactable.d.ts +17 -2
  129. package/lib/engine-components/Interactable.js +17 -2
  130. package/lib/engine-components/Interactable.js.map +1 -1
  131. package/lib/engine-components/Joints.d.ts +50 -7
  132. package/lib/engine-components/Joints.js +50 -7
  133. package/lib/engine-components/Joints.js.map +1 -1
  134. package/lib/engine-components/LODGroup.d.ts +36 -14
  135. package/lib/engine-components/LODGroup.js +43 -11
  136. package/lib/engine-components/LODGroup.js.map +1 -1
  137. package/lib/engine-components/Light.d.ts +30 -5
  138. package/lib/engine-components/Light.js +30 -5
  139. package/lib/engine-components/Light.js.map +1 -1
  140. package/lib/engine-components/LookAtConstraint.d.ts +22 -7
  141. package/lib/engine-components/LookAtConstraint.js +22 -7
  142. package/lib/engine-components/LookAtConstraint.js.map +1 -1
  143. package/lib/engine-components/NeedleMenu.d.ts +27 -5
  144. package/lib/engine-components/NeedleMenu.js +27 -5
  145. package/lib/engine-components/NeedleMenu.js.map +1 -1
  146. package/lib/engine-components/NestedGltf.d.ts +39 -4
  147. package/lib/engine-components/NestedGltf.js +42 -4
  148. package/lib/engine-components/NestedGltf.js.map +1 -1
  149. package/lib/engine-components/OffsetConstraint.d.ts +27 -3
  150. package/lib/engine-components/OffsetConstraint.js +27 -3
  151. package/lib/engine-components/OffsetConstraint.js.map +1 -1
  152. package/lib/engine-components/OrbitControls.d.ts +41 -3
  153. package/lib/engine-components/OrbitControls.js +41 -3
  154. package/lib/engine-components/OrbitControls.js.map +1 -1
  155. package/lib/engine-components/PlayerColor.d.ts +1 -1
  156. package/lib/engine-components/PlayerColor.js +1 -1
  157. package/lib/engine-components/ReflectionProbe.d.ts +17 -2
  158. package/lib/engine-components/ReflectionProbe.js +17 -3
  159. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  160. package/lib/engine-components/Renderer.d.ts +35 -0
  161. package/lib/engine-components/Renderer.js +36 -2
  162. package/lib/engine-components/Renderer.js.map +1 -1
  163. package/lib/engine-components/RigidBody.d.ts +57 -5
  164. package/lib/engine-components/RigidBody.js +57 -5
  165. package/lib/engine-components/RigidBody.js.map +1 -1
  166. package/lib/engine-components/SceneSwitcher.d.ts +11 -0
  167. package/lib/engine-components/SceneSwitcher.js +11 -0
  168. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  169. package/lib/engine-components/ScreenCapture.d.ts +39 -6
  170. package/lib/engine-components/ScreenCapture.js +39 -6
  171. package/lib/engine-components/ScreenCapture.js.map +1 -1
  172. package/lib/engine-components/SeeThrough.d.ts +70 -5
  173. package/lib/engine-components/SeeThrough.js +70 -5
  174. package/lib/engine-components/SeeThrough.js.map +1 -1
  175. package/lib/engine-components/ShadowCatcher.d.ts +56 -4
  176. package/lib/engine-components/ShadowCatcher.js +56 -4
  177. package/lib/engine-components/ShadowCatcher.js.map +1 -1
  178. package/lib/engine-components/Skybox.d.ts +43 -7
  179. package/lib/engine-components/Skybox.js +43 -7
  180. package/lib/engine-components/Skybox.js.map +1 -1
  181. package/lib/engine-components/SmoothFollow.d.ts +66 -7
  182. package/lib/engine-components/SmoothFollow.js +66 -7
  183. package/lib/engine-components/SmoothFollow.js.map +1 -1
  184. package/lib/engine-components/SpatialTrigger.d.ts +48 -1
  185. package/lib/engine-components/SpatialTrigger.js +48 -1
  186. package/lib/engine-components/SpatialTrigger.js.map +1 -1
  187. package/lib/engine-components/SpectatorCamera.d.ts +21 -3
  188. package/lib/engine-components/SpectatorCamera.js +21 -3
  189. package/lib/engine-components/SpectatorCamera.js.map +1 -1
  190. package/lib/engine-components/SyncedRoom.d.ts +7 -1
  191. package/lib/engine-components/SyncedRoom.js +7 -1
  192. package/lib/engine-components/SyncedRoom.js.map +1 -1
  193. package/lib/engine-components/SyncedTransform.d.ts +55 -6
  194. package/lib/engine-components/SyncedTransform.js +55 -6
  195. package/lib/engine-components/SyncedTransform.js.map +1 -1
  196. package/lib/engine-components/TransformGizmo.d.ts +30 -3
  197. package/lib/engine-components/TransformGizmo.js +30 -3
  198. package/lib/engine-components/TransformGizmo.js.map +1 -1
  199. package/lib/engine-components/VideoPlayer.d.ts +33 -6
  200. package/lib/engine-components/VideoPlayer.js +51 -6
  201. package/lib/engine-components/VideoPlayer.js.map +1 -1
  202. package/lib/engine-components/Voip.d.ts +33 -2
  203. package/lib/engine-components/Voip.js +33 -2
  204. package/lib/engine-components/Voip.js.map +1 -1
  205. package/lib/engine-components/export/usdz/USDZExporter.d.ts +47 -13
  206. package/lib/engine-components/export/usdz/USDZExporter.js +47 -13
  207. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  208. package/lib/engine-components/particlesystem/ParticleSystem.d.ts +82 -3
  209. package/lib/engine-components/particlesystem/ParticleSystem.js +82 -3
  210. package/lib/engine-components/particlesystem/ParticleSystem.js.map +1 -1
  211. package/lib/engine-components/postprocessing/Effects/Antialiasing.d.ts +1 -0
  212. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +1 -0
  213. package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
  214. package/lib/engine-components/postprocessing/Effects/BloomEffect.d.ts +1 -1
  215. package/lib/engine-components/postprocessing/Effects/BloomEffect.js +1 -1
  216. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.d.ts +1 -1
  217. package/lib/engine-components/postprocessing/Effects/ChromaticAberration.js +1 -1
  218. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.d.ts +1 -1
  219. package/lib/engine-components/postprocessing/Effects/ColorAdjustments.js +1 -1
  220. package/lib/engine-components/postprocessing/Effects/DepthOfField.d.ts +1 -1
  221. package/lib/engine-components/postprocessing/Effects/DepthOfField.js +1 -1
  222. package/lib/engine-components/postprocessing/Effects/EffectWrapper.d.ts +1 -0
  223. package/lib/engine-components/postprocessing/Effects/EffectWrapper.js +1 -0
  224. package/lib/engine-components/postprocessing/Effects/EffectWrapper.js.map +1 -1
  225. package/lib/engine-components/postprocessing/Effects/Pixelation.d.ts +1 -1
  226. package/lib/engine-components/postprocessing/Effects/Pixelation.js +1 -1
  227. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.d.ts +1 -1
  228. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.js +1 -1
  229. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.d.ts +1 -1
  230. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
  231. package/lib/engine-components/postprocessing/Effects/Sharpening.d.ts +1 -1
  232. package/lib/engine-components/postprocessing/Effects/Sharpening.js +1 -1
  233. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.d.ts +1 -1
  234. package/lib/engine-components/postprocessing/Effects/TiltShiftEffect.js +1 -1
  235. package/lib/engine-components/postprocessing/Effects/Tonemapping.d.ts +1 -1
  236. package/lib/engine-components/postprocessing/Effects/Tonemapping.js +1 -1
  237. package/lib/engine-components/postprocessing/Effects/Vignette.d.ts +1 -1
  238. package/lib/engine-components/postprocessing/Effects/Vignette.js +1 -1
  239. package/lib/engine-components/postprocessing/PostProcessingHandler.d.ts +1 -1
  240. package/lib/engine-components/postprocessing/PostProcessingHandler.js +1 -1
  241. package/lib/engine-components/postprocessing/Volume.d.ts +1 -1
  242. package/lib/engine-components/postprocessing/Volume.js +1 -1
  243. package/lib/engine-components/splines/Spline.d.ts +409 -12
  244. package/lib/engine-components/splines/Spline.js +409 -12
  245. package/lib/engine-components/splines/Spline.js.map +1 -1
  246. package/lib/engine-components/splines/SplineUtils.d.ts +1 -0
  247. package/lib/engine-components/splines/SplineUtils.js +1 -0
  248. package/lib/engine-components/splines/SplineUtils.js.map +1 -1
  249. package/lib/engine-components/splines/SplineWalker.d.ts +3 -1
  250. package/lib/engine-components/splines/SplineWalker.js +3 -1
  251. package/lib/engine-components/splines/SplineWalker.js.map +1 -1
  252. package/lib/engine-components/timeline/PlayableDirector.d.ts +103 -14
  253. package/lib/engine-components/timeline/PlayableDirector.js +95 -25
  254. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  255. package/lib/engine-components/timeline/TimelineModels.d.ts +14 -0
  256. package/lib/engine-components/timeline/TimelineModels.js +4 -0
  257. package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
  258. package/lib/engine-components/ui/Button.d.ts +29 -3
  259. package/lib/engine-components/ui/Button.js +29 -3
  260. package/lib/engine-components/ui/Button.js.map +1 -1
  261. package/lib/engine-components/ui/Canvas.d.ts +29 -4
  262. package/lib/engine-components/ui/Canvas.js +29 -4
  263. package/lib/engine-components/ui/Canvas.js.map +1 -1
  264. package/lib/engine-components/ui/CanvasGroup.d.ts +1 -1
  265. package/lib/engine-components/ui/CanvasGroup.js +1 -1
  266. package/lib/engine-components/ui/EventSystem.d.ts +1 -1
  267. package/lib/engine-components/ui/EventSystem.js +1 -1
  268. package/lib/engine-components/ui/Graphic.d.ts +1 -0
  269. package/lib/engine-components/ui/Graphic.js +1 -0
  270. package/lib/engine-components/ui/Graphic.js.map +1 -1
  271. package/lib/engine-components/ui/Image.d.ts +22 -3
  272. package/lib/engine-components/ui/Image.js +22 -3
  273. package/lib/engine-components/ui/Image.js.map +1 -1
  274. package/lib/engine-components/ui/InputField.d.ts +1 -1
  275. package/lib/engine-components/ui/InputField.js +1 -1
  276. package/lib/engine-components/ui/Layout.d.ts +3 -0
  277. package/lib/engine-components/ui/Layout.js +3 -0
  278. package/lib/engine-components/ui/Layout.js.map +1 -1
  279. package/lib/engine-components/ui/Outline.d.ts +1 -1
  280. package/lib/engine-components/ui/Outline.js +1 -1
  281. package/lib/engine-components/ui/PointerEvents.d.ts +1 -1
  282. package/lib/engine-components/ui/PointerEvents.js +1 -1
  283. package/lib/engine-components/ui/Raycaster.d.ts +55 -6
  284. package/lib/engine-components/ui/Raycaster.js +55 -6
  285. package/lib/engine-components/ui/Raycaster.js.map +1 -1
  286. package/lib/engine-components/ui/RectTransform.d.ts +1 -1
  287. package/lib/engine-components/ui/RectTransform.js +1 -1
  288. package/lib/engine-components/ui/SpatialHtml.d.ts +1 -1
  289. package/lib/engine-components/ui/SpatialHtml.js +1 -1
  290. package/lib/engine-components/ui/Text.d.ts +23 -1
  291. package/lib/engine-components/ui/Text.js +23 -1
  292. package/lib/engine-components/ui/Text.js.map +1 -1
  293. package/lib/engine-components/utils/LookAt.d.ts +1 -1
  294. package/lib/engine-components/utils/LookAt.js +1 -1
  295. package/lib/engine-components/utils/OpenURL.d.ts +2 -1
  296. package/lib/engine-components/utils/OpenURL.js +2 -1
  297. package/lib/engine-components/utils/OpenURL.js.map +1 -1
  298. package/lib/engine-components/web/Clickthrough.d.ts +116 -7
  299. package/lib/engine-components/web/Clickthrough.js +116 -7
  300. package/lib/engine-components/web/Clickthrough.js.map +1 -1
  301. package/lib/engine-components/web/CursorFollow.d.ts +172 -7
  302. package/lib/engine-components/web/CursorFollow.js +172 -7
  303. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  304. package/lib/engine-components/web/HoverAnimation.d.ts +140 -11
  305. package/lib/engine-components/web/HoverAnimation.js +140 -11
  306. package/lib/engine-components/web/HoverAnimation.js.map +1 -1
  307. package/lib/engine-components/web/ScrollFollow.d.ts +5 -1
  308. package/lib/engine-components/web/ScrollFollow.js +5 -1
  309. package/lib/engine-components/web/ScrollFollow.js.map +1 -1
  310. package/lib/engine-components/web/ViewBox.d.ts +116 -16
  311. package/lib/engine-components/web/ViewBox.js +110 -16
  312. package/lib/engine-components/web/ViewBox.js.map +1 -1
  313. package/lib/engine-components/webxr/TeleportTarget.d.ts +21 -2
  314. package/lib/engine-components/webxr/TeleportTarget.js +21 -2
  315. package/lib/engine-components/webxr/TeleportTarget.js.map +1 -1
  316. package/lib/engine-components/webxr/WebARCameraBackground.d.ts +9 -0
  317. package/lib/engine-components/webxr/WebARCameraBackground.js +9 -0
  318. package/lib/engine-components/webxr/WebARCameraBackground.js.map +1 -1
  319. package/lib/engine-components/webxr/WebXR.d.ts +11 -2
  320. package/lib/engine-components/webxr/WebXR.js +11 -2
  321. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  322. package/lib/engine-components/webxr/WebXRAvatar.d.ts +39 -2
  323. package/lib/engine-components/webxr/WebXRAvatar.js +35 -3
  324. package/lib/engine-components/webxr/WebXRAvatar.js.map +1 -1
  325. package/lib/engine-components/webxr/WebXRImageTracking.d.ts +266 -30
  326. package/lib/engine-components/webxr/WebXRImageTracking.js +266 -30
  327. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  328. package/lib/engine-components/webxr/WebXRPlaneTracking.d.ts +1 -1
  329. package/lib/engine-components/webxr/WebXRPlaneTracking.js +1 -1
  330. package/lib/engine-components/webxr/XRFlag.d.ts +29 -2
  331. package/lib/engine-components/webxr/XRFlag.js +29 -2
  332. package/lib/engine-components/webxr/XRFlag.js.map +1 -1
  333. package/package.json +3 -3
  334. package/plugins/vite/custom-element-data.js +128 -19
  335. package/src/engine/engine_context.ts +33 -3
  336. package/src/engine/engine_gameobject.ts +73 -0
  337. package/src/engine/engine_input.ts +83 -7
  338. package/src/engine/engine_math.ts +81 -2
  339. package/src/engine/engine_networking.ts +186 -17
  340. package/src/engine/engine_networking_auto.ts +36 -9
  341. package/src/engine/engine_physics.ts +41 -1
  342. package/src/engine/engine_physics_rapier.ts +81 -0
  343. package/src/engine/engine_serialization_decorator.ts +28 -2
  344. package/src/engine/engine_time.ts +23 -3
  345. package/src/engine/engine_util_decorator.ts +31 -1
  346. package/src/engine/engine_utils.ts +22 -5
  347. package/src/engine/engine_utils_screenshot.ts +241 -17
  348. package/src/engine/engine_utils_screenshot.xr.ts +1 -1
  349. package/src/engine/extensions/NEEDLE_materialx.ts +5 -4
  350. package/src/engine/extensions/NEEDLE_techniques_webgl.ts +3 -0
  351. package/src/engine/extensions/index.ts +2 -2
  352. package/src/engine/xr/NeedleXRSession.ts +5 -0
  353. package/src/engine-components/AlignmentConstraint.ts +24 -4
  354. package/src/engine-components/Animation.ts +44 -2
  355. package/src/engine-components/Animator.ts +40 -7
  356. package/src/engine-components/AudioListener.ts +1 -1
  357. package/src/engine-components/AudioSource.ts +37 -15
  358. package/src/engine-components/AxesHelper.ts +23 -4
  359. package/src/engine-components/BasicIKConstraint.ts +28 -5
  360. package/src/engine-components/Camera.ts +33 -3
  361. package/src/engine-components/CharacterController.ts +74 -7
  362. package/src/engine-components/Collider.ts +78 -21
  363. package/src/engine-components/ContactShadows.ts +41 -11
  364. package/src/engine-components/DeleteBox.ts +43 -2
  365. package/src/engine-components/DeviceFlag.ts +22 -3
  366. package/src/engine-components/DragControls.ts +32 -2
  367. package/src/engine-components/DropListener.ts +41 -29
  368. package/src/engine-components/Duplicatable.ts +37 -6
  369. package/src/engine-components/EventList.ts +43 -15
  370. package/src/engine-components/EventTrigger.ts +1 -1
  371. package/src/engine-components/Fog.ts +23 -1
  372. package/src/engine-components/GridHelper.ts +18 -2
  373. package/src/engine-components/GroundProjection.ts +25 -3
  374. package/src/engine-components/Interactable.ts +17 -2
  375. package/src/engine-components/Joints.ts +51 -8
  376. package/src/engine-components/LODGroup.ts +45 -11
  377. package/src/engine-components/Light.ts +35 -13
  378. package/src/engine-components/LookAtConstraint.ts +26 -8
  379. package/src/engine-components/NeedleMenu.ts +29 -7
  380. package/src/engine-components/NestedGltf.ts +40 -4
  381. package/src/engine-components/OffsetConstraint.ts +27 -3
  382. package/src/engine-components/OrbitControls.ts +41 -3
  383. package/src/engine-components/PlayerColor.ts +1 -1
  384. package/src/engine-components/ReflectionProbe.ts +19 -5
  385. package/src/engine-components/Renderer.ts +35 -1
  386. package/src/engine-components/RigidBody.ts +64 -8
  387. package/src/engine-components/SceneSwitcher.ts +11 -0
  388. package/src/engine-components/ScreenCapture.ts +42 -9
  389. package/src/engine-components/SeeThrough.ts +76 -9
  390. package/src/engine-components/ShadowCatcher.ts +61 -6
  391. package/src/engine-components/Skybox.ts +48 -12
  392. package/src/engine-components/SmoothFollow.ts +68 -7
  393. package/src/engine-components/SpatialTrigger.ts +51 -4
  394. package/src/engine-components/SpectatorCamera.ts +23 -5
  395. package/src/engine-components/SyncedRoom.ts +8 -2
  396. package/src/engine-components/SyncedTransform.ts +59 -10
  397. package/src/engine-components/TransformGizmo.ts +31 -4
  398. package/src/engine-components/VideoPlayer.ts +54 -6
  399. package/src/engine-components/Voip.ts +33 -2
  400. package/src/engine-components/export/usdz/USDZExporter.ts +47 -13
  401. package/src/engine-components/particlesystem/ParticleSystem.ts +84 -5
  402. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +1 -0
  403. package/src/engine-components/postprocessing/Effects/BloomEffect.ts +1 -1
  404. package/src/engine-components/postprocessing/Effects/ChromaticAberration.ts +1 -1
  405. package/src/engine-components/postprocessing/Effects/ColorAdjustments.ts +1 -1
  406. package/src/engine-components/postprocessing/Effects/DepthOfField.ts +1 -1
  407. package/src/engine-components/postprocessing/Effects/EffectWrapper.ts +1 -0
  408. package/src/engine-components/postprocessing/Effects/Pixelation.ts +1 -1
  409. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusion.ts +1 -1
  410. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
  411. package/src/engine-components/postprocessing/Effects/Sharpening.ts +1 -1
  412. package/src/engine-components/postprocessing/Effects/TiltShiftEffect.ts +1 -1
  413. package/src/engine-components/postprocessing/Effects/Tonemapping.ts +1 -1
  414. package/src/engine-components/postprocessing/Effects/Vignette.ts +1 -1
  415. package/src/engine-components/postprocessing/PostProcessingHandler.ts +1 -1
  416. package/src/engine-components/postprocessing/Volume.ts +1 -1
  417. package/src/engine-components/splines/Spline.ts +412 -14
  418. package/src/engine-components/splines/SplineUtils.ts +1 -0
  419. package/src/engine-components/splines/SplineWalker.ts +4 -2
  420. package/src/engine-components/timeline/PlayableDirector.ts +108 -27
  421. package/src/engine-components/timeline/SignalAsset.ts +1 -1
  422. package/src/engine-components/timeline/TimelineModels.ts +18 -2
  423. package/src/engine-components/ui/Button.ts +29 -3
  424. package/src/engine-components/ui/Canvas.ts +29 -4
  425. package/src/engine-components/ui/CanvasGroup.ts +2 -2
  426. package/src/engine-components/ui/EventSystem.ts +1 -1
  427. package/src/engine-components/ui/Graphic.ts +1 -0
  428. package/src/engine-components/ui/Image.ts +22 -3
  429. package/src/engine-components/ui/InputField.ts +2 -2
  430. package/src/engine-components/ui/Layout.ts +3 -0
  431. package/src/engine-components/ui/Outline.ts +1 -1
  432. package/src/engine-components/ui/PointerEvents.ts +1 -1
  433. package/src/engine-components/ui/Raycaster.ts +57 -8
  434. package/src/engine-components/ui/RectTransform.ts +2 -2
  435. package/src/engine-components/ui/SpatialHtml.ts +1 -1
  436. package/src/engine-components/ui/Text.ts +24 -2
  437. package/src/engine-components/utils/LookAt.ts +1 -1
  438. package/src/engine-components/utils/OpenURL.ts +2 -1
  439. package/src/engine-components/web/Clickthrough.ts +119 -10
  440. package/src/engine-components/web/CursorFollow.ts +175 -9
  441. package/src/engine-components/web/HoverAnimation.ts +142 -13
  442. package/src/engine-components/web/ScrollFollow.ts +5 -1
  443. package/src/engine-components/web/ViewBox.ts +118 -18
  444. package/src/engine-components/webxr/TeleportTarget.ts +23 -4
  445. package/src/engine-components/webxr/WebARCameraBackground.ts +12 -3
  446. package/src/engine-components/webxr/WebXR.ts +12 -3
  447. package/src/engine-components/webxr/WebXRAvatar.ts +41 -4
  448. package/src/engine-components/webxr/WebXRImageTracking.ts +282 -38
  449. package/src/engine-components/webxr/WebXRPlaneTracking.ts +1 -1
  450. package/src/engine-components/webxr/XRFlag.ts +30 -3
  451. package/dist/gltf-progressive-BURrJW0U.umd.cjs +0 -8
  452. package/dist/gltf-progressive-DHLDFNvQ.min.js +0 -8
@@ -17,16 +17,125 @@ onStart(ctx => {
17
17
  }
18
18
  });
19
19
  /**
20
- * ClickThrough component allows pointer events to "click through" the 3D canvas to HTML elements behind it.
20
+ * [ClickThrough](https://engine.needle.tools/docs/api/ClickThrough) enables pointer events to pass through the 3D canvas to HTML elements positioned behind it.
21
+ * This component dynamically toggles `pointer-events: none` on the canvas when no 3D objects are hit by raycasts, allowing interaction with underlying HTML content.
21
22
  *
22
- * This is useful if you have a transparent canvas overlaying HTML content and want to interact with the HTML content through the transparent areas of the canvas.
23
+ * ![](https://cloud.needle.tools/-/media/VeahihyjzpBWf4jHHVnrqw.gif)
23
24
  *
24
- * Usage Options:
25
- * - Add the ClickThrough component to any GameObject in your scene.
26
- * - Alternatively, add the `clickthrough` attribute to the `<needle-engine>` HTML element (e.g. `<needle-engine clickthrough></needle-engine>`).
25
+ * **How It Works:**
26
+ * The component listens to pointer events and performs raycasts to detect if any 3D objects are under the cursor:
27
+ * - **When 3D objects are hit**: Canvas has `pointer-events: all` (normal 3D interaction)
28
+ * - **When nothing is hit**: Canvas has `pointer-events: none` (clicks pass through to HTML)
27
29
  *
28
- * - Example https://stackblitz.com/~/github.com/needle-engine/sample-3d-over-html
29
- * @summary Allows pointer events to "click through" the 3D canvas to HTML elements behind it.
30
+ * This creates a seamless experience where users can interact with both 3D objects and underlying HTML elements
31
+ * through the same canvas area, depending on what's under the cursor.
32
+ *
33
+ * **Key Features:**
34
+ * - Automatic pointer event routing based on 3D hit detection
35
+ * - Works with both mouse and touch input
36
+ * - Supports transparent or semi-transparent canvases
37
+ * - Can be enabled via component or HTML attribute
38
+ * - No performance impact when disabled
39
+ * - Handles multi-touch scenarios correctly
40
+ *
41
+ * **Common Use Cases:**
42
+ * - Overlaying 3D elements on top of HTML content (headers, hero sections)
43
+ * - Creating "floating" 3D objects that don't block underlying UI
44
+ * - Mixed 2D/3D interfaces where both need to be interactive
45
+ * - Transparent 3D overlays on websites
46
+ * - Product showcases with clickable text/buttons beneath the 3D view
47
+ * - Interactive storytelling with mixed HTML and 3D content
48
+ *
49
+ * **Setup Options:**
50
+ *
51
+ * **Option 1: Component-based** (programmatic setup)
52
+ * ```ts
53
+ * // Add to any GameObject in your scene
54
+ * scene.addComponent(ClickThrough);
55
+ * ```
56
+ *
57
+ * **Option 2: HTML attribute** (declarative setup, recommended)
58
+ * ```html
59
+ * <!-- Enable clickthrough via HTML attribute -->
60
+ * <needle-engine clickthrough></needle-engine>
61
+ *
62
+ * <!-- Dynamically toggle clickthrough -->
63
+ * <needle-engine id="engine" clickthrough="true"></needle-engine>
64
+ * <script>
65
+ * // Disable clickthrough
66
+ * document.getElementById('engine').setAttribute('clickthrough', 'false');
67
+ * </script>
68
+ * ```
69
+ *
70
+ * @example Basic transparent canvas over HTML
71
+ * ```html
72
+ * <style>
73
+ * .container { position: relative; }
74
+ * needle-engine { position: absolute; top: 0; left: 0; }
75
+ * .html-content { position: absolute; top: 0; left: 0; }
76
+ * </style>
77
+ *
78
+ * <div class="container">
79
+ * <div class="html-content">
80
+ * <h1>Click me!</h1>
81
+ * <button>I'm clickable through the 3D canvas</button>
82
+ * </div>
83
+ * <needle-engine clickthrough src="scene.glb"></needle-engine>
84
+ * </div>
85
+ * ```
86
+ *
87
+ * @example Programmatic setup with toggle
88
+ * ```ts
89
+ * const clickthrough = scene.addComponent(ClickThrough);
90
+ *
91
+ * // Toggle clickthrough based on some condition
92
+ * function setInteractiveMode(mode: 'html' | '3d' | 'mixed') {
93
+ * switch(mode) {
94
+ * case 'html':
95
+ * clickthrough.enabled = false; // 3D blocks HTML
96
+ * break;
97
+ * case '3d':
98
+ * clickthrough.enabled = false; // 3D only
99
+ * break;
100
+ * case 'mixed':
101
+ * clickthrough.enabled = true; // Smart switching
102
+ * break;
103
+ * }
104
+ * }
105
+ * ```
106
+ *
107
+ * @example 3D header with clickable logo beneath
108
+ * ```html
109
+ * <!-- 3D animated object over a clickable logo -->
110
+ * <div class="header">
111
+ * <a href="/" class="logo">My Brand</a>
112
+ * <needle-engine clickthrough src="header-animation.glb"></needle-engine>
113
+ * </div>
114
+ * ```
115
+ *
116
+ * **Technical Notes:**
117
+ * - The component uses `pointer-events` CSS property for passthrough
118
+ * - Touch events are handled separately with a special timing mechanism
119
+ * - Only pointer ID 0 is tracked to avoid multi-touch issues
120
+ * - The component stores the previous `pointer-events` value and restores it on disable
121
+ * - Raycasts are performed on both `pointerdown` and `pointermove` events
122
+ *
123
+ * **Troubleshooting:**
124
+ * - Ensure your canvas has a transparent background if you want to see HTML beneath
125
+ * - Make sure 3D objects have colliders or are raycastable
126
+ * - If clicks aren't passing through, check that no invisible objects are blocking raycasts
127
+ * - HTML elements must be properly positioned (z-index) behind the canvas
128
+ *
129
+ * **Live Example:**
130
+ * - [3D Over HTML Sample on Stackblitz](https://stackblitz.com/~/github.com/needle-engine/sample-3d-over-html)
131
+ *
132
+ * @see {@link Context.input} - The input system used for pointer event detection
133
+ * @see {@link Context.physics.raycast} - Used to detect 3D object hits
134
+ * @see {@link ObjectRaycaster} - Controls which objects are raycastable
135
+ * @see {@link PointerEvents} - For more complex pointer interaction handling
136
+ * @see {@link NEPointerEvent} - The pointer event type used internally
137
+ *
138
+ * @summary Enables pointer events to pass through canvas to HTML elements behind it
30
139
  * @category Web
31
140
  * @group Components
32
141
  * @component
@@ -1 +1 @@
1
- {"version":3,"file":"Clickthrough.js","sourceRoot":"","sources":["../../../src/engine-components/web/Clickthrough.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,+GAA+G;AAC/G,OAAO,CAAC,GAAG,CAAC,EAAE;IACV,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IAC9D,IAAI,mBAAmB,CAAC,SAAS,CAAC,EAAE;QAChC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAClD,0BAA0B,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,EAAE;YAC5D,MAAM,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;YAC9D,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;KACN;IAED,SAAS,mBAAmB,CAAC,GAAkB;QAC3C,OAAO,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,OAAO,CAAC;IAC1D,CAAC;AACL,CAAC,CAAC,CAAC;AAGH;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAE/B,sBAAsB,GAAW,KAAK,CAAC;IAE/C,QAAQ;QACJ,mDAAmD;QACnD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,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makes the object follow the cursor (or touch) position on screen.
3
+ * [CursorFollow](https://engine.needle.tools/docs/api/CursorFollow) makes an object smoothly follow the cursor or touch position in 3D space.
4
+ * The component tracks pointer movement and updates the object's position to follow it, with optional damping for smooth motion.
4
5
  *
5
- * - Example: [Look At Cursor sample](https://engine.needle.tools/samples/look-at-cursor-interactive-3d-header/). This sample combines the CursorFollow component with a LookAt component to create an interactive 3D header that looks at the cursor.
6
+ * ![](https://cloud.needle.tools/-/media/GDspQGC_kB85Bc9IyEtr9Q.gif)
6
7
  *
7
- * @summary Makes the object follow the cursor position on screen
8
+ * **How It Works:**
9
+ * The component creates a ray from the camera through the cursor position and places the object along that ray.
10
+ * By default, it maintains the object's initial distance from the camera, creating a natural cursor-following effect
11
+ * that works consistently regardless of camera movement.
12
+ *
13
+ * **Key Features:**
14
+ * - Smooth cursor following with configurable damping
15
+ * - Works with both mouse and touch input
16
+ * - Can follow cursor across the entire page or just within the canvas
17
+ * - Maintains consistent distance from camera by default
18
+ * - Optional surface snapping using raycasts
19
+ * - Responds to camera movement automatically
20
+ *
21
+ * **Common Use Cases:**
22
+ * - Interactive 3D cursors or pointers
23
+ * - Look-at effects combined with {@link LookAtConstraint}
24
+ * - Floating UI elements that track cursor
25
+ * - Interactive product showcases
26
+ * - 3D header effects and hero sections
27
+ * - Virtual laser pointers in XR experiences
28
+ *
29
+ * @example Basic cursor follow with smooth damping
30
+ * ```ts
31
+ * const follower = new Object3D();
32
+ * follower.position.set(0, 0, -5); // Initial position 5 units from camera
33
+ * follower.addComponent(CursorFollow, {
34
+ * damping: 0.2, // Smooth following with 200ms damping
35
+ * keepDistance: true, // Maintain initial distance
36
+ * useFullPage: true // Track cursor across entire page
37
+ * });
38
+ * scene.add(follower);
39
+ * ```
40
+ *
41
+ * @example Surface-snapping cursor with raycast
42
+ * ```ts
43
+ * const cursor = new Object3D();
44
+ * cursor.addComponent(CursorFollow, {
45
+ * snapToSurface: true, // Snap to surfaces in the scene
46
+ * keepDistance: false, // Don't maintain distance when snapping
47
+ * damping: 0.1 // Quick, responsive movement
48
+ * });
49
+ * scene.add(cursor);
50
+ * ```
51
+ *
52
+ * @example Instant cursor following (no damping)
53
+ * ```ts
54
+ * gameObject.addComponent(CursorFollow, {
55
+ * damping: 0, // Instant movement
56
+ * useFullPage: false // Only track within canvas
57
+ * });
58
+ * ```
59
+ *
60
+ * @example Interactive 3D header that looks at cursor
61
+ * ```ts
62
+ * const character = loadModel("character.glb");
63
+ * const lookTarget = new Object3D();
64
+ * lookTarget.addComponent(CursorFollow, { damping: 0.3 });
65
+ * character.addComponent(LookAtConstraint, { target: lookTarget });
66
+ * scene.add(lookTarget, character);
67
+ * ```
68
+ *
69
+ * - Example: [Look At Cursor sample](https://engine.needle.tools/samples/look-at-cursor-interactive-3d-header/) - Combines CursorFollow with LookAt for an interactive 3D header
70
+ *
71
+ * @see {@link LookAtConstraint} - Commonly combined with CursorFollow for look-at effects
72
+ * @see {@link PointerEvents} - For more complex pointer interaction handling
73
+ * @see {@link DragControls} - For dragging objects in 3D space
74
+ * @see {@link OrbitControls} - For camera controls that work alongside CursorFollow
75
+ * @see {@link Context.input} - The input system that provides cursor position
76
+ * @see {@link Context.physics.raycastFromRay} - Used when snapToSurface is enabled
77
+ *
78
+ * @summary Makes objects follow the cursor/touch position in 3D space
8
79
  * @category Interactivity
80
+ * @category Web
9
81
  * @group Components
10
82
  * @component
11
83
  */
12
84
  export declare class CursorFollow extends Behaviour {
13
85
  static readonly NAME = "CursorFollow";
14
86
  /**
15
- * Damping for the movement, set to 0 for instant movement
87
+ * Damping factor controlling how smoothly the object follows the cursor (in seconds).
88
+ *
89
+ * This value determines the "lag" or smoothness of the following motion:
90
+ * - `0`: Instant movement, no damping (object snaps directly to cursor position)
91
+ * - `0.1-0.2`: Quick, responsive following with slight smoothing
92
+ * - `0.3-0.5`: Noticeable smooth trailing effect
93
+ * - `1.0+`: Slow, heavily damped movement
94
+ *
95
+ * The damping uses delta time, so the movement speed is framerate-independent and
96
+ * provides consistent behavior across different devices.
97
+ *
98
+ * **Tip:** For look-at effects, values between 0.2-0.4 typically feel most natural.
99
+ * For cursor indicators, 0.1 or less provides better responsiveness.
100
+ *
16
101
  * @default 0
17
102
  */
18
103
  damping: number;
19
104
  /**
20
- * When enabled the object will follow the cursor even outside of the needle-engine canvas. This is useful for example for look at effects where you have a small needle-engine element on your page and you want the 3D object to keep looking at the cursor even when it's outside of the canvas.
105
+ * Whether the object should track the cursor across the entire webpage or only within the canvas.
106
+ *
107
+ * **When `true` (default):**
108
+ * - The object follows the cursor anywhere on the page, even outside the canvas bounds
109
+ * - Perfect for look-at effects where you want continuous tracking
110
+ * - Great for embedded 3D elements that should feel aware of the whole page
111
+ * - Example: A 3D character in a hero section that watches the cursor as you scroll
112
+ *
113
+ * **When `false`:**
114
+ * - The object only follows the cursor when it's inside the Needle Engine canvas
115
+ * - Useful for contained experiences where the 3D element shouldn't react to external cursor movement
116
+ * - Better for multi-canvas scenarios or when you want isolated 3D interactions
117
+ *
118
+ * **Note:** When enabled, the component listens to `window.pointermove` events to track the
119
+ * full-page cursor position. When disabled, it uses the context's input system which is
120
+ * canvas-relative.
121
+ *
122
+ * @see {@link Context.input.mousePositionRC} for canvas-relative cursor position
21
123
  * @default true
22
124
  */
23
125
  useFullPage: boolean;
24
126
  /**
25
- * If true, the initial distance to the camera is maintained when following the cursor.
127
+ * Whether to maintain the object's initial distance from the camera while following the cursor.
128
+ *
129
+ * **When `true` (default):**
130
+ * - The object stays at a constant distance from the camera, moving in a spherical arc around it
131
+ * - Creates a natural "floating at cursor position" effect
132
+ * - The object's depth remains consistent as you move the cursor around
133
+ * - Perfect for cursors, pointers, or look-at targets
134
+ *
135
+ * **When `false`:**
136
+ * - The object's distance can change based on where the cursor projects in 3D space
137
+ * - More useful when combined with {@link snapToSurface} to follow surface geometry
138
+ * - Can create unusual depth behavior if not carefully configured
139
+ *
140
+ * **How it works:**
141
+ * On the first update, the component measures the distance from the object to the camera.
142
+ * This initial distance is then maintained throughout the object's lifetime (unless {@link updateDistance} is called).
143
+ * The object moves along a ray from the camera through the cursor, staying at this fixed distance.
144
+ *
145
+ * @see {@link updateDistance} to manually recalculate the distance
26
146
  * @default true
27
147
  */
28
148
  keepDistance: boolean;
29
149
  /**
30
- * If true, the object will attempt to snap to the surface of other objects in the scene using a raycast.
150
+ * When enabled, the object snaps to the surfaces of other objects in the scene using raycasting.
151
+ *
152
+ * **How it works:**
153
+ * After positioning the object at the cursor location, a raycast is performed backwards toward the camera.
154
+ * If the ray hits any surface, the object is moved to that hit point, effectively "snapping" to the surface.
155
+ *
156
+ * **Use cases:**
157
+ * - 3D paint or decal placement tools
158
+ * - Surface markers or waypoints
159
+ * - Interactive object placement in AR/VR
160
+ * - Cursor that follows terrain or mesh surfaces
161
+ *
162
+ * **Important notes:**
163
+ * - Requires objects in the scene to have colliders for raycasting to work
164
+ * - Works best with {@link keepDistance} set to `false` to allow depth changes
165
+ * - Can be combined with {@link damping} for smooth surface following
166
+ * - The raycast uses the physics system's raycast functionality
167
+ *
168
+ * **Debug mode:**
169
+ * Add `?debugcursor` to your URL to visualize the raycast hits with green debug lines.
170
+ *
171
+ * @see {@link Context.physics.raycastFromRay} for the underlying raycast implementation
172
+ * @see {@link keepDistance} should typically be false when using surface snapping
173
+ * @default false
31
174
  */
32
175
  snapToSurface: boolean;
33
176
  private _distance;
177
+ /**
178
+ * Manually recalculates the distance between the object and the camera.
179
+ *
180
+ * By default, the distance is calculated once when the component starts and then maintained
181
+ * when {@link keepDistance} is enabled. Use this method to update the reference distance
182
+ * if the camera or object has moved significantly.
183
+ *
184
+ * **Use cases:**
185
+ * - After teleporting the camera or object
186
+ * - When switching between different camera positions
187
+ * - After zoom operations that change the desired following distance
188
+ * - Dynamically adjusting the cursor's depth in response to user input
189
+ *
190
+ * @param force - If `true`, forces a recalculation even if {@link keepDistance} is enabled and distance was already set
191
+ *
192
+ * @example Recalculate distance after camera movement
193
+ * ```ts
194
+ * const cursorFollow = gameObject.getComponent(CursorFollow);
195
+ * camera.position.set(0, 0, 10); // Move camera
196
+ * cursorFollow?.updateDistance(true); // Update the reference distance
197
+ * ```
198
+ */
34
199
  updateDistance(force?: boolean): void;
35
200
  /** @internal */
36
201
  awake(): void;
@@ -12,12 +12,84 @@ import { getParam } from "../../engine/engine_utils.js";
12
12
  import { Behaviour } from "../Component.js";
13
13
  const debug = getParam("debugcursor");
14
14
  /**
15
- * The CursorFollow component makes the object follow the cursor (or touch) position on screen.
15
+ * [CursorFollow](https://engine.needle.tools/docs/api/CursorFollow) makes an object smoothly follow the cursor or touch position in 3D space.
16
+ * The component tracks pointer movement and updates the object's position to follow it, with optional damping for smooth motion.
16
17
  *
17
- * - Example: [Look At Cursor sample](https://engine.needle.tools/samples/look-at-cursor-interactive-3d-header/). This sample combines the CursorFollow component with a LookAt component to create an interactive 3D header that looks at the cursor.
18
+ * ![](https://cloud.needle.tools/-/media/GDspQGC_kB85Bc9IyEtr9Q.gif)
18
19
  *
19
- * @summary Makes the object follow the cursor position on screen
20
+ * **How It Works:**
21
+ * The component creates a ray from the camera through the cursor position and places the object along that ray.
22
+ * By default, it maintains the object's initial distance from the camera, creating a natural cursor-following effect
23
+ * that works consistently regardless of camera movement.
24
+ *
25
+ * **Key Features:**
26
+ * - Smooth cursor following with configurable damping
27
+ * - Works with both mouse and touch input
28
+ * - Can follow cursor across the entire page or just within the canvas
29
+ * - Maintains consistent distance from camera by default
30
+ * - Optional surface snapping using raycasts
31
+ * - Responds to camera movement automatically
32
+ *
33
+ * **Common Use Cases:**
34
+ * - Interactive 3D cursors or pointers
35
+ * - Look-at effects combined with {@link LookAtConstraint}
36
+ * - Floating UI elements that track cursor
37
+ * - Interactive product showcases
38
+ * - 3D header effects and hero sections
39
+ * - Virtual laser pointers in XR experiences
40
+ *
41
+ * @example Basic cursor follow with smooth damping
42
+ * ```ts
43
+ * const follower = new Object3D();
44
+ * follower.position.set(0, 0, -5); // Initial position 5 units from camera
45
+ * follower.addComponent(CursorFollow, {
46
+ * damping: 0.2, // Smooth following with 200ms damping
47
+ * keepDistance: true, // Maintain initial distance
48
+ * useFullPage: true // Track cursor across entire page
49
+ * });
50
+ * scene.add(follower);
51
+ * ```
52
+ *
53
+ * @example Surface-snapping cursor with raycast
54
+ * ```ts
55
+ * const cursor = new Object3D();
56
+ * cursor.addComponent(CursorFollow, {
57
+ * snapToSurface: true, // Snap to surfaces in the scene
58
+ * keepDistance: false, // Don't maintain distance when snapping
59
+ * damping: 0.1 // Quick, responsive movement
60
+ * });
61
+ * scene.add(cursor);
62
+ * ```
63
+ *
64
+ * @example Instant cursor following (no damping)
65
+ * ```ts
66
+ * gameObject.addComponent(CursorFollow, {
67
+ * damping: 0, // Instant movement
68
+ * useFullPage: false // Only track within canvas
69
+ * });
70
+ * ```
71
+ *
72
+ * @example Interactive 3D header that looks at cursor
73
+ * ```ts
74
+ * const character = loadModel("character.glb");
75
+ * const lookTarget = new Object3D();
76
+ * lookTarget.addComponent(CursorFollow, { damping: 0.3 });
77
+ * character.addComponent(LookAtConstraint, { target: lookTarget });
78
+ * scene.add(lookTarget, character);
79
+ * ```
80
+ *
81
+ * - Example: [Look At Cursor sample](https://engine.needle.tools/samples/look-at-cursor-interactive-3d-header/) - Combines CursorFollow with LookAt for an interactive 3D header
82
+ *
83
+ * @see {@link LookAtConstraint} - Commonly combined with CursorFollow for look-at effects
84
+ * @see {@link PointerEvents} - For more complex pointer interaction handling
85
+ * @see {@link DragControls} - For dragging objects in 3D space
86
+ * @see {@link OrbitControls} - For camera controls that work alongside CursorFollow
87
+ * @see {@link Context.input} - The input system that provides cursor position
88
+ * @see {@link Context.physics.raycastFromRay} - Used when snapToSurface is enabled
89
+ *
90
+ * @summary Makes objects follow the cursor/touch position in 3D space
20
91
  * @category Interactivity
92
+ * @category Web
21
93
  * @group Components
22
94
  * @component
23
95
  */
@@ -25,25 +97,118 @@ export class CursorFollow extends Behaviour {
25
97
  // testing this for compilation
26
98
  static NAME = "CursorFollow";
27
99
  /**
28
- * Damping for the movement, set to 0 for instant movement
100
+ * Damping factor controlling how smoothly the object follows the cursor (in seconds).
101
+ *
102
+ * This value determines the "lag" or smoothness of the following motion:
103
+ * - `0`: Instant movement, no damping (object snaps directly to cursor position)
104
+ * - `0.1-0.2`: Quick, responsive following with slight smoothing
105
+ * - `0.3-0.5`: Noticeable smooth trailing effect
106
+ * - `1.0+`: Slow, heavily damped movement
107
+ *
108
+ * The damping uses delta time, so the movement speed is framerate-independent and
109
+ * provides consistent behavior across different devices.
110
+ *
111
+ * **Tip:** For look-at effects, values between 0.2-0.4 typically feel most natural.
112
+ * For cursor indicators, 0.1 or less provides better responsiveness.
113
+ *
29
114
  * @default 0
30
115
  */
31
116
  damping = 0;
32
117
  /**
33
- * When enabled the object will follow the cursor even outside of the needle-engine canvas. This is useful for example for look at effects where you have a small needle-engine element on your page and you want the 3D object to keep looking at the cursor even when it's outside of the canvas.
118
+ * Whether the object should track the cursor across the entire webpage or only within the canvas.
119
+ *
120
+ * **When `true` (default):**
121
+ * - The object follows the cursor anywhere on the page, even outside the canvas bounds
122
+ * - Perfect for look-at effects where you want continuous tracking
123
+ * - Great for embedded 3D elements that should feel aware of the whole page
124
+ * - Example: A 3D character in a hero section that watches the cursor as you scroll
125
+ *
126
+ * **When `false`:**
127
+ * - The object only follows the cursor when it's inside the Needle Engine canvas
128
+ * - Useful for contained experiences where the 3D element shouldn't react to external cursor movement
129
+ * - Better for multi-canvas scenarios or when you want isolated 3D interactions
130
+ *
131
+ * **Note:** When enabled, the component listens to `window.pointermove` events to track the
132
+ * full-page cursor position. When disabled, it uses the context's input system which is
133
+ * canvas-relative.
134
+ *
135
+ * @see {@link Context.input.mousePositionRC} for canvas-relative cursor position
34
136
  * @default true
35
137
  */
36
138
  useFullPage = true;
37
139
  /**
38
- * If true, the initial distance to the camera is maintained when following the cursor.
140
+ * Whether to maintain the object's initial distance from the camera while following the cursor.
141
+ *
142
+ * **When `true` (default):**
143
+ * - The object stays at a constant distance from the camera, moving in a spherical arc around it
144
+ * - Creates a natural "floating at cursor position" effect
145
+ * - The object's depth remains consistent as you move the cursor around
146
+ * - Perfect for cursors, pointers, or look-at targets
147
+ *
148
+ * **When `false`:**
149
+ * - The object's distance can change based on where the cursor projects in 3D space
150
+ * - More useful when combined with {@link snapToSurface} to follow surface geometry
151
+ * - Can create unusual depth behavior if not carefully configured
152
+ *
153
+ * **How it works:**
154
+ * On the first update, the component measures the distance from the object to the camera.
155
+ * This initial distance is then maintained throughout the object's lifetime (unless {@link updateDistance} is called).
156
+ * The object moves along a ray from the camera through the cursor, staying at this fixed distance.
157
+ *
158
+ * @see {@link updateDistance} to manually recalculate the distance
39
159
  * @default true
40
160
  */
41
161
  keepDistance = true;
42
162
  /**
43
- * If true, the object will attempt to snap to the surface of other objects in the scene using a raycast.
163
+ * When enabled, the object snaps to the surfaces of other objects in the scene using raycasting.
164
+ *
165
+ * **How it works:**
166
+ * After positioning the object at the cursor location, a raycast is performed backwards toward the camera.
167
+ * If the ray hits any surface, the object is moved to that hit point, effectively "snapping" to the surface.
168
+ *
169
+ * **Use cases:**
170
+ * - 3D paint or decal placement tools
171
+ * - Surface markers or waypoints
172
+ * - Interactive object placement in AR/VR
173
+ * - Cursor that follows terrain or mesh surfaces
174
+ *
175
+ * **Important notes:**
176
+ * - Requires objects in the scene to have colliders for raycasting to work
177
+ * - Works best with {@link keepDistance} set to `false` to allow depth changes
178
+ * - Can be combined with {@link damping} for smooth surface following
179
+ * - The raycast uses the physics system's raycast functionality
180
+ *
181
+ * **Debug mode:**
182
+ * Add `?debugcursor` to your URL to visualize the raycast hits with green debug lines.
183
+ *
184
+ * @see {@link Context.physics.raycastFromRay} for the underlying raycast implementation
185
+ * @see {@link keepDistance} should typically be false when using surface snapping
186
+ * @default false
44
187
  */
45
188
  snapToSurface = false;
46
189
  _distance = -1;
190
+ /**
191
+ * Manually recalculates the distance between the object and the camera.
192
+ *
193
+ * By default, the distance is calculated once when the component starts and then maintained
194
+ * when {@link keepDistance} is enabled. Use this method to update the reference distance
195
+ * if the camera or object has moved significantly.
196
+ *
197
+ * **Use cases:**
198
+ * - After teleporting the camera or object
199
+ * - When switching between different camera positions
200
+ * - After zoom operations that change the desired following distance
201
+ * - Dynamically adjusting the cursor's depth in response to user input
202
+ *
203
+ * @param force - If `true`, forces a recalculation even if {@link keepDistance} is enabled and distance was already set
204
+ *
205
+ * @example Recalculate distance after camera movement
206
+ * ```ts
207
+ * const cursorFollow = gameObject.getComponent(CursorFollow);
208
+ * camera.position.set(0, 0, 10); // Move camera
209
+ * cursorFollow?.updateDistance(true); // Update the reference distance
210
+ * ```
211
+ */
47
212
  updateDistance(force = false) {
48
213
  if (!force && (this.keepDistance && this._distance !== -1)) {
49
214
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"CursorFollow.js","sourceRoot":"","sources":["../../../src/engine-components/web/CursorFollow.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AAEtC;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IAEvC,+BAA+B;IAC/B,MAAM,CAAU,IAAI,GAAG,cAAc,CAAC;IAEtC;;;OAGG;IAEH,OAAO,GAAW,CAAC,CAAC;IAEpB;;;OAGG;IAEH,WAAW,GAAY,IAAI,CAAC;IAE5B;;;OAGG;IAEH,YAAY,GAAY,IAAI,CAAC;IAE7B;;OAEG;IAEH,aAAa,GAAY,KAAK,CAAC;IAGvB,SAAS,GAAW,CA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