@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
@@ -15,17 +15,48 @@ const debug = getParam("debugcharactercontroller");
15
15
 
16
16
  /**
17
17
  * CharacterController adds a capsule collider and rigidbody to the object, constrains rotation, and provides movement and grounded state.
18
- * It is designed for typical character movement in 3D environments.
18
+ * It is designed for typical character movement in 3D environments.
19
+ *
20
+ * The controller automatically:
21
+ * - Creates a {@link CapsuleCollider} if one doesn't exist
22
+ * - Creates a {@link Rigidbody} if one doesn't exist
23
+ * - Locks rotation on all axes to prevent tipping over
24
+ * - Tracks ground contact for jump detection
25
+ *
26
+ * @example Basic character movement
27
+ * ```ts
28
+ * export class MyCharacter extends Behaviour {
29
+ * @serializable(CharacterController)
30
+ * controller?: CharacterController;
31
+ *
32
+ * update() {
33
+ * const input = this.context.input;
34
+ * const move = new Vector3();
35
+ * if (input.isKeyPressed("KeyW")) move.z = 0.1;
36
+ * if (input.isKeyPressed("KeyS")) move.z = -0.1;
37
+ * this.controller?.move(move);
38
+ * }
39
+ * }
40
+ * ```
41
+ *
19
42
  * @summary Character Movement Controller
20
- * @category Character
43
+ * @category Character
21
44
  * @group Components
45
+ * @see {@link CharacterControllerInput} for ready-to-use input handling
46
+ * @see {@link Rigidbody} for physics configuration
47
+ * @see {@link CapsuleCollider} for collision shape
22
48
  */
23
49
  export class CharacterController extends Behaviour {
24
50
 
51
+ /** Center offset of the capsule collider in local space */
25
52
  @serializable(Vector3)
26
53
  center: Vector3 = new Vector3(0, 0, 0);
54
+
55
+ /** Radius of the capsule collider */
27
56
  @serializable()
28
57
  radius: number = .5;
58
+
59
+ /** Height of the capsule collider */
29
60
  @serializable()
30
61
  height: number = 2;
31
62
 
@@ -70,6 +101,11 @@ export class CharacterController extends Behaviour {
70
101
  rb.lockRotationZ = true;
71
102
  }
72
103
 
104
+ /**
105
+ * Moves the character by adding the given vector to its position.
106
+ * Movement is applied directly without physics simulation.
107
+ * @param vec The movement vector to apply
108
+ */
73
109
  move(vec: Vector3) {
74
110
  this.gameObject.position.add(vec);
75
111
  }
@@ -92,9 +128,15 @@ export class CharacterController extends Behaviour {
92
128
  }
93
129
  }
94
130
 
131
+ /** Returns true if the character is currently touching the ground */
95
132
  get isGrounded(): boolean { return this._activeGroundCollisions.size > 0; }
96
133
 
97
134
  private _contactVelocity: Vector3 = new Vector3();
