@needle-tools/engine 5.1.0-canary.30cc545 → 5.1.0-canary.40da791

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 (341) hide show
  1. package/.needle/generated/needle-bindings.gen.d.ts +5 -0
  2. package/CHANGELOG.md +91 -0
  3. package/SKILL.md +4 -1
  4. package/components.needle.json +1 -1
  5. package/dist/{needle-engine.bundle-d_9mSxN4.js → needle-engine.bundle-Cu2B9CsR.js} +16112 -15269
  6. package/dist/needle-engine.bundle-ZoVUaB89.umd.cjs +1733 -0
  7. package/dist/needle-engine.bundle-hBWUJPxm.min.js +1733 -0
  8. package/dist/needle-engine.d.ts +1527 -384
  9. package/dist/needle-engine.js +573 -569
  10. package/dist/needle-engine.min.js +1 -1
  11. package/dist/needle-engine.umd.cjs +1 -1
  12. package/dist/three.js +1 -0
  13. package/dist/three.min.js +21 -21
  14. package/dist/three.umd.cjs +16 -16
  15. package/lib/engine/api.d.ts +8 -1
  16. package/lib/engine/api.js +6 -0
  17. package/lib/engine/api.js.map +1 -1
  18. package/lib/engine/codegen/register_types.js +10 -18
  19. package/lib/engine/codegen/register_types.js.map +1 -1
  20. package/lib/engine/debug/debug_spatial_console.d.ts +2 -0
  21. package/lib/engine/debug/debug_spatial_console.js +10 -7
  22. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  23. package/lib/engine/engine_addressables.d.ts +2 -0
  24. package/lib/engine/engine_addressables.js +6 -3
  25. package/lib/engine/engine_addressables.js.map +1 -1
  26. package/lib/engine/engine_audio.d.ts +68 -0
  27. package/lib/engine/engine_audio.js +172 -0
  28. package/lib/engine/engine_audio.js.map +1 -1
  29. package/lib/engine/engine_camera.fit.js +16 -4
  30. package/lib/engine/engine_camera.fit.js.map +1 -1
  31. package/lib/engine/engine_components.js +1 -1
  32. package/lib/engine/engine_components.js.map +1 -1
  33. package/lib/engine/engine_context.d.ts +41 -27
  34. package/lib/engine/engine_context.js +57 -30
  35. package/lib/engine/engine_context.js.map +1 -1
  36. package/lib/engine/engine_context_eventbus.d.ts +47 -0
  37. package/lib/engine/engine_context_eventbus.js +47 -0
  38. package/lib/engine/engine_context_eventbus.js.map +1 -0
  39. package/lib/engine/engine_disposable.d.ts +172 -0
  40. package/lib/engine/engine_disposable.js +136 -0
  41. package/lib/engine/engine_disposable.js.map +1 -0
  42. package/lib/engine/engine_gameobject.d.ts +1 -10
  43. package/lib/engine/engine_gameobject.js +22 -120
  44. package/lib/engine/engine_gameobject.js.map +1 -1
  45. package/lib/engine/engine_gltf_builtin_components.js +7 -69
  46. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  47. package/lib/engine/engine_init.js +16 -1
  48. package/lib/engine/engine_init.js.map +1 -1
  49. package/lib/engine/engine_input.d.ts +24 -5
  50. package/lib/engine/engine_input.js +3 -2
  51. package/lib/engine/engine_input.js.map +1 -1
  52. package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
  53. package/lib/engine/engine_instantiate_resolve.js +372 -0
  54. package/lib/engine/engine_instantiate_resolve.js.map +1 -0
  55. package/lib/engine/engine_license.d.ts +2 -0
  56. package/lib/engine/engine_license.js +14 -6
  57. package/lib/engine/engine_license.js.map +1 -1
  58. package/lib/engine/engine_lifecycle_functions_internal.js +5 -0
  59. package/lib/engine/engine_lifecycle_functions_internal.js.map +1 -1
  60. package/lib/engine/engine_mainloop_utils.js +7 -4
  61. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  62. package/lib/engine/engine_networking.d.ts +51 -37
  63. package/lib/engine/engine_networking.js +132 -82
  64. package/lib/engine/engine_networking.js.map +1 -1
  65. package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
  66. package/lib/engine/engine_networking.transport.websocket.js +38 -0
  67. package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
  68. package/lib/engine/engine_networking_blob.js +1 -1
  69. package/lib/engine/engine_networking_blob.js.map +1 -1
  70. package/lib/engine/engine_networking_instantiate.js +2 -2
  71. package/lib/engine/engine_networking_instantiate.js.map +1 -1
  72. package/lib/engine/engine_networking_types.d.ts +39 -1
  73. package/lib/engine/engine_networking_types.js +7 -0
  74. package/lib/engine/engine_networking_types.js.map +1 -1
  75. package/lib/engine/engine_physics_rapier.d.ts +21 -3
  76. package/lib/engine/engine_physics_rapier.js +94 -25
  77. package/lib/engine/engine_physics_rapier.js.map +1 -1
  78. package/lib/engine/engine_scenedata.d.ts +13 -17
  79. package/lib/engine/engine_scenedata.js +58 -31
  80. package/lib/engine/engine_scenedata.js.map +1 -1
  81. package/lib/engine/engine_serialization_builtin_serializer.d.ts +10 -16
  82. package/lib/engine/engine_serialization_builtin_serializer.js +56 -46
  83. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  84. package/lib/engine/engine_serialization_core.d.ts +1 -0
  85. package/lib/engine/engine_serialization_core.js +7 -0
  86. package/lib/engine/engine_serialization_core.js.map +1 -1
  87. package/lib/engine/engine_ssr.d.ts +2 -0
  88. package/lib/engine/engine_ssr.js +2 -0
  89. package/lib/engine/engine_ssr.js.map +1 -1
  90. package/lib/engine/engine_types.d.ts +31 -11
  91. package/lib/engine/engine_types.js +1 -1
  92. package/lib/engine/engine_types.js.map +1 -1
  93. package/lib/engine/engine_util_decorator.js +7 -2
  94. package/lib/engine/engine_util_decorator.js.map +1 -1
  95. package/lib/engine/engine_utils.d.ts +1 -1
  96. package/lib/engine/engine_utils.js +19 -5
  97. package/lib/engine/engine_utils.js.map +1 -1
  98. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  99. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
  100. package/lib/engine/webcomponents/jsx.d.ts +51 -0
  101. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  102. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +3 -4
  103. package/lib/engine/webcomponents/needle menu/needle-menu.js +1 -1
  104. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  105. package/lib/engine/webcomponents/needle-button.js.map +1 -1
  106. package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
  107. package/lib/engine/webcomponents/needle-engine.js +1 -1
  108. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  109. package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
  110. package/lib/engine/xr/NeedleXRSession.js +50 -14
  111. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  112. package/lib/engine/xr/events.d.ts +1 -1
  113. package/lib/engine/xr/events.js.map +1 -1
  114. package/lib/engine-components/Animation.js +17 -16
  115. package/lib/engine-components/Animation.js.map +1 -1
  116. package/lib/engine-components/AnimationBuilder.d.ts +158 -0
  117. package/lib/engine-components/AnimationBuilder.js +305 -0
  118. package/lib/engine-components/AnimationBuilder.js.map +1 -0
  119. package/lib/engine-components/Animator.d.ts +6 -0
  120. package/lib/engine-components/Animator.js +23 -13
  121. package/lib/engine-components/Animator.js.map +1 -1
  122. package/lib/engine-components/AnimatorController.builder.d.ts +191 -0
  123. package/lib/engine-components/AnimatorController.builder.js +263 -0
  124. package/lib/engine-components/AnimatorController.builder.js.map +1 -0
  125. package/lib/engine-components/AnimatorController.d.ts +4 -119
  126. package/lib/engine-components/AnimatorController.js +37 -233
  127. package/lib/engine-components/AnimatorController.js.map +1 -1
  128. package/lib/engine-components/AudioSource.d.ts +19 -3
  129. package/lib/engine-components/AudioSource.js +121 -68
  130. package/lib/engine-components/AudioSource.js.map +1 -1
  131. package/lib/engine-components/Collider.d.ts +18 -9
  132. package/lib/engine-components/Collider.js +61 -14
  133. package/lib/engine-components/Collider.js.map +1 -1
  134. package/lib/engine-components/Component.d.ts +72 -9
  135. package/lib/engine-components/Component.js +114 -10
  136. package/lib/engine-components/Component.js.map +1 -1
  137. package/lib/engine-components/ContactShadows.d.ts +1 -0
  138. package/lib/engine-components/ContactShadows.js +14 -1
  139. package/lib/engine-components/ContactShadows.js.map +1 -1
  140. package/lib/engine-components/DragControls.d.ts +7 -0
  141. package/lib/engine-components/DragControls.js +19 -7
  142. package/lib/engine-components/DragControls.js.map +1 -1
  143. package/lib/engine-components/DropListener.js +3 -0
  144. package/lib/engine-components/DropListener.js.map +1 -1
  145. package/lib/engine-components/EventList.d.ts +31 -9
  146. package/lib/engine-components/EventList.js +37 -76
  147. package/lib/engine-components/EventList.js.map +1 -1
  148. package/lib/engine-components/Joints.d.ts +4 -2
  149. package/lib/engine-components/Joints.js +19 -3
  150. package/lib/engine-components/Joints.js.map +1 -1
  151. package/lib/engine-components/Light.d.ts +6 -8
  152. package/lib/engine-components/Light.js +48 -27
  153. package/lib/engine-components/Light.js.map +1 -1
  154. package/lib/engine-components/Networking.d.ts +1 -1
  155. package/lib/engine-components/Networking.js +1 -1
  156. package/lib/engine-components/OrbitControls.d.ts +0 -2
  157. package/lib/engine-components/OrbitControls.js +30 -12
  158. package/lib/engine-components/OrbitControls.js.map +1 -1
  159. package/lib/engine-components/ReflectionProbe.js +2 -0
  160. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  161. package/lib/engine-components/RigidBody.d.ts +12 -4
  162. package/lib/engine-components/RigidBody.js +18 -4
  163. package/lib/engine-components/RigidBody.js.map +1 -1
  164. package/lib/engine-components/SceneSwitcher.js +3 -0
  165. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  166. package/lib/engine-components/SeeThrough.js +2 -2
  167. package/lib/engine-components/SeeThrough.js.map +1 -1
  168. package/lib/engine-components/api.d.ts +2 -1
  169. package/lib/engine-components/api.js +2 -1
  170. package/lib/engine-components/api.js.map +1 -1
  171. package/lib/engine-components/codegen/components.d.ts +7 -13
  172. package/lib/engine-components/codegen/components.js +7 -13
  173. package/lib/engine-components/codegen/components.js.map +1 -1
  174. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
  175. package/lib/engine-components/postprocessing/VolumeParameter.d.ts +2 -0
  176. package/lib/engine-components/postprocessing/VolumeParameter.js +4 -1
  177. package/lib/engine-components/postprocessing/VolumeParameter.js.map +1 -1
  178. package/lib/engine-components/timeline/PlayableDirector.d.ts +21 -11
  179. package/lib/engine-components/timeline/PlayableDirector.js +75 -67
  180. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  181. package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
  182. package/lib/engine-components/timeline/SignalAsset.js +1 -0
  183. package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
  184. package/lib/engine-components/timeline/TimelineBuilder.d.ts +413 -0
  185. package/lib/engine-components/timeline/TimelineBuilder.js +506 -0
  186. package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
  187. package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
  188. package/lib/engine-components/timeline/TimelineModels.js +3 -0
  189. package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
  190. package/lib/engine-components/timeline/TimelineTracks.d.ts +37 -6
  191. package/lib/engine-components/timeline/TimelineTracks.js +92 -26
  192. package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
  193. package/lib/engine-components/timeline/index.d.ts +2 -1
  194. package/lib/engine-components/timeline/index.js +2 -0
  195. package/lib/engine-components/timeline/index.js.map +1 -1
  196. package/lib/engine-components/ui/Canvas.d.ts +1 -1
  197. package/lib/engine-components/ui/Canvas.js +2 -8
  198. package/lib/engine-components/ui/Canvas.js.map +1 -1
  199. package/lib/engine-components/ui/Text.d.ts +1 -0
  200. package/lib/engine-components/ui/Text.js +10 -7
  201. package/lib/engine-components/ui/Text.js.map +1 -1
  202. package/lib/engine-components/web/CursorFollow.d.ts +0 -1
  203. package/lib/engine-components/web/CursorFollow.js +21 -13
  204. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  205. package/lib/engine-components/webxr/WebXRImageTracking.js +4 -0
  206. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  207. package/lib/needle-engine.d.ts +2 -0
  208. package/lib/needle-engine.js +2 -0
  209. package/lib/needle-engine.js.map +1 -1
  210. package/package.json +3 -83
  211. package/plugins/common/license.js +5 -2
  212. package/plugins/common/worker.js +9 -4
  213. package/plugins/dts-generator/dts.codegen.js +255 -50
  214. package/plugins/dts-generator/dts.scan.js +37 -9
  215. package/plugins/dts-generator/dts.writer.js +1 -1
  216. package/plugins/dts-generator/glb.discovery.js +140 -23
  217. package/plugins/dts-generator/glb.extractor.js +48 -8
  218. package/plugins/dts-generator/glb.reader.js +80 -27
  219. package/plugins/dts-generator/index.js +1 -1
  220. package/plugins/types/needle-bindings.d.ts +25 -14
  221. package/plugins/types/userconfig.d.ts +12 -0
  222. package/plugins/vite/asap.js +18 -9
  223. package/plugins/vite/dependencies.js +29 -10
  224. package/plugins/vite/dependency-watcher.d.ts +2 -2
  225. package/plugins/vite/dependency-watcher.js +5 -6
  226. package/plugins/vite/drop.d.ts +2 -2
  227. package/plugins/vite/drop.js +3 -4
  228. package/plugins/vite/dts-generator.d.ts +2 -2
  229. package/plugins/vite/dts-generator.js +43 -9
  230. package/plugins/vite/editor-connection.js +3 -3
  231. package/plugins/vite/index.d.ts +9 -3
  232. package/plugins/vite/index.js +23 -10
  233. package/plugins/vite/license.js +19 -1
  234. package/plugins/vite/local-files-core.js +3 -3
  235. package/plugins/vite/local-files-utils.d.ts +3 -1
  236. package/plugins/vite/local-files-utils.js +29 -5
  237. package/plugins/vite/meta.js +4 -2
  238. package/plugins/vite/poster.d.ts +2 -2
  239. package/plugins/vite/poster.js +3 -5
  240. package/plugins/vite/reload.d.ts +2 -2
  241. package/plugins/vite/reload.js +23 -23
  242. package/plugins/vite/server.js +2 -1
  243. package/src/engine/api.ts +11 -1
  244. package/src/engine/codegen/register_types.ts +10 -18
  245. package/src/engine/debug/debug_spatial_console.ts +10 -7
  246. package/src/engine/engine_addressables.ts +6 -3
  247. package/src/engine/engine_audio.ts +184 -0
  248. package/src/engine/engine_camera.fit.ts +15 -4
  249. package/src/engine/engine_components.ts +1 -1
  250. package/src/engine/engine_context.ts +67 -37
  251. package/src/engine/engine_context_eventbus.ts +73 -0
  252. package/src/engine/engine_disposable.ts +214 -0
  253. package/src/engine/engine_gameobject.ts +54 -159
  254. package/src/engine/engine_gltf_builtin_components.ts +7 -76
  255. package/src/engine/engine_init.ts +15 -1
  256. package/src/engine/engine_input.ts +28 -7
  257. package/src/engine/engine_instantiate_resolve.ts +407 -0
  258. package/src/engine/engine_license.ts +12 -10
  259. package/src/engine/engine_lifecycle_functions_internal.ts +7 -0
  260. package/src/engine/engine_mainloop_utils.ts +7 -4
  261. package/src/engine/engine_networking.transport.websocket.ts +45 -0
  262. package/src/engine/engine_networking.ts +161 -137
  263. package/src/engine/engine_networking_blob.ts +1 -1
  264. package/src/engine/engine_networking_instantiate.ts +2 -2
  265. package/src/engine/engine_networking_types.ts +41 -1
  266. package/src/engine/engine_physics_rapier.ts +102 -33
  267. package/src/engine/engine_scenedata.ts +56 -30
  268. package/src/engine/engine_serialization_builtin_serializer.ts +64 -52
  269. package/src/engine/engine_serialization_core.ts +9 -0
  270. package/src/engine/engine_ssr.ts +3 -0
  271. package/src/engine/engine_types.ts +48 -27
  272. package/src/engine/engine_util_decorator.ts +7 -2
  273. package/src/engine/engine_utils.ts +16 -5
  274. package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  275. package/src/engine/webcomponents/jsx.d.ts +51 -0
  276. package/src/engine/webcomponents/logo-element.ts +1 -0
  277. package/src/engine/webcomponents/needle menu/needle-menu.ts +3 -2
  278. package/src/engine/webcomponents/needle-button.ts +1 -0
  279. package/src/engine/webcomponents/needle-engine.ts +11 -4
  280. package/src/engine/xr/NeedleXRSession.ts +48 -13
  281. package/src/engine/xr/events.ts +1 -1
  282. package/src/engine-components/Animation.ts +19 -16
  283. package/src/engine-components/AnimationBuilder.ts +472 -0
  284. package/src/engine-components/Animator.ts +24 -12
  285. package/src/engine-components/AnimatorController.builder.ts +387 -0
  286. package/src/engine-components/AnimatorController.ts +24 -292
  287. package/src/engine-components/AudioSource.ts +130 -79
  288. package/src/engine-components/Collider.ts +66 -18
  289. package/src/engine-components/Component.ts +118 -20
  290. package/src/engine-components/ContactShadows.ts +15 -1
  291. package/src/engine-components/DragControls.ts +18 -11
  292. package/src/engine-components/DropListener.ts +3 -0
  293. package/src/engine-components/EventList.ts +45 -83
  294. package/src/engine-components/Joints.ts +20 -4
  295. package/src/engine-components/Light.ts +49 -27
  296. package/src/engine-components/Networking.ts +1 -1
  297. package/src/engine-components/OrbitControls.ts +34 -14
  298. package/src/engine-components/ReflectionProbe.ts +2 -0
  299. package/src/engine-components/RigidBody.ts +18 -4
  300. package/src/engine-components/SceneSwitcher.ts +3 -0
  301. package/src/engine-components/SeeThrough.ts +2 -2
  302. package/src/engine-components/api.ts +2 -1
  303. package/src/engine-components/codegen/components.ts +7 -13
  304. package/src/engine-components/postprocessing/VolumeParameter.ts +4 -1
  305. package/src/engine-components/timeline/PlayableDirector.ts +83 -81
  306. package/src/engine-components/timeline/SignalAsset.ts +4 -1
  307. package/src/engine-components/timeline/TimelineBuilder.ts +824 -0
  308. package/src/engine-components/timeline/TimelineModels.ts +5 -1
  309. package/src/engine-components/timeline/TimelineTracks.ts +96 -27
  310. package/src/engine-components/timeline/index.ts +2 -1
  311. package/src/engine-components/ui/Canvas.ts +2 -8
  312. package/src/engine-components/ui/Text.ts +12 -8
  313. package/src/engine-components/web/CursorFollow.ts +21 -14
  314. package/src/engine-components/webxr/WebXRImageTracking.ts +2 -0
  315. package/src/needle-engine.ts +3 -0
  316. package/dist/needle-engine.bundle-BMlLSACE.umd.cjs +0 -1732
  317. package/dist/needle-engine.bundle-BXPPQRer.min.js +0 -1732
  318. package/lib/engine-components/AvatarLoader.d.ts +0 -80
  319. package/lib/engine-components/AvatarLoader.js +0 -232
  320. package/lib/engine-components/AvatarLoader.js.map +0 -1
  321. package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
  322. package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
  323. package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
  324. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
  325. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
  326. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
  327. package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
  328. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
  329. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
  330. package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
  331. package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
  332. package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
  333. package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
  334. package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
  335. package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
  336. package/src/engine-components/AvatarLoader.ts +0 -264
  337. package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
  338. package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
  339. package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
  340. package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
  341. package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
