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,233 @@
1
+ import {
2
+ DoubleSide,
3
+ CanvasTexture,
4
+ Mesh,
5
+ MeshBasicMaterial,
6
+ NodeMaterial,
7
+ OrthographicCamera,
8
+ PlaneGeometry,
9
+ Scene,
10
+ DepthTexture,
11
+ Vector2
12
+ } from 'three/webgpu';
13
+ import { uv, uniform, textureLoad } from 'three/tsl';
14
+
15
+ /**
16
+ * This is a helper for visualising a given light's shadow map.
17
+ * It works for shadow casting lights: DirectionalLight and SpotLight.
18
+ * It renders out the shadow map and displays it on a HUD.
19
+ *
20
+ * This module can only be used with {@link WebGPURenderer}. When using {@link WebGLRenderer},
21
+ * import the class from `ShadowMapViewer.js`.
22
+ *
23
+ * ```js
24
+ * const lightShadowMapViewer = new ShadowMapViewer( light );
25
+ * lightShadowMapViewer.position.x = 10;
26
+ * lightShadowMapViewer.position.y = SCREEN_HEIGHT - ( SHADOW_MAP_HEIGHT / 4 ) - 10;
27
+ * lightShadowMapViewer.size.width = SHADOW_MAP_WIDTH / 4;
28
+ * lightShadowMapViewer.size.height = SHADOW_MAP_HEIGHT / 4;
29
+ * lightShadowMapViewer.update();
30
+ * ```
31
+ *
32
+ * @three_import import { ShadowMapViewer } from 'three/addons/utils/ShadowMapViewerGPU.js';
33
+ */
34
+ class ShadowMapViewer {
35
+
36
+ /**
37
+ * Constructs a new shadow map viewer.
38
+ *
39
+ * @param {Light} light - The shadow casting light.
40
+ */
41
+ constructor( light ) {
42
+
43
+ //- Internals
44
+ const scope = this;
45
+ const doRenderLabel = ( light.name !== undefined && light.name !== '' );
46
+ let currentAutoClear;
47
+
48
+ //Holds the initial position and dimension of the HUD
49
+ const frame = {
50
+ x: 10,
51
+ y: 10,
52
+ width: 256,
53
+ height: 256
54
+ };
55
+
56
+ const camera = new OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 1, 10 );
57
+ camera.position.set( 0, 0, 2 );
58
+ const scene = new Scene();
59
+
60
+ //HUD for shadow map
61
+
62
+ const material = new NodeMaterial();
63
+
64
+ const textureDimension = uniform( new Vector2() );
65
+
66
+ const shadowMapUniform = textureLoad( new DepthTexture(), uv().flipY().mul( textureDimension ) );
67
+ material.fragmentNode = shadowMapUniform.x.oneMinus();
68
+
69
+ const plane = new PlaneGeometry( frame.width, frame.height );
70
+ const mesh = new Mesh( plane, material );
71
+
72
+ scene.add( mesh );
73
+
74
+ //Label for light's name
75
+ let labelCanvas, labelMesh;
76
+
77
+ if ( doRenderLabel ) {
78
+
79
+ labelCanvas = document.createElement( 'canvas' );
80
+
81
+ const context = labelCanvas.getContext( '2d' );
82
+ context.font = 'Bold 20px Arial';
83
+
84
+ const labelWidth = context.measureText( light.name ).width;
85
+ labelCanvas.width = labelWidth;
86
+ labelCanvas.height = 25; //25 to account for g, p, etc.
87
+
88
+ context.font = 'Bold 20px Arial';
89
+ context.fillStyle = 'rgba( 255, 0, 0, 1 )';
90
+ context.fillText( light.name, 0, 20 );
91
+
92
+ const labelTexture = new CanvasTexture( labelCanvas );
93
+
94
+ const labelMaterial = new MeshBasicMaterial( { map: labelTexture, side: DoubleSide, transparent: true } );
95
+
96
+ const labelPlane = new PlaneGeometry( labelCanvas.width, labelCanvas.height );
97
+ labelMesh = new Mesh( labelPlane, labelMaterial );
98
+
99
+ scene.add( labelMesh );
100
+
101
+ }
102
+
103
+ function resetPosition() {
104
+
105
+ scope.position.set( scope.position.x, scope.position.y );
106
+
107
+ }
108
+
109
+ /**
110
+ * Whether to display the shadow map viewer or not.
111
+ *
112
+ * @type {boolean}
113
+ * @default true
114
+ */
115
+ this.enabled = true;
116
+
117
+ /**
118
+ * The size of the viewer. When changing this property, make sure
119
+ * to call {@link ShadowMapViewer#update}.
120
+ *
121
+ * @type {{width:number,height:number}}
122
+ * @default true
123
+ */
124
+ this.size = {
125
+ width: frame.width,
126
+ height: frame.height,
127
+ set: function ( width, height ) {
128
+
129
+ this.width = width;
130
+ this.height = height;
131
+
132
+ mesh.scale.set( this.width / frame.width, this.height / frame.height, 1 );
133
+
134
+ //Reset the position as it is off when we scale stuff
135
+ resetPosition();
136
+
137
+ }
138
+ };
139
+
140
+ /**
141
+ * The position of the viewer. When changing this property, make sure
142
+ * to call {@link ShadowMapViewer#update}.
143
+ *
144
+ * @type {{width:number,height:number}}
145
+ * @default true
146
+ */
147
+ this.position = {
148
+ x: frame.x,
149
+ y: frame.y,
150
+ set: function ( x, y ) {
151
+
152
+ this.x = x;
153
+ this.y = y;
154
+
155
+ const width = scope.size.width;
156
+ const height = scope.size.height;
157
+
158
+ mesh.position.set( - window.innerWidth / 2 + width / 2 + this.x, window.innerHeight / 2 - height / 2 - this.y, 0 );
159
+
160
+ if ( doRenderLabel ) labelMesh.position.set( mesh.position.x, mesh.position.y - scope.size.height / 2 + labelCanvas.height / 2, 0 );
161
+
162
+ }
163
+ };
164
+
165
+ /**
166
+ * Renders the viewer. This method must be called in the app's animation loop.
167
+ *
168
+ * @param {WebGPURenderer} renderer - The renderer.
169
+ */
170
+ this.render = function ( renderer ) {
171
+
172
+ if ( this.enabled ) {
173
+
174
+ //Because a light's .shadowMap is only initialised after the first render pass
175
+ //we have to make sure the correct map is sent into the shader, otherwise we
176
+ //always end up with the scene's first added shadow casting light's shadowMap
177
+ //in the shader
178
+ //See: https://github.com/mrdoob/three.js/issues/5932
179
+
180
+ const depthTexture = light.shadow.map.depthTexture;
181
+
182
+ shadowMapUniform.value = depthTexture;
183
+ textureDimension.value.set( depthTexture.width, depthTexture.height );
184
+
185
+ currentAutoClear = renderer.autoClear;
186
+ renderer.autoClear = false; // To allow render overlay
187
+ renderer.clearDepth();
188
+ renderer.render( scene, camera );
189
+ renderer.autoClear = currentAutoClear;
190
+
191
+ }
192
+
193
+ };
194
+
195
+ /**
196
+ * Resizes the viewer. This method should be called whenever the app's
197
+ * window is resized.
198
+ */
199
+ this.updateForWindowResize = function () {
200
+
201
+ if ( this.enabled ) {
202
+
203
+ camera.left = window.innerWidth / - 2;
204
+ camera.right = window.innerWidth / 2;
205
+ camera.top = window.innerHeight / 2;
206
+ camera.bottom = window.innerHeight / - 2;
207
+ camera.updateProjectionMatrix();
208
+
209
+ this.update();
210
+
211
+ }
212
+
213
+ };
214
+
215
+ /**
216
+ * Updates the viewer.
217
+ */
218
+ this.update = function () {
219
+
220
+ this.position.set( this.position.x, this.position.y );
221
+ this.size.set( this.size.width, this.size.height );
222
+
223
+ };
224
+
225
+ //Force an update to set position/size
226
+ this.update();
227
+
228
+ }
229
+
230
+ }
231
+
232
+
233
+ export { ShadowMapViewer };
@@ -0,0 +1,496 @@
1
+ import {
2
+ AnimationClip,
3
+ AnimationMixer,
4
+ Matrix4,
5
+ Quaternion,
6
+ QuaternionKeyframeTrack,
7
+ SkeletonHelper,
8
+ Vector3,
9
+ VectorKeyframeTrack
10
+ } from 'three';
11
+
12
+ /**
13
+ * @module SkeletonUtils
14
+ * @three_import import * as SkeletonUtils from 'three/addons/utils/SkeletonUtils.js';
15
+ */
16
+
17
+ function getBoneName( bone, options ) {
18
+
19
+ if ( options.getBoneName !== undefined ) {
20
+
21
+ return options.getBoneName( bone );
22
+
23
+ }
24
+
25
+ return options.names[ bone.name ];
26
+
27
+ }
28
+
29
+ /**
30
+ * Retargets the skeleton from the given source to the target.
31
+ *
32
+ * Both `target` and `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
33
+ * or a {@link Skeleton} directly.
34
+ *
35
+ * @param {Object3D|Skeleton} target - The target object.
36
+ * @param {Object3D|Skeleton} source - The source object.
37
+ * @param {module:SkeletonUtils~RetargetOptions} options - The options.
38
+ */
39
+ function retarget( target, source, options = {} ) {
40
+
41
+ const quat = new Quaternion(),
42
+ scale = new Vector3(),
43
+ relativeMatrix = new Matrix4(),
44
+ globalMatrix = new Matrix4();
45
+
46
+ options.preserveBoneMatrix = options.preserveBoneMatrix !== undefined ? options.preserveBoneMatrix : true;
47
+ options.preserveBonePositions = options.preserveBonePositions !== undefined ? options.preserveBonePositions : true;
48
+ options.useTargetMatrix = options.useTargetMatrix !== undefined ? options.useTargetMatrix : false;
49
+ options.hip = options.hip !== undefined ? options.hip : 'hip';
50
+ options.hipInfluence = options.hipInfluence !== undefined ? options.hipInfluence : new Vector3( 1, 1, 1 );
51
+ options.scale = options.scale !== undefined ? options.scale : 1;
52
+ options.names = options.names || {};
53
+
54
+ const sourceBones = source.isObject3D ? source.skeleton.bones : getBones( source ),
55
+ bones = target.isObject3D ? target.skeleton.bones : getBones( target );
56
+
57
+ let bone, name, boneTo,
58
+ bonesPosition;
59
+
60
+ // reset bones
61
+
62
+ if ( target.isObject3D ) {
63
+
64
+ target.skeleton.pose();
65
+
66
+ } else {
67
+
68
+ options.useTargetMatrix = true;
69
+ options.preserveBoneMatrix = false;
70
+
71
+ }
72
+
73
+ if ( options.preserveBonePositions ) {
74
+
75
+ bonesPosition = [];
76
+
77
+ for ( let i = 0; i < bones.length; i ++ ) {
78
+
79
+ bonesPosition.push( bones[ i ].position.clone() );
80
+
81
+ }
82
+
83
+ }
84
+
85
+ if ( options.preserveBoneMatrix ) {
86
+
87
+ // reset matrix
88
+
89
+ target.updateMatrixWorld();
90
+
91
+ target.matrixWorld.identity();
92
+
93
+ // reset children matrix
94
+
95
+ for ( let i = 0; i < target.children.length; ++ i ) {
96
+
97
+ target.children[ i ].updateMatrixWorld( true );
98
+
99
+ }
100
+
101
+ }
102
+
103
+ for ( let i = 0; i < bones.length; ++ i ) {
104
+
105
+ bone = bones[ i ];
106
+ name = getBoneName( bone, options );
107
+
108
+ boneTo = getBoneByName( name, sourceBones );
109
+
110
+ globalMatrix.copy( bone.matrixWorld );
111
+
112
+ if ( boneTo ) {
113
+
114
+ boneTo.updateMatrixWorld();
115
+
116
+ if ( options.useTargetMatrix ) {
117
+
118
+ relativeMatrix.copy( boneTo.matrixWorld );
119
+
120
+ } else {
121
+
122
+ relativeMatrix.copy( target.matrixWorld ).invert();
123
+ relativeMatrix.multiply( boneTo.matrixWorld );
124
+
125
+ }
126
+
127
+ // ignore scale to extract rotation
128
+
129
+ scale.setFromMatrixScale( relativeMatrix );
130
+ relativeMatrix.scale( scale.set( 1 / scale.x, 1 / scale.y, 1 / scale.z ) );
131
+
132
+ // apply to global matrix
133
+
134
+ globalMatrix.makeRotationFromQuaternion( quat.setFromRotationMatrix( relativeMatrix ) );
135
+
136
+ if ( target.isObject3D ) {
137
+
138
+ if ( options.localOffsets ) {
139
+
140
+ if ( options.localOffsets[ bone.name ] ) {
141
+
142
+ globalMatrix.multiply( options.localOffsets[ bone.name ] );
143
+
144
+ }
145
+
146
+ }
147
+
148
+ }
149
+
150
+ globalMatrix.copyPosition( relativeMatrix );
151
+
152
+ }
153
+
154
+ if ( name === options.hip ) {
155
+
156
+ globalMatrix.elements[ 12 ] *= options.scale * options.hipInfluence.x;
157
+ globalMatrix.elements[ 13 ] *= options.scale * options.hipInfluence.y;
158
+ globalMatrix.elements[ 14 ] *= options.scale * options.hipInfluence.z;
159
+
160
+ if ( options.hipPosition !== undefined ) {
161
+
162
+ globalMatrix.elements[ 12 ] += options.hipPosition.x * options.scale;
163
+ globalMatrix.elements[ 13 ] += options.hipPosition.y * options.scale;
164
+ globalMatrix.elements[ 14 ] += options.hipPosition.z * options.scale;
165
+
166
+ }
167
+
168
+ }
169
+
170
+ if ( bone.parent ) {
171
+
172
+ bone.matrix.copy( bone.parent.matrixWorld ).invert();
173
+ bone.matrix.multiply( globalMatrix );
174
+
175
+ } else {
176
+
177
+ bone.matrix.copy( globalMatrix );
178
+
179
+ }
180
+
181
+ bone.matrix.decompose( bone.position, bone.quaternion, bone.scale );
182
+
183
+ bone.updateMatrixWorld();
184
+
185
+ }
186
+
187
+ if ( options.preserveBonePositions ) {
188
+
189
+ for ( let i = 0; i < bones.length; ++ i ) {
190
+
191
+ bone = bones[ i ];
192
+ name = getBoneName( bone, options ) || bone.name;
193
+
194
+ if ( name !== options.hip ) {
195
+
196
+ bone.position.copy( bonesPosition[ i ] );
197
+
198
+ }
199
+
200
+ }
201
+
202
+ }
203
+
204
+ if ( options.preserveBoneMatrix ) {
205
+
206
+ // restore matrix
207
+
208
+ target.updateMatrixWorld( true );
209
+
210
+ }
211
+
212
+ }
213
+
214
+ /**
215
+ * Retargets the animation clip of the source to the target 3D object.
216
+ *
217
+ * The `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
218
+ * or a {@link Skeleton} directly.
219
+ *
220
+ * @param {Object3D} target - The target 3D object. Must have a `skeleton` property.
221
+ * @param {Object3D|Skeleton} source - The source object.
222
+ * @param {AnimationClip} clip - The animation clip.
223
+ * @param {module:SkeletonUtils~RetargetOptions} options - The options.
224
+ * @return {AnimationClip} The retargeted animation clip.
225
+ */
226
+ function retargetClip( target, source, clip, options = {} ) {
227
+
228
+ options.useFirstFramePosition = options.useFirstFramePosition !== undefined ? options.useFirstFramePosition : false;
229
+
230
+ // Calculate the fps from the source clip based on the track with the most frames, unless fps is already provided.
231
+ options.fps = options.fps !== undefined ? options.fps : ( Math.max( ...clip.tracks.map( track => track.times.length ) ) / clip.duration );
232
+ options.names = options.names || [];
233
+
234
+ if ( ! source.isObject3D ) {
235
+
236
+ source = getHelperFromSkeleton( source );
237
+
238
+ }
239
+
240
+ const numFrames = Math.round( clip.duration * ( options.fps / 1000 ) * 1000 ),
241
+ delta = clip.duration / ( numFrames - 1 ),
242
+ convertedTracks = [],
243
+ mixer = new AnimationMixer( source ),
244
+ bones = getBones( target.skeleton ),
245
+ boneDatas = [];
246
+
247
+ let positionOffset,
248
+ bone, boneTo, boneData,
249
+ name;
250
+
251
+ mixer.clipAction( clip ).play();
252
+
253
+ // trim
254
+
255
+ let start = 0, end = numFrames;
256
+
257
+ if ( options.trim !== undefined ) {
258
+
259
+ start = Math.round( options.trim[ 0 ] * options.fps );
260
+ end = Math.min( Math.round( options.trim[ 1 ] * options.fps ), numFrames ) - start;
261
+
262
+ mixer.update( options.trim[ 0 ] );
263
+
264
+ } else {
265
+
266
+ mixer.update( 0 );
267
+
268
+ }
269
+
270
+ source.updateMatrixWorld();
271
+
272
+ //
273
+
274
+ for ( let frame = 0; frame < end; ++ frame ) {
275
+
276
+ const time = frame * delta;
277
+
278
+ retarget( target, source, options );
279
+
280
+ for ( let j = 0; j < bones.length; ++ j ) {
281
+
282
+ bone = bones[ j ];
283
+ name = getBoneName( bone, options ) || bone.name;
284
+ boneTo = getBoneByName( name, source.skeleton );
285
+
286
+ if ( boneTo ) {
287
+
288
+ boneData = boneDatas[ j ] = boneDatas[ j ] || { bone: bone };
289
+
290
+ if ( options.hip === name ) {
291
+
292
+ if ( ! boneData.pos ) {
293
+
294
+ boneData.pos = {
295
+ times: new Float32Array( end ),
296
+ values: new Float32Array( end * 3 )
297
+ };
298
+
299
+ }
300
+
301
+ if ( options.useFirstFramePosition ) {
302
+
303
+ if ( frame === 0 ) {
304
+
305
+ positionOffset = bone.position.clone();
306
+
307
+ }
308
+
309
+ bone.position.sub( positionOffset );
310
+
311
+ }
312
+
313
+ boneData.pos.times[ frame ] = time;
314
+
315
+ bone.position.toArray( boneData.pos.values, frame * 3 );
316
+
317
+ }
318
+
319
+ if ( ! boneData.quat ) {
320
+
321
+ boneData.quat = {
322
+ times: new Float32Array( end ),
323
+ values: new Float32Array( end * 4 )
324
+ };
325
+
326
+ }
327
+
328
+ boneData.quat.times[ frame ] = time;
329
+
330
+ bone.quaternion.toArray( boneData.quat.values, frame * 4 );
331
+
332
+ }
333
+
334
+ }
335
+
336
+ if ( frame === end - 2 ) {
337
+
338
+ // last mixer update before final loop iteration
339
+ // make sure we do not go over or equal to clip duration
340
+ mixer.update( delta - 0.0000001 );
341
+
342
+ } else {
343
+
344
+ mixer.update( delta );
345
+
346
+ }
347
+
348
+ source.updateMatrixWorld();
349
+
350
+ }
351
+
352
+ for ( let i = 0; i < boneDatas.length; ++ i ) {
353
+
354
+ boneData = boneDatas[ i ];
355
+
356
+ if ( boneData ) {
357
+
358
+ if ( boneData.pos ) {
359
+
360
+ convertedTracks.push( new VectorKeyframeTrack(
361
+ '.bones[' + boneData.bone.name + '].position',
362
+ boneData.pos.times,
363
+ boneData.pos.values
364
+ ) );
365
+
366
+ }
367
+
368
+ convertedTracks.push( new QuaternionKeyframeTrack(
369
+ '.bones[' + boneData.bone.name + '].quaternion',
370
+ boneData.quat.times,
371
+ boneData.quat.values
372
+ ) );
373
+
374
+ }
375
+
376
+ }
377
+
378
+ mixer.uncacheAction( clip );
379
+
380
+ return new AnimationClip( clip.name, - 1, convertedTracks );
381
+
382
+ }
383
+
384
+ /**
385
+ * Clones the given 3D object and its descendants, ensuring that any `SkinnedMesh` instances are
386
+ * correctly associated with their bones. Bones are also cloned, and must be descendants of the
387
+ * object passed to this method. Other data, like geometries and materials, are reused by reference.
388
+ *
389
+ * @param {Object3D} source - The 3D object to clone.
390
+ * @return {Object3D} The cloned 3D object.
391
+ */
392
+ function clone( source ) {
393
+
394
+ const sourceLookup = new Map();
395
+ const cloneLookup = new Map();
396
+
397
+ const clone = source.clone();
398
+
399
+ parallelTraverse( source, clone, function ( sourceNode, clonedNode ) {
400
+
401
+ sourceLookup.set( clonedNode, sourceNode );
402
+ cloneLookup.set( sourceNode, clonedNode );
403
+
404
+ } );
405
+
406
+ clone.traverse( function ( node ) {
407
+
408
+ if ( ! node.isSkinnedMesh ) return;
409
+
410
+ const clonedMesh = node;
411
+ const sourceMesh = sourceLookup.get( node );
412
+ const sourceBones = sourceMesh.skeleton.bones;
413
+
414
+ clonedMesh.skeleton = sourceMesh.skeleton.clone();
415
+ clonedMesh.bindMatrix.copy( sourceMesh.bindMatrix );
416
+
417
+ clonedMesh.skeleton.bones = sourceBones.map( function ( bone ) {
418
+
419
+ return cloneLookup.get( bone );
420
+
421
+ } );
422
+
423
+ clonedMesh.bind( clonedMesh.skeleton, clonedMesh.bindMatrix );
424
+
425
+ } );
426
+
427
+ return clone;
428
+
429
+ }
430
+
431
+ // internal helper
432
+
433
+ function getBoneByName( name, skeleton ) {
434
+
435
+ for ( let i = 0, bones = getBones( skeleton ); i < bones.length; i ++ ) {
436
+
437
+ if ( name === bones[ i ].name )
438
+
439
+ return bones[ i ];
440
+
441
+ }
442
+
443
+ }
444
+
445
+ function getBones( skeleton ) {
446
+
447
+ return Array.isArray( skeleton ) ? skeleton : skeleton.bones;
448
+
449
+ }
450
+
451
+
452
+ function getHelperFromSkeleton( skeleton ) {
453
+
454
+ const source = new SkeletonHelper( skeleton.bones[ 0 ] );
455
+ source.skeleton = skeleton;
456
+
457
+ return source;
458
+
459
+ }
460
+
461
+ function parallelTraverse( a, b, callback ) {
462
+
463
+ callback( a, b );
464
+
465
+ for ( let i = 0; i < a.children.length; i ++ ) {
466
+
467
+ parallelTraverse( a.children[ i ], b.children[ i ], callback );
468
+
469
+ }
470
+
471
+ }
472
+
473
+ /**
474
+ * Retarget options of `SkeletonUtils`.
475
+ *
476
+ * @typedef {Object} module:SkeletonUtils~RetargetOptions
477
+ * @property {boolean} [useFirstFramePosition=false] - Whether to use the position of the first frame or not.
478
+ * @property {number} [fps] - The FPS of the clip.
479
+ * @property {Object<string,string>} [names] - A dictionary for mapping target to source bone names.
480
+ * @property {function(string):string} [getBoneName] - A function for mapping bone names. Alternative to `names`.
481
+ * @property {Array<number>} [trim] - Whether to trim the clip or not. If set the array should hold two values for the start and end.
482
+ * @property {boolean} [preserveBoneMatrix=true] - Whether to preserve bone matrices or not.
483
+ * @property {boolean} [preserveBonePositions=true] - Whether to preserve bone positions or not.
484
+ * @property {boolean} [useTargetMatrix=false] - Whether to use the target matrix or not.
485
+ * @property {string} [hip='hip'] - The name of the source's hip bone.
486
+ * @property {Vector3} [hipInfluence=(1,1,1)] - The hip influence.
487
+ * @property {number} [scale=1] - The scale.
488
+ * @property {Object<string,Matrix4>} [localOffsets] - Per-bone local offset matrices, keyed by bone name.
489
+ * @property {Vector3} [hipPosition] - An additional position offset applied to the hip bone.
490
+ **/
491
+
492
+ export {
493
+ retarget,
494
+ retargetClip,
495
+ clone,
496
+ };