@needle-tools/three-mesh-effects 0.1.0 → 0.2.0

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 (34) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +114 -16
  3. package/build/hull-effects.js +5747 -0
  4. package/build/hull-effects.js.map +7 -0
  5. package/build/index.js +57 -0
  6. package/build/index.js.map +7 -0
  7. package/build/internal/rendering/hull-effect-metadata.js +136 -0
  8. package/build/internal/rendering/hull-effect-metadata.js.map +7 -0
  9. package/build/{wrap-effects.js → internal/rendering/hull-effect-runtime.js} +131 -64
  10. package/build/internal/rendering/hull-effect-runtime.js.map +7 -0
  11. package/build/internal/rendering/wrap-preview-settings.js +14 -10
  12. package/build/internal/rendering/wrap-preview-settings.js.map +2 -2
  13. package/build/internal/rendering/wrap-preview.js +33 -30
  14. package/build/internal/rendering/wrap-preview.js.map +2 -2
  15. package/build/types/public/hull-effects.d.ts +6 -0
  16. package/build/types/public/hull-effects.js +1 -0
  17. package/build/types/public/index.d.ts +23 -0
  18. package/build/types/public/index.js +1 -0
  19. package/build/types/rendering/hull-effect-metadata.d.ts +12 -0
  20. package/build/types/rendering/hull-effect-metadata.js +1 -0
  21. package/build/types/rendering/hull-effect-runtime.d.ts +39 -0
  22. package/build/types/rendering/hull-effect-runtime.js +1 -0
  23. package/build/types/rendering/wrap-preview-settings.d.ts +6 -7
  24. package/build/types/rendering/wrap-preview.d.ts +8 -6
  25. package/package.json +12 -6
  26. package/src/public/{wrap-effects.js → hull-effects.js} +7 -4
  27. package/src/public/index.js +73 -0
  28. package/src/rendering/hull-effect-metadata.js +27 -0
  29. package/src/rendering/hull-effect-runtime.js +89 -0
  30. package/src/rendering/wrap-preview-settings.js +7 -6
  31. package/src/rendering/wrap-preview.js +35 -32
  32. package/build/types/public/wrap-effects.d.ts +0 -4
  33. package/build/types/public/wrap-effects.js +0 -1
  34. package/build/wrap-effects.js.map +0 -7