@@ -0,0 +1,263 @@
1
+ import { AnimatorConditionMode, AnimatorControllerParameterType } from "../engine/extensions/NEEDLE_animator_controller_model.js";
2
+ import { InstantiateIdProvider } from "../engine/engine_networking_instantiate.js";
3
+ import { AnimatorController } from "./AnimatorController.js";
4
+ import { resolveClipSource, track as trackFn } from "./AnimationBuilder.js";
5
+ function conditionModeToEnum(mode) {
6
+ switch (mode) {
7
+ case "if": return AnimatorConditionMode.If;
8
+ case "ifNot": return AnimatorConditionMode.IfNot;
9
+ case "greater": return AnimatorConditionMode.Greater;
10
+ case "less": return AnimatorConditionMode.Less;
11
+ case "equals": return AnimatorConditionMode.Equals;
12
+ case "notEqual": return AnimatorConditionMode.NotEqual;
13
+ }
14
+ }
15
+ /**
16
+ * A fluent builder for creating {@link AnimatorController} instances from code.
17
+ *
18
+ * Use {@link AnimatorControllerBuilder.create} or {@link AnimatorController.build} to create a new builder.
19
+ *
20
+ * The builder tracks state names and parameter types through the fluent chain,
21
+ * providing autocomplete for state names in `.transition()` and type-aware
22
+ * `.condition()` calls (e.g., trigger parameters don't require a mode argument).
23
+ *
24
+ * @example With pre-built AnimationClips
25
+ * ```ts
26
+ * const controller = AnimatorControllerBuilder.create("CharacterController")
27
+ * .floatParameter("Speed", 0)
28
+ * .triggerParameter("Jump")
29
+ * .state("Idle", { clip: idleClip, loop: true })
30
+ * .state("Walk", { clip: walkClip, loop: true })
31
+ * .state("Jump", { clip: jumpClip })
32
+ * .transition("Idle", "Walk", { duration: 0.25 })
33
+ * .condition("Speed", "greater", 0.1)
34
+ * .transition("Walk", "Idle", { duration: 0.25 })
35
+ * .condition("Speed", "less", 0.1)
36
+ * .transition("*", "Jump", { duration: 0.1 })
37
+ * .condition("Jump")
38
+ * .transition("Jump", "Idle", { hasExitTime: true, exitTime: 0.9, duration: 0.25 })
39
+ * .build();
40
+ * ```
41
+ *
42
+ * @example With inline tracks (no pre-built clips needed)
43
+ * ```ts
44
+ * const controller = AnimatorControllerBuilder.create("Door")
45
+ * .boolParameter("Open", false)
46
+ * .state("Closed", { loop: true })
47
+ * .track(door, "position", { from: [0, 0, 0], to: [0, 0, 0], duration: 1 })
48
+ * .state("Open", { loop: true })
49
+ * .track(door, "position", { from: [0, 0, 0], to: [2, 0, 0], duration: 1 })
50
+ * .track(light, "intensity", { from: 0, to: 5, duration: 1 })
51
+ * .transition("Closed", "Open", { duration: 0.25 })
52
+ * .condition("Open", "if")
53
+ * .transition("Open", "Closed", { duration: 0.25 })
54
+ * .condition("Open", "ifNot")
55
+ * .build(room);
56
+ * ```
57
+ *
58
+ * @typeParam TStates - Union of state names added via `.state()`. Used for autocomplete and validation in `.transition()` and `.defaultState()`.
59
+ * @typeParam TParams - Record mapping parameter names to their types (`"trigger"`, `"bool"`, `"float"`, `"int"`). Used for type-aware `.condition()` overloads.
60
+ *
61
+ * @category Animation and Sequencing
62
+ * @group Utilities
63
+ */
64
+ export class AnimatorControllerBuilder {
65
+ _name;
66
+ _parameters = [];
67
+ _states = [];
68
+ _anyStateTransitions = [];
69
+ _defaultStateName = null;
70
+ _lastTransition = null;
71
+ _lastState = null;
72
+ /**
73
+ * Creates a new AnimatorControllerBuilder instance.
74
+ * @param name - Optional name for the controller
75
+ */
76
+ static create(name) {
77
+ return new AnimatorControllerBuilder(name);
78
+ }
79
+ constructor(name) {
80
+ this._name = name ?? "AnimatorController";
81
+ }
82
+ /** Adds a float parameter */
83
+ floatParameter(name, defaultValue = 0) {
84
+ this._parameters.push({ name, hash: this._parameters.length, type: AnimatorControllerParameterType.Float, value: defaultValue });
85
+ return this;
86
+ }
87
+ /** Adds an integer parameter */
88
+ intParameter(name, defaultValue = 0) {
89
+ this._parameters.push({ name, hash: this._parameters.length, type: AnimatorControllerParameterType.Int, value: defaultValue });
90
+ return this;
91
+ }
92
+ /** Adds a boolean parameter */
93
+ boolParameter(name, defaultValue = false) {
94
+ this._parameters.push({ name, hash: this._parameters.length, type: AnimatorControllerParameterType.Bool, value: defaultValue });
95
+ return this;
96
+ }
97
+ /** Adds a trigger parameter */
98
+ triggerParameter(name) {
99
+ this._parameters.push({ name, hash: this._parameters.length, type: AnimatorControllerParameterType.Trigger, value: false });
100
+ return this;
101
+ }
102
+ /**
103
+ * Adds a state to the controller. The first state added becomes the default state.
104
+ *
105
+ * When `options.clip` is provided, the state uses that clip directly.
106
+ * When omitted, chain `.track()` calls to define animation tracks inline:
107
+ * ```ts
108
+ * .state("Open", { loop: true })
109
+ * .track(door, "position", { from: [0,0,0], to: [2,0,0], duration: 1 })
110
+ * .track(light, "intensity", { from: 0, to: 5, duration: 1 })
111
+ * ```
112
+ *
113
+ * @param name - Unique name for the state
114
+ * @param options - State configuration including clip, loop, speed. When omitted, use `.track()` to add animation data.
115
+ */
116
+ state(name, options) {
117
+ const state = { name, options: options ?? {}, inlineTracks: [], transitions: [] };
118
+ this._states.push(state);
119
+ this._lastState = state;
120
+ return this;
121
+ }
122
+ /**
123
+ * Adds a transition between two states.
124
+ * Use `"*"` as the source to create a transition from any state.
125
+ * Chain `.condition()` calls after this to add conditions.
126
+ * @param from - Source state name, or `"*"` for any-state transition
127
+ * @param to - Destination state name
128
+ * @param options - Transition configuration
129
+ */
130
+ transition(from, to, options) {
131
+ this._lastState = null;
132
+ const t = { to: to, options: options ?? {}, conditions: [] };
133
+ if (from === "*") {
134
+ this._anyStateTransitions.push(t);
135
+ }
136
+ else {
137
+ const state = this._states.find(s => s.name === from);
138
+ if (!state)
139
+ throw new Error(`AnimatorControllerBuilder: source state "${from}" not found. Add it with .state() first.`);
140
+ state.transitions.push(t);
141
+ }
142
+ this._lastTransition = t;
143
+ return this;
144
+ }
145
+ condition(parameter, mode, threshold) {
146
+ if (!this._lastTransition)
147
+ throw new Error("AnimatorControllerBuilder: .condition() must be called after .transition()");
148
+ this._lastTransition.conditions.push({ parameter, mode: mode ?? "if", threshold: threshold ?? 0 });
149
+ return this;
150
+ }
151
+ /**
152
+ * Adds an animation track to the most recently added state.
153
+ * Must be called after `.state()`. The track has the same type-safe overloads
154
+ * as the standalone {@link track} function.
155
+ *
156
+ * @param target - The object whose type determines valid properties and value types
157
+ * @param property - The property to animate
158
+ * @param keyframes - Keyframe array or {@link Tween} shorthand
159
+ * @param options - Optional {@link TrackOptions} with a `root` for named targeting
160
+ */
161
+ track(target, property, keyframes, options) {
162
+ if (!this._lastState)
163
+ throw new Error("AnimatorControllerBuilder: .track() must be called after .state()");
164
+ if (this._lastState.options.clip)
165
+ throw new Error(`AnimatorControllerBuilder: state "${this._lastState.name}" already has a clip. Use either .track() or { clip: ... }, not both.`);
166
+ this._lastState.inlineTracks.push(trackFn(target, property, keyframes, options));
167
+ return this;
168
+ }
169
+ /**
170
+ * Sets which state is the default/entry state.
171
+ * If not called, the first added state is used.
172
+ * @param name - Name of the state
173
+ */
174
+ defaultState(name) {
175
+ this._defaultStateName = name;
176
+ return this;
177
+ }
178
+ /**
179
+ * Builds and returns the {@link AnimatorController}.
180
+ * Resolves all state name references to indices.
181
+ * @param root - Optional root Object3D for resolving {@link TrackDescriptor} track paths.
182
+ * When provided, tracks targeting a different object use `target.name` for named resolution.
183
+ */
184
+ build(root) {
185
+ const stateIndexMap = new Map();
186
+ this._states.forEach((s, i) => stateIndexMap.set(s.name, i));
187
+ let defaultStateIndex = 0;
188
+ if (this._defaultStateName !== null) {
189
+ const idx = stateIndexMap.get(this._defaultStateName);
190
+ if (idx === undefined)
191
+ throw new Error(`AnimatorControllerBuilder: default state "${this._defaultStateName}" not found`);
192
+ defaultStateIndex = idx;
193
+ }
194
+ const resolveTransition = (t) => {
195
+ const destIndex = stateIndexMap.get(t.to);
196
+ if (destIndex === undefined)
197
+ throw new Error(`AnimatorControllerBuilder: transition target "${t.to}" not found`);
198
+ return {
199
+ exitTime: t.options.exitTime ?? 1,
200
+ hasExitTime: t.options.exitTime !== undefined,
201
+ duration: t.options.duration ?? 0,
202
+ offset: t.options.offset ?? 0,
203
+ hasFixedDuration: t.options.hasFixedDuration ?? false,
204
+ destinationState: destIndex,
205
+ conditions: t.conditions.map(c => ({
206
+ parameter: c.parameter,
207
+ mode: conditionModeToEnum(c.mode),
208
+ threshold: c.threshold,
209
+ })),
210
+ };
211
+ };
212
+ const states = this._states.map((s, index) => {
213
+ const transitions = s.transitions.map(resolveTransition);
214
+ // Replicate any-state transitions onto every state (except self-targeting)
215
+ for (const anyT of this._anyStateTransitions) {
216
+ const destIndex = stateIndexMap.get(anyT.to);
217
+ if (destIndex === index)
218
+ continue;
219
+ transitions.push(resolveTransition(anyT));
220
+ }
221
+ // Resolve clip: from options.clip, inline .track() calls, or error
222
+ let clip;
223
+ if (s.options.clip) {
224
+ clip = resolveClipSource(s.options.clip, root);
225
+ }
226
+ else if (s.inlineTracks.length > 0) {
227
+ clip = resolveClipSource(s.inlineTracks, root);
228
+ }
229
+ else {
230
+ throw new Error(`AnimatorControllerBuilder: state "${s.name}" has no clip and no inline tracks. Provide { clip } or chain .track() calls.`);
231
+ }
232
+ return {
233
+ name: s.name,
234
+ hash: index,
235
+ motion: {
236
+ name: clip.name,
237
+ clip: clip,
238
+ isLooping: s.options.loop ?? false,
239
+ },
240
+ transitions,
241
+ behaviours: [],
242
+ speed: s.options.speed,
243
+ speedParameter: s.options.speedParameter,
244
+ cycleOffset: s.options.cycleOffset,
245
+ cycleOffsetParameter: s.options.cycleOffsetParameter,
246
+ };
247
+ });
248
+ const model = {
249
+ name: this._name,
250
+ guid: new InstantiateIdProvider(Date.now()).generateUUID(),
251
+ parameters: this._parameters,
252
+ layers: [{
253
+ name: "Base Layer",
254
+ stateMachine: {
255
+ defaultState: defaultStateIndex,
256
+ states,
257
+ }
258
+ }],
259
+ };
260
+ return new AnimatorController(model);
261
+ }
262
+ }
263
+ //# sourceMappingURL=AnimatorController.builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatorController.builder.js","sourceRoot":"","sources":["../../src/engine-components/AnimatorController.builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,MAAM,0DAA0D,CAAC;AAElI,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,KAAK,IAAI,OAAO,EAAiJ,MAAM,uBAAuB,CAAC;AAqD3N,SAAS,mBAAmB,CAAC,IAAmB;IAC5C,QAAQ,IAAI,EAAE,CAAC;QACX,KAAK,IAAI,CAAC,CAAC,OAAO,qBAAqB,CAAC,EAAE,CAAC;QAC3C,KAAK,OAAO,CAAC,CAAC,OAAO,qBAAqB,CAAC,KAAK,CAAC;QACjD,KAAK,SAAS,CAAC,CAAC,OAAO,qBAAqB,CAAC,OAAO,CAAC;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J,CAAC;YAED,OAAO;gBACH,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE;oBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,IAAI,EAAE,IAAI;oBACV,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK;iBACrC;gBACD,WAAW;gBACX,UAAU,EAAE,EAAE;gBACd,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK;gBACtB,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc;gBACxC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW;gBAClC,oBAAoB,EAAE,CAAC,CAAC,OAAO,CAAC,oBAAoB;aACvD,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAA4B;YACnC,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,IAAI,EAAE,IAAI,qBAAqB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,YAAY,EAAE;YAC1D,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,MAAM,EAAE,CAAC;oBACL,IAAI,EAAE,YAAY;oBAClB,YAAY,EAAE;wBACV,YAAY,EAAE,iBAAiB;wBAC/B,MAAM;qBACT;iBACJ,CAAC;SACL,CAAC;QAEF,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACJ"}
@@ -3,6 +3,8 @@ import { Context } from "../engine/engine_setup.js";
3
3
  import type { AnimatorControllerModel, State } from "../engine/extensions/NEEDLE_animator_controller_model.js";
4
4
  import { AnimatorStateInfo } from "../engine/extensions/NEEDLE_animator_controller_model.js";
5
5
  import type { Animator } from "./Animator.js";
6
+ import { AnimatorControllerBuilder } from "./AnimatorController.builder.js";
7
+ export { AnimatorControllerBuilder, type ConditionMode, type StateOptions, type TransitionOptions } from "./AnimatorController.builder.js";
6
8
  /**
7
9
  * Configuration options for creating an AnimatorController
8
10
  */
@@ -14,117 +16,6 @@ declare type CreateAnimatorControllerOptions = {
14
16
  /** Duration in seconds for transitions between states */
15
17
  transitionDuration?: number;
16
18
  };
17
- /**
18
- * Configuration for an animation state in the builder
19
- */
20
- export declare type StateOptions = {
21
- /** The animation clip for this state */
22
- clip: AnimationClip;
23
- /** Whether the animation should loop (default: false) */
24
- loop?: boolean;
25
- /** Base speed multiplier (default: 1) */
26
- speed?: number;
27
- /** Name of a float parameter to multiply with speed */
28
- speedParameter?: string;
29
- /** Normalized cycle offset 0-1 (default: 0) */
30
- cycleOffset?: number;
31
- /** Name of a float parameter to use as cycle offset */
32
- cycleOffsetParameter?: string;
33
- };
34
- /**
35
- * Configuration for a transition in the builder
36
- */
37
- export declare type TransitionOptions = {
38
- /** Duration of the crossfade in seconds (default: 0) */
39
- duration?: number;
40
- /** Normalized exit time 0-1 (default: 1). Only used when hasExitTime is true */
41
- exitTime?: number;
42
- /** Whether the transition waits for exitTime before transitioning (default: false) */
43
- hasExitTime?: boolean;
44
- /** Normalized offset into the destination state's animation (default: 0) */
45
- offset?: number;
46
- /** Whether duration is in seconds (true) or normalized (false) (default: false) */
47
- hasFixedDuration?: boolean;
48
- };
49
- /** String condition modes for the builder, mapped to {@link AnimatorConditionMode} */
50
- export type ConditionMode = "if" | "ifNot" | "greater" | "less" | "equals" | "notEqual";
51
- /**
52
- * A fluent builder for creating {@link AnimatorController} instances from code.
53
- *
54
- * Use {@link AnimatorController.build} to create a new builder.
55
- *
56
- * @example
57
- * ```ts
58
- * const controller = AnimatorController.build("CharacterController")
59
- * .floatParameter("Speed", 0)
60
- * .triggerParameter("Jump")
61
- * .state("Idle", { clip: idleClip, loop: true })
62
- * .state("Walk", { clip: walkClip, loop: true })
63
- * .state("Jump", { clip: jumpClip })
64
- * .transition("Idle", "Walk", { duration: 0.25 })
65
- * .condition("Speed", "greater", 0.1)
66
- * .transition("Walk", "Idle", { duration: 0.25 })
67
- * .condition("Speed", "less", 0.1)
68
- * .transition("*", "Jump", { duration: 0.1 })
69
- * .condition("Jump", "if")
70
- * .transition("Jump", "Idle", { hasExitTime: true, exitTime: 0.9, duration: 0.25 })
71
- * .build();
72
- * ```
73
- *
74
- * @category Animation and Sequencing
75
- * @group Utilities
76
- */
77
- export declare class AnimatorControllerBuilder {
78
- private _name;
79
- private _parameters;
80
- private _states;
81
- private _anyStateTransitions;
82
- private _defaultStateName;
83
- private _lastTransition;
84
- constructor(name?: string);
85
- /** Adds a float parameter */
86
- floatParameter(name: string, defaultValue?: number): this;
87
- /** Adds an integer parameter */
88
- intParameter(name: string, defaultValue?: number): this;
89
- /** Adds a boolean parameter */
90
- boolParameter(name: string, defaultValue?: boolean): this;
91
- /** Adds a trigger parameter */
92
- triggerParameter(name: string): this;
93
- /**
94
- * Adds a state to the controller. The first state added becomes the default state.
95
- * @param name - Unique name for the state
96
- * @param options - State configuration including clip, loop, speed
97
- */
98
- state(name: string, options: StateOptions): this;
99
- /**
100
- * Adds a transition between two states.
101
- * Use `"*"` as the source to create a transition from any state.
102
- * Chain `.condition()` calls after this to add conditions.
103
- * @param from - Source state name, or `"*"` for any-state transition
104
- * @param to - Destination state name
105
- * @param options - Transition configuration
106
- */
107
- transition(from: string, to: string, options?: TransitionOptions): this;
108
- /**
109
- * Adds a condition to the most recently added transition.
110
- * Multiple conditions on the same transition are AND-ed together.
111
- * @param parameter - Name of the parameter to evaluate
112
- * @param mode - Condition mode: `"if"`, `"ifNot"`, `"greater"`, `"less"`, `"equals"`, `"notEqual"`
113
- * @param threshold - Comparison threshold for numeric conditions (default: 0)
114
- */
115
- condition(parameter: string, mode: ConditionMode, threshold?: number): this;
116
- /**
117
- * Sets which state is the default/entry state.
118
- * If not called, the first added state is used.
119
- * @param name - Name of the state
120
- */
121
- defaultState(name: string): this;
122
- /**
123
- * Builds and returns the {@link AnimatorController}.
124
- * Resolves all state name references to indices.
125
- */
126
- build(): AnimatorController;
127
- }
128
19
  /**
129
20
  * Controls the playback of animations using a state machine architecture.
130
21
  *
@@ -315,13 +206,6 @@ export declare class AnimatorController {
315
206
  * @param animator - The animator to bind this controller to
316
207
  */
317
208
  bind(animator: Animator): void;
318
- /**
319
- * Creates a deep copy of this controller.
320
- * Clones the model data but does not copy runtime state.
321
- *
322
- * @returns A new AnimatorController instance with the same configuration
323
- */
324
- clone(): AnimatorController | null;
325
209
  /**
326
210
  * Updates the controller's state machine and animations.
327
211
  * Called each frame by the animator component.
@@ -360,4 +244,5 @@ export declare class AnimatorController {
360
244
  enumerateActions(): Generator<AnimationAction, void, unknown>;
361
245
  private rootMotionHandler?;
362
246
  }
363
- export {};
247
+ /** @internal */
248
+ export declare function initAnimatorControllerSerializer(): void;