135
+
136
+ /**
137
+ * Returns the combined velocity of all objects the character is standing on.
138
+ * Useful for moving platforms - add this to your movement for proper platform riding.
139
+ */
98
140
  get contactVelocity(): Vector3 {
99
141
  this._contactVelocity.set(0, 0, 0);
100
142
  for (const col of this._activeGroundCollisions) {
@@ -110,31 +152,56 @@ export class CharacterController extends Behaviour {
110
152
  }
111
153
 
112
154
  /**
113
- * CharacterControllerInput handles user input to control a CharacterController.
114
- * It supports movement, looking around, jumping, and double jumping.
115
- * You can customize movement speed, rotation speed, and jump forces.
116
- * It also integrates with an Animator component for character animations.
155
+ * CharacterControllerInput handles user input to control a {@link CharacterController}.
156
+ * It supports movement, looking around, jumping, and double jumping.
157
+ *
158
+ * Default controls:
159
+ * - **W/S**: Move forward/backward
160
+ * - **A/D**: Rotate left/right
161
+ * - **Space**: Jump (supports double jump)
162
+ *
163
+ * The component automatically sets animator parameters:
164
+ * - `running` (bool): True when moving
165
+ * - `jumping` (bool): True when starting a jump
166
+ * - `doubleJump` (bool): True during double jump
167
+ * - `falling` (bool): True when falling from height
168
+ *
169
+ * @example Custom input handling
170
+ * ```ts
171
+ * const input = this.gameObject.getComponent(CharacterControllerInput);
172
+ * input?.move(new Vector2(0, 1)); // Move forward
173
+ * input?.jump(); // Trigger jump
174
+ * ```
175
+ *
117
176
  * @summary User Input for Character Controller
118
177
  * @category Character
119
178
  * @group Components
179
+ * @see {@link CharacterController} for the movement controller
180
+ * @see {@link Animator} for animation integration
120
181
  */
121
182
  export class CharacterControllerInput extends Behaviour {
122
183
 
184
+ /** The CharacterController to drive with input */
123
185
  @serializable(CharacterController)
124
186
  controller?: CharacterController;
125
187
 
188
+ /** Movement speed multiplier */
126
189
  @serializable()
127
190
  movementSpeed: number = 2;
128
191
 
192
+ /** Rotation speed multiplier */
129
193
  @serializable()
130
194
  rotationSpeed: number = 2;
131
195
 
196
+ /** Impulse force applied when jumping from ground */
132
197
  @serializable()
133
198
  jumpForce: number = 1;
134
199
 
200
+ /** Impulse force applied for the second jump (set to 0 to disable double jump) */
135
201
  @serializable()
136
202
  doubleJumpForce: number = 2;
137
203
 
204
+ /** Optional Animator for character animations */
138
205
  @serializable(Animator)
139
206
  animator?: Animator;
140
207
 
@@ -14,17 +14,43 @@ import { Behaviour } from "./Component.js";
14
14
  import { Rigidbody } from "./RigidBody.js";
15
15
 
16
16
  /**
17
- * Collider is the base class for all colliders. A collider is a physical shape that is used to detect collisions with other objects in the scene.
18
- * Colliders are used in combination with a {@link Rigidbody} to create physical interactions between objects.
19
- * Colliders are registered with the physics engine when they are enabled and removed when they are disabled.
17
+ * Collider is the base class for all physics collision shapes.
18
+ * Colliders define the physical boundary of objects for collision detection.
20
19
  *
20
+ * ![](https://cloud.needle.tools/-/media/slYWnXyaxdlrCqu8GP_lFQ.gif)
21
+ *
22
+ * **Usage with Rigidbody:**
23
+ * - Add a collider to define collision shape
24
+ * - Add a {@link Rigidbody} to the same or parent object for physics simulation
25
+ * - Without Rigidbody, collider acts as static geometry
26
+ *
27
+ * **Trigger mode:**
28
+ * Set `isTrigger = true` for detection without physical collision.
29
+ * Triggers fire `onTriggerEnter`, `onTriggerStay`, `onTriggerExit` events.
30
+ *
31
+ * **Collision filtering:**
32
+ * Use `membership` and `filter` arrays to control which objects collide.
33
+ *
34
+ * @example Add a box collider to an object
35
+ * ```ts
36
+ * const collider = myObject.addComponent(BoxCollider);
37
+ * collider.size = new Vector3(1, 2, 1);
38
+ * collider.center = new Vector3(0, 1, 0);
39
+ * ```
40
+ *
21
41
  * - Example: https://samples.needle.tools/physics-basic
22
42
  * - Example: https://samples.needle.tools/physics-playground
23
- * - Example: https://samples.needle.tools/physics-&-animation
24
- *
25
- * @summary Physics collider
26
- * @category Physics
43
+ *
44
+ * @summary Physics collider base class
45
+ * @category Physics
27
46
  * @group Components
47
+ * @see {@link BoxCollider} for box-shaped colliders
48
+ * @see {@link SphereCollider} for sphere-shaped colliders
49
+ * @see {@link CapsuleCollider} for capsule-shaped colliders
50
+ * @see {@link MeshCollider} for mesh-based colliders
51
+ * @see {@link Rigidbody} for physics simulation
52
+ * @link https://engine.needle.tools/samples/?room=needle272&overlay=samples&tag=physics
53
+ * @link https://engine.needle.tools/samples-uploads/basic-physics/?showcolliders
28
54
  */
29
55
  export abstract class Collider extends Behaviour implements ICollider {
30
56
 
@@ -116,15 +142,26 @@ export abstract class Collider extends Behaviour implements ICollider {
116
142
  }
117
143
 
118
144
  /**
119
- * SphereCollider represents a sphere-shaped collision volume.
120
- * Useful for objects that are roughly spherical in shape or need a simple collision boundary.
145
+ * SphereCollider represents a sphere-shaped collision volume.
146
+ * Efficient and suitable for balls, projectiles, or approximate collision bounds.
121
147
  *
148
+ * ![](https://cloud.needle.tools/-/media/slYWnXyaxdlrCqu8GP_lFQ.gif)
149
+ *
150
+ * @example Create a bouncing ball
151
+ * ```ts
152
+ * const sphere = ball.addComponent(SphereCollider);
153
+ * sphere.radius = 0.5;
154
+ * const rb = ball.addComponent(Rigidbody);
155
+ * rb.mass = 1;
156
+ * ```
157
+ *
122
158
  * - Example: https://samples.needle.tools/physics-basic
123
- * - Example: https://samples.needle.tools/physics-playground
124
- * - Example: https://samples.needle.tools/physics-&-animation
125
- *
159
+ *
160
+ * @summary Sphere-shaped physics collider
126
161
  * @category Physics
127
162
  * @group Components
163
+ * @see {@link Collider} for base collider functionality
164
+ * @see {@link CapsuleCollider} for elongated sphere shapes
128
165
  */
129
166
  export class SphereCollider extends Collider implements ISphereCollider {
130
167
 
@@ -167,15 +204,31 @@ export class SphereCollider extends Collider implements ISphereCollider {
167
204
  }
168
205
 
169
206
  /**
170
- * BoxCollider represents a box-shaped collision volume.
171
- * Ideal for rectangular objects or objects that need a simple cuboid collision boundary.
207
+ * BoxCollider represents a box-shaped (cuboid) collision volume.
208
+ * Most common collider type, efficient for walls, floors, crates, and rectangular objects.
172
209
  *
210
+ * ![](https://cloud.needle.tools/-/media/slYWnXyaxdlrCqu8GP_lFQ.gif)
211
+ *
212
+ * @example Create a floor collider
213
+ * ```ts
214
+ * const box = floor.addComponent(BoxCollider);
215
+ * box.size = new Vector3(10, 0.1, 10);
216
+ * box.center = new Vector3(0, -0.05, 0);
217
+ * ```
218
+ *
219
+ * @example Auto-fit to mesh geometry
220
+ * ```ts
221
+ * const collider = BoxCollider.add(myMesh, { rigidbody: true });
222
+ * // Collider size is automatically set from mesh bounds
223
+ * ```
224
+ *
173
225
  * - Example: https://samples.needle.tools/physics-basic
174
- * - Example: https://samples.needle.tools/physics-playground
175
- * - Example: https://samples.needle.tools/physics-&-animation
176
- *
226
+ *
227
+ * @summary Box-shaped physics collider
177
228
  * @category Physics
178
229
  * @group Components
230
+ * @see {@link Collider} for base collider functionality
231
+ * @see {@link SphereCollider} for sphere shapes
179
232
  */
180
233
  export class BoxCollider extends Collider implements IBoxCollider {
181
234
 
@@ -274,8 +327,10 @@ export class BoxCollider extends Collider implements IBoxCollider {
274
327
  }
275
328
 
276
329
  /**
277
- * MeshCollider creates a collision shape from a mesh geometry.
278
- * Allows for complex collision shapes that match the exact geometry of an object.
330
+ * MeshCollider creates a collision shape from a mesh geometry.
331
+ * Allows for complex collision shapes that match the exact geometry of an object.
332
+ *
333
+ * ![](https://cloud.needle.tools/-/media/slYWnXyaxdlrCqu8GP_lFQ.gif)
279
334
  *
280
335
  * - Example: https://samples.needle.tools/physics-basic
281
336
  * - Example: https://samples.needle.tools/physics-playground
@@ -362,8 +417,10 @@ export class MeshCollider extends Collider {
362
417
  }
363
418
 
364
419
  /**
365
- * CapsuleCollider represents a capsule-shaped collision volume (cylinder with hemispherical ends).
366
- * Ideal for character controllers and objects that need a rounded collision shape.
420
+ * CapsuleCollider represents a capsule-shaped collision volume (cylinder with hemispherical ends).
421
+ * Ideal for character controllers and objects that need a rounded collision shape.
422
+ *
423
+ * ![](https://cloud.needle.tools/-/media/slYWnXyaxdlrCqu8GP_lFQ.gif)
367
424
  *
368
425
  * - Example: https://samples.needle.tools/physics-basic
369
426
  * - Example: https://samples.needle.tools/physics-playground
@@ -44,19 +44,38 @@ type FitParameters = {
44
44
  // - node can simply be scaled in Y to adjust max. ground height
45
45
 
46
46
  /**
47
- * ContactShadows is a component that allows to display contact shadows in the scene. It has options for darkness, opacity and blur of the shadows.
48
- *
49
- * - Example: https://samples.needle.tools/contact-shadows
50
- *
51
- * ## Usage
52
- * You can use {@link ContactShadows.auto} to automatically create a ContactShadows instance for the scene or you can add the component to an object in the scene. Note that the scale of the object will be used to define the size of the shadow area.
53
- *
54
- * ContactShadows can also be enabled on the `<needle-engine>` web component directly by adding the `contactshadows` attribute. The value of the attribute will be used as opacity and darkness of the shadows: `<needle-engine contactshadows="0.7">`.
47
+ * ContactShadows renders proximity-based soft shadows on flat surfaces.
48
+ * Ideal for products or objects that need visual grounding without real-time shadows.
55
49
  *
50
+ * ![](https://cloud.needle.tools/-/media/87bPTNXHcsbV-An-oSEvHQ.gif)
51
+ *
52
+ * **Setup options:**
53
+ * 1. `ContactShadows.auto(context)` - Auto-create and fit to scene
54
+ * 2. Add component manually to control position and scale
55
+ * 3. HTML attribute: `<needle-engine contactshadows="0.7">`
56
+ *
57
+ * **Properties:**
58
+ * - `opacity` / `darkness` - Shadow intensity
59
+ * - `blur` - Softness of shadow edges
60
+ * - Object scale defines shadow area size
61
+ *
62
+ * **Debug:** Use `?debugcontactshadows` URL parameter.
63
+ *
64
+ *
65
+ * @example Auto-create contact shadows
66
+ * ```ts
67
+ * const shadows = ContactShadows.auto(this.context);
68
+ * shadows.opacity = 0.5;
69
+ * shadows.darkness = 0.8;
70
+ * ```
71
+ *
56
72
  * @summary Display contact shadows on the ground
57
73
  * @category Rendering
58
74
  * @group Components
59
- */
75
+ * @see {@link Light} for real-time shadow casting
76
+ * @see {@link Renderer} for material/rendering control
77
+ * @link https://engine.needle.tools/samples/contact-shadows for a demo of contact shadows
78
+ */
60
79
  export class ContactShadows extends Behaviour {
61
80
 
62
81
  private static readonly _instances: Map<Context, ContactShadows> = new Map();
@@ -74,6 +93,7 @@ export class ContactShadows extends Behaviour {
74
93
  let instance = this._instances.get(context);
75
94
  if (!instance || instance.destroyed) {
76
95
  const obj = new Object3D();
96
+ obj.name = "ContactShadows";
77
97
  instance = addComponent(obj, ContactShadows, {
78
98
  autoFit: false,
79
99
  occludeBelowGround: false
@@ -160,6 +180,7 @@ export class ContactShadows extends Behaviour {
160
180
  private occluderMesh?: Mesh;
161
181
  private blurPlane?: Mesh;
162
182
 
183
+ private planeMaterial?: MeshBasicMaterial;
163
184
  private depthMaterial?: MeshDepthMaterial;
164
185
  private horizontalBlurMaterial?: ShaderMaterial;
165
186
  private verticalBlurMaterial?: ShaderMaterial;
@@ -257,7 +278,7 @@ export class ContactShadows extends Behaviour {
257
278
  // mat.depthWrite = false;
258
279
  }
259
280
 
260
- const planeMaterial = new MeshBasicMaterial({
281
+ const planeMaterial = this.planeMaterial = new MeshBasicMaterial({
261
282
  map: this.renderTarget.texture,
262
283
  opacity: this.opacity,
263
284
  color: 0x000000,
@@ -295,7 +316,12 @@ export class ContactShadows extends Behaviour {
295
316
  this.shadowCamera = new OrthographicCamera(-1 / 2, 1 / 2, 1 / 2, -1 / 2, near, far);
296
317
  this.shadowCamera.layers.enableAll();
297
318
  this.shadowCamera.rotation.x = Math.PI / 2; // get the camera to look up
319
+ // Disable automatic matrix world updates because Camera.updateMatrixWorld
320
+ // resets scale to 1 which would break the shadow camera transform
321
+ this.shadowCamera.matrixWorldAutoUpdate = false;
298
322
  this.shadowGroup.add(this.shadowCamera);
323
+ // Update the local matrix after setting position/rotation
324
+ this.shadowCamera.updateMatrix();
299
325
 
300
326
  // like MeshDepthMaterial, but goes from black to transparent
301
327
  this.depthMaterial = new MeshDepthMaterial();
@@ -370,11 +396,16 @@ export class ContactShadows extends Behaviour {
370
396
  if (!this.renderTarget || !this.renderTargetBlur ||
371
397
  !this.depthMaterial || !this.shadowCamera ||
372
398
  !this.blurPlane || !this.shadowGroup || !this.plane ||
373
- !this.horizontalBlurMaterial || !this.verticalBlurMaterial) {
399
+ !this.horizontalBlurMaterial || !this.verticalBlurMaterial || !this.planeMaterial) {
374
400
  if (debug) console.error("ContactShadows: not initialized yet");
375
401
  return;
376
402
  }
377
403
 
404
+ // Update properties that might have been changed
405
+ this.depthMaterial.userData.darkness.value = this.darkness;
406
+ this.planeMaterial.opacity = this.opacity;
407
+
408
+
378
409
  const scene = this.context.scene;
379
410
  const renderer = this.context.renderer;
380
411
  const initialRenderTarget = renderer.getRenderTarget();
@@ -442,6 +473,15 @@ export class ContactShadows extends Behaviour {
442
473
  }
443
474
  }
444
475
 
476
+ // Manually update shadow camera's matrix world without calling Camera.updateMatrixWorld
477
+ // (which would reset scale to 1 for glTF conformance)
478
+ if (this.shadowCamera.parent) {
479
+ this.shadowCamera.matrixWorld.multiplyMatrices(this.shadowCamera.parent.matrixWorld, this.shadowCamera.matrix);
480
+ } else {
481
+ this.shadowCamera.matrixWorld.copy(this.shadowCamera.matrix);
482
+ }
483
+ this.shadowCamera.matrixWorldInverse.copy(this.shadowCamera.matrixWorld).invert();
484
+
445
485
  // render to the render target to get the depths
446
486
  renderer.setRenderTarget(this.renderTarget);
447
487
  renderer.clear();
@@ -10,11 +10,37 @@ import { UsageMarker } from "./Interactable.js";
10
10
 
11
11
  const debug = getParam("debugdeletable");
12
12
  /**
13
- * A box-shaped area that can be used to delete objects that get into it. Useful for sandbox-style builders or physics simulations.
13
+ * DeleteBox creates an invisible deletion zone that destroys objects entering it.
14
+ * Works with objects that have a {@link Deletable} component attached.
14
15
  *
16
+ * ![](https://cloud.needle.tools/-/media/J-Gmdhl214kfdjkfYViG8g.gif)
17
+ *
18
+ * **Use cases:**
19
+ * - Trash bins in sandbox builders
20
+ * - Kill zones in physics simulations
21
+ * - Cleanup areas for multiplayer scenes
22
+ *
23
+ * **Setup:**
24
+ * 1. Add DeleteBox to a GameObject with a BoxCollider-like shape
25
+ * 2. Add {@link Deletable} component to objects that should be destroyable
26
+ * 3. Objects entering the box will be destroyed (synced across network)
27
+ *
28
+ * **Debug:** Use `?debugdeletable` URL parameter to visualize deletion areas.
29
+ *
30
+ * - Example: https://engine.needle.tools/samples/collaborative-sandbox
31
+ *
32
+ * @example Create a deletion zone
33
+ * ```ts
34
+ * const trashBin = trashBinModel.addComponent(DeleteBox);
35
+ * // Objects with Deletable component will be destroyed when entering
36
+ * ```
37
+ *
15
38
  * @summary Box area that deletes objects entering it
16
39
  * @category Interactivity
17
40
  * @group Components
41
+ * @see {@link Deletable} - Add to objects that can be destroyed
42
+ * @see {@link Duplicatable} for spawning objects
43
+ * @see {@link DragControls} for moving objects
18
44
  */
19
45
  export class DeleteBox extends BoxHelperComponent {
20
46
  static _instances: DeleteBox[] = [];
@@ -29,9 +55,24 @@ export class DeleteBox extends BoxHelperComponent {
29
55
  }
30
56
  }
31
57
 
32
- /** Objects with this component can be destroyed by the {@link DeleteBox} component.
58
+ /**
59
+ * Marks a GameObject as deletable by {@link DeleteBox} zones.
60
+ * Objects with this component will be destroyed (and synced across network)
61
+ * when they enter a DeleteBox area.
62
+ *
63
+ * **Note:** Objects currently being used (with {@link UsageMarker}) are protected from deletion.
64
+ *
65
+ * @example Make an object deletable
66
+ * ```ts
67
+ * const deletable = spawnedObject.addComponent(Deletable);
68
+ * // Object can now be destroyed by entering a DeleteBox
69
+ * ```
70
+ *
71
+ * @summary Marks object as destroyable by DeleteBox
33
72
  * @category Interactivity
34
73
  * @group Components
74
+ * @see {@link DeleteBox} for the deletion trigger
75
+ * @see {@link UsageMarker} for protecting objects in use
35
76
  */
36
77
  export class Deletable extends Behaviour {
37
78
 
@@ -11,12 +11,31 @@ export enum DeviceType {
11
11
  }
12
12
 
13
13
  /**
14
- * Enables or disables the GameObject based on the device type (mobile or desktop).
15
- * You can use this to show or hide objects depending on whether the user is on a mobile device or a desktop.
16
- *
14
+ * DeviceFlag shows or hides GameObjects based on device type.
15
+ * Use for responsive 3D content - show different UI, models, or interactions
16
+ * depending on mobile vs desktop.
17
+ *
18
+ * **Device types:**
19
+ * - `Desktop` - Traditional computers with mouse/keyboard
20
+ * - `Mobile` - Phones and tablets with touch input
21
+ * - Combine with bitwise OR for multiple: `Desktop | Mobile`
22
+ *
23
+ * @example Show only on desktop
24
+ * ```ts
25
+ * const flag = myObject.addComponent(DeviceFlag);
26
+ * flag.visibleOn = DeviceType.Desktop;
27
+ * ```
28
+ *
29
+ * @example Show on both mobile and desktop
30
+ * ```ts
31
+ * flag.visibleOn = DeviceType.Desktop | DeviceType.Mobile;
32
+ * ```
33
+ *
17
34
  * @summary Show or hide GameObject based on device type
18
35
  * @category Utilities
19
36
  * @group Components
37
+ * @see {@link DeviceType} for device options
38
+ * @see {@link XRFlag} for XR-based visibility
20
39
  */
21
40
  export class DeviceFlag extends Behaviour {
22
41
 
@@ -43,12 +43,42 @@ export enum DragMode {
43
43
  }
44
44
 
45
45
  /**
46
- * DragControls allows you to drag objects around in the scene. It can be used to move objects in 2D (screen space) or 3D (world space).
47
- * Debug mode can be enabled with the URL parameter `?debugdrag`, which shows visual helpers and logs drag operations.
46
+ * [DragControls](https://engine.needle.tools/docs/api/DragControls) enables interactive dragging of objects in 2D (screen space) or 3D (world space).
47
+ *
48
+ * ![](https://cloud.needle.tools/-/media/HyrtRDLjdmndr23_SR4mYw.gif)
48
49
  *
50
+ * **Drag modes:**
51
+ * - `XZPlane` - Drag on horizontal plane (good for floor objects)
52
+ * - `Attached` - Follow pointer directly (screen plane in 2D, controller in XR)
53
+ * - `HitNormal` - Drag along the surface normal where clicked
54
+ * - `DynamicViewAngle` - Auto-switch between XZ and screen based on view angle
55
+ * - `SnapToSurfaces` - Snap to scene geometry while dragging
56
+ *
57
+ * **Features:**
58
+ * - Works across desktop, mobile, VR, and AR
59
+ * - Optional grid snapping (`snapGridResolution`)
60
+ * - Rotation preservation (`keepRotation`)
61
+ * - Automatic networking with {@link SyncedTransform}
62
+ *
63
+ *
64
+ * **Debug:** Use `?debugdrag` URL parameter for visual helpers.
65
+ *
66
+ * @example Basic draggable object
67
+ * ```ts
68
+ * const drag = myObject.addComponent(DragControls);
69
+ * drag.dragMode = DragMode.XZPlane;
70
+ * drag.snapGridResolution = 0.5; // Snap to 0.5 unit grid
71
+ * ```
72
+ *
73
+ * - Example: https://engine.needle.tools/samples/collaborative-sandbox
74
+ *
49
75
  * @summary Enables dragging of objects in 2D or 3D space
50
76
  * @category Interactivity
51
77
  * @group Components
78
+ * @see {@link DragMode} for available drag behaviors
79
+ * @see {@link Duplicatable} for drag-to-duplicate functionality
80
+ * @see {@link SyncedTransform} for networked dragging
81
+ * @see {@link ObjectRaycaster} for pointer detection
52
82
  */
53
83
  export class DragControls extends Behaviour implements IPointerEventHandler {
54
84
 
@@ -3,7 +3,6 @@ import { Box3, Object3D, Vector2, Vector3 } from "three";
3
3
  import { isDevEnvironment } from "../engine/debug/index.js";
4
4
  import { AnimationUtils } from "../engine/engine_animation.js";
5
5
  import { Context } from "../engine/engine_context.js";
6
- import { destroy } from "../engine/engine_gameobject.js";
7
6
  import { Gizmos } from "../engine/engine_gizmos.js";
8
7
  import { getLoader } from "../engine/engine_gltf.js";
9
8
  import { BlobStorage } from "../engine/engine_networking_blob.js";
@@ -18,6 +17,8 @@ import { Behaviour } from "./Component.js";
18
17
  import { EventList } from "./EventList.js";
19
18
  import { Renderer } from "./Renderer.js";
20
19
 
20
+ import type { AssetReference } from "../engine/engine_addressables.js"
21
+
21
22
  /**
22
23
  * Debug mode can be enabled with the URL parameter `?debugdroplistener`, which
23
24
  * logs additional information during drag and drop events and visualizes hit points.
@@ -109,40 +110,52 @@ class DropListenerAddedEvent<T extends DropListenerOnDropArguments> extends Cust
109
110
  */
110
111
  const blobKeyName = "blob";
111
112
 
112
- /** The DropListener component is used to listen for drag and drop events in the browser and add the dropped files to the scene
113
- * It can be used to allow users to drag and drop glTF files into the scene to add new objects.
114
- * Existing child objects will behave like placeholders and will be removed when new files are dropped.
115
- *
116
- * If {@link useNetworking} is enabled, the DropListener will automatically synchronize dropped files to other connected clients.
117
- * Enable {@link fitIntoVolume} to automatically scale dropped objects to fit within the volume defined by {@link fitVolumeSize}.
118
- *
119
- * - Example: [DropListener Sample](https://droplistener-zubcksz1veaoo.needle.run/)
120
- *
121
- * The following events are dispatched by the DropListener:
122
- * - **object-added** - dispatched when a new object is added to the scene
123
- * - **file-dropped** - dispatched when a file is dropped into the scene
124
- *
125
- * @example
126
- * ```typescript
127
- * import { DropListener, DropListenerEvents } from "@needle-tools/engine";
128
- *
129
- * const dropListener = new DropListener();
130
- *
131
- * gameObject.addComponent(dropListener);
132
- * dropListener.on(DropListenerEvents.FileDropped, (evt) => {
133
- * console.log("File dropped", evt.detail);
134
- * const file = evt.detail as File;
135
- * });
113
+ /**
114
+ * DropListener enables drag-and-drop loading of 3D files directly into your scene.
115
+ * Users can drop glTF/GLB files onto the canvas to dynamically add new objects at runtime.
136
116
  *
117
+ * [![](https://cloud.needle.tools/-/media/p5LNPTQ0u4mRXA6WiSmzIQ.gif)](https://engine.needle.tools/samples/droplistener)
118
+ *
119
+ * **Supported formats:** glTF, GLB, FBX, OBJ, USDZ, VRM
120
+ *
121
+ * **Key features:**
122
+ * - Drop files directly onto canvas or onto a specific {@link dropArea}
123
+ * - Paste URLs from clipboard (Ctrl/Cmd+V)
124
+ * - Auto-fit objects to a specific size with {@link fitIntoVolume}
125
+ * - Network sync to share dropped objects with other users
126
+ * - Special handling for GitHub and Polyhaven URLs
127
+ *
128
+ * **Events:**
129
+ * - `file-dropped` - Fired for each dropped file
130
+ * - `object-added` - Fired when object is loaded and added to scene
131
+ *
132
+ * **Debug:** Use `?debugdroplistener` URL parameter
133
+ *
134
+ * @example Listen for dropped objects
135
+ * ```ts
136
+ * const dropListener = myObject.addComponent(DropListener);
137
+ * dropListener.useNetworking = true;
138
+ * dropListener.fitIntoVolume = true;
139
+ *
137
140
  * dropListener.on(DropListenerEvents.ObjectAdded, (evt) => {
138
- * console.log("Object added", evt.detail);
139
- * const gltf = evt.detail as GLTF;
141
+ * const { object, model } = evt.detail;
142
+ * console.log("Added:", object.name);
140
143
  * });
141
144
  * ```
142
- *
143
- * @summary Component to handle drag and drop of files into the scene
145
+ *
146
+ * @example Load from URL programmatically
147
+ * ```ts
148
+ * const obj = await dropListener.loadFromURL("https://example.com/model.glb");
149
+ * ```
150
+ * Hint: We recommend to use {@link AssetReference} for preloading and referencing assets in code if you simply want to load a model.
151
+ *
152
+ * @summary Drag-and-drop file loading for 3D assets
144
153
  * @category Asset Management
145
154
  * @group Components
155
+ * @see {@link SceneSwitcher} for loading entire scenes
156
+ * @see {@link AssetReference} for preloading assets
157
+ * @see {@link SyncedTransform} for networking support
158
+ * @link https://engine.needle.tools/samples/droplistener for a live demo
146
159
  */
147
160
  export class DropListener extends Behaviour {
148
161