package/build/index.js ADDED
@@ -0,0 +1,57 @@
1
+ // @ts-nocheck
2
+
3
+ // src/public/index.js
4
+ var registrations = /* @__PURE__ */ new WeakMap();
5
+ function useLoader(loader, renderer, options = {}) {
6
+ const disabled = new Set(options.disable);
7
+ const existing = registrations.get(loader);
8
+ if (existing) {
9
+ existing.renderer = renderer;
10
+ existing.disabled = disabled;
11
+ return loader;
12
+ }
13
+ const state = { renderer, disabled };
14
+ registrations.set(loader, state);
15
+ const register = (name, apply) => {
16
+ loader.register((parser) => {
17
+ const disabled2 = state.disabled.has(name);
18
+ const renderer2 = state.renderer;
19
+ return {
20
+ name,
21
+ async afterRoot(result) {
22
+ const json = (
23
+ /** @type {{extensionsUsed?: string[], extensionsRequired?: string[]}} */
24
+ parser.json
25
+ );
26
+ if (!json.extensionsUsed?.includes(name) && !json.extensionsRequired?.includes(name)) return;
27
+ if (disabled2) {
28
+ if (json.extensionsRequired?.includes(name)) throw new Error(`Required glTF extension ${name} is disabled in useLoader.`);
29
+ return;
30
+ }
31
+ await apply(parser, result, renderer2);
32
+ }
33
+ };
34
+ });
35
+ };
36
+ register("NEEDLE_deformation_rig", async (parser, result) => {
37
+ const { NeedleDeformationRigLoaderPlugin } = await import("@needle-tools/three-mesh-effects/deformation-runtime");
38
+ await new NeedleDeformationRigLoaderPlugin(parser).afterRoot(result);
39
+ });
40
+ register("NEEDLE_mesh_impostor", async (parser, result, renderer2) => {
41
+ const { NeedleImpostorLoaderPlugin } = await import("@needle-tools/three-mesh-effects/impostor-runtime");
42
+ await new NeedleImpostorLoaderPlugin(parser, { renderer: renderer2 }).afterRoot(result);
43
+ });
44
+ register("NEEDLE_pixel_impostor", async (parser, result) => {
45
+ const { NeedlePixelImpostorLoaderPlugin } = await import("@needle-tools/three-mesh-effects/pixel-impostor-runtime");
46
+ await new NeedlePixelImpostorLoaderPlugin(parser).afterRoot(result);
47
+ });
48
+ register("NEEDLE_hull_effect", async (parser, result) => {
49
+ const { NeedleHullEffectLoaderPlugin } = await import("@needle-tools/three-mesh-effects/hull-effects");
50
+ await new NeedleHullEffectLoaderPlugin(parser).afterRoot(result);
51
+ });
52
+ return loader;
53
+ }
54
+ export {
55
+ useLoader
56
+ };
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/public/index.js"],
4
+ "sourcesContent": ["// @ts-check\n\n/** @typedef {import('three/addons/loaders/GLTFLoader.js').GLTFLoader} GLTFLoader */\n/** @typedef {import('three/addons/loaders/GLTFLoader.js').GLTFParser} GLTFParser */\n/** @typedef {import('three/addons/loaders/GLTFLoader.js').GLTF} GLTF */\n/** @typedef {import('../impostor/impostor-node-material.js').ImpostorRenderer} Renderer */\n\n/** @typedef {'NEEDLE_deformation_rig' | 'NEEDLE_mesh_impostor' | 'NEEDLE_pixel_impostor' | 'NEEDLE_hull_effect'} NeedleExtension */\n/** @typedef {{disable?: readonly NeedleExtension[]}} LoaderOptions */\n\n/** @type {WeakMap<GLTFLoader, {renderer: Renderer, disabled: Set<NeedleExtension>}>} */\nconst registrations = new WeakMap();\n\n/**\n * Enable all Needle glTF extensions before calling load/loadAsync or parse/parseAsync.\n * Handlers are imported only when a parsed asset declares their extension. Returns\n * the same loader; repeated registration updates its renderer without adding plugins.\n * Existing decoder and texture-loader configuration is preserved.\n * Disabled optional extensions retain their portable fallback; disabled required\n * extensions reject the load. Calling again replaces the options for future parses.\n *\n * @template {GLTFLoader} T\n * @param {T} loader\n * @param {Renderer} renderer\n * @param {LoaderOptions} [options]\n * @returns {T}\n */\nexport function useLoader(loader, renderer, options = {}) {\n const disabled = new Set(options.disable);\n const existing = registrations.get(loader);\n if (existing) { existing.renderer = renderer; existing.disabled = disabled; return loader; }\n const state = { renderer, disabled };\n registrations.set(loader, state);\n\n // Register each real extension name synchronously so GLTFLoader recognizes\n // required extensions before asynchronous postprocessing starts.\n /** @param {NeedleExtension} name @param {(parser: GLTFParser, result: GLTF, renderer: Renderer) => Promise<void>} apply */\n const register = (name, apply) => {\n loader.register(parser => {\n const disabled = state.disabled.has(name);\n const renderer = state.renderer;\n return {\n name,\n async afterRoot(result) {\n const json = /** @type {{extensionsUsed?: string[], extensionsRequired?: string[]}} */ (parser.json);\n if (!json.extensionsUsed?.includes(name) && !json.extensionsRequired?.includes(name)) return;\n if (disabled) {\n if (json.extensionsRequired?.includes(name)) throw new Error(`Required glTF extension ${name} is disabled in useLoader.`);\n return;\n }\n await apply(parser, result, renderer);\n },\n };\n });\n };\n register('NEEDLE_deformation_rig', async (parser, result) => {\n const { NeedleDeformationRigLoaderPlugin } = await import('@needle-tools/three-mesh-effects/deformation-runtime');\n await new NeedleDeformationRigLoaderPlugin(parser).afterRoot(result);\n });\n register('NEEDLE_mesh_impostor', async (parser, result, renderer) => {\n const { NeedleImpostorLoaderPlugin } = await import('@needle-tools/three-mesh-effects/impostor-runtime');\n await new NeedleImpostorLoaderPlugin(parser, { renderer }).afterRoot(result);\n });\n register('NEEDLE_pixel_impostor', async (parser, result) => {\n const { NeedlePixelImpostorLoaderPlugin } = await import('@needle-tools/three-mesh-effects/pixel-impostor-runtime');\n await new NeedlePixelImpostorLoaderPlugin(parser).afterRoot(result);\n });\n register('NEEDLE_hull_effect', async (parser, result) => {\n const { NeedleHullEffectLoaderPlugin } = await import('@needle-tools/three-mesh-effects/hull-effects');\n await new NeedleHullEffectLoaderPlugin(parser).afterRoot(result);\n });\n return loader;\n}\n"],
5
+ "mappings": ";;;AAWA,IAAM,gBAAgB,oBAAI,QAAQ;AAgB3B,SAAS,UAAU,QAAQ,UAAU,UAAU,CAAC,GAAG;AACxD,QAAM,WAAW,IAAI,IAAI,QAAQ,OAAO;AACxC,QAAM,WAAW,cAAc,IAAI,MAAM;AACzC,MAAI,UAAU;AAAE,aAAS,WAAW;AAAU,aAAS,WAAW;AAAU,WAAO;AAAA,EAAQ;AAC3F,QAAM,QAAQ,EAAE,UAAU,SAAS;AACnC,gBAAc,IAAI,QAAQ,KAAK;AAK/B,QAAM,WAAW,CA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}
@@ -0,0 +1,136 @@
1
+ // @ts-nocheck
2
+
3
+ // src/rendering/wrap-preview-settings.js
4
+ var HULL_EFFECT_CONTROLS = {
5
+ "heat-haze": [
6
+ { key: "strength", label: "Distortion", min: 0, max: 1, step: 0.01, value: 0.35, title: "Strength of the bubbling refractive normals." },
7
+ { key: "detail", label: "Detail", min: 1, max: 16, step: 0.25, value: 5, title: "Spatial scale of the smooth heat bubbles." },
8
+ { key: "speed", label: "Speed", min: 0, max: 4, step: 0.05, value: 1, title: "Upward motion and evolution of the heat distortion." },
9
+ { key: "thickness", label: "Thickness", min: 0.01, max: 1, step: 0.01, value: 0.15, title: "Optical thickness of the transmissive hull." }
10
+ ],
11
+ shroud: [
12
+ { key: "color", kind: "color", label: "Color", min: 0, max: 16777215, step: 1, value: 1051928, title: "Deep shadow cloud color." },
13
+ { key: "coverage", label: "Coverage", min: 0, max: 1, step: 0.01, value: 0.33, title: "Fraction of the surface hidden in swirling clouds." },
14
+ { key: "detail", label: "Detail", min: 1, max: 12, step: 0.25, value: 5.5, title: "Cloud and eddy scale." },
15
+ { key: "depth", label: "Cloud depth", min: 0, max: 0.1, step: 1e-3, value: 0.016, title: "Surface-hugging cloud thickness relative to model size." },
16
+ { key: "amplitude", label: "Vertex curl", min: 0, max: 0.08, step: 1e-3, value: 0.063, title: "Full 3D curl displacement of the cloud vertices. Zero removes the vertex curl calculations from the shader." },
17
+ { key: "fresnel", label: "Edge fade", min: 0, max: 8, step: 0.05, value: 1.5, title: "Fade clouds to transparent at grazing angles. Higher values soften more of the silhouette; zero disables the fade." },
18
+ { key: "speed", label: "Swirl speed", min: 0, max: 4, step: 0.05, value: 2.25, title: "Cloud circulation speed; no upward flame motion." },
19
+ { key: "opacity", label: "Opacity", min: 0, max: 1, step: 0.01, value: 0.99, title: "Maximum shadow opacity per layer." }
20
+ ],
21
+ lava: [
22
+ { key: "noise", label: "Growth noise", min: 0, max: 1, step: 0.01, value: 0.6, title: "3D noise variation in the advancing front. Zero removes the growth-noise graph." },
23
+ { key: "transition", label: "Transition zone", min: 0.05, max: 0.4, step: 0.01, value: 0.2, title: "Width of the zone where volcanic plates form and expand." },
24
+ { key: "color", kind: "color", label: "Lava color", min: 0, max: 16777215, step: 1, value: 16725765, title: "Molten crack color, graduating to yellow-white in the hottest cores." },
25
+ { key: "fill", label: "Fill from bottom", min: 0, max: 1, step: 0.01, value: 0.65, title: "Fill height from the base to the top of the rest-pose hull. Zero hides all lava; one covers all of it." },
26
+ { key: "detail", label: "Detail", min: 2, max: 24, step: 0.5, value: 12, title: "Scale of the irregular volcanic plates." },
27
+ { key: "cracks", label: "Crack width", min: 0.01, max: 0.3, step: 5e-3, value: 0.065, title: "Width of the molten seams between crust plates." },
28
+ { key: "glow", label: "Heat", min: 0, max: 8, step: 0.1, value: 3, title: "Emission of the molten cracks." },
29
+ { key: "speed", label: "Flow speed", min: 0, max: 3, step: 0.05, value: 0.5, title: "Slow molten heat flow beneath stationary crust." }
30
+ ],
31
+ ivy: [
32
+ { key: "noise", label: "Growth noise", min: 0, max: 1, step: 0.01, value: 0.6, title: "3D variation in vine and leaf growth timing. Zero removes the growth-noise graph." },
33
+ { key: "transition", label: "Transition zone", min: 0.05, max: 0.4, step: 0.01, value: 0.2, title: "Width of the zone where twigs extend and leaves unfurl from their roots." },
34
+ { key: "color", kind: "color", label: "Leaf color", min: 0, max: 16777215, step: 1, value: 3767076, title: "Leaf green, with lighter veins and younger tips." },
35
+ { key: "growth", label: "Growth", min: 0, max: 1, step: 0.01, value: 1, title: "Reveal climbing stems and leaves from the bottom upward." },
36
+ { key: "detail", label: "Detail", min: 2, max: 24, step: 0.25, value: 10, title: "Scale of the procedural vines and leaves on the hull." },
37
+ { key: "leafSize", label: "Leaf size", min: 0.2, max: 1, step: 0.01, value: 0.7, title: "Lobed leaf size relative to the vine spacing." },
38
+ { key: "speed", label: "Breeze speed", min: 0, max: 3, step: 0.05, value: 0.6, title: "Gentle leaf movement; stems stay attached to the hull." }
39
+ ],
40
+ ice: [
41
+ { key: "dispersion", label: "Dispersion", min: 0, max: 2, step: 0.01, value: 0.25, title: "Spectral refraction through the ice. Zero removes dispersion from the shader." },
42
+ { key: "frost", label: "Frost", min: 0, max: 1, step: 0.01, value: 0.55, title: "Cloudiness of the physical ice." },
43
+ { key: "facets", label: "Facets", min: 0, max: 1, step: 0.01, value: 0.5, title: "Blend rounded normals into cut-crystal facets." },
44
+ { key: "thickness", label: "Thickness", min: 0.02, max: 1, step: 0.01, value: 0.35, title: "Optical thickness relative to model size." }
45
+ ],
46
+ "force-field": [
47
+ { key: "color", kind: "color", label: "Color", min: 0, max: 16777215, step: 1, value: 2872559, title: "Energy color of both hex field layers." },
48
+ { key: "density", label: "Hex density", min: 4, max: 40, step: 1, value: 26, title: "Scale of the biplanar hex grid on both field layers." },
49
+ { key: "speed", label: "Speed", min: 0, max: 4, step: 0.05, value: 1.75, title: "Speed of the per-hex energy pulses and shifting outer patches." },
50
+ { key: "glow", label: "Glow", min: 0.1, max: 5, step: 0.1, value: 0.4, title: "Field and Fresnel brightness." },
51
+ { key: "detail", label: "Detail", min: 1, max: 12, step: 0.25, value: 4, title: "Spatial detail of curl motion and outer patches, independent of hex density." },
52
+ { key: "noise", label: "Noise strength", min: 0, max: 2, step: 0.05, value: 1, title: "Curl displacement and outer-patch noise. Zero removes noise calculations from the shader." },
53
+ { key: "fresnel", label: "Fresnel", min: 0.25, max: 8, step: 0.05, value: 3, title: "Concentrate the glow toward grazing edges. Higher values make a tighter rim." }
54
+ ],
55
+ "tech-cage": [
56
+ { key: "color", kind: "color", label: "Color", min: 0, max: 16777215, step: 1, value: 5433087, title: "Color of the cage wires and vertex nodes." },
57
+ { key: "amplitude", label: "Curl strength", min: 0, max: 0.2, step: 5e-3, value: 0.035, title: "Shared curl displacement of cage vertices and node centers, relative to model size." },
58
+ { key: "speed", label: "Speed", min: 0, max: 4, step: 0.05, value: 0.7, title: "Speed of the animated 3D curl field." },
59
+ { key: "nodeSize", label: "Node size", min: 2e-3, max: 0.04, step: 1e-3, value: 9e-3, title: "Radius of the instanced smooth icospheres, relative to model size." },
60
+ { key: "width", label: "Wire width", min: 0.25, max: 4, step: 0.25, value: 1.25, title: "Antialiased wire width in screen pixels." }
61
+ ],
62
+ flames: [
63
+ { key: "color", kind: "color", label: "Cool", min: 0, max: 16777215, step: 1, value: 16727040, title: "Cooling plume tips and weak wisps in the stylized temperature estimate." },
64
+ { key: "warmColor", kind: "color", label: "Warm", min: 0, max: 16777215, step: 1, value: 16758058, title: "Middle of the flame temperature gradient." },
65
+ { key: "hotColor", kind: "color", label: "Hot", min: 0, max: 16777215, step: 1, value: 16774358, title: "Hot reaction region just beyond the emitting surface; the plume cools toward its tips." },
66
+ { key: "radialUp", label: "Radial up", min: 0, max: 1, step: 0.01, value: 0, title: "0: vertical world up. 1: outward and upward from the wrap\u2019s bottom-center floor point." },
67
+ { key: "upThreshold", label: "Upward threshold", min: -1, max: 0.95, step: 0.05, value: 0.05, title: "Outward geometry-normal alignment with the selected up direction. Lower values include more side faces." },
68
+ { key: "height", label: "Flame height", min: 0, max: 1, step: 0.01, value: 0.35, title: "Upward flame displacement relative to model size." },
69
+ { key: "speed", label: "Speed", min: 0, max: 4, step: 0.05, value: 1.4, title: "Upward flow speed of the aura." },
70
+ { key: "scale", label: "Flame detail", min: 1, max: 12, step: 0.25, value: 5, title: "Spatial frequency of the flame tongues." }
71
+ ],
72
+ aura: [
73
+ { key: "color", kind: "color", label: "Color", min: 0, max: 16777215, step: 1, value: 16766250, title: "Aura color." },
74
+ { key: "radialUp", label: "Radial up", min: 0, max: 1, step: 0.01, value: 0.68, title: "Blend vertical up into outward rays from the bottom-center floor point." },
75
+ { key: "upThreshold", label: "Upward threshold", min: -1, max: 0.95, step: 0.05, value: -0.2, title: "Outward geometry-normal alignment required to emit spikes." },
76
+ { key: "height", label: "Spike height", min: 0, max: 1, step: 0.01, value: 0.39, title: "Length of the pointed aura tongues relative to model size." },
77
+ { key: "speed", label: "Speed", min: 0, max: 4, step: 0.05, value: 2.85, title: "General spike pulsing and shape variation, independent of inward travel and bending." },
78
+ { key: "wanderSpeed", label: "Inward travel speed", min: -4, max: 4, step: 0.05, value: 2.45, title: "Polar spike travel speed. Negative reverses toward the base; zero stops travel without stopping the other animation." },
79
+ { key: "bendStrength", label: "Bend strength", min: 0, max: 0.5, step: 0.01, value: 0.1, title: "Strength of the separate travelling shell bend. Zero disables the bend." },
80
+ { key: "bendSpeed", label: "Bend speed", min: 0, max: 4, step: 0.05, value: 4, title: "Speed of the shell bend, independent of spike travel." },
81
+ { key: "scale", label: "Detail", min: 1, max: 12, step: 0.25, value: 6.75, title: "Spatial frequency of the pointed energy tongues." },
82
+ { key: "fresnel", label: "Fresnel", min: 0.25, max: 12, step: 0.05, value: 5, title: "Concentrate flat golden energy around the silhouette." },
83
+ { key: "opacity", label: "Opacity", min: 0, max: 1, step: 0.01, value: 0.17, title: "Opacity of the flat-color aura shell." }
84
+ ],
85
+ outline: [
86
+ { key: "color", kind: "color", label: "Color", min: 0, max: 16777215, step: 1, value: 16777215, title: "Solid inner outline color." },
87
+ { key: "expand", label: "Normal expand", min: 0, max: 0.2, step: 1e-3, value: 0.01, title: "Inner shell expansion along smooth normals, relative to model size." },
88
+ { key: "borderColor", kind: "color", label: "Border color", min: 0, max: 16777215, step: 1, value: 0, title: "Solid outer outline color." },
89
+ { key: "borderOffset", label: "Border offset", min: 0, max: 0.1, step: 1e-3, value: 5e-3, title: "Additional normal expansion beyond the inner shell." }
90
+ ],
91
+ godrays: [
92
+ { key: "azimuth", kind: "direction", label: "Direction", min: -180, max: 180, step: 1, value: 25, title: "Drag to rotate the ray direction. Arrow keys rotate; Home resets." },
93
+ { key: "elevation", kind: "hidden", label: "Elevation", min: -89, max: 89, step: 1, value: 55, title: "" },
94
+ { key: "angle", label: "Angle", min: 1, max: 80, step: 1, value: 25, title: "Angular spread of the directional rays." },
95
+ { key: "length", label: "Length", min: 0, max: 2, step: 0.01, value: 0.6, title: "Ray length relative to the wrap size." },
96
+ { key: "opacity", label: "Strength", min: 0, max: 1, step: 0.01, value: 0.65, title: "Multiplicative darkening of the rays." },
97
+ { key: "fresnel", label: "Edge softness", min: 0.25, max: 5, step: 0.05, value: 1.5, title: "Fade grazing edges smoothly." }
98
+ ],
99
+ "wind-frosted": [
100
+ { key: "azimuth", kind: "direction", label: "Direction", min: -180, max: 180, step: 1, value: 25, title: "Direction the freezing wind travels. Icicles point away with the wind." },
101
+ { key: "elevation", kind: "hidden", label: "Elevation", min: -89, max: 89, step: 1, value: -25, title: "" },
102
+ { key: "coverage", label: "Coverage", min: 0, max: 1, step: 0.01, value: 0.55, title: "Amount of directional snow and frost coverage." },
103
+ { key: "normalOffset", label: "Windward offset", min: 0, max: 0.2, step: 1e-3, value: 0, title: "Push the wind-facing coating outward along its normals, relative to model size." },
104
+ { key: "height", label: "Icicle length", min: 0, max: 0.5, step: 0.01, value: 0.12, title: "Length of sharp downwind icicles relative to model size." },
105
+ { key: "scale", label: "Detail", min: 1, max: 12, step: 0.25, value: 5, title: "Detail of frost patches and pointed icicles." }
106
+ ]
107
+ };
108
+
109
+ // src/rendering/hull-effect-metadata.js
110
+ var NEEDLE_HULL_EFFECT = "NEEDLE_hull_effect";
111
+ function parseHullEffectDescriptor(raw) {
112
+ if (!raw || typeof raw !== "object") throw new Error("Invalid NEEDLE_hull_effect descriptor.");
113
+ const record = (
114
+ /** @type {Record<string, unknown>} */
115
+ raw
116
+ );
117
+ if (record.version !== 1) throw new Error("Unsupported NEEDLE_hull_effect version.");
118
+ if (typeof record.mode !== "string" || !Object.hasOwn(HULL_EFFECT_CONTROLS, record.mode)) throw new Error("Unknown NEEDLE_hull_effect mode.");
119
+ if (!record.values || typeof record.values !== "object" || Array.isArray(record.values)) throw new Error("Invalid NEEDLE_hull_effect values.");
120
+ const input = (
121
+ /** @type {Record<string, unknown>} */
122
+ record.values
123
+ );
124
+ const values = {};
125
+ for (const control of HULL_EFFECT_CONTROLS[record.mode]) {
126
+ const value = Object.hasOwn(input, control.key) ? input[control.key] : control.value;
127
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`Invalid NEEDLE_hull_effect value: ${control.key}.`);
128
+ values[control.key] = Math.max(control.min, Math.min(control.max, value));
129
+ }
130
+ return { version: 1, mode: record.mode, values };
131
+ }
132
+ export {
133
+ NEEDLE_HULL_EFFECT,
134
+ parseHullEffectDescriptor
135
+ };
136
+ //# sourceMappingURL=hull-effect-metadata.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/rendering/wrap-preview-settings.js", "../../../src/rendering/hull-effect-metadata.js"],
4
+ "sourcesContent": ["// Lightweight UI contract; importing controls must not import shader graphs.\nexport const HULL_EFFECT_MODES = ['ice', 'force-field', 'tech-cage', 'flames', 'aura', 'outline', 'godrays', 'wind-frosted', 'shroud', 'lava', 'ivy', 'heat-haze'];\n/** @type {Record<string, {key: string, label: string, min: number, max: number, step: number, value: number, title: string, kind?: string}[]>} */\nexport const HULL_EFFECT_CONTROLS = {\n 'heat-haze': [\n { key: 'strength', label: 'Distortion', min: 0, max: 1, step: 0.01, value: 0.35, title: 'Strength of the bubbling refractive normals.' },\n { key: 'detail', label: 'Detail', min: 1, max: 16, step: 0.25, value: 5, title: 'Spatial scale of the smooth heat bubbles.' },\n { key: 'speed', label: 'Speed', min: 0, max: 4, step: 0.05, value: 1, title: 'Upward motion and evolution of the heat distortion.' },\n { key: 'thickness', label: 'Thickness', min: 0.01, max: 1, step: 0.01, value: 0.15, title: 'Optical thickness of the transmissive hull.' },\n ],\n shroud: [\n { key: 'color', kind: 'color', label: 'Color', min: 0, max: 16777215, step: 1, value: 0x100d18, title: 'Deep shadow cloud color.' },\n { key: 'coverage', label: 'Coverage', min: 0, max: 1, step: 0.01, value: 0.33, title: 'Fraction of the surface hidden in swirling clouds.' },\n { key: 'detail', label: 'Detail', min: 1, max: 12, step: 0.25, value: 5.5, title: 'Cloud and eddy scale.' },\n { key: 'depth', label: 'Cloud depth', min: 0, max: 0.1, step: 0.001, value: 0.016, title: 'Surface-hugging cloud thickness relative to model size.' },\n { key: 'amplitude', label: 'Vertex curl', min: 0, max: 0.08, step: 0.001, value: 0.063, title: 'Full 3D curl displacement of the cloud vertices. Zero removes the vertex curl calculations from the shader.' },\n { key: 'fresnel', label: 'Edge fade', min: 0, max: 8, step: 0.05, value: 1.5, title: 'Fade clouds to transparent at grazing angles. Higher values soften more of the silhouette; zero disables the fade.' },\n { key: 'speed', label: 'Swirl speed', min: 0, max: 4, step: 0.05, value: 2.25, title: 'Cloud circulation speed; no upward flame motion.' },\n { key: 'opacity', label: 'Opacity', min: 0, max: 1, step: 0.01, value: 0.99, title: 'Maximum shadow opacity per layer.' },\n ],\n lava: [\n { key: 'noise', label: 'Growth noise', min: 0, max: 1, step: 0.01, value: 0.6, title: '3D noise variation in the advancing front. Zero removes the growth-noise graph.' },\n { key: 'transition', label: 'Transition zone', min: 0.05, max: 0.4, step: 0.01, value: 0.2, title: 'Width of the zone where volcanic plates form and expand.' },\n { key: 'color', kind: 'color', label: 'Lava color', min: 0, max: 16777215, step: 1, value: 0xff3705, title: 'Molten crack color, graduating to yellow-white in the hottest cores.' },\n { key: 'fill', label: 'Fill from bottom', min: 0, max: 1, step: 0.01, value: 0.65, title: 'Fill height from the base to the top of the rest-pose hull. Zero hides all lava; one covers all of it.' },\n { key: 'detail', label: 'Detail', min: 2, max: 24, step: 0.5, value: 12, title: 'Scale of the irregular volcanic plates.' },\n { key: 'cracks', label: 'Crack width', min: 0.01, max: 0.3, step: 0.005, value: 0.065, title: 'Width of the molten seams between crust plates.' },\n { key: 'glow', label: 'Heat', min: 0, max: 8, step: 0.1, value: 3, title: 'Emission of the molten cracks.' },\n { key: 'speed', label: 'Flow speed', min: 0, max: 3, step: 0.05, value: 0.5, title: 'Slow molten heat flow beneath stationary crust.' },\n ],\n ivy: [\n { key: 'noise', label: 'Growth noise', min: 0, max: 1, step: 0.01, value: 0.6, title: '3D variation in vine and leaf growth timing. Zero removes the growth-noise graph.' },\n { key: 'transition', label: 'Transition zone', min: 0.05, max: 0.4, step: 0.01, value: 0.2, title: 'Width of the zone where twigs extend and leaves unfurl from their roots.' },\n { key: 'color', kind: 'color', label: 'Leaf color', min: 0, max: 16777215, step: 1, value: 0x397b24, title: 'Leaf green, with lighter veins and younger tips.' },\n { key: 'growth', label: 'Growth', min: 0, max: 1, step: 0.01, value: 1, title: 'Reveal climbing stems and leaves from the bottom upward.' },\n { key: 'detail', label: 'Detail', min: 2, max: 24, step: 0.25, value: 10, title: 'Scale of the procedural vines and leaves on the hull.' },\n { key: 'leafSize', label: 'Leaf size', min: 0.2, max: 1, step: 0.01, value: 0.7, title: 'Lobed leaf size relative to the vine spacing.' },\n { key: 'speed', label: 'Breeze speed', min: 0, max: 3, step: 0.05, value: 0.6, title: 'Gentle leaf movement; stems stay attached to the hull.' },\n ],\n ice: [\n { key: 'dispersion', label: 'Dispersion', min: 0, max: 2, step: 0.01, value: 0.25, title: 'Spectral refraction through the ice. Zero removes dispersion from the shader.' },\n { key: 'frost', label: 'Frost', min: 0, max: 1, step: 0.01, value: 0.55, title: 'Cloudiness of the physical ice.' },\n { key: 'facets', label: 'Facets', min: 0, max: 1, step: 0.01, value: 0.5, title: 'Blend rounded normals into cut-crystal facets.' },\n { key: 'thickness', label: 'Thickness', min: 0.02, max: 1, step: 0.01, value: 0.35, title: 'Optical thickness relative to model size.' },\n ],\n 'force-field': [\n { key: 'color', kind: 'color', label: 'Color', min: 0, max: 16777215, step: 1, value: 0x2bd4ef, title: 'Energy color of both hex field layers.' },\n { key: 'density', label: 'Hex density', min: 4, max: 40, step: 1, value: 26, title: 'Scale of the biplanar hex grid on both field layers.' },\n { key: 'speed', label: 'Speed', min: 0, max: 4, step: 0.05, value: 1.75, title: 'Speed of the per-hex energy pulses and shifting outer patches.' },\n { key: 'glow', label: 'Glow', min: 0.1, max: 5, step: 0.1, value: 0.4, title: 'Field and Fresnel brightness.' },\n { key: 'detail', label: 'Detail', min: 1, max: 12, step: 0.25, value: 4, title: 'Spatial detail of curl motion and outer patches, independent of hex density.' },\n { key: 'noise', label: 'Noise strength', min: 0, max: 2, step: 0.05, value: 1, title: 'Curl displacement and outer-patch noise. Zero removes noise calculations from the shader.' },\n { key: 'fresnel', label: 'Fresnel', min: 0.25, max: 8, step: 0.05, value: 3, title: 'Concentrate the glow toward grazing edges. Higher values make a tighter rim.' },\n ],\n 'tech-cage': [\n { key: 'color', kind: 'color', label: 'Color', min: 0, max: 16777215, step: 1, value: 0x52e6ff, title: 'Color of the cage wires and vertex nodes.' },\n { key: 'amplitude', label: 'Curl strength', min: 0, max: 0.2, step: 0.005, value: 0.035, title: 'Shared curl displacement of cage vertices and node centers, relative to model size.' },\n { key: 'speed', label: 'Speed', min: 0, max: 4, step: 0.05, value: 0.7, title: 'Speed of the animated 3D curl field.' },\n { key: 'nodeSize', label: 'Node size', min: 0.002, max: 0.04, step: 0.001, value: 0.009, title: 'Radius of the instanced smooth icospheres, relative to model size.' },\n { key: 'width', label: 'Wire width', min: 0.25, max: 4, step: 0.25, value: 1.25, title: 'Antialiased wire width in screen pixels.' },\n ],\n flames: [\n { key: 'color', kind: 'color', label: 'Cool', min: 0, max: 16777215, step: 1, value: 0xff3c00, title: 'Cooling plume tips and weak wisps in the stylized temperature estimate.' },\n { key: 'warmColor', kind: 'color', label: 'Warm', min: 0, max: 16777215, step: 1, value: 0xffb52a, title: 'Middle of the flame temperature gradient.' },\n { key: 'hotColor', kind: 'color', label: 'Hot', min: 0, max: 16777215, step: 1, value: 0xfff4d6, title: 'Hot reaction region just beyond the emitting surface; the plume cools toward its tips.' },\n { key: 'radialUp', label: 'Radial up', min: 0, max: 1, step: 0.01, value: 0, title: '0: vertical world up. 1: outward and upward from the wrap\u2019s bottom-center floor point.' },\n { key: 'upThreshold', label: 'Upward threshold', min: -1, max: 0.95, step: 0.05, value: 0.05, title: 'Outward geometry-normal alignment with the selected up direction. Lower values include more side faces.' },\n { key: 'height', label: 'Flame height', min: 0, max: 1, step: 0.01, value: 0.35, title: 'Upward flame displacement relative to model size.' },\n { key: 'speed', label: 'Speed', min: 0, max: 4, step: 0.05, value: 1.4, title: 'Upward flow speed of the aura.' },\n { key: 'scale', label: 'Flame detail', min: 1, max: 12, step: 0.25, value: 5, title: 'Spatial frequency of the flame tongues.' },\n ],\n aura: [\n { key: 'color', kind: 'color', label: 'Color', min: 0, max: 16777215, step: 1, value: 0xffd52a, title: 'Aura color.' },\n { key: 'radialUp', label: 'Radial up', min: 0, max: 1, step: 0.01, value: 0.68, title: 'Blend vertical up into outward rays from the bottom-center floor point.' },\n { key: 'upThreshold', label: 'Upward threshold', min: -1, max: 0.95, step: 0.05, value: -0.2, title: 'Outward geometry-normal alignment required to emit spikes.' },\n { key: 'height', label: 'Spike height', min: 0, max: 1, step: 0.01, value: 0.39, title: 'Length of the pointed aura tongues relative to model size.' },\n { key: 'speed', label: 'Speed', min: 0, max: 4, step: 0.05, value: 2.85, title: 'General spike pulsing and shape variation, independent of inward travel and bending.' },\n { key: 'wanderSpeed', label: 'Inward travel speed', min: -4, max: 4, step: 0.05, value: 2.45, title: 'Polar spike travel speed. Negative reverses toward the base; zero stops travel without stopping the other animation.' },\n { key: 'bendStrength', label: 'Bend strength', min: 0, max: 0.5, step: 0.01, value: 0.1, title: 'Strength of the separate travelling shell bend. Zero disables the bend.' },\n { key: 'bendSpeed', label: 'Bend speed', min: 0, max: 4, step: 0.05, value: 4, title: 'Speed of the shell bend, independent of spike travel.' },\n { key: 'scale', label: 'Detail', min: 1, max: 12, step: 0.25, value: 6.75, title: 'Spatial frequency of the pointed energy tongues.' },\n { key: 'fresnel', label: 'Fresnel', min: 0.25, max: 12, step: 0.05, value: 5, title: 'Concentrate flat golden energy around the silhouette.' },\n { key: 'opacity', label: 'Opacity', min: 0, max: 1, step: 0.01, value: 0.17, title: 'Opacity of the flat-color aura shell.' },\n ],\n outline: [\n { key: 'color', kind: 'color', label: 'Color', min: 0, max: 16777215, step: 1, value: 0xffffff, title: 'Solid inner outline color.' },\n { key: 'expand', label: 'Normal expand', min: 0, max: 0.2, step: 0.001, value: 0.01, title: 'Inner shell expansion along smooth normals, relative to model size.' },\n { key: 'borderColor', kind: 'color', label: 'Border color', min: 0, max: 16777215, step: 1, value: 0x000000, title: 'Solid outer outline color.' },\n { key: 'borderOffset', label: 'Border offset', min: 0, max: 0.1, step: 0.001, value: 0.005, title: 'Additional normal expansion beyond the inner shell.' },\n ],\n godrays: [\n { key: 'azimuth', kind: 'direction', label: 'Direction', min: -180, max: 180, step: 1, value: 25, title: 'Drag to rotate the ray direction. Arrow keys rotate; Home resets.' },\n { key: 'elevation', kind: 'hidden', label: 'Elevation', min: -89, max: 89, step: 1, value: 55, title: '' },\n { key: 'angle', label: 'Angle', min: 1, max: 80, step: 1, value: 25, title: 'Angular spread of the directional rays.' },\n { key: 'length', label: 'Length', min: 0, max: 2, step: 0.01, value: 0.6, title: 'Ray length relative to the wrap size.' },\n { key: 'opacity', label: 'Strength', min: 0, max: 1, step: 0.01, value: 0.65, title: 'Multiplicative darkening of the rays.' },\n { key: 'fresnel', label: 'Edge softness', min: 0.25, max: 5, step: 0.05, value: 1.5, title: 'Fade grazing edges smoothly.' },\n ],\n 'wind-frosted': [\n { key: 'azimuth', kind: 'direction', label: 'Direction', min: -180, max: 180, step: 1, value: 25, title: 'Direction the freezing wind travels. Icicles point away with the wind.' },\n { key: 'elevation', kind: 'hidden', label: 'Elevation', min: -89, max: 89, step: 1, value: -25, title: '' },\n { key: 'coverage', label: 'Coverage', min: 0, max: 1, step: 0.01, value: 0.55, title: 'Amount of directional snow and frost coverage.' },\n { key: 'normalOffset', label: 'Windward offset', min: 0, max: 0.2, step: 0.001, value: 0, title: 'Push the wind-facing coating outward along its normals, relative to model size.' },\n { key: 'height', label: 'Icicle length', min: 0, max: 0.5, step: 0.01, value: 0.12, title: 'Length of sharp downwind icicles relative to model size.' },\n { key: 'scale', label: 'Detail', min: 1, max: 12, step: 0.25, value: 5, title: 'Detail of frost patches and pointed icicles.' },\n ],\n};\n/** @returns {Record<string, Record<string, number> & {mode: string}>} */\nexport function createHullEffectValues() {\n return /** @type {Record<string, Record<string, number> & {mode: string}>} */ (/** @type {unknown} */ (Object.fromEntries(Object.entries(HULL_EFFECT_CONTROLS).map(([mode, controls]) => [mode,\n { mode, ...Object.fromEntries(controls.map(control => [control.key, control.value])) },\n ]))));\n}\n\n/** Includes older reports whose wrap stages live inside material groups.\n * @param {unknown} topology\n * @returns {boolean}\n */\nexport function isWrapTopology(topology) {\n if (!topology || typeof topology !== 'object') return false;\n if ('mode' in topology && topology.mode === 'hull') return true;\n return 'groups' in topology && Array.isArray(topology.groups)\n && topology.groups.some(group => group && typeof group === 'object' && 'report' in group && isWrapTopology(group.report));\n}\n", "// @ts-check\nimport { HULL_EFFECT_CONTROLS } from './wrap-preview-settings.js';\n\nexport const NEEDLE_HULL_EFFECT = 'NEEDLE_hull_effect';\n\n/** @typedef {{version: 1, mode: string, values: Record<string, number>}} HullEffectDescriptor */\n\n/** Validate the runtime contract before building any shader graphs.\n * @param {unknown} raw\n * @returns {HullEffectDescriptor}\n */\nexport function parseHullEffectDescriptor(raw) {\n if (!raw || typeof raw !== 'object') throw new Error('Invalid NEEDLE_hull_effect descriptor.');\n const record = /** @type {Record<string, unknown>} */ (raw);\n if (record.version !== 1) throw new Error('Unsupported NEEDLE_hull_effect version.');\n if (typeof record.mode !== 'string' || !Object.hasOwn(HULL_EFFECT_CONTROLS, record.mode)) throw new Error('Unknown NEEDLE_hull_effect mode.');\n if (!record.values || typeof record.values !== 'object' || Array.isArray(record.values)) throw new Error('Invalid NEEDLE_hull_effect values.');\n const input = /** @type {Record<string, unknown>} */ (record.values);\n /** @type {Record<string, number>} */\n const values = {};\n for (const control of HULL_EFFECT_CONTROLS[record.mode]) {\n const value = Object.hasOwn(input, control.key) ? input[control.key] : control.value;\n if (typeof value !== 'number' || !Number.isFinite(value)) throw new Error(`Invalid NEEDLE_hull_effect value: ${control.key}.`);\n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@@ import { clone as cloneSkeleton } from "three/addons/utils/SkeletonUtils.js";
7
7
  import { mergeVertices } from "three/addons/utils/BufferGeometryUtils.js";
8
8
 
9
9
  // src/rendering/wrap-preview-settings.js
10
- var WRAP_PREVIEW_MODES = ["ice", "force-field", "tech-cage", "flames", "aura", "outline", "godrays", "wind-frosted", "shroud", "lava", "ivy", "heat-haze"];
11
- var WRAP_PREVIEW_CONTROLS = {
10
+ var HULL_EFFECT_CONTROLS = {
12
11
  "heat-haze": [
13
12
  { key: "strength", label: "Distortion", min: 0, max: 1, step: 0.01, value: 0.35, title: "Strength of the bubbling refractive normals." },
14
13
  { key: "detail", label: "Detail", min: 1, max: 16, step: 0.25, value: 5, title: "Spatial scale of the smooth heat bubbles." },
@@ -112,17 +111,6 @@ var WRAP_PREVIEW_CONTROLS = {
112
111
  { key: "scale", label: "Detail", min: 1, max: 12, step: 0.25, value: 5, title: "Detail of frost patches and pointed icicles." }
113
112
  ]
114
113
  };
115
- function createWrapPreviewValues() {
116
- return Object.fromEntries(Object.entries(WRAP_PREVIEW_CONTROLS).map(([mode, controls]) => [
117
- mode,
118
- Object.fromEntries(controls.map((control) => [control.key, control.value]))
119
- ]));
120
- }
121
- function isWrapTopology(topology) {
122
- if (!topology || typeof topology !== "object") return false;
123
- if ("mode" in topology && topology.mode === "hull") return true;
124
- return "groups" in topology && Array.isArray(topology.groups) && topology.groups.some((group) => group && typeof group === "object" && "report" in group && isWrapTopology(group.report));
125
- }
126
114
 
127
115
  // src/rendering/wrap-skin.js
128
116
  import * as THREE from "three";
@@ -4752,12 +4740,6 @@ function projectSkinGeometry(source, target, options = {}) {
4752
4740
 
4753
4741
  // src/rendering/wrap-skin.js
4754
4742
  var restMatrices = /* @__PURE__ */ new WeakMap();
4755
- function captureWrapSkinPose(root) {
4756
- root.traverse((node) => {
4757
- node.updateMatrix();
4758
- restMatrices.set(node, node.matrix.clone());
4759
- });
4760
- }
4761
4743
  function createWrapSkin(original, copy, asset, animate) {
4762
4744
  const sourceNodes = [];
4763
4745
  const copyNodes = [];
@@ -4917,9 +4899,6 @@ function createPreviewWireframeMaterial(sourceMaterial, isImpostor, thickness, b
4917
4899
  applyPreviewWireframeBlendMode(material, blendMode);
4918
4900
  return material;
4919
4901
  }
4920
- function parseWireframeBlendMode(value) {
4921
- return value === "white" || value === "invert" ? value : "black";
4922
- }
4923
4902
  function applyPreviewWireframeBlendMode(material, mode) {
4924
4903
  const basic = (
4925
4904
  /** @type {import('three/webgpu').MeshBasicNodeMaterial} */
@@ -5079,14 +5058,15 @@ function prepareRayGeometry(source) {
5079
5058
  geometry.setAttribute("rayTangent", new THREE3.Float32BufferAttribute(tangents, 3));
5080
5059
  return geometry;
5081
5060
  }
5082
- function createWrapPreview(asset, original, mode, values, options = {}) {
5083
- const controls = mode === "control" ? [] : WRAP_PREVIEW_CONTROLS[mode];
5084
- if (!controls) throw new Error(`Unknown wrap preview: ${mode}`);
5085
- const validatedValues = (input) => Object.fromEntries(controls.map((control) => [
5086
- control.key,
5087
- Number.isFinite(input[control.key]) ? THREE3.MathUtils.clamp(input[control.key], control.min, control.max) : control.value
5088
- ]));
5089
- values = validatedValues(values);
5061
+ function createHullEffect(asset, original, effect, options = {}) {
5062
+ const { mode, ...inputValues } = effect;
5063
+ const controls = mode === "control" ? [] : HULL_EFFECT_CONTROLS[mode];
5064
+ if (!controls) throw new Error(`Unknown hull effect: ${mode}`);
5065
+ const validatedValues = (input) => Object.fromEntries(controls.map((control) => {
5066
+ const value = input[control.key];
5067
+ return [control.key, typeof value === "number" && Number.isFinite(value) ? THREE3.MathUtils.clamp(value, control.min, control.max) : control.value];
5068
+ }));
5069
+ const values = validatedValues(inputValues);
5090
5070
  const group = new THREE3.Group();
5091
5071
  group.name = `Wrap preview: ${mode}`;
5092
5072
  group.userData.wrapPreview = true;
@@ -5104,7 +5084,7 @@ function createWrapPreview(asset, original, mode, values, options = {}) {
5104
5084
  const hazeNoiseEnabled = mode === "heat-haze" && values.strength > 0;
5105
5085
  const shroudCurlEnabled = mode === "shroud" && values.amplitude > 0;
5106
5086
  asset.updateWorldMatrix(true, true);
5107
- original.updateWorldMatrix(true, true);
5087
+ original?.updateWorldMatrix(true, true);
5108
5088
  const inverse = asset.matrixWorld.clone().invert();
5109
5089
  const shells = [];
5110
5090
  asset.traverse((object) => {
@@ -5122,12 +5102,14 @@ function createWrapPreview(asset, original, mode, values, options = {}) {
5122
5102
  const center = uniform2(bounds.getCenter(new THREE3.Vector3()));
5123
5103
  const size = Math.max(bounds.getSize(new THREE3.Vector3()).length(), 1e-5);
5124
5104
  const normalized = positionLocal.sub(center).div(size);
5125
- const sourceCopy = cloneSkeleton(original);
5126
- sourceCopy.name = "Original inside wrap";
5127
- if (mode === "control") sourceCopy.visible = false;
5128
- sourceCopy.matrix.copy(inverse.clone().multiply(original.matrixWorld));
5105
+ const animationSource = original ?? asset;
5106
+ const sourceCopy = cloneSkeleton(animationSource);
5107
+ sourceCopy.name = original ? "Original inside wrap" : "Hull animation driver";
5108
+ if (!original || mode === "control") sourceCopy.visible = false;
5109
+ if (original) sourceCopy.matrix.copy(inverse.clone().multiply(original.matrixWorld));
5110
+ else sourceCopy.matrix.identity();
5129
5111
  sourceCopy.matrixAutoUpdate = false;
5130
- const skin = createWrapSkin(original, sourceCopy, asset, options.animate);
5112
+ const skin = createWrapSkin(animationSource, sourceCopy, asset, options.animate);
5131
5113
  const helpers = [];
5132
5114
  sourceCopy.traverse((object) => {
5133
5115
  if (object.userData.previewWireframeOverlay || object.userData.previewGaussianSplat || object.userData.wrapPreview) helpers.push(object);
@@ -5144,7 +5126,7 @@ function createWrapPreview(asset, original, mode, values, options = {}) {
5144
5126
  };
5145
5127
  object.material = Array.isArray(object.material) ? object.material.map(cloneMaterial) : cloneMaterial(object.material);
5146
5128
  });
5147
- group.add(sourceCopy);
5129
+ if (original || skin) group.add(sourceCopy);
5148
5130
  const clock = time.mul(uniforms.speed ?? 1);
5149
5131
  const curl = (p) => {
5150
5132
  const q = p.sub(center).div(size).mul(mode === "force-field" || mode === "shroud" ? uniforms.detail : 4).add(vec32(0, clock.mul(0.3), clock.mul(0.2)));
@@ -5595,20 +5577,20 @@ function createWrapPreview(asset, original, mode, values, options = {}) {
5595
5577
  syncAnimation() {
5596
5578
  skin?.update();
5597
5579
  },
5598
- /** @param {Record<string, number>} next */
5580
+ /** @param {Record<string, string | number>} next */
5599
5581
  update(next) {
5600
- next = validatedValues(next);
5601
- if (mode === "ice" && next.dispersion > 0 !== dispersionEnabled) return false;
5602
- if (mode === "force-field" && next.noise > 0 !== fieldNoiseEnabled) return false;
5603
- if ((mode === "ivy" || mode === "lava") && next.noise > 0 !== growthNoiseEnabled) return false;
5604
- if (mode === "heat-haze" && next.strength > 0 !== hazeNoiseEnabled) return false;
5605
- if (mode === "shroud" && next.amplitude > 0 !== shroudCurlEnabled) return false;
5606
- effectColor.value.setHex(next.color ?? 16777215);
5607
- borderColor.value.setHex(next.borderColor ?? 0);
5608
- warmColor.value.setHex(next.warmColor ?? 16758058);
5609
- hotColor.value.setHex(next.hotColor ?? 16774358);
5610
- for (const [key, value] of Object.entries(next)) if (uniforms[key]) uniforms[key].value = value;
5611
- for (const material of materials) if (material.userData.previewWireframeThickness) material.userData.previewWireframeThickness.value = next.width;
5582
+ const validated = validatedValues(next);
5583
+ if (mode === "ice" && validated.dispersion > 0 !== dispersionEnabled) return false;
5584
+ if (mode === "force-field" && validated.noise > 0 !== fieldNoiseEnabled) return false;
5585
+ if ((mode === "ivy" || mode === "lava") && validated.noise > 0 !== growthNoiseEnabled) return false;
5586
+ if (mode === "heat-haze" && validated.strength > 0 !== hazeNoiseEnabled) return false;
5587
+ if (mode === "shroud" && validated.amplitude > 0 !== shroudCurlEnabled) return false;
5588
+ effectColor.value.setHex(validated.color ?? 16777215);
5589
+ borderColor.value.setHex(validated.borderColor ?? 0);
5590
+ warmColor.value.setHex(validated.warmColor ?? 16758058);
5591
+ hotColor.value.setHex(validated.hotColor ?? 16774358);
5592
+ for (const [key, value] of Object.entries(validated)) if (uniforms[key]) uniforms[key].value = value;
5593
+ for (const material of materials) if (material.userData.previewWireframeThickness) material.userData.previewWireframeThickness.value = validated.width;
5612
5594
  return true;
5613
5595
  },
5614
5596
  dispose() {
@@ -5622,19 +5604,104 @@ function createWrapPreview(asset, original, mode, values, options = {}) {
5622
5604
  }
5623
5605
  };
5624
5606
  }
5607
+
5608
+ // src/rendering/hull-effect-metadata.js
5609
+ var NEEDLE_HULL_EFFECT = "NEEDLE_hull_effect";
5610
+ function parseHullEffectDescriptor(raw) {
5611
+ if (!raw || typeof raw !== "object") throw new Error("Invalid NEEDLE_hull_effect descriptor.");
5612
+ const record = (
5613
+ /** @type {Record<string, unknown>} */
5614
+ raw
5615
+ );
5616
+ if (record.version !== 1) throw new Error("Unsupported NEEDLE_hull_effect version.");
5617
+ if (typeof record.mode !== "string" || !Object.hasOwn(HULL_EFFECT_CONTROLS, record.mode)) throw new Error("Unknown NEEDLE_hull_effect mode.");
5618
+ if (!record.values || typeof record.values !== "object" || Array.isArray(record.values)) throw new Error("Invalid NEEDLE_hull_effect values.");
5619
+ const input = (
5620
+ /** @type {Record<string, unknown>} */
5621
+ record.values
5622
+ );
5623
+ const values = {};
5624
+ for (const control of HULL_EFFECT_CONTROLS[record.mode]) {
5625
+ const value = Object.hasOwn(input, control.key) ? input[control.key] : control.value;
5626
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new Error(`Invalid NEEDLE_hull_effect value: ${control.key}.`);
5627
+ values[control.key] = Math.max(control.min, Math.min(control.max, value));
5628
+ }
5629
+ return { version: 1, mode: record.mode, values };
5630
+ }
5631
+
5632
+ // src/rendering/hull-effect-runtime.js
5633
+ var hulls = /* @__PURE__ */ new WeakMap();
5634
+ function getHullEffect(hull) {
5635
+ return hulls.get(hull)?.effect;
5636
+ }
5637
+ function bindHull(hull, original, options = {}) {
5638
+ const state = hulls.get(hull);
5639
+ if (!state || state.disposed) throw new Error("Load this hull with useLoader before calling bindHull.");
5640
+ if (original && (original === hull || isAncestor(hull, original) || isAncestor(original, hull))) throw new Error("Hull and original must have separate hierarchies.");
5641
+ state.effect.dispose();
5642
+ const effect = createHullEffect(hull, original, { ...state.descriptor.values, mode: state.descriptor.mode }, options);
5643
+ state.effect = manageEffect(hull, state, effect);
5644
+ state.disposed = false;
5645
+ hulls.set(hull, state);
5646
+ return state.effect;
5647
+ }
5648
+ function isAncestor(ancestor, object) {
5649
+ for (let parent = object.parent; parent; parent = parent.parent) if (parent === ancestor) return true;
5650
+ return false;
5651
+ }
5652
+ function manageEffect(hull, state, effect) {
5653
+ const update = effect.update.bind(effect), dispose = effect.dispose.bind(effect);
5654
+ let disposed = false;
5655
+ effect.update = (next) => {
5656
+ if (disposed || !update(next)) return false;
5657
+ state.descriptor = parseHullEffectDescriptor({ ...state.descriptor, values: next });
5658
+ return true;
5659
+ };
5660
+ effect.dispose = () => {
5661
+ if (disposed) return;
5662
+ disposed = true;
5663
+ dispose();
5664
+ if (state.effect === effect) {
5665
+ state.disposed = true;
5666
+ hulls.delete(hull);
5667
+ }
5668
+ };
5669
+ return effect;
5670
+ }
5671
+ var NeedleHullEffectLoaderPlugin = class {
5672
+ name = NEEDLE_HULL_EFFECT;
5673
+ /** @param {import('three/addons/loaders/GLTFLoader.js').GLTFParser} parser */
5674
+ constructor(parser) {
5675
+ this.parser = parser;
5676
+ }
5677
+ /** @param {import('three/addons/loaders/GLTFLoader.js').GLTF} result */
5678
+ async afterRoot(result) {
5679
+ const json = (
5680
+ /** @type {{scenes?: {extensions?: Record<string, unknown>}[]}} */
5681
+ this.parser.json
5682
+ );
5683
+ const pending = result.scenes.flatMap((scene, index) => {
5684
+ const raw = json.scenes?.[index]?.extensions?.[this.name];
5685
+ return raw === void 0 ? [] : [{ scene, descriptor: parseHullEffectDescriptor(raw) }];
5686
+ });
5687
+ const created = [];
5688
+ try {
5689
+ for (const { scene, descriptor } of pending) {
5690
+ const effect = createHullEffect(scene, null, { ...descriptor.values, mode: descriptor.mode }, { animate: result.animations.length ? true : void 0 });
5691
+ const state = { descriptor, effect, disposed: false };
5692
+ state.effect = manageEffect(scene, state, effect);
5693
+ hulls.set(scene, state);
5694
+ created.push(state.effect);
5695
+ }
5696
+ } catch (error) {
5697
+ for (const effect of created) effect.dispose();
5698
+ throw error;
5699
+ }
5700
+ }
5701
+ };
5625
5702
  export {
5626
- WRAP_PREVIEW_CONTROLS,
5627
- WRAP_PREVIEW_MODES,
5628
- applyPreviewWireframeBlendMode,
5629
- captureWrapSkinPose,
5630
- createBarycentricWireframeGeometry,
5631
- createPreviewWireframeMaterial,
5632
- createWrapPreview,
5633
- createWrapPreviewValues,
5634
- isWrapTopology,
5635
- parseWireframeBlendMode,
5636
- prepareAuraGeometry,
5637
- prepareIceNormalAttributes,
5638
- prepareRayGeometry
5703
+ NeedleHullEffectLoaderPlugin,
5704
+ bindHull,
5705
+ getHullEffect
5639
5706
  };
5640
- //# sourceMappingURL=wrap-effects.js.map
5707
+ //# sourceMappingURL=hull-effect-runtime.js.map