@needle-tools/engine 5.1.0-canary.fbdfce3 → 5.1.0-experimental.03e8105

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 (311) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/SKILL.md +4 -1
  3. package/components.needle.json +1 -1
  4. package/dist/{needle-engine.bundle-BFSj2Fz8.js → needle-engine.bundle-BNqUjnSQ.js} +19180 -18386
  5. package/dist/needle-engine.bundle-Bt8ULD7E.umd.cjs +1733 -0
  6. package/dist/needle-engine.bundle-DF6ovbwD.min.js +1733 -0
  7. package/dist/needle-engine.d.ts +1487 -356
  8. package/dist/needle-engine.js +544 -542
  9. package/dist/needle-engine.min.js +1 -1
  10. package/dist/needle-engine.umd.cjs +1 -1
  11. package/dist/three.js +1 -0
  12. package/dist/three.min.js +21 -21
  13. package/dist/three.umd.cjs +16 -16
  14. package/lib/engine/api.d.ts +8 -1
  15. package/lib/engine/api.js +7 -1
  16. package/lib/engine/api.js.map +1 -1
  17. package/lib/engine/codegen/register_types.js +10 -18
  18. package/lib/engine/codegen/register_types.js.map +1 -1
  19. package/lib/engine/engine_audio.d.ts +68 -0
  20. package/lib/engine/engine_audio.js +172 -0
  21. package/lib/engine/engine_audio.js.map +1 -1
  22. package/lib/engine/engine_camera.fit.js +16 -4
  23. package/lib/engine/engine_camera.fit.js.map +1 -1
  24. package/lib/engine/engine_components.js +1 -1
  25. package/lib/engine/engine_components.js.map +1 -1
  26. package/lib/engine/engine_context.d.ts +21 -8
  27. package/lib/engine/engine_context.js +32 -16
  28. package/lib/engine/engine_context.js.map +1 -1
  29. package/lib/engine/engine_context_eventbus.d.ts +47 -0
  30. package/lib/engine/engine_context_eventbus.js +47 -0
  31. package/lib/engine/engine_context_eventbus.js.map +1 -0
  32. package/lib/engine/engine_disposable.d.ts +172 -0
  33. package/lib/engine/engine_disposable.js +136 -0
  34. package/lib/engine/engine_disposable.js.map +1 -0
  35. package/lib/engine/engine_gameobject.d.ts +1 -10
  36. package/lib/engine/engine_gameobject.js +22 -120
  37. package/lib/engine/engine_gameobject.js.map +1 -1
  38. package/lib/engine/engine_gltf_builtin_components.js +7 -69
  39. package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
  40. package/lib/engine/engine_init.js +7 -7
  41. package/lib/engine/engine_init.js.map +1 -1
  42. package/lib/engine/engine_input.d.ts +24 -5
  43. package/lib/engine/engine_input.js +3 -2
  44. package/lib/engine/engine_input.js.map +1 -1
  45. package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
  46. package/lib/engine/engine_instantiate_resolve.js +372 -0
  47. package/lib/engine/engine_instantiate_resolve.js.map +1 -0
  48. package/lib/engine/engine_license.d.ts +7 -7
  49. package/lib/engine/engine_license.js +183 -57
  50. package/lib/engine/engine_license.js.map +1 -1
  51. package/lib/engine/engine_mainloop_utils.js +7 -4
  52. package/lib/engine/engine_mainloop_utils.js.map +1 -1
  53. package/lib/engine/engine_networking.d.ts +51 -37
  54. package/lib/engine/engine_networking.js +132 -82
  55. package/lib/engine/engine_networking.js.map +1 -1
  56. package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
  57. package/lib/engine/engine_networking.transport.websocket.js +38 -0
  58. package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
  59. package/lib/engine/engine_networking_blob.js +4 -4
  60. package/lib/engine/engine_networking_blob.js.map +1 -1
  61. package/lib/engine/engine_networking_instantiate.js +2 -2
  62. package/lib/engine/engine_networking_instantiate.js.map +1 -1
  63. package/lib/engine/engine_networking_types.d.ts +39 -1
  64. package/lib/engine/engine_networking_types.js +7 -0
  65. package/lib/engine/engine_networking_types.js.map +1 -1
  66. package/lib/engine/engine_physics_rapier.d.ts +21 -3
  67. package/lib/engine/engine_physics_rapier.js +94 -25
  68. package/lib/engine/engine_physics_rapier.js.map +1 -1
  69. package/lib/engine/engine_scenedata.js +2 -2
  70. package/lib/engine/engine_scenedata.js.map +1 -1
  71. package/lib/engine/engine_serialization_builtin_serializer.js +28 -5
  72. package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
  73. package/lib/engine/engine_serialization_core.d.ts +1 -0
  74. package/lib/engine/engine_serialization_core.js +7 -0
  75. package/lib/engine/engine_serialization_core.js.map +1 -1
  76. package/lib/engine/engine_types.d.ts +29 -11
  77. package/lib/engine/engine_types.js +1 -1
  78. package/lib/engine/engine_types.js.map +1 -1
  79. package/lib/engine/engine_util_decorator.js +7 -2
  80. package/lib/engine/engine_util_decorator.js.map +1 -1
  81. package/lib/engine/engine_utils.d.ts +1 -1
  82. package/lib/engine/engine_utils.js +19 -5
  83. package/lib/engine/engine_utils.js.map +1 -1
  84. package/lib/engine/engine_utils_qrcode.js +2 -2
  85. package/lib/engine/engine_utils_qrcode.js.map +1 -1
  86. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  87. package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
  88. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
  89. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  90. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +1 -1
  91. package/lib/engine/webcomponents/needle menu/needle-menu.js +6 -6
  92. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  93. package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
  94. package/lib/engine/webcomponents/needle-engine.js +3 -3
  95. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  96. package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
  97. package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
  98. package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
  99. package/lib/engine/xr/NeedleXRSession.js +50 -14
  100. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  101. package/lib/engine/xr/TempXRContext.js +2 -2
  102. package/lib/engine/xr/TempXRContext.js.map +1 -1
  103. package/lib/engine/xr/events.d.ts +1 -1
  104. package/lib/engine/xr/events.js.map +1 -1
  105. package/lib/engine-components/Animation.js +17 -16
  106. package/lib/engine-components/Animation.js.map +1 -1
  107. package/lib/engine-components/AnimationBuilder.d.ts +158 -0
  108. package/lib/engine-components/AnimationBuilder.js +305 -0
  109. package/lib/engine-components/AnimationBuilder.js.map +1 -0
  110. package/lib/engine-components/Animator.d.ts +6 -0
  111. package/lib/engine-components/Animator.js +23 -13
  112. package/lib/engine-components/Animator.js.map +1 -1
  113. package/lib/engine-components/AnimatorController.builder.d.ts +191 -0
  114. package/lib/engine-components/AnimatorController.builder.js +263 -0
  115. package/lib/engine-components/AnimatorController.builder.js.map +1 -0
  116. package/lib/engine-components/AnimatorController.d.ts +2 -119
  117. package/lib/engine-components/AnimatorController.js +33 -232
  118. package/lib/engine-components/AnimatorController.js.map +1 -1
  119. package/lib/engine-components/AudioSource.d.ts +19 -3
  120. package/lib/engine-components/AudioSource.js +121 -68
  121. package/lib/engine-components/AudioSource.js.map +1 -1
  122. package/lib/engine-components/Collider.d.ts +18 -9
  123. package/lib/engine-components/Collider.js +61 -14
  124. package/lib/engine-components/Collider.js.map +1 -1
  125. package/lib/engine-components/Component.d.ts +72 -9
  126. package/lib/engine-components/Component.js +114 -10
  127. package/lib/engine-components/Component.js.map +1 -1
  128. package/lib/engine-components/ContactShadows.d.ts +1 -0
  129. package/lib/engine-components/ContactShadows.js +14 -1
  130. package/lib/engine-components/ContactShadows.js.map +1 -1
  131. package/lib/engine-components/DragControls.d.ts +7 -0
  132. package/lib/engine-components/DragControls.js +19 -7
  133. package/lib/engine-components/DragControls.js.map +1 -1
  134. package/lib/engine-components/DropListener.js +3 -0
  135. package/lib/engine-components/DropListener.js.map +1 -1
  136. package/lib/engine-components/EventList.d.ts +31 -9
  137. package/lib/engine-components/EventList.js +37 -76
  138. package/lib/engine-components/EventList.js.map +1 -1
  139. package/lib/engine-components/Joints.d.ts +4 -2
  140. package/lib/engine-components/Joints.js +19 -3
  141. package/lib/engine-components/Joints.js.map +1 -1
  142. package/lib/engine-components/Light.js +9 -1
  143. package/lib/engine-components/Light.js.map +1 -1
  144. package/lib/engine-components/Networking.d.ts +1 -1
  145. package/lib/engine-components/Networking.js +1 -1
  146. package/lib/engine-components/OrbitControls.d.ts +0 -2
  147. package/lib/engine-components/OrbitControls.js +30 -12
  148. package/lib/engine-components/OrbitControls.js.map +1 -1
  149. package/lib/engine-components/RigidBody.d.ts +12 -4
  150. package/lib/engine-components/RigidBody.js +18 -4
  151. package/lib/engine-components/RigidBody.js.map +1 -1
  152. package/lib/engine-components/SceneSwitcher.js +3 -0
  153. package/lib/engine-components/SceneSwitcher.js.map +1 -1
  154. package/lib/engine-components/SeeThrough.js +2 -2
  155. package/lib/engine-components/SeeThrough.js.map +1 -1
  156. package/lib/engine-components/api.d.ts +2 -1
  157. package/lib/engine-components/api.js +2 -1
  158. package/lib/engine-components/api.js.map +1 -1
  159. package/lib/engine-components/codegen/components.d.ts +7 -13
  160. package/lib/engine-components/codegen/components.js +7 -13
  161. package/lib/engine-components/codegen/components.js.map +1 -1
  162. package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
  163. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  164. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
  165. package/lib/engine-components/timeline/PlayableDirector.d.ts +21 -11
  166. package/lib/engine-components/timeline/PlayableDirector.js +75 -67
  167. package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
  168. package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
  169. package/lib/engine-components/timeline/SignalAsset.js +1 -0
  170. package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
  171. package/lib/engine-components/timeline/TimelineBuilder.d.ts +413 -0
  172. package/lib/engine-components/timeline/TimelineBuilder.js +506 -0
  173. package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
  174. package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
  175. package/lib/engine-components/timeline/TimelineModels.js +3 -0
  176. package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
  177. package/lib/engine-components/timeline/TimelineTracks.d.ts +37 -6
  178. package/lib/engine-components/timeline/TimelineTracks.js +92 -26
  179. package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
  180. package/lib/engine-components/timeline/index.d.ts +2 -1
  181. package/lib/engine-components/timeline/index.js +2 -0
  182. package/lib/engine-components/timeline/index.js.map +1 -1
  183. package/lib/engine-components/ui/Canvas.d.ts +1 -1
  184. package/lib/engine-components/ui/Canvas.js +2 -8
  185. package/lib/engine-components/ui/Canvas.js.map +1 -1
  186. package/lib/engine-components/ui/Text.d.ts +1 -0
  187. package/lib/engine-components/ui/Text.js +10 -7
  188. package/lib/engine-components/ui/Text.js.map +1 -1
  189. package/lib/engine-components/web/CursorFollow.d.ts +0 -1
  190. package/lib/engine-components/web/CursorFollow.js +21 -13
  191. package/lib/engine-components/web/CursorFollow.js.map +1 -1
  192. package/lib/engine-components/webxr/WebXRImageTracking.js +4 -0
  193. package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
  194. package/package.json +2 -83
  195. package/plugins/common/cloud.js +6 -1
  196. package/plugins/common/license.js +31 -10
  197. package/plugins/common/worker.js +9 -4
  198. package/plugins/vite/asap.js +17 -8
  199. package/plugins/vite/dependencies.js +29 -10
  200. package/plugins/vite/dependency-watcher.js +2 -2
  201. package/plugins/vite/editor-connection.js +3 -3
  202. package/plugins/vite/license.js +46 -7
  203. package/plugins/vite/local-files-core.js +3 -3
  204. package/plugins/vite/local-files-utils.d.ts +3 -1
  205. package/plugins/vite/local-files-utils.js +29 -5
  206. package/plugins/vite/reload.js +1 -1
  207. package/plugins/vite/server.js +2 -1
  208. package/src/engine/api.ts +11 -1
  209. package/src/engine/codegen/register_types.ts +10 -18
  210. package/src/engine/engine_audio.ts +184 -0
  211. package/src/engine/engine_camera.fit.ts +15 -4
  212. package/src/engine/engine_components.ts +1 -1
  213. package/src/engine/engine_context.ts +34 -18
  214. package/src/engine/engine_context_eventbus.ts +73 -0
  215. package/src/engine/engine_disposable.ts +214 -0
  216. package/src/engine/engine_gameobject.ts +54 -159
  217. package/src/engine/engine_gltf_builtin_components.ts +7 -76
  218. package/src/engine/engine_init.ts +7 -7
  219. package/src/engine/engine_input.ts +28 -7
  220. package/src/engine/engine_instantiate_resolve.ts +407 -0
  221. package/src/engine/engine_license.ts +197 -55
  222. package/src/engine/engine_mainloop_utils.ts +7 -4
  223. package/src/engine/engine_networking.transport.websocket.ts +45 -0
  224. package/src/engine/engine_networking.ts +161 -137
  225. package/src/engine/engine_networking_blob.ts +4 -4
  226. package/src/engine/engine_networking_instantiate.ts +2 -2
  227. package/src/engine/engine_networking_types.ts +41 -1
  228. package/src/engine/engine_physics_rapier.ts +102 -33
  229. package/src/engine/engine_scenedata.ts +3 -3
  230. package/src/engine/engine_serialization_builtin_serializer.ts +32 -9
  231. package/src/engine/engine_serialization_core.ts +9 -0
  232. package/src/engine/engine_types.ts +46 -27
  233. package/src/engine/engine_util_decorator.ts +7 -2
  234. package/src/engine/engine_utils.ts +16 -5
  235. package/src/engine/engine_utils_qrcode.ts +2 -2
  236. package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
  237. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
  238. package/src/engine/webcomponents/needle menu/needle-menu.ts +6 -6
  239. package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
  240. package/src/engine/webcomponents/needle-engine.ts +12 -6
  241. package/src/engine/xr/NeedleXRSession.ts +48 -13
  242. package/src/engine/xr/TempXRContext.ts +2 -2
  243. package/src/engine/xr/events.ts +1 -1
  244. package/src/engine-components/Animation.ts +19 -16
  245. package/src/engine-components/AnimationBuilder.ts +472 -0
  246. package/src/engine-components/Animator.ts +24 -12
  247. package/src/engine-components/AnimatorController.builder.ts +387 -0
  248. package/src/engine-components/AnimatorController.ts +20 -291
  249. package/src/engine-components/AudioSource.ts +130 -79
  250. package/src/engine-components/Collider.ts +66 -18
  251. package/src/engine-components/Component.ts +118 -20
  252. package/src/engine-components/ContactShadows.ts +15 -1
  253. package/src/engine-components/DragControls.ts +18 -11
  254. package/src/engine-components/DropListener.ts +3 -0
  255. package/src/engine-components/EventList.ts +45 -83
  256. package/src/engine-components/Joints.ts +20 -4
  257. package/src/engine-components/Light.ts +10 -2
  258. package/src/engine-components/Networking.ts +1 -1
  259. package/src/engine-components/OrbitControls.ts +34 -14
  260. package/src/engine-components/RigidBody.ts +18 -4
  261. package/src/engine-components/SceneSwitcher.ts +3 -0
  262. package/src/engine-components/SeeThrough.ts +2 -2
  263. package/src/engine-components/api.ts +2 -1
  264. package/src/engine-components/codegen/components.ts +7 -13
  265. package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
  266. package/src/engine-components/timeline/PlayableDirector.ts +83 -81
  267. package/src/engine-components/timeline/SignalAsset.ts +4 -1
  268. package/src/engine-components/timeline/TimelineBuilder.ts +824 -0
  269. package/src/engine-components/timeline/TimelineModels.ts +5 -1
  270. package/src/engine-components/timeline/TimelineTracks.ts +96 -27
  271. package/src/engine-components/timeline/index.ts +2 -1
  272. package/src/engine-components/ui/Canvas.ts +2 -8
  273. package/src/engine-components/ui/Text.ts +12 -8
  274. package/src/engine-components/web/CursorFollow.ts +21 -14
  275. package/src/engine-components/webxr/WebXRImageTracking.ts +2 -0
  276. package/dist/needle-engine.bundle-CmxIO5uH.min.js +0 -1732
  277. package/dist/needle-engine.bundle-tJIZukCz.umd.cjs +0 -1732
  278. package/lib/engine-components/AvatarLoader.d.ts +0 -80
  279. package/lib/engine-components/AvatarLoader.js +0 -232
  280. package/lib/engine-components/AvatarLoader.js.map +0 -1
  281. package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
  282. package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
  283. package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
  284. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
  285. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
  286. package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
  287. package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
  288. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
  289. package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
  290. package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
  291. package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
  292. package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
  293. package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
  294. package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
  295. package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
  296. package/plugins/dts-generator/dts.codegen.js +0 -334
  297. package/plugins/dts-generator/dts.scan.js +0 -99
  298. package/plugins/dts-generator/dts.writer.js +0 -59
  299. package/plugins/dts-generator/glb.discovery.js +0 -279
  300. package/plugins/dts-generator/glb.extractor.js +0 -215
  301. package/plugins/dts-generator/glb.reader.js +0 -167
  302. package/plugins/dts-generator/index.js +0 -36
  303. package/plugins/dts-generator/manifest.types.js +0 -174
  304. package/plugins/gltf-packer.mjs +0 -1
  305. package/src/engine-components/AvatarLoader.ts +0 -264
  306. package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
  307. package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
  308. package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
  309. package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
  310. package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
  311. package/src/vite-env.d.ts +0 -16
@@ -1 +0,0 @@
1
- {"version":3,"file":"Avatar_Brain_LookAt.js","sourceRoot":"","sources":["../../../src/engine-components/avatar/Avatar_Brain_LookAt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,OAAO,EAAE,MAA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CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;wBAAE,OAAO;oBACrD,IAAI,CAAC,oBAAoB,GAAG,GAAG,CAAC,GAAG,CAAC;oBACpC,0CAA0C;gBAC9C,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
@@ -1,15 +0,0 @@
1
- import { Object3D } from "three";
2
- import { Behaviour } from "../Component.js";
3
- /** @internal */
4
- export declare class Avatar_MouthShapes extends Behaviour {
5
- idle: Object3D[];
6
- talking: Object3D[];
7
- private marker;
8
- private voip;
9
- private lastMouthChangeTime;
10
- private mouthChangeLength;
11
- awake(): void;
12
- update(): void;
13
- private updateLips;
14
- private setMouthShapeActive;
15
- }
@@ -1,80 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Object3D } from "three";
8
- import { serializable } from "../../engine/engine_serialization_decorator.js";
9
- import * as utils from "../../engine/engine_utils.js";
10
- import { Behaviour, GameObject } from "../Component.js";
11
- import { Voip } from "../Voip.js";
12
- import { AvatarMarker } from "../webxr/WebXRAvatar.js";
13
- const debug = utils.getParam("debugmouth");
14
- /** @internal */
15
- export class Avatar_MouthShapes extends Behaviour {
16
- idle = [];
17
- talking = [];
18
- marker = null;
19
- voip = null;
20
- lastMouthChangeTime = 0;
21
- mouthChangeLength = 0;
22
- awake() {
23
- setTimeout(() => {
24
- this.voip = GameObject.findObjectOfType(Voip, this.context);
25
- if (!this.marker)
26
- this.marker = GameObject.getComponentInParent(this.gameObject, AvatarMarker);
27
- }, 3000);
28
- }
29
- update() {
30
- if (!this.voip)
31
- return;
32
- if (this.context.time.frameCount % 10 !== 0)
33
- return;
34
- let id = this.marker?.connectionId ?? null;
35
- if (!id) {
36
- if (debug)
37
- id = null;
38
- return;
39
- }
40
- const freq = this.voip.getFrequency(id) ?? 0;
41
- this.updateLips(freq);
42
- }
43
- updateLips(frequency) {
44
- if (this.context.time.time - this.lastMouthChangeTime > this.mouthChangeLength) {
45
- this.mouthChangeLength = .05 + Math.random() * .1;
46
- if (this.talking && this.talking.length > 0 && frequency > 30) {
47
- this.lastMouthChangeTime = this.context.time.time;
48
- const index = Math.floor(Math.random() * this.talking.length);
49
- this.setMouthShapeActive(this.talking, index);
50
- }
51
- else if (this.idle.length > 0 && this.context.time.time - this.lastMouthChangeTime > .5) {
52
- this.lastMouthChangeTime = this.context.time.time;
53
- const index = Math.floor(Math.random() * this.idle.length);
54
- this.setMouthShapeActive(this.idle, index);
55
- }
56
- }
57
- }
58
- setMouthShapeActive(arr, index) {
59
- if (!arr)
60
- return;
61
- // hide other
62
- if (arr != this.idle)
63
- this.idle.map(i => i.visible = false);
64
- else
65
- this.talking.map(i => i.visible = false);
66
- for (let i = 0; i < arr.length; i++) {
67
- const shape = arr[i];
68
- if (shape) {
69
- shape.visible = i === index;
70
- }
71
- }
72
- }
73
- }
74
- __decorate([
75
- serializable(Object3D)
76
- ], Avatar_MouthShapes.prototype, "idle", void 0);
77
- __decorate([
78
- serializable(Object3D)
79
- ], Avatar_MouthShapes.prototype, "talking", void 0);
80
- //# sourceMappingURL=Avatar_MouthShapes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Avatar_MouthShapes.js","sourceRoot":"","sources":["../../../src/engine-components/avatar/Avatar_MouthShapes.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,KAAK,KAAK,MAAM,8BAA8B,CAAC;A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EjB,aAAa;QACb,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;;YACvD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;QAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,KAAK,EAAE,CAAC;gBACR,KAAK,CAAC,OAAO,GAAG,CAAC,KAAK,KAAK,CAAC;YAChC,CAAC;QACL,CAAC;IACL,CAAC;CAaJ;AAtEU;IADN,YAAY,CAAC,QAAQ,CAAC;gDACM;AAEtB;IADN,YAAY,CAAC,QAAQ,CAAC;mDACS"}
@@ -1,9 +0,0 @@
1
- import { Behaviour } from "../Component.js";
2
- /** @internal */
3
- export declare class Avatar_MustacheShake extends Behaviour {
4
- private voip;
5
- private marker;
6
- private _startPosition;
7
- awake(): void;
8
- update(): void;
9
- }
@@ -1,30 +0,0 @@
1
- import { Behaviour, GameObject } from "../Component.js";
2
- import { Voip } from "../Voip.js";
3
- import { AvatarMarker } from "../webxr/WebXRAvatar.js";
4
- /** @internal */
5
- export class Avatar_MustacheShake extends Behaviour {
6
- voip = null;
7
- marker = null;
8
- _startPosition = null;
9
- awake() {
10
- this.voip = GameObject.findObjectOfType(Voip, this.context);
11
- this.marker = GameObject.getComponentInParent(this.gameObject, AvatarMarker);
12
- // console.log(this);
13
- }
14
- update() {
15
- if (!this.voip || !this.marker)
16
- return;
17
- if (this.context.time.frameCount % 10 !== 0)
18
- return;
19
- const id = this.marker.connectionId;
20
- const freq = this.voip.getFrequency(id);
21
- if (freq == null)
22
- return;
23
- if (!this._startPosition) {
24
- this._startPosition = this.gameObject.position.clone();
25
- }
26
- const t = freq / 100;
27
- this.gameObject.position.y = this._startPosition.y + t * 0.07;
28
- }
29
- }
30
- //# sourceMappingURL=Avatar_MustacheShake.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Avatar_MustacheShake.js","sourceRoot":"","sources":["../../../src/engine-components/avatar/Avatar_MustacheShake.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,gBAAgB;AAChB,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IACvC,IAAI,GAAgB,IAAI,CAAC;IACzB,MAAM,GAAwB,IAAI,CAAC;IAEnC,cAAc,GAAoB,IAAI,CAAC;IAE/C,KAAK;QACD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC7E,qBAAqB;IACzB,CAAC;IAED,MAAM;QACF,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO;QACvC,IAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,KAAK,CAAC;YAAE,OAAO;QACnD,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;QACpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxC,IAAG,IAAI,IAAI,IAAI;YAAE,OAAO;QACxB,IAAG,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC3D,CAAC;QACD,MAAM,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC;QACrB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAClE,CAAC;CACJ"}
@@ -1,334 +0,0 @@
1
- // @ts-check
2
- /**
3
- * Pure string generators — no I/O.
4
- *
5
- * Takes `BindingEntry[]` from dts.scan.js and produces:
6
- * - `needle-bindings.gen.d.ts` (TypeScript ambient module augmentation)
7
- * - `needle-html-data.json` (VS Code HTML custom data for data-bind-needle completions)
8
- *
9
- * Each scene node is emitted as a named type alias so VS Code hover shows
10
- * the alias name + JSDoc summary rather than expanding the full object type:
11
- *
12
- * /** `Minimal/Cube` — MeshRenderer, BoxCollider *\/
13
- * type $Minimal__Cube = { $object: THREE.Mesh; $components: { ... }; };
14
- *
15
- * interface SceneData {
16
- * Minimal: { Minimal: { Cube: $Minimal__Minimal__Cube; }; }; };
17
- * }
18
- */
19
-
20
- /** @typedef {import('./dts.scan.js').BindingEntry} BindingEntry */
21
-
22
- /** Append `?view` to Needle Cloud asset URLs so the link opens the viewer. @param {string} url @returns {string} */
23
- function addViewParam(url) {
24
- if (!url.includes("cloud.needle.tools")) return url;
25
- return url.includes("?") ? `${url}&view` : `${url}?view`;
26
- }
27
-
28
- /** @param {string} name @returns {string} */
29
- function propKey(name) {
30
- return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name) ? name : `"${name}"`;
31
- }
32
-
33
- /**
34
- * Convert a node path like "Minimal/Cube_1/Child Of Cube" to a safe type alias name.
35
- * @param {string} nodePath
36
- * @returns {string}
37
- */
38
- function typeAliasName(nodePath) {
39
- const safe = nodePath.replace(/[^a-zA-Z0-9]/g, "_");
40
- return `$${safe}`;
41
- }
42
-
43
- /**
44
- * @typedef {{
45
- * threeType: string,
46
- * components: Map<string, { isEngineComponent: boolean, fields: Map<string, Set<string>> }>,
47
- * children: Map<string, TreeNode>
48
- * }} TreeNode
49
- */
50
-
51
- /** @returns {TreeNode} */
52
- function makeNode() {
53
- return { threeType: `import("three").Object3D`, components: new Map(), children: new Map() };
54
- }
55
-
56
- /**
57
- * Build a tree from BindingEntry[]. Each entry's nodePath (e.g. "UI/Camera/Target")
58
- * defines where in the tree the node lives.
59
- *
60
- * @param {BindingEntry[]} entries
61
- * @returns {Map<string, TreeNode>} Root-level nodes
62
- */
63
- function buildTree(entries) {
64
- /** @type {Map<string, TreeNode>} */
65
- const roots = new Map();
66
-
67
- for (const { nodePath, componentName, fieldTypes, isEngineComponent, nodeThreeType } of entries) {
68
- const parts = nodePath.split("/").filter(Boolean);
69
- if (parts.length === 0) continue;
70
-
71
- let map = roots;
72
- /** @type {TreeNode | null} */
73
- let node = null;
74
- for (const part of parts) {
75
- if (!map.has(part)) map.set(part, makeNode());
76
- node = /** @type {TreeNode} */ (map.get(part));
77
- map = node.children;
78
- }
79
- if (!node) continue;
80
-
81
- node.threeType = nodeThreeType;
82
-
83
- if (componentName) {
84
- if (!node.components.has(componentName)) {
85
- node.components.set(componentName, { isEngineComponent, fields: new Map() });
86
- }
87
- const comp = /** @type {{ isEngineComponent: boolean, fields: Map<string, Set<string>> }} */ (node.components.get(componentName));
88
- for (const [field, tsType] of Object.entries(fieldTypes)) {
89
- if (!comp.fields.has(field)) comp.fields.set(field, new Set());
90
- /** @type {Set<string>} */ (comp.fields.get(field)).add(tsType);
91
- }
92
- }
93
- }
94
-
95
- return roots;
96
- }
97
-
98
- /**
99
- * Compute the human-readable summary for a node (component names or Three.js type).
100
- * @param {TreeNode} node
101
- * @returns {string}
102
- */
103
- function nodeSummary(node) {
104
- const threeShortType = node.threeType.replace(/import\("three"\)\./g, "THREE.");
105
- const compNames = Array.from(node.components.keys()).filter(n => n !== "").sort();
106
- return compNames.length > 0 ? compNames.join(", ") : threeShortType;
107
- }
108
-
109
- /**
110
- * Recursively collect type alias declarations for all nodes in the tree.
111
- * Emits one `type $Alias = { ... }` per node, with JSDoc summary.
112
- *
113
- * @param {string} _key
114
- * @param {TreeNode} node
115
- * @param {string} nodePath Full path e.g. "Minimal/Cube"
116
- * @param {string[]} aliases Accumulator — lines pushed in bottom-up order
117
- */
118
- function collectTypeAliases(_key, node, nodePath, aliases) {
119
- // Recurse into children first (bottom-up so aliases are defined before use)
120
- for (const [childKey, childNode] of Array.from(node.children.entries()).sort(([a], [b]) => a.localeCompare(b))) {
121
- collectTypeAliases(childKey, childNode, `${nodePath}/${childKey}`, aliases);
122
- }
123
-
124
- const threeShortType = node.threeType.replace(/import\("three"\)\./g, "THREE.");
125
- const compEntries = Array.from(node.components.entries())
126
- .filter(([n]) => n !== "")
127
- .sort(([a], [b]) => a.localeCompare(b));
128
- const summary = nodeSummary(node);
129
-
130
- const alias = typeAliasName(nodePath);
131
-
132
- // Emit as an interface so each child property can carry JSDoc
133
- const lines = [];
134
- lines.push(`/** \`${nodePath}\` — ${summary} */`);
135
- lines.push(`interface ${alias} {`);
136
- lines.push(` $object: ${threeShortType};`);
137
-
138
- if (compEntries.length > 0) {
139
- const compParts = compEntries.map(([compName, { isEngineComponent, fields }]) => {
140
- if (isEngineComponent) {
141
- return `${propKey(compName)}: NE.${compName}`;
142
- } else {
143
- const fieldParts = [`enabled: boolean`];
144
- for (const [field, types] of Array.from(fields.entries()).sort(([a], [b]) => a.localeCompare(b))) {
145
- fieldParts.push(`${field}: ${Array.from(types).join(" | ")}`);
146
- }
147
- return `${propKey(compName)}: { ${fieldParts.join("; ")} }`;
148
- }
149
- });
150
- lines.push(` /** Needle Engine components on this node. Access via \`getComponent()\`, \`addComponent()\`, or \`findObjectOfType()\` / \`findObjectsOfType()\`. */`);
151
- lines.push(` $components: { ${compParts.join("; ")} };`);
152
- }
153
-
154
- for (const [childKey, childNode] of Array.from(node.children.entries()).sort(([a], [b]) => a.localeCompare(b))) {
155
- const childAlias = typeAliasName(`${nodePath}/${childKey}`);
156
- const childSummary = nodeSummary(childNode);
157
- lines.push(` /** ${childSummary} */`);
158
- lines.push(` ${propKey(childKey)}: ${childAlias};`);
159
- }
160
-
161
- lines.push(`}`);
162
-
163
- aliases.push(lines.join("\n"));
164
- }
165
-
166
- /**
167
- * Recursively render a tree node as indented JSDoc lines.
168
- * @param {string} key
169
- * @param {TreeNode} node
170
- * @param {number} depth
171
- * @param {string[]} lines
172
- */
173
- /** @param {string} threeType @returns {string} */
174
- function nodeEmoji(threeType) {
175
- if (threeType.includes("Scene")) return "🎬";
176
- if (threeType.includes("SkinnedMesh")) return "🦴";
177
- if (threeType.includes("Mesh")) return "⊞";
178
- if (threeType.includes("PerspectiveCamera") || threeType.includes("OrthographicCamera") || threeType.includes("Camera")) return "👁";
179
- if (threeType.includes("Light")) return "💡";
180
- return "";
181
- }
182
-
183
- function buildTreeDoc(key, node, depth, lines) {
184
- const indent = " ".repeat(depth);
185
- const hasComponents = Array.from(node.components.keys()).some(n => n !== "");
186
- const summary = nodeSummary(node);
187
- const emoji = nodeEmoji(node.threeType);
188
- const prefix = emoji ? `${emoji} ` : "";
189
- // Bold + components for nodes that have something actionable; plain name for empty containers
190
- const label = hasComponents ? `${prefix}**${key}** — ${summary}` : `${prefix}${key}`;
191
- lines.push(` * ${indent}- ${label}`);
192
- for (const [childKey, childNode] of Array.from(node.children.entries()).sort(([a], [b]) => a.localeCompare(b))) {
193
- buildTreeDoc(childKey, childNode, depth + 1, lines);
194
- }
195
- }
196
-
197
- /**
198
- * Generate the `needle-bindings.gen.d.ts` content from binding entries.
199
- *
200
- * @param {BindingEntry[]} entries
201
- * @returns {string}
202
- */
203
- export function generateDts(entries) {
204
- /** @type {Map<string, BindingEntry[]>} */
205
- const byGlb = new Map();
206
- /** @type {Map<string, string>} glbKey → source path/URL */
207
- const glbSrcMap = new Map();
208
- /** @type {Map<string, Set<string>>} glbKey → set of source files referencing it */
209
- const glbSourceFilesMap = new Map();
210
- for (const entry of entries) {
211
- const k = entry.glbKey;
212
- if (!byGlb.has(k)) byGlb.set(k, []);
213
- /** @type {BindingEntry[]} */ (byGlb.get(k)).push(entry);
214
- if (entry.glbSrc && !glbSrcMap.has(k)) glbSrcMap.set(k, entry.glbSrc);
215
- if (entry.glbSourceFiles?.length) {
216
- if (!glbSourceFilesMap.has(k)) glbSourceFilesMap.set(k, new Set());
217
- for (const sf of entry.glbSourceFiles) /** @type {Set<string>} */ (glbSourceFilesMap.get(k)).add(sf);
218
- }
219
- }
220
-
221
- const header = [
222
- `// Auto-generated by @needle-tools/engine — do not edit`,
223
- `// Regenerated on each vite dev-server start and GLB change.`,
224
- `// Augments the base "needle-bindings" declaration in @needle-tools/engine.`,
225
- `import type * as NE from "../../lib/needle-engine.js";`,
226
- `import type * as THREE from "three";`,
227
- ];
228
-
229
- /** @type {string[]} */
230
- const aliases = [];
231
- /** @type {string[]} */
232
- const interfaceLines = [
233
- `declare module "needle-bindings" {`,
234
- ` interface SceneData {`,
235
- ];
236
-
237
- for (const [glbKey, glbEntries] of Array.from(byGlb.entries()).sort(([a], [b]) => a.localeCompare(b))) {
238
- const roots = buildTree(glbEntries);
239
- if (roots.size === 0) continue;
240
-
241
- // Collect type aliases for all nodes in this GLB
242
- for (const [rootKey, rootNode] of Array.from(roots.entries()).sort(([a], [b]) => a.localeCompare(b))) {
243
- collectTypeAliases(rootKey, rootNode, `${glbKey}/${rootKey}`, aliases);
244
- }
245
-
246
- // Emit SceneData property references with hierarchy JSDoc
247
- const glbSrc = glbSrcMap.get(glbKey);
248
- const sourceFiles = glbSourceFilesMap.get(glbKey);
249
- const treeDocLines = [` * GLB/glTF scene file`];
250
- const glbSrcLink = glbSrc
251
- ? (glbSrc.startsWith("http://") || glbSrc.startsWith("https://")
252
- ? ` — [${glbSrc}](${addViewParam(glbSrc)})`
253
- : ` — \`${glbSrc}\``)
254
- : "";
255
- treeDocLines.push(` * \`${glbKey}\`${glbSrcLink}`);
256
- if (sourceFiles?.size) {
257
- treeDocLines.push(` *`);
258
- treeDocLines.push(` * **Referenced from:**`);
259
- for (const sf of Array.from(sourceFiles).sort()) {
260
- treeDocLines.push(` * - \`${sf}\``);
261
- }
262
- }
263
- treeDocLines.push(` *`);
264
- treeDocLines.push(` * ---`);
265
- treeDocLines.push(` *`);
266
- for (const [rootKey, rootNode] of Array.from(roots.entries()).sort(([a], [b]) => a.localeCompare(b))) {
267
- buildTreeDoc(rootKey, rootNode, 0, treeDocLines);
268
- }
269
- interfaceLines.push(` /**\n ${treeDocLines.join("\n ")}\n */`);
270
- interfaceLines.push(` $${glbKey}: {`);
271
- for (const [rootKey, rootNode] of Array.from(roots.entries()).sort(([a], [b]) => a.localeCompare(b))) {
272
- const alias = typeAliasName(`${glbKey}/${rootKey}`);
273
- const summary = nodeSummary(rootNode);
274
- interfaceLines.push(` /** ${summary} */`);
275
- interfaceLines.push(` ${propKey(rootKey)}: ${alias};`);
276
- }
277
- interfaceLines.push(` };`);
278
- }
279
-
280
- interfaceLines.push(` }`);
281
- interfaceLines.push(`}`);
282
-
283
- return [...header, ``, ...aliases, ``, ...interfaceLines, ``].join("\n");
284
- }
285
-
286
- /**
287
- * Generate VS Code HTML custom data JSON for `data-bind-needle` completions.
288
- *
289
- * @param {BindingEntry[]} entries
290
- * @returns {string} JSON string
291
- */
292
- export function generateHtmlCustomData(entries) {
293
- const pairs = Array.from(
294
- new Set(entries.filter(e => e.componentName).map(e => `${e.nodePath}/${e.componentName}`))
295
- ).sort();
296
-
297
- const values = pairs.map(pair => {
298
- const slash = pair.lastIndexOf("/");
299
- const nodePath = pair.slice(0, slash);
300
- const compName = pair.slice(slash + 1);
301
- return {
302
- name: pair,
303
- description: `Bind to the **${compName}** component on node \`${nodePath}\`.`,
304
- };
305
- });
306
-
307
- const data = {
308
- version: 1.1,
309
- globalAttributes: [
310
- {
311
- name: "data-bind-needle",
312
- description: {
313
- kind: "markdown",
314
- value: [
315
- "Binds this HTML element to a Needle Engine scene component.",
316
- "",
317
- "**Format:** `NodePath/ComponentName`",
318
- "",
319
- "The Needle Engine runtime will associate this element with the specified",
320
- "component instance in the live scene graph.",
321
- "",
322
- "**Example:**",
323
- "```html",
324
- '<div data-bind-needle="Camera/OrbitControls">',
325
- "```",
326
- ].join("\n"),
327
- },
328
- values,
329
- },
330
- ],
331
- };
332
-
333
- return JSON.stringify(data, null, 2) + "\n";
334
- }
@@ -1,99 +0,0 @@
1
- // @ts-check
2
- /**
3
- * Scans GLB/glTF files and returns structured binding data.
4
- *
5
- * Combines file discovery, JSON reading, component extraction, and manifest
6
- * type resolution into the `BindingEntry[]` array consumed by codegen.
7
- */
8
-
9
- import { resolveEntrypointGlbs, collectSceneFiles, glbFriendlyName } from './glb.discovery.js';
10
- import { readGlbJsonChunk, readGltfJsonFile, readRemoteGlbJsonChunk } from './glb.reader.js';
11
- import { extractComponentBindings, inferTsType } from './glb.extractor.js';
12
- import { componentsManifest } from './manifest.types.js';
13
- import { needleLog } from '../vite/logging.js';
14
-
15
- const PLUGIN = "needle:dts-generator";
16
-
17
- /**
18
- * @typedef {Object} BindingEntry
19
- * @property {string} nodeName
20
- * @property {string} nodePath Full hierarchy path e.g. "Scene/Cube/Child_Of_Cube"
21
- * @property {string} componentName
22
- * @property {Record<string, string>} fieldTypes field name → TS type string
23
- * @property {boolean} isEngineComponent true if the component exists in components.needle.json
24
- * @property {string} nodeThreeType Three.js type of the parent node (e.g. `import("three").Mesh`)
25
- * @property {string} glbKey Friendly identifier derived from the GLB name (e.g. "myScene", "MaterialXNodes")
26
- * @property {string} glbSrc Project-relative path or URL of the GLB file
27
- * @property {string[]} [glbSourceFiles] Source files (relative to project root) that reference this GLB
28
- */
29
-
30
- /**
31
- * Scan GLB/glTF files and return structured binding data.
32
- * Uses entrypoint GLBs (from index.html, gen.js, or source files) when available,
33
- * otherwise falls back to scanning all GLBs in assetsDir.
34
- *
35
- * @param {string} assetsDir Absolute path to the assets directory
36
- * @param {string} [projectRoot] Absolute path to the project root (enables entrypoint detection)
37
- * @param {string} [codegenDir] Absolute path to the codegen directory
38
- * @returns {Promise<BindingEntry[]>}
39
- */
40
- export async function scanBindings(assetsDir, projectRoot, codegenDir) {
41
- /** @type {Array<{path: string, type: "glb"|"gltf", remote?: boolean, key?: string}>} */
42
- const files = /** @type {any} */ ((projectRoot ? resolveEntrypointGlbs(projectRoot, assetsDir, codegenDir) : null)
43
- ?? collectSceneFiles(assetsDir));
44
-
45
- needleLog(PLUGIN, `Discovered ${files.length} GLB(s):\n${files.map(f => ` ${f.path}`).join("\n")}`);
46
-
47
- /** @type {BindingEntry[]} */
48
- const entries = [];
49
-
50
- for (const file of files) {
51
- let json = /** @type {Record<string, unknown> | null} */ (null);
52
- let contentDispositionFilename = /** @type {string | null} */ (null);
53
-
54
- if (file.remote) {
55
- needleLog(PLUGIN, `Fetching remote GLB: ${file.path}`);
56
- const result = await readRemoteGlbJsonChunk(file.path);
57
- if (!result) { needleLog(PLUGIN, `Skipped (fetch failed): ${file.path}`, "warn"); continue; }
58
- json = result.json;
59
- contentDispositionFilename = result.filename;
60
- needleLog(PLUGIN, `Remote GLB ok — Content-Disposition: ${contentDispositionFilename ?? "(none)"}`);
61
- } else {
62
- json = file.type === "glb" ? readGlbJsonChunk(file.path) : readGltfJsonFile(file.path);
63
- }
64
- if (!json) continue;
65
-
66
- // Derive a friendly identifier for this GLB (used as SceneData key).
67
- // For local files: basename without extension.
68
- // For remote: Content-Disposition filename > last non-generic URL segment.
69
- const localPathForName = file.remote ? file.path : (
70
- projectRoot
71
- ? file.path.replace(projectRoot + "/", "").replace(projectRoot + "\\", "")
72
- : file.path
73
- );
74
- const glbKey = glbFriendlyName(localPathForName, contentDispositionFilename);
75
-
76
- for (const { nodeName, nodePath, componentName, fields, nodeThreeType } of extractComponentBindings(json)) {
77
- /** @type {Record<string, string>} */
78
- const fieldTypes = {};
79
- if (componentName) {
80
- const manifestFields = componentsManifest.get(componentName);
81
- if (manifestFields) {
82
- for (const [k, tsType] of manifestFields) {
83
- fieldTypes[k] = tsType;
84
- }
85
- } else {
86
- for (const [k, v] of Object.entries(fields)) {
87
- fieldTypes[k] = inferTsType(v);
88
- }
89
- }
90
- }
91
- const isEngineComponent = componentName ? componentsManifest.has(componentName) : false;
92
- const glbSrc = file.remote ? file.path : localPathForName;
93
- const glbSourceFiles = /** @type {string[] | undefined} */ (/** @type {any} */ (file).sourceFiles);
94
- entries.push({ nodeName, nodePath, componentName, fieldTypes, isEngineComponent, nodeThreeType, glbKey, glbSrc, glbSourceFiles });
95
- }
96
- }
97
-
98
- return entries;
99
- }
@@ -1,59 +0,0 @@
1
- // @ts-check
2
- /**
3
- * File writer — the only module that performs I/O writes.
4
- *
5
- * Orchestrates scanning, codegen, and writes the output files.
6
- * Returns false if content was already up-to-date (no write performed).
7
- */
8
-
9
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
10
- import { join, dirname } from 'path';
11
- import { scanBindings } from './dts.scan.js';
12
- import { generateDts, generateHtmlCustomData } from './dts.codegen.js';
13
-
14
- /**
15
- * Scan assets and write `needle-bindings.d.ts` and `needle-html-data.json`
16
- * to the output directory.
17
- * Returns the number of bindings written, or `false` if content was already up-to-date.
18
- *
19
- * @param {object} opts
20
- * @param {string} opts.assetsDir Absolute path to assets directory
21
- * @param {string} opts.outputPath Absolute path to write needle-bindings.d.ts
22
- * @param {string} [opts.projectRoot] Project root — enables entrypoint GLB detection
23
- * @param {string} [opts.codegenDir] Codegen directory — used to find gen.js and write needle-html-data.json (no binding copy written here)
24
- * @returns {Promise<number | false>}
25
- */
26
- export async function generateBindingsDts({ assetsDir, outputPath, projectRoot, codegenDir }) {
27
- const entries = await scanBindings(assetsDir, projectRoot, codegenDir);
28
- const content = generateDts(entries);
29
- const htmlContent = generateHtmlCustomData(entries);
30
-
31
- mkdirSync(dirname(outputPath), { recursive: true });
32
-
33
- let dtsChanged = false;
34
- try {
35
- const existing = existsSync(outputPath) ? readFileSync(outputPath, "utf8") : "";
36
- if (existing !== content) {
37
- writeFileSync(outputPath, content, "utf8");
38
- dtsChanged = true;
39
- }
40
- } catch (_e) {
41
- writeFileSync(outputPath, content, "utf8");
42
- dtsChanged = true;
43
- }
44
-
45
- const htmlDataPath = join(dirname(outputPath), "needle-html-data.json");
46
- try {
47
- const existingHtml = existsSync(htmlDataPath) ? readFileSync(htmlDataPath, "utf8") : "";
48
- if (existingHtml !== htmlContent) {
49
- writeFileSync(htmlDataPath, htmlContent, "utf8");
50
- }
51
- } catch (_e) {
52
- writeFileSync(htmlDataPath, htmlContent, "utf8");
53
- }
54
-
55
- if (!dtsChanged) return false;
56
- const nodeCount = new Set(entries.map(e => e.nodeName)).size;
57
- const bindingCount = new Set(entries.filter(e => e.componentName).map(e => `${e.nodeName}/${e.componentName}`)).size;
58
- return bindingCount > 0 ? bindingCount : nodeCount;
59
- }