sdl-mcp 0.12.2 → 0.12.3

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 (276) hide show
  1. package/README.md +10 -0
  2. package/config/sdlmcp.config.example.json +53 -8
  3. package/config/sdlmcp.config.schema.json +530 -106
  4. package/dist/.tsbuildinfo +1 -1
  5. package/dist/benchmark/external-manifest.d.ts +162 -0
  6. package/dist/benchmark/external-manifest.d.ts.map +1 -0
  7. package/dist/benchmark/external-manifest.js +336 -0
  8. package/dist/benchmark/external-manifest.js.map +1 -0
  9. package/dist/benchmark/external-runner.d.ts +100 -0
  10. package/dist/benchmark/external-runner.d.ts.map +1 -0
  11. package/dist/benchmark/external-runner.js +1171 -0
  12. package/dist/benchmark/external-runner.js.map +1 -0
  13. package/dist/benchmark/output-file.d.ts +3 -0
  14. package/dist/benchmark/output-file.d.ts.map +1 -0
  15. package/dist/benchmark/output-file.js +8 -0
  16. package/dist/benchmark/output-file.js.map +1 -0
  17. package/dist/cli/argParsing.d.ts.map +1 -1
  18. package/dist/cli/argParsing.js +6 -0
  19. package/dist/cli/argParsing.js.map +1 -1
  20. package/dist/cli/commands/benchmark.d.ts.map +1 -1
  21. package/dist/cli/commands/benchmark.js +3 -2
  22. package/dist/cli/commands/benchmark.js.map +1 -1
  23. package/dist/cli/commands/index.d.ts +1 -0
  24. package/dist/cli/commands/index.d.ts.map +1 -1
  25. package/dist/cli/commands/index.js +13 -7
  26. package/dist/cli/commands/index.js.map +1 -1
  27. package/dist/cli/commands/init.d.ts +5 -1
  28. package/dist/cli/commands/init.d.ts.map +1 -1
  29. package/dist/cli/commands/init.js +73 -3
  30. package/dist/cli/commands/init.js.map +1 -1
  31. package/dist/cli/commands/serve.d.ts.map +1 -1
  32. package/dist/cli/commands/serve.js +2 -0
  33. package/dist/cli/commands/serve.js.map +1 -1
  34. package/dist/cli/index.js +2 -0
  35. package/dist/cli/index.js.map +1 -1
  36. package/dist/cli/transport/http.d.ts +1 -35
  37. package/dist/cli/transport/http.d.ts.map +1 -1
  38. package/dist/cli/transport/http.js +151 -175
  39. package/dist/cli/transport/http.js.map +1 -1
  40. package/dist/cli/types.d.ts +1 -0
  41. package/dist/cli/types.d.ts.map +1 -1
  42. package/dist/config/constants.d.ts +30 -0
  43. package/dist/config/constants.d.ts.map +1 -1
  44. package/dist/config/constants.js +30 -0
  45. package/dist/config/constants.js.map +1 -1
  46. package/dist/config/types.d.ts +53 -1
  47. package/dist/config/types.d.ts.map +1 -1
  48. package/dist/config/types.js +62 -14
  49. package/dist/config/types.js.map +1 -1
  50. package/dist/db/ladybug-batching.d.ts +1 -0
  51. package/dist/db/ladybug-batching.d.ts.map +1 -1
  52. package/dist/db/ladybug-batching.js +1 -0
  53. package/dist/db/ladybug-batching.js.map +1 -1
  54. package/dist/db/ladybug-core.d.ts +3 -0
  55. package/dist/db/ladybug-core.d.ts.map +1 -1
  56. package/dist/db/ladybug-core.js +72 -2
  57. package/dist/db/ladybug-core.js.map +1 -1
  58. package/dist/db/ladybug-embeddings.d.ts +6 -1
  59. package/dist/db/ladybug-embeddings.d.ts.map +1 -1
  60. package/dist/db/ladybug-embeddings.js +6 -1
  61. package/dist/db/ladybug-embeddings.js.map +1 -1
  62. package/dist/db/ladybug-file-summaries.d.ts.map +1 -1
  63. package/dist/db/ladybug-file-summaries.js +23 -0
  64. package/dist/db/ladybug-file-summaries.js.map +1 -1
  65. package/dist/db/ladybug-queries.js +1 -1
  66. package/dist/db/ladybug-queries.js.map +1 -1
  67. package/dist/db/migrations/index.d.ts.map +1 -1
  68. package/dist/db/migrations/index.js +2 -0
  69. package/dist/db/migrations/index.js.map +1 -1
  70. package/dist/db/migrations/m007-copy-embeddings-to-symbol.d.ts +5 -9
  71. package/dist/db/migrations/m007-copy-embeddings-to-symbol.d.ts.map +1 -1
  72. package/dist/db/migrations/m007-copy-embeddings-to-symbol.js +24 -126
  73. package/dist/db/migrations/m007-copy-embeddings-to-symbol.js.map +1 -1
  74. package/dist/db/migrations/m021-remediate-symbol-embeddings.d.ts +5 -0
  75. package/dist/db/migrations/m021-remediate-symbol-embeddings.d.ts.map +1 -0
  76. package/dist/db/migrations/m021-remediate-symbol-embeddings.js +7 -0
  77. package/dist/db/migrations/m021-remediate-symbol-embeddings.js.map +1 -0
  78. package/dist/db/migrations/symbol-embedding-remediation.d.ts +57 -0
  79. package/dist/db/migrations/symbol-embedding-remediation.d.ts.map +1 -0
  80. package/dist/db/migrations/symbol-embedding-remediation.js +335 -0
  81. package/dist/db/migrations/symbol-embedding-remediation.js.map +1 -0
  82. package/dist/graph/layout/force-layout.d.ts +4 -0
  83. package/dist/graph/layout/force-layout.d.ts.map +1 -0
  84. package/dist/graph/layout/force-layout.js +127 -0
  85. package/dist/graph/layout/force-layout.js.map +1 -0
  86. package/dist/graph/layout/layout-service.d.ts +37 -0
  87. package/dist/graph/layout/layout-service.d.ts.map +1 -0
  88. package/dist/graph/layout/layout-service.js +172 -0
  89. package/dist/graph/layout/layout-service.js.map +1 -0
  90. package/dist/graph/layout/native-engine.d.ts +9 -0
  91. package/dist/graph/layout/native-engine.d.ts.map +1 -0
  92. package/dist/graph/layout/native-engine.js +59 -0
  93. package/dist/graph/layout/native-engine.js.map +1 -0
  94. package/dist/graph/layout/prng.d.ts +3 -0
  95. package/dist/graph/layout/prng.d.ts.map +1 -0
  96. package/dist/graph/layout/prng.js +19 -0
  97. package/dist/graph/layout/prng.js.map +1 -0
  98. package/dist/graph/layout/serializer.d.ts +3 -0
  99. package/dist/graph/layout/serializer.d.ts.map +1 -0
  100. package/dist/graph/layout/serializer.js +20 -0
  101. package/dist/graph/layout/serializer.js.map +1 -0
  102. package/dist/graph/layout/types.d.ts +30 -0
  103. package/dist/graph/layout/types.d.ts.map +1 -0
  104. package/dist/graph/layout/types.js +2 -0
  105. package/dist/graph/layout/types.js.map +1 -0
  106. package/dist/indexer/embeddings.d.ts +7 -0
  107. package/dist/indexer/embeddings.d.ts.map +1 -1
  108. package/dist/indexer/embeddings.js +44 -4
  109. package/dist/indexer/embeddings.js.map +1 -1
  110. package/dist/indexer/file-summary-embeddings.d.ts +12 -0
  111. package/dist/indexer/file-summary-embeddings.d.ts.map +1 -1
  112. package/dist/indexer/file-summary-embeddings.js +83 -21
  113. package/dist/indexer/file-summary-embeddings.js.map +1 -1
  114. package/dist/indexer/fileWalker.d.ts.map +1 -1
  115. package/dist/indexer/fileWalker.js +2 -1
  116. package/dist/indexer/fileWalker.js.map +1 -1
  117. package/dist/indexer/metrics-updater.d.ts.map +1 -1
  118. package/dist/indexer/metrics-updater.js +27 -4
  119. package/dist/indexer/metrics-updater.js.map +1 -1
  120. package/dist/indexer/watcher.d.ts.map +1 -1
  121. package/dist/indexer/watcher.js +2 -1
  122. package/dist/indexer/watcher.js.map +1 -1
  123. package/dist/mcp/context-response-projection.d.ts.map +1 -1
  124. package/dist/mcp/context-response-projection.js +49 -13
  125. package/dist/mcp/context-response-projection.js.map +1 -1
  126. package/dist/mcp/tools/search-edit/planner.d.ts.map +1 -1
  127. package/dist/mcp/tools/search-edit/planner.js +10 -3
  128. package/dist/mcp/tools/search-edit/planner.js.map +1 -1
  129. package/dist/observability/event-tap.d.ts +2 -1
  130. package/dist/observability/event-tap.d.ts.map +1 -1
  131. package/dist/observability/event-tap.js.map +1 -1
  132. package/dist/observability/service.d.ts +11 -4
  133. package/dist/observability/service.d.ts.map +1 -1
  134. package/dist/observability/service.js +83 -13
  135. package/dist/observability/service.js.map +1 -1
  136. package/dist/observability/types.d.ts +48 -2
  137. package/dist/observability/types.d.ts.map +1 -1
  138. package/dist/ui/.tsbuildinfo +1 -0
  139. package/dist/ui/vendor/fflate.js +2692 -0
  140. package/dist/ui/vendor/jsm/controls/ArcballControls.js +3543 -0
  141. package/dist/ui/vendor/jsm/controls/DragControls.js +452 -0
  142. package/dist/ui/vendor/jsm/controls/FirstPersonControls.js +488 -0
  143. package/dist/ui/vendor/jsm/controls/FlyControls.js +384 -0
  144. package/dist/ui/vendor/jsm/controls/MapControls.js +116 -0
  145. package/dist/ui/vendor/jsm/controls/OrbitControls.js +1963 -0
  146. package/dist/ui/vendor/jsm/controls/PointerLockControls.js +264 -0
  147. package/dist/ui/vendor/jsm/controls/TrackballControls.js +1001 -0
  148. package/dist/ui/vendor/jsm/controls/TransformControls.js +2003 -0
  149. package/dist/ui/vendor/jsm/loaders/3DMLoader.js +1836 -0
  150. package/dist/ui/vendor/jsm/loaders/3MFLoader.js +1621 -0
  151. package/dist/ui/vendor/jsm/loaders/AMFLoader.js +541 -0
  152. package/dist/ui/vendor/jsm/loaders/BVHLoader.js +484 -0
  153. package/dist/ui/vendor/jsm/loaders/ColladaLoader.js +153 -0
  154. package/dist/ui/vendor/jsm/loaders/DDSLoader.js +385 -0
  155. package/dist/ui/vendor/jsm/loaders/DRACOLoader.js +772 -0
  156. package/dist/ui/vendor/jsm/loaders/EXRLoader.js +3395 -0
  157. package/dist/ui/vendor/jsm/loaders/FBXLoader.js +4580 -0
  158. package/dist/ui/vendor/jsm/loaders/FontLoader.js +260 -0
  159. package/dist/ui/vendor/jsm/loaders/GCodeLoader.js +318 -0
  160. package/dist/ui/vendor/jsm/loaders/GLTFLoader.js +4860 -0
  161. package/dist/ui/vendor/jsm/loaders/HDRCubeTextureLoader.js +164 -0
  162. package/dist/ui/vendor/jsm/loaders/HDRLoader.js +463 -0
  163. package/dist/ui/vendor/jsm/loaders/IESLoader.js +379 -0
  164. package/dist/ui/vendor/jsm/loaders/KMZLoader.js +163 -0
  165. package/dist/ui/vendor/jsm/loaders/KTX2Loader.js +1276 -0
  166. package/dist/ui/vendor/jsm/loaders/KTXLoader.js +197 -0
  167. package/dist/ui/vendor/jsm/loaders/LDrawLoader.js +2510 -0
  168. package/dist/ui/vendor/jsm/loaders/LUT3dlLoader.js +205 -0
  169. package/dist/ui/vendor/jsm/loaders/LUTCubeLoader.js +190 -0
  170. package/dist/ui/vendor/jsm/loaders/LUTImageLoader.js +190 -0
  171. package/dist/ui/vendor/jsm/loaders/LWOLoader.js +1051 -0
  172. package/dist/ui/vendor/jsm/loaders/LottieLoader.js +130 -0
  173. package/dist/ui/vendor/jsm/loaders/MD2Loader.js +435 -0
  174. package/dist/ui/vendor/jsm/loaders/MDDLoader.js +147 -0
  175. package/dist/ui/vendor/jsm/loaders/MTLLoader.js +593 -0
  176. package/dist/ui/vendor/jsm/loaders/MaterialXLoader.js +1126 -0
  177. package/dist/ui/vendor/jsm/loaders/NRRDLoader.js +718 -0
  178. package/dist/ui/vendor/jsm/loaders/OBJLoader.js +955 -0
  179. package/dist/ui/vendor/jsm/loaders/PCDLoader.js +620 -0
  180. package/dist/ui/vendor/jsm/loaders/PDBLoader.js +272 -0
  181. package/dist/ui/vendor/jsm/loaders/PLYLoader.js +968 -0
  182. package/dist/ui/vendor/jsm/loaders/PVRLoader.js +270 -0
  183. package/dist/ui/vendor/jsm/loaders/RGBELoader.js +18 -0
  184. package/dist/ui/vendor/jsm/loaders/STLLoader.js +421 -0
  185. package/dist/ui/vendor/jsm/loaders/SVGLoader.js +3319 -0
  186. package/dist/ui/vendor/jsm/loaders/TDSLoader.js +1142 -0
  187. package/dist/ui/vendor/jsm/loaders/TGALoader.js +538 -0
  188. package/dist/ui/vendor/jsm/loaders/TIFFLoader.js +59 -0
  189. package/dist/ui/vendor/jsm/loaders/TTFLoader.js +261 -0
  190. package/dist/ui/vendor/jsm/loaders/USDLoader.js +303 -0
  191. package/dist/ui/vendor/jsm/loaders/USDZLoader.js +16 -0
  192. package/dist/ui/vendor/jsm/loaders/UltraHDRLoader.js +755 -0
  193. package/dist/ui/vendor/jsm/loaders/VOXLoader.js +919 -0
  194. package/dist/ui/vendor/jsm/loaders/VRMLLoader.js +3646 -0
  195. package/dist/ui/vendor/jsm/loaders/VTKLoader.js +1293 -0
  196. package/dist/ui/vendor/jsm/loaders/XYZLoader.js +143 -0
  197. package/dist/ui/vendor/jsm/loaders/collada/ColladaComposer.js +3044 -0
  198. package/dist/ui/vendor/jsm/loaders/collada/ColladaParser.js +1977 -0
  199. package/dist/ui/vendor/jsm/loaders/lwo/IFFParser.js +1217 -0
  200. package/dist/ui/vendor/jsm/loaders/lwo/LWO2Parser.js +414 -0
  201. package/dist/ui/vendor/jsm/loaders/lwo/LWO3Parser.js +373 -0
  202. package/dist/ui/vendor/jsm/loaders/usd/USDAParser.js +901 -0
  203. package/dist/ui/vendor/jsm/loaders/usd/USDCParser.js +1878 -0
  204. package/dist/ui/vendor/jsm/loaders/usd/USDComposer.js +4627 -0
  205. package/dist/ui/vendor/jsm/utils/BufferGeometryUtils.js +1501 -0
  206. package/dist/ui/vendor/jsm/utils/CameraUtils.js +82 -0
  207. package/dist/ui/vendor/jsm/utils/ColorUtils.js +76 -0
  208. package/dist/ui/vendor/jsm/utils/GeometryCompressionUtils.js +547 -0
  209. package/dist/ui/vendor/jsm/utils/GeometryUtils.js +226 -0
  210. package/dist/ui/vendor/jsm/utils/LDrawUtils.js +211 -0
  211. package/dist/ui/vendor/jsm/utils/SceneOptimizer.js +458 -0
  212. package/dist/ui/vendor/jsm/utils/SceneUtils.js +363 -0
  213. package/dist/ui/vendor/jsm/utils/ShadowMapViewer.js +244 -0
  214. package/dist/ui/vendor/jsm/utils/ShadowMapViewerGPU.js +233 -0
  215. package/dist/ui/vendor/jsm/utils/SkeletonUtils.js +496 -0
  216. package/dist/ui/vendor/jsm/utils/SortUtils.js +175 -0
  217. package/dist/ui/vendor/jsm/utils/UVsDebug.js +173 -0
  218. package/dist/ui/vendor/jsm/utils/WebGLTextureUtils.js +115 -0
  219. package/dist/ui/vendor/jsm/utils/WebGPUTextureUtils.js +81 -0
  220. package/dist/ui/vendor/jsm/utils/WorkerPool.js +167 -0
  221. package/dist/ui/vendor/three.core.min.js +6 -0
  222. package/dist/ui/vendor/three.module.min.js +6 -0
  223. package/dist/ui/viewer/ambient.js +39 -0
  224. package/dist/ui/viewer/api.js +93 -0
  225. package/dist/ui/viewer/chrome.js +36 -0
  226. package/dist/ui/viewer/edges.js +33 -0
  227. package/dist/ui/viewer/index.html +32 -0
  228. package/dist/ui/viewer/inspector.js +23 -0
  229. package/dist/ui/viewer/lenses/activity.js +24 -0
  230. package/dist/ui/viewer/lenses/community.js +5 -0
  231. package/dist/ui/viewer/lenses/edges.js +4 -0
  232. package/dist/ui/viewer/lenses/impact.js +6 -0
  233. package/dist/ui/viewer/lenses/search.js +69 -0
  234. package/dist/ui/viewer/lod.js +100 -0
  235. package/dist/ui/viewer/main.js +92 -0
  236. package/dist/ui/viewer/picking.js +45 -0
  237. package/dist/ui/viewer/scene.js +85 -0
  238. package/dist/ui/viewer/skins/default-skin.js +15 -0
  239. package/dist/ui/viewer/skins/loader.js +44 -0
  240. package/dist/ui/viewer/skins/manifest-schema.js +30 -0
  241. package/dist/ui/viewer/state.js +44 -0
  242. package/dist/ui/viewer/theme.js +23 -0
  243. package/dist/ui/viewer/universe.js +151 -0
  244. package/dist/ui/viewer/viewer.css +85 -0
  245. package/dist/util/safeRegex.d.ts.map +1 -1
  246. package/dist/util/safeRegex.js +221 -68
  247. package/dist/util/safeRegex.js.map +1 -1
  248. package/dist/viewer/legacy-graph.d.ts +40 -0
  249. package/dist/viewer/legacy-graph.d.ts.map +1 -0
  250. package/dist/viewer/legacy-graph.js +152 -0
  251. package/dist/viewer/legacy-graph.js.map +1 -0
  252. package/dist/viewer/routes.d.ts +10 -0
  253. package/dist/viewer/routes.d.ts.map +1 -0
  254. package/dist/viewer/routes.js +221 -0
  255. package/dist/viewer/routes.js.map +1 -0
  256. package/dist/viewer/service.d.ts +44 -0
  257. package/dist/viewer/service.d.ts.map +1 -0
  258. package/dist/viewer/service.js +160 -0
  259. package/dist/viewer/service.js.map +1 -0
  260. package/dist/viewer/types.d.ts +63 -0
  261. package/dist/viewer/types.d.ts.map +1 -0
  262. package/dist/viewer/types.js +2 -0
  263. package/dist/viewer/types.js.map +1 -0
  264. package/dist/viewer/viewer-config.d.ts +12 -0
  265. package/dist/viewer/viewer-config.d.ts.map +1 -0
  266. package/dist/viewer/viewer-config.js +36 -0
  267. package/dist/viewer/viewer-config.js.map +1 -0
  268. package/package.json +18 -9
  269. package/templates/SDL.md +19 -0
  270. package/templates/claude-code.json +8 -43
  271. package/dist/ui/graph.css +0 -108
  272. package/dist/ui/graph.d.ts +0 -2
  273. package/dist/ui/graph.d.ts.map +0 -1
  274. package/dist/ui/graph.html +0 -52
  275. package/dist/ui/graph.js +0 -259
  276. package/dist/ui/graph.js.map +0 -1
@@ -0,0 +1,130 @@
1
+ import {
2
+ FileLoader,
3
+ Loader,
4
+ CanvasTexture,
5
+ NearestFilter,
6
+ SRGBColorSpace
7
+ } from 'three';
8
+
9
+ import lottie from 'https://cdn.jsdelivr.net/npm/lottie-web@5.13.0/+esm';
10
+
11
+ /**
12
+ * A loader for the Lottie texture animation format.
13
+ *
14
+ * The loader returns an instance of {@link CanvasTexture} to represent
15
+ * the animated texture. Two additional properties are added to each texture:
16
+ * - `animation`: The return value of `lottie.loadAnimation()` which is an object
17
+ * with an API for controlling the animation's playback.
18
+ * - `image`: The image container.
19
+ *
20
+ * ```js
21
+ * const loader = new LottieLoader();
22
+ * loader.setQuality( 2 );
23
+ * const texture = await loader.loadAsync( 'textures/lottie/24017-lottie-logo-animation.json' );
24
+ *
25
+ * const geometry = new THREE.BoxGeometry();
26
+ * const material = new THREE.MeshBasicMaterial( { map: texture } );
27
+ * const mesh = new THREE.Mesh( geometry, material );
28
+ * scene.add( mesh );
29
+ * ```
30
+ *
31
+ * @augments Loader
32
+ * @three_import import { LottieLoader } from 'three/addons/loaders/LottieLoader.js';
33
+ */
34
+ class LottieLoader extends Loader {
35
+
36
+ /**
37
+ * Constructs a new Lottie loader.
38
+ *
39
+ * @deprecated The loader has been deprecated and will be removed with r186. Use lottie-web instead and create your animated texture manually.
40
+ * @param {LoadingManager} [manager] - The loading manager.
41
+ */
42
+ constructor( manager ) {
43
+
44
+ super( manager );
45
+
46
+ console.warn( 'THREE.LottieLoader: The loader has been deprecated and will be removed with r186. Use lottie-web instead and create your animated texture manually.' );
47
+
48
+ }
49
+
50
+ /**
51
+ * Sets the texture quality.
52
+ *
53
+ * @param {number} value - The texture quality.
54
+ */
55
+ setQuality( value ) {
56
+
57
+ this._quality = value;
58
+
59
+ }
60
+
61
+ /**
62
+ * Starts loading from the given URL and passes the loaded Lottie asset
63
+ * to the `onLoad()` callback.
64
+ *
65
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
66
+ * @param {function(CanvasTexture)} onLoad - Executed when the loading process has been finished.
67
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
68
+ * @param {onErrorCallback} onError - Executed when errors occur.
69
+ * @returns {CanvasTexture} The Lottie texture.
70
+ */
71
+ load( url, onLoad, onProgress, onError ) {
72
+
73
+ const quality = this._quality || 1;
74
+
75
+ const texture = new CanvasTexture();
76
+ texture.minFilter = NearestFilter;
77
+ texture.generateMipmaps = false;
78
+ texture.colorSpace = SRGBColorSpace;
79
+
80
+ const loader = new FileLoader( this.manager );
81
+ loader.setPath( this.path );
82
+ loader.setWithCredentials( this.withCredentials );
83
+
84
+ loader.load( url, function ( text ) {
85
+
86
+ const data = JSON.parse( text );
87
+
88
+ // lottie uses container.offsetWidth and offsetHeight
89
+ // to define width/height
90
+
91
+ const container = document.createElement( 'div' );
92
+ container.style.width = data.w + 'px';
93
+ container.style.height = data.h + 'px';
94
+ document.body.appendChild( container );
95
+
96
+ const animation = lottie.loadAnimation( {
97
+ container: container,
98
+ animType: 'canvas',
99
+ loop: true,
100
+ autoplay: true,
101
+ animationData: data,
102
+ rendererSettings: { dpr: quality }
103
+ } );
104
+
105
+ texture.animation = animation;
106
+ texture.image = animation.container;
107
+
108
+ animation.addEventListener( 'enterFrame', function () {
109
+
110
+ texture.needsUpdate = true;
111
+
112
+ } );
113
+
114
+ container.style.display = 'none';
115
+
116
+ if ( onLoad !== undefined ) {
117
+
118
+ onLoad( texture );
119
+
120
+ }
121
+
122
+ }, onProgress, onError );
123
+
124
+ return texture;
125
+
126
+ }
127
+
128
+ }
129
+
130
+ export { LottieLoader };
@@ -0,0 +1,435 @@
1
+ import {
2
+ AnimationClip,
3
+ BufferGeometry,
4
+ FileLoader,
5
+ Float32BufferAttribute,
6
+ Loader,
7
+ Vector3
8
+ } from 'three';
9
+
10
+ const _normalData = [
11
+ [ - 0.525731, 0.000000, 0.850651 ], [ - 0.442863, 0.238856, 0.864188 ],
12
+ [ - 0.295242, 0.000000, 0.955423 ], [ - 0.309017, 0.500000, 0.809017 ],
13
+ [ - 0.162460, 0.262866, 0.951056 ], [ 0.000000, 0.000000, 1.000000 ],
14
+ [ 0.000000, 0.850651, 0.525731 ], [ - 0.147621, 0.716567, 0.681718 ],
15
+ [ 0.147621, 0.716567, 0.681718 ], [ 0.000000, 0.525731, 0.850651 ],
16
+ [ 0.309017, 0.500000, 0.809017 ], [ 0.525731, 0.000000, 0.850651 ],
17
+ [ 0.295242, 0.000000, 0.955423 ], [ 0.442863, 0.238856, 0.864188 ],
18
+ [ 0.162460, 0.262866, 0.951056 ], [ - 0.681718, 0.147621, 0.716567 ],
19
+ [ - 0.809017, 0.309017, 0.500000 ], [ - 0.587785, 0.425325, 0.688191 ],
20
+ [ - 0.850651, 0.525731, 0.000000 ], [ - 0.864188, 0.442863, 0.238856 ],
21
+ [ - 0.716567, 0.681718, 0.147621 ], [ - 0.688191, 0.587785, 0.425325 ],
22
+ [ - 0.500000, 0.809017, 0.309017 ], [ - 0.238856, 0.864188, 0.442863 ],
23
+ [ - 0.425325, 0.688191, 0.587785 ], [ - 0.716567, 0.681718, - 0.147621 ],
24
+ [ - 0.500000, 0.809017, - 0.309017 ], [ - 0.525731, 0.850651, 0.000000 ],
25
+ [ 0.000000, 0.850651, - 0.525731 ], [ - 0.238856, 0.864188, - 0.442863 ],
26
+ [ 0.000000, 0.955423, - 0.295242 ], [ - 0.262866, 0.951056, - 0.162460 ],
27
+ [ 0.000000, 1.000000, 0.000000 ], [ 0.000000, 0.955423, 0.295242 ],
28
+ [ - 0.262866, 0.951056, 0.162460 ], [ 0.238856, 0.864188, 0.442863 ],
29
+ [ 0.262866, 0.951056, 0.162460 ], [ 0.500000, 0.809017, 0.309017 ],
30
+ [ 0.238856, 0.864188, - 0.442863 ], [ 0.262866, 0.951056, - 0.162460 ],
31
+ [ 0.500000, 0.809017, - 0.309017 ], [ 0.850651, 0.525731, 0.000000 ],
32
+ [ 0.716567, 0.681718, 0.147621 ], [ 0.716567, 0.681718, - 0.147621 ],
33
+ [ 0.525731, 0.850651, 0.000000 ], [ 0.425325, 0.688191, 0.587785 ],
34
+ [ 0.864188, 0.442863, 0.238856 ], [ 0.688191, 0.587785, 0.425325 ],
35
+ [ 0.809017, 0.309017, 0.500000 ], [ 0.681718, 0.147621, 0.716567 ],
36
+ [ 0.587785, 0.425325, 0.688191 ], [ 0.955423, 0.295242, 0.000000 ],
37
+ [ 1.000000, 0.000000, 0.000000 ], [ 0.951056, 0.162460, 0.262866 ],
38
+ [ 0.850651, - 0.525731, 0.000000 ], [ 0.955423, - 0.295242, 0.000000 ],
39
+ [ 0.864188, - 0.442863, 0.238856 ], [ 0.951056, - 0.162460, 0.262866 ],
40
+ [ 0.809017, - 0.309017, 0.500000 ], [ 0.681718, - 0.147621, 0.716567 ],
41
+ [ 0.850651, 0.000000, 0.525731 ], [ 0.864188, 0.442863, - 0.238856 ],
42
+ [ 0.809017, 0.309017, - 0.500000 ], [ 0.951056, 0.162460, - 0.262866 ],
43
+ [ 0.525731, 0.000000, - 0.850651 ], [ 0.681718, 0.147621, - 0.716567 ],
44
+ [ 0.681718, - 0.147621, - 0.716567 ], [ 0.850651, 0.000000, - 0.525731 ],
45
+ [ 0.809017, - 0.309017, - 0.500000 ], [ 0.864188, - 0.442863, - 0.238856 ],
46
+ [ 0.951056, - 0.162460, - 0.262866 ], [ 0.147621, 0.716567, - 0.681718 ],
47
+ [ 0.309017, 0.500000, - 0.809017 ], [ 0.425325, 0.688191, - 0.587785 ],
48
+ [ 0.442863, 0.238856, - 0.864188 ], [ 0.587785, 0.425325, - 0.688191 ],
49
+ [ 0.688191, 0.587785, - 0.425325 ], [ - 0.147621, 0.716567, - 0.681718 ],
50
+ [ - 0.309017, 0.500000, - 0.809017 ], [ 0.000000, 0.525731, - 0.850651 ],
51
+ [ - 0.525731, 0.000000, - 0.850651 ], [ - 0.442863, 0.238856, - 0.864188 ],
52
+ [ - 0.295242, 0.000000, - 0.955423 ], [ - 0.162460, 0.262866, - 0.951056 ],
53
+ [ 0.000000, 0.000000, - 1.000000 ], [ 0.295242, 0.000000, - 0.955423 ],
54
+ [ 0.162460, 0.262866, - 0.951056 ], [ - 0.442863, - 0.238856, - 0.864188 ],
55
+ [ - 0.309017, - 0.500000, - 0.809017 ], [ - 0.162460, - 0.262866, - 0.951056 ],
56
+ [ 0.000000, - 0.850651, - 0.525731 ], [ - 0.147621, - 0.716567, - 0.681718 ],
57
+ [ 0.147621, - 0.716567, - 0.681718 ], [ 0.000000, - 0.525731, - 0.850651 ],
58
+ [ 0.309017, - 0.500000, - 0.809017 ], [ 0.442863, - 0.238856, - 0.864188 ],
59
+ [ 0.162460, - 0.262866, - 0.951056 ], [ 0.238856, - 0.864188, - 0.442863 ],
60
+ [ 0.500000, - 0.809017, - 0.309017 ], [ 0.425325, - 0.688191, - 0.587785 ],
61
+ [ 0.716567, - 0.681718, - 0.147621 ], [ 0.688191, - 0.587785, - 0.425325 ],
62
+ [ 0.587785, - 0.425325, - 0.688191 ], [ 0.000000, - 0.955423, - 0.295242 ],
63
+ [ 0.000000, - 1.000000, 0.000000 ], [ 0.262866, - 0.951056, - 0.162460 ],
64
+ [ 0.000000, - 0.850651, 0.525731 ], [ 0.000000, - 0.955423, 0.295242 ],
65
+ [ 0.238856, - 0.864188, 0.442863 ], [ 0.262866, - 0.951056, 0.162460 ],
66
+ [ 0.500000, - 0.809017, 0.309017 ], [ 0.716567, - 0.681718, 0.147621 ],
67
+ [ 0.525731, - 0.850651, 0.000000 ], [ - 0.238856, - 0.864188, - 0.442863 ],
68
+ [ - 0.500000, - 0.809017, - 0.309017 ], [ - 0.262866, - 0.951056, - 0.162460 ],
69
+ [ - 0.850651, - 0.525731, 0.000000 ], [ - 0.716567, - 0.681718, - 0.147621 ],
70
+ [ - 0.716567, - 0.681718, 0.147621 ], [ - 0.525731, - 0.850651, 0.000000 ],
71
+ [ - 0.500000, - 0.809017, 0.309017 ], [ - 0.238856, - 0.864188, 0.442863 ],
72
+ [ - 0.262866, - 0.951056, 0.162460 ], [ - 0.864188, - 0.442863, 0.238856 ],
73
+ [ - 0.809017, - 0.309017, 0.500000 ], [ - 0.688191, - 0.587785, 0.425325 ],
74
+ [ - 0.681718, - 0.147621, 0.716567 ], [ - 0.442863, - 0.238856, 0.864188 ],
75
+ [ - 0.587785, - 0.425325, 0.688191 ], [ - 0.309017, - 0.500000, 0.809017 ],
76
+ [ - 0.147621, - 0.716567, 0.681718 ], [ - 0.425325, - 0.688191, 0.587785 ],
77
+ [ - 0.162460, - 0.262866, 0.951056 ], [ 0.442863, - 0.238856, 0.864188 ],
78
+ [ 0.162460, - 0.262866, 0.951056 ], [ 0.309017, - 0.500000, 0.809017 ],
79
+ [ 0.147621, - 0.716567, 0.681718 ], [ 0.000000, - 0.525731, 0.850651 ],
80
+ [ 0.425325, - 0.688191, 0.587785 ], [ 0.587785, - 0.425325, 0.688191 ],
81
+ [ 0.688191, - 0.587785, 0.425325 ], [ - 0.955423, 0.295242, 0.000000 ],
82
+ [ - 0.951056, 0.162460, 0.262866 ], [ - 1.000000, 0.000000, 0.000000 ],
83
+ [ - 0.850651, 0.000000, 0.525731 ], [ - 0.955423, - 0.295242, 0.000000 ],
84
+ [ - 0.951056, - 0.162460, 0.262866 ], [ - 0.864188, 0.442863, - 0.238856 ],
85
+ [ - 0.951056, 0.162460, - 0.262866 ], [ - 0.809017, 0.309017, - 0.500000 ],
86
+ [ - 0.864188, - 0.442863, - 0.238856 ], [ - 0.951056, - 0.162460, - 0.262866 ],
87
+ [ - 0.809017, - 0.309017, - 0.500000 ], [ - 0.681718, 0.147621, - 0.716567 ],
88
+ [ - 0.681718, - 0.147621, - 0.716567 ], [ - 0.850651, 0.000000, - 0.525731 ],
89
+ [ - 0.688191, 0.587785, - 0.425325 ], [ - 0.587785, 0.425325, - 0.688191 ],
90
+ [ - 0.425325, 0.688191, - 0.587785 ], [ - 0.425325, - 0.688191, - 0.587785 ],
91
+ [ - 0.587785, - 0.425325, - 0.688191 ], [ - 0.688191, - 0.587785, - 0.425325 ]
92
+ ];
93
+
94
+ /**
95
+ * A loader for the MD2 format.
96
+ *
97
+ * The loader represents the animations of the MD2 asset as an array of animation
98
+ * clips and stores them in the `animations` property of the geometry.
99
+ *
100
+ * ```js
101
+ * const loader = new MD2Loader();
102
+ * const geometry = await loader.loadAsync( './models/md2/ogro/ogro.md2' );
103
+ *
104
+ * const animations = geometry.animations;
105
+ * ```
106
+ *
107
+ * @augments Loader
108
+ * @three_import import { MD2Loader } from 'three/addons/loaders/MD2Loader.js';
109
+ */
110
+ class MD2Loader extends Loader {
111
+
112
+ /**
113
+ * Constructs a new MD2 loader.
114
+ *
115
+ * @param {LoadingManager} [manager] - The loading manager.
116
+ */
117
+ constructor( manager ) {
118
+
119
+ super( manager );
120
+
121
+ }
122
+
123
+ /**
124
+ * Starts loading from the given URL and passes the loaded MD2 asset
125
+ * to the `onLoad()` callback.
126
+ *
127
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
128
+ * @param {function(BufferGeometry)} onLoad - Executed when the loading process has been finished.
129
+ * @param {onProgressCallback} [onProgress] - Executed while the loading is in progress.
130
+ * @param {onErrorCallback} [onError] - Executed when errors occur.
131
+ */
132
+ load( url, onLoad, onProgress, onError ) {
133
+
134
+ const scope = this;
135
+
136
+ const loader = new FileLoader( scope.manager );
137
+ loader.setPath( scope.path );
138
+ loader.setResponseType( 'arraybuffer' );
139
+ loader.setRequestHeader( scope.requestHeader );
140
+ loader.setWithCredentials( scope.withCredentials );
141
+ loader.load( url, function ( buffer ) {
142
+
143
+ try {
144
+
145
+ onLoad( scope.parse( buffer ) );
146
+
147
+ } catch ( e ) {
148
+
149
+ if ( onError ) {
150
+
151
+ onError( e );
152
+
153
+ } else {
154
+
155
+ console.error( e );
156
+
157
+ }
158
+
159
+ scope.manager.itemError( url );
160
+
161
+ }
162
+
163
+ }, onProgress, onError );
164
+
165
+ }
166
+
167
+ /**
168
+ * Parses the given MD2 data and returns a geometry.
169
+ *
170
+ * @param {ArrayBuffer} buffer - The raw MD2 data as an array buffer.
171
+ * @return {BufferGeometry} The parsed geometry data.
172
+ */
173
+ parse( buffer ) {
174
+
175
+ const data = new DataView( buffer );
176
+
177
+ // http://tfc.duke.free.fr/coding/md2-specs-en.html
178
+
179
+ const header = {};
180
+ const headerNames = [
181
+ 'ident', 'version',
182
+ 'skinwidth', 'skinheight',
183
+ 'framesize',
184
+ 'num_skins', 'num_vertices', 'num_st', 'num_tris', 'num_glcmds', 'num_frames',
185
+ 'offset_skins', 'offset_st', 'offset_tris', 'offset_frames', 'offset_glcmds', 'offset_end'
186
+ ];
187
+
188
+ for ( let i = 0; i < headerNames.length; i ++ ) {
189
+
190
+ header[ headerNames[ i ] ] = data.getInt32( i * 4, true );
191
+
192
+ }
193
+
194
+ if ( header.ident !== 844121161 || header.version !== 8 ) {
195
+
196
+ console.error( 'Not a valid MD2 file' );
197
+ return;
198
+
199
+ }
200
+
201
+ if ( header.offset_end !== data.byteLength ) {
202
+
203
+ console.error( 'Corrupted MD2 file' );
204
+ return;
205
+
206
+ }
207
+
208
+ //
209
+
210
+ const geometry = new BufferGeometry();
211
+
212
+ // uvs
213
+
214
+ const uvsTemp = [];
215
+ let offset = header.offset_st;
216
+
217
+ for ( let i = 0, l = header.num_st; i < l; i ++ ) {
218
+
219
+ const u = data.getInt16( offset + 0, true );
220
+ const v = data.getInt16( offset + 2, true );
221
+
222
+ uvsTemp.push( u / header.skinwidth, 1 - ( v / header.skinheight ) );
223
+
224
+ offset += 4;
225
+
226
+ }
227
+
228
+ // triangles
229
+
230
+ offset = header.offset_tris;
231
+
232
+ const vertexIndices = [];
233
+ const uvIndices = [];
234
+
235
+ for ( let i = 0, l = header.num_tris; i < l; i ++ ) {
236
+
237
+ vertexIndices.push(
238
+ data.getUint16( offset + 0, true ),
239
+ data.getUint16( offset + 2, true ),
240
+ data.getUint16( offset + 4, true )
241
+ );
242
+
243
+ uvIndices.push(
244
+ data.getUint16( offset + 6, true ),
245
+ data.getUint16( offset + 8, true ),
246
+ data.getUint16( offset + 10, true )
247
+ );
248
+
249
+ offset += 12;
250
+
251
+ }
252
+
253
+ // frames
254
+
255
+ const translation = new Vector3();
256
+ const scale = new Vector3();
257
+
258
+ const frames = [];
259
+
260
+ offset = header.offset_frames;
261
+
262
+ for ( let i = 0, l = header.num_frames; i < l; i ++ ) {
263
+
264
+ scale.set(
265
+ data.getFloat32( offset + 0, true ),
266
+ data.getFloat32( offset + 4, true ),
267
+ data.getFloat32( offset + 8, true )
268
+ );
269
+
270
+ translation.set(
271
+ data.getFloat32( offset + 12, true ),
272
+ data.getFloat32( offset + 16, true ),
273
+ data.getFloat32( offset + 20, true )
274
+ );
275
+
276
+ offset += 24;
277
+
278
+ const string = [];
279
+
280
+ for ( let j = 0; j < 16; j ++ ) {
281
+
282
+ const character = data.getUint8( offset + j );
283
+ if ( character === 0 ) break;
284
+
285
+ string[ j ] = character;
286
+
287
+ }
288
+
289
+ const frame = {
290
+ name: String.fromCharCode.apply( null, string ),
291
+ vertices: [],
292
+ normals: []
293
+ };
294
+
295
+ offset += 16;
296
+
297
+ for ( let j = 0; j < header.num_vertices; j ++ ) {
298
+
299
+ let x = data.getUint8( offset ++ );
300
+ let y = data.getUint8( offset ++ );
301
+ let z = data.getUint8( offset ++ );
302
+ const n = _normalData[ data.getUint8( offset ++ ) ];
303
+
304
+ x = x * scale.x + translation.x;
305
+ y = y * scale.y + translation.y;
306
+ z = z * scale.z + translation.z;
307
+
308
+ frame.vertices.push( x, z, y ); // convert to Y-up
309
+ frame.normals.push( n[ 0 ], n[ 2 ], n[ 1 ] ); // convert to Y-up
310
+
311
+ }
312
+
313
+ frames.push( frame );
314
+
315
+ }
316
+
317
+ // static
318
+
319
+ const positions = [];
320
+ const normals = [];
321
+ const uvs = [];
322
+
323
+ const verticesTemp = frames[ 0 ].vertices;
324
+ const normalsTemp = frames[ 0 ].normals;
325
+
326
+ for ( let i = 0, l = vertexIndices.length; i < l; i ++ ) {
327
+
328
+ const vertexIndex = vertexIndices[ i ];
329
+ let stride = vertexIndex * 3;
330
+
331
+ //
332
+
333
+ const x = verticesTemp[ stride ];
334
+ const y = verticesTemp[ stride + 1 ];
335
+ const z = verticesTemp[ stride + 2 ];
336
+
337
+ positions.push( x, y, z );
338
+
339
+ //
340
+
341
+ const nx = normalsTemp[ stride ];
342
+ const ny = normalsTemp[ stride + 1 ];
343
+ const nz = normalsTemp[ stride + 2 ];
344
+
345
+ normals.push( nx, ny, nz );
346
+
347
+ //
348
+
349
+ const uvIndex = uvIndices[ i ];
350
+ stride = uvIndex * 2;
351
+
352
+ const u = uvsTemp[ stride ];
353
+ const v = uvsTemp[ stride + 1 ];
354
+
355
+ uvs.push( u, v );
356
+
357
+ }
358
+
359
+ geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
360
+ geometry.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
361
+ geometry.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
362
+
363
+ // animation
364
+
365
+ const morphPositions = [];
366
+ const morphNormals = [];
367
+
368
+ for ( let i = 0, l = frames.length; i < l; i ++ ) {
369
+
370
+ const frame = frames[ i ];
371
+ const attributeName = frame.name;
372
+
373
+ if ( frame.vertices.length > 0 ) {
374
+
375
+ const positions = [];
376
+
377
+ for ( let j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
378
+
379
+ const vertexIndex = vertexIndices[ j ];
380
+ const stride = vertexIndex * 3;
381
+
382
+ const x = frame.vertices[ stride ];
383
+ const y = frame.vertices[ stride + 1 ];
384
+ const z = frame.vertices[ stride + 2 ];
385
+
386
+ positions.push( x, y, z );
387
+
388
+ }
389
+
390
+ const positionAttribute = new Float32BufferAttribute( positions, 3 );
391
+ positionAttribute.name = attributeName;
392
+
393
+ morphPositions.push( positionAttribute );
394
+
395
+ }
396
+
397
+ if ( frame.normals.length > 0 ) {
398
+
399
+ const normals = [];
400
+
401
+ for ( let j = 0, jl = vertexIndices.length; j < jl; j ++ ) {
402
+
403
+ const vertexIndex = vertexIndices[ j ];
404
+ const stride = vertexIndex * 3;
405
+
406
+ const nx = frame.normals[ stride ];
407
+ const ny = frame.normals[ stride + 1 ];
408
+ const nz = frame.normals[ stride + 2 ];
409
+
410
+ normals.push( nx, ny, nz );
411
+
412
+ }
413
+
414
+ const normalAttribute = new Float32BufferAttribute( normals, 3 );
415
+ normalAttribute.name = attributeName;
416
+
417
+ morphNormals.push( normalAttribute );
418
+
419
+ }
420
+
421
+ }
422
+
423
+ geometry.morphAttributes.position = morphPositions;
424
+ geometry.morphAttributes.normal = morphNormals;
425
+ geometry.morphTargetsRelative = false;
426
+
427
+ geometry.animations = AnimationClip.CreateClipsFromMorphTargetSequences( frames, 10, false );
428
+
429
+ return geometry;
430
+
431
+ }
432
+
433
+ }
434
+
435
+ export { MD2Loader };
@@ -0,0 +1,147 @@
1
+ import {
2
+ AnimationClip,
3
+ BufferAttribute,
4
+ FileLoader,
5
+ Loader,
6
+ NumberKeyframeTrack
7
+ } from 'three';
8
+
9
+ /**
10
+ * A loader for the MDD format.
11
+ *
12
+ * MDD stores a position for every vertex in a model for every frame in an animation.
13
+ * Similar to BVH, it can be used to transfer animation data between different 3D applications or engines.
14
+ *
15
+ * MDD stores its data in binary format (big endian) in the following way:
16
+ *
17
+ * - number of frames (a single uint32)
18
+ * - number of vertices (a single uint32)
19
+ * - time values for each frame (sequence of float32)
20
+ * - vertex data for each frame (sequence of float32)
21
+ *
22
+ * ```js
23
+ * const loader = new MDDLoader();
24
+ * const result = await loader.loadAsync( 'models/mdd/cube.mdd' );
25
+ *
26
+ * const morphTargets = result.morphTargets;
27
+ * const clip = result.clip;
28
+ * // clip.optimize(); // optional
29
+ *
30
+ * const geometry = new THREE.BoxGeometry();
31
+ * geometry.morphAttributes.position = morphTargets; // apply morph targets (vertex data must match)
32
+ *
33
+ * const material = new THREE.MeshBasicMaterial();
34
+ *
35
+ * const mesh = new THREE.Mesh( geometry, material );
36
+ * scene.add( mesh );
37
+ *
38
+ * const mixer = new THREE.AnimationMixer( mesh );
39
+ * mixer.clipAction( clip ).play();
40
+ * ```
41
+ *
42
+ * @augments Loader
43
+ * @three_import import { MDDLoader } from 'three/addons/loaders/MDDLoader.js';
44
+ */
45
+ class MDDLoader extends Loader {
46
+
47
+ /**
48
+ * Constructs a new MDD loader.
49
+ *
50
+ * @param {LoadingManager} [manager] - The loading manager.
51
+ */
52
+ constructor( manager ) {
53
+
54
+ super( manager );
55
+
56
+ }
57
+
58
+ /**
59
+ * Starts loading from the given URL and passes the loaded MDD asset
60
+ * to the `onLoad()` callback.
61
+ *
62
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
63
+ * @param {function({clip:AnimationClip, morphTargets:Array<BufferAttribute>})} onLoad - Executed when the loading process has been finished.
64
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
65
+ * @param {onErrorCallback} onError - Executed when errors occur.
66
+ */
67
+ load( url, onLoad, onProgress, onError ) {
68
+
69
+ const scope = this;
70
+
71
+ const loader = new FileLoader( this.manager );
72
+ loader.setPath( this.path );
73
+ loader.setResponseType( 'arraybuffer' );
74
+ loader.load( url, function ( data ) {
75
+
76
+ onLoad( scope.parse( data ) );
77
+
78
+ }, onProgress, onError );
79
+
80
+ }
81
+
82
+ /**
83
+ * Parses the given MDD data and returns an object holding the animation clip and the respective
84
+ * morph targets.
85
+ *
86
+ * @param {ArrayBuffer} data - The raw XYZ data as an array buffer.
87
+ * @return {{clip:AnimationClip, morphTargets:Array<BufferAttribute>}} The result object.
88
+ */
89
+ parse( data ) {
90
+
91
+ const view = new DataView( data );
92
+
93
+ const totalFrames = view.getUint32( 0 );
94
+ const totalPoints = view.getUint32( 4 );
95
+
96
+ let offset = 8;
97
+
98
+ // animation clip
99
+
100
+ const times = new Float32Array( totalFrames );
101
+ const values = new Float32Array( totalFrames * totalFrames ).fill( 0 );
102
+
103
+ for ( let i = 0; i < totalFrames; i ++ ) {
104
+
105
+ times[ i ] = view.getFloat32( offset ); offset += 4;
106
+ values[ ( totalFrames * i ) + i ] = 1;
107
+
108
+ }
109
+
110
+ const track = new NumberKeyframeTrack( '.morphTargetInfluences', times, values );
111
+ const clip = new AnimationClip( 'default', times[ times.length - 1 ], [ track ] );
112
+
113
+ // morph targets
114
+
115
+ const morphTargets = [];
116
+
117
+ for ( let i = 0; i < totalFrames; i ++ ) {
118
+
119
+ const morphTarget = new Float32Array( totalPoints * 3 );
120
+
121
+ for ( let j = 0; j < totalPoints; j ++ ) {
122
+
123
+ const stride = ( j * 3 );
124
+
125
+ morphTarget[ stride + 0 ] = view.getFloat32( offset ); offset += 4; // x
126
+ morphTarget[ stride + 1 ] = view.getFloat32( offset ); offset += 4; // y
127
+ morphTarget[ stride + 2 ] = view.getFloat32( offset ); offset += 4; // z
128
+
129
+ }
130
+
131
+ const attribute = new BufferAttribute( morphTarget, 3 );
132
+ attribute.name = 'morph_' + i;
133
+
134
+ morphTargets.push( attribute );
135
+
136
+ }
137
+
138
+ return {
139
+ morphTargets: morphTargets,
140
+ clip: clip
141
+ };
142
+
143
+ }
144
+
145
+ }
146
+
147
+ export { MDDLoader };