BlueGit

timfa questward

Add fluid palette preview icons and strengthen lava coasts.

Bake 3×3-center 16×16 thumbs for water, deep water, and lava for the editor palette. Lava coasts now use water-style retreat/clip to black with a darker crust band so shore edges read clearly.

timfa Tim Falken · pushed by timfa

Authored 2026-09-04 · 2 months ago

Hash
2d9436524a852ea60f078c4346c9ce8eab35ca8e
Parent
e7ccfdf6
10 files changed +283 −21
client/assets/grounds/deep-water/deep-water-preview.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/grounds/lava/lava-preview.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/grounds/water/water-preview.png added Binary file +0 −0

The contents of this binary file are not shown.

client/scripts/write-fluid-preview-icons.mjs added +225 −0
@@ -0,0 +1,225 @@
1 /**
2 * Bake 16×16 editor palette icons for procedural fluids.
3 * Renders a 3×3 tile neighborhood and crops the center tile so noise is continuous.
4 *
5 * node client/scripts/write-fluid-preview-icons.mjs
6 */
7 import { join } from "node:path";
8 import { makeRgba, writeRgbaPng } from "../../server/src/assets/placeholderPng.js";
9 import { DEFAULT_WATER_DEBUG, DEFAULT_LAVA_DEBUG } from "../src/play/waterDebug.js";
10
11 const TILE = 16;
12 const GRID = 3;
13 const BAKE = TILE * GRID;
14 const TIME = 2.4;
15 const root = join(import.meta.dirname, "..", "assets", "grounds");
16
17 function clamp (v, lo, hi)
18 {
19 return Math.min(hi, Math.max(lo, v));
20 }
21
22 function mix (a, b, t)
23 {
24 return a + (b - a) * t;
25 }
26
27 function smoothstep (edge0, edge1, x)
28 {
29 const t = clamp((x - edge0) / Math.max(1e-6, edge1 - edge0), 0, 1);
30 return t * t * (3 - 2 * t);
31 }
32
33 /** Compact value-noise FBM (preview-only stand-in for simplex). */
34 function hash3 (x, y, z)
35 {
36 const n = Math.sin(x * 127.1 + y * 311.7 + z * 74.7) * 43758.5453123;
37 return n - Math.floor(n);
38 }
39
40 function valueNoise3 (x, y, z)
41 {
42 const x0 = Math.floor(x);
43 const y0 = Math.floor(y);
44 const z0 = Math.floor(z);
45 const fx = x - x0;
46 const fy = y - y0;
47 const fz = z - z0;
48 const ux = fx * fx * (3 - 2 * fx);
49 const uy = fy * fy * (3 - 2 * fy);
50 const uz = fz * fz * (3 - 2 * fz);
51 const n000 = hash3(x0, y0, z0);
52 const n100 = hash3(x0 + 1, y0, z0);
53 const n010 = hash3(x0, y0 + 1, z0);
54 const n110 = hash3(x0 + 1, y0 + 1, z0);
55 const n001 = hash3(x0, y0, z0 + 1);
56 const n101 = hash3(x0 + 1, y0, z0 + 1);
57 const n011 = hash3(x0, y0 + 1, z0 + 1);
58 const n111 = hash3(x0 + 1, y0 + 1, z0 + 1);
59 const nx00 = mix(n000, n100, ux);
60 const nx10 = mix(n010, n110, ux);
61 const nx01 = mix(n001, n101, ux);
62 const nx11 = mix(n011, n111, ux);
63 const nxy0 = mix(nx00, nx10, uy);
64 const nxy1 = mix(nx01, nx11, uy);
65 return mix(nxy0, nxy1, uz) * 2 - 1;
66 }
67
68 function fbm3 (x, y, z)
69 {
70 let sum = 0;
71 let amp = 0.5;
72 let px = x;
73 let py = y;
74 let pz = z;
75 for (let i = 0; i < 4; i++)
76 {
77 sum += amp * valueNoise3(px, py, pz);
78 px *= 2;
79 py *= 2;
80 pz *= 2;
81 amp *= 0.5;
82 }
83 return sum;
84 }
85
86 function sampleHeight (worldX, worldY, p, timeSec)
87 {
88 const flowX = timeSec * p.flowX;
89 const flowY = timeSec * p.flowY;
90 const baseX = worldX * p.waveScale + flowX;
91 const baseY = worldY * p.waveScale + flowY;
92 const baseZ = timeSec * p.flowZ;
93 const eps = Math.max(p.normalEps, 0.001);
94 const nC = fbm3(baseX, baseY, baseZ);
95 const nL = fbm3(baseX - eps, baseY, baseZ);
96 const nR = fbm3(baseX + eps, baseY, baseZ);
97 const nD = fbm3(baseX, baseY - eps, baseZ);
98 const nU = fbm3(baseX, baseY + eps, baseZ);
99 const h = nC * p.fbmAmp;
100 const ndotl = clamp(
101 (-(nL - nR) * p.lightDirX + -(nD - nU) * p.lightDirY + p.normalZ * p.lightDirZ)
102 / Math.hypot(nL - nR, nD - nU, p.normalZ),
103 0,
104 1
105 );
106 const wave = clamp(h * p.waveGain + 0.5, 0, 1);
107 const crest = smoothstep(p.crestLo, Math.max(p.crestHi, p.crestLo + 0.01), wave) ** Math.max(p.crestPow, 0.01);
108 let glitter = (ndotl ** Math.max(p.glitterPow, 0.01)) * crest;
109 glitter = Math.max(glitter, (crest ** 2.5) * p.crestGlitter);
110 return { wave, glitter, ndotl };
111 }
112
113 function rgbBytes (r, g, b)
114 {
115 return [
116 Math.round(clamp(r, 0, 1) * 255),
117 Math.round(clamp(g, 0, 1) * 255),
118 Math.round(clamp(b, 0, 1) * 255),
119 255
120 ];
121 }
122
123 function paintWaterPixel (worldX, worldY, deepAmt, p)
124 {
125 const { wave, glitter, ndotl } = sampleHeight(worldX, worldY, p, TIME);
126 const darkW = clamp(p.deepDark, 0, 1);
127 const deepCol = [
128 mix(0.12, mix(0.05, 0.015, darkW), deepAmt),
129 mix(0.34, mix(0.16, 0.055, darkW), deepAmt),
130 mix(0.54, mix(0.34, 0.14, darkW), deepAmt)
131 ];
132 const midCol = [
133 mix(0.24, mix(0.10, 0.04, darkW), deepAmt),
134 mix(0.52, mix(0.30, 0.14, darkW), deepAmt),
135 mix(0.70, mix(0.50, 0.28, darkW), deepAmt)
136 ];
137 const litCol = [
138 mix(0.52, mix(0.26, 0.12, darkW), deepAmt),
139 mix(0.78, mix(0.46, 0.28, darkW), deepAmt),
140 mix(0.90, mix(0.66, 0.46, darkW), deepAmt)
141 ];
142 const sparkCol = [
143 mix(0.98, mix(0.72, 0.48, darkW), deepAmt),
144 mix(1.0, mix(0.88, 0.68, darkW), deepAmt),
145 mix(1.0, mix(0.98, 0.86, darkW), deepAmt)
146 ];
147 const body = smoothstep(p.bodyLo, Math.max(p.bodyHi, p.bodyLo + 0.01), wave);
148 const litAmt = smoothstep(p.litLo, Math.max(p.litHi, p.litLo + 0.01), wave) * p.litMix;
149 let r = mix(deepCol[0], midCol[0], body);
150 let g = mix(deepCol[1], midCol[1], body);
151 let b = mix(deepCol[2], midCol[2], body);
152 r = mix(r, litCol[0], litAmt);
153 g = mix(g, litCol[1], litAmt);
154 b = mix(b, litCol[2], litAmt);
155 const shade = mix(p.shadeLo, p.shadeHi, ndotl);
156 r *= shade;
157 g *= shade;
158 b *= shade;
159 const spark = Math.min(glitter, p.glitterCap) * p.glitterMix;
160 r = mix(r, sparkCol[0], spark);
161 g = mix(g, sparkCol[1], spark);
162 b = mix(b, sparkCol[2], spark);
163 return rgbBytes(r, g, b);
164 }
165
166 function paintLavaPixel (worldX, worldY, p)
167 {
168 const { wave, glitter, ndotl } = sampleHeight(worldX, worldY, p, TIME);
169 let heat = smoothstep(p.bodyLo, Math.max(p.bodyHi, p.bodyLo + 0.01), wave);
170 heat = mix(heat, 1, smoothstep(p.litLo, Math.max(p.litHi, p.litLo + 0.01), wave) * p.litMix * 0.35);
171 heat = clamp(heat + Math.min(glitter, p.glitterCap) * p.glitterMix * 0.45, 0, 1);
172 let r = mix(0.16, 0.78, smoothstep(0, 0.38, heat));
173 let g = mix(0.015, 0.08, smoothstep(0, 0.38, heat));
174 let b = mix(0.01, 0.02, smoothstep(0, 0.38, heat));
175 r = mix(r, 0.98, smoothstep(0.28, 0.68, heat));
176 g = mix(g, 0.38, smoothstep(0.28, 0.68, heat));
177 b = mix(b, 0.04, smoothstep(0.28, 0.68, heat));
178 const yellowAmt = smoothstep(0.55, 0.98, heat);
179 r = mix(r, 1.0, yellowAmt);
180 g = mix(g, 0.9, yellowAmt);
181 b = mix(b, 0.28, yellowAmt);
182 const shade = mix(p.shadeLo, p.shadeHi, ndotl);
183 return rgbBytes(r * shade, g * shade, b * shade);
184 }
185
186 function bakeCenterTile (paintPixel)
187 {
188 const full = makeRgba(BAKE, BAKE, [0, 0, 0, 255]);
189 const origin = 1;
190 for (let py = 0; py < BAKE; py++)
191 {
192 for (let px = 0; px < BAKE; px++)
193 {
194 const worldX = origin + px / TILE;
195 const worldY = origin + py / TILE;
196 full.pixels.set(paintPixel(worldX, worldY), (py * BAKE + px) * 4);
197 }
198 }
199 const out = makeRgba(TILE, TILE, [0, 0, 0, 255]);
200 for (let y = 0; y < TILE; y++)
201 {
202 for (let x = 0; x < TILE; x++)
203 {
204 const sx = TILE + x;
205 const sy = TILE + y;
206 const src = (sy * BAKE + sx) * 4;
207 out.pixels.set(full.pixels.subarray(src, src + 4), (y * TILE + x) * 4);
208 }
209 }
210 return out;
211 }
212
213 const waterP = { ...DEFAULT_WATER_DEBUG };
214 const lavaP = { ...DEFAULT_LAVA_DEBUG };
215
216 const waterIcon = bakeCenterTile((x, y) => paintWaterPixel(x, y, 0, waterP));
217 writeRgbaPng(join(root, "water", "water-preview.png"), TILE, TILE, waterIcon.pixels);
218
219 const deepIcon = bakeCenterTile((x, y) => paintWaterPixel(x, y, Math.pow(1, waterP.deepAbrupt), waterP));
220 writeRgbaPng(join(root, "deep-water", "deep-water-preview.png"), TILE, TILE, deepIcon.pixels);
221
222 const lavaIcon = bakeCenterTile((x, y) => paintLavaPixel(x, y, lavaP));
223 writeRgbaPng(join(root, "lava", "lava-preview.png"), TILE, TILE, lavaIcon.pixels);
224
225 console.log("Wrote water / deep-water / lava preview icons (3×3 center crop).");
@@ -0,0 +1,225 @@
1/**
2 * Bake 16×16 editor palette icons for procedural fluids.
3 * Renders a 3×3 tile neighborhood and crops the center tile so noise is continuous.
4 *
5 * node client/scripts/write-fluid-preview-icons.mjs
6 */
7import { join } from "node:path";
8import { makeRgba, writeRgbaPng } from "../../server/src/assets/placeholderPng.js";
9import { DEFAULT_WATER_DEBUG, DEFAULT_LAVA_DEBUG } from "../src/play/waterDebug.js";
10
11const TILE = 16;
12const GRID = 3;
13const BAKE = TILE * GRID;
14const TIME = 2.4;
15const root = join(import.meta.dirname, "..", "assets", "grounds");
16
17function clamp (v, lo, hi)
18{
19 return Math.min(hi, Math.max(lo, v));
20}
21
22function mix (a, b, t)
23{
24 return a + (b - a) * t;
25}
26
27function smoothstep (edge0, edge1, x)
28{
29 const t = clamp((x - edge0) / Math.max(1e-6, edge1 - edge0), 0, 1);
30 return t * t * (3 - 2 * t);
31}
32
33/** Compact value-noise FBM (preview-only stand-in for simplex). */
34function hash3 (x, y, z)
35{
36 const n = Math.sin(x * 127.1 + y * 311.7 + z * 74.7) * 43758.5453123;
37 return n - Math.floor(n);
38}
39
40function valueNoise3 (x, y, z)
41{
42 const x0 = Math.floor(x);
43 const y0 = Math.floor(y);
44 const z0 = Math.floor(z);
45 const fx = x - x0;
46 const fy = y - y0;
47 const fz = z - z0;
48 const ux = fx * fx * (3 - 2 * fx);
49 const uy = fy * fy * (3 - 2 * fy);
50 const uz = fz * fz * (3 - 2 * fz);
51 const n000 = hash3(x0, y0, z0);
52 const n100 = hash3(x0 + 1, y0, z0);
53 const n010 = hash3(x0, y0 + 1, z0);
54 const n110 = hash3(x0 + 1, y0 + 1, z0);
55 const n001 = hash3(x0, y0, z0 + 1);
56 const n101 = hash3(x0 + 1, y0, z0 + 1);
57 const n011 = hash3(x0, y0 + 1, z0 + 1);
58 const n111 = hash3(x0 + 1, y0 + 1, z0 + 1);
59 const nx00 = mix(n000, n100, ux);
60 const nx10 = mix(n010, n110, ux);
61 const nx01 = mix(n001, n101, ux);
62 const nx11 = mix(n011, n111, ux);
63 const nxy0 = mix(nx00, nx10, uy);
64 const nxy1 = mix(nx01, nx11, uy);
65 return mix(nxy0, nxy1, uz) * 2 - 1;
66}
67
68function fbm3 (x, y, z)
69{
70 let sum = 0;
71 let amp = 0.5;
72 let px = x;
73 let py = y;
74 let pz = z;
75 for (let i = 0; i < 4; i++)
76 {
77 sum += amp * valueNoise3(px, py, pz);
78 px *= 2;
79 py *= 2;
80 pz *= 2;
81 amp *= 0.5;
82 }
83 return sum;
84}
85
86function sampleHeight (worldX, worldY, p, timeSec)
87{
88 const flowX = timeSec * p.flowX;
89 const flowY = timeSec * p.flowY;
90 const baseX = worldX * p.waveScale + flowX;
91 const baseY = worldY * p.waveScale + flowY;
92 const baseZ = timeSec * p.flowZ;
93 const eps = Math.max(p.normalEps, 0.001);
94 const nC = fbm3(baseX, baseY, baseZ);
95 const nL = fbm3(baseX - eps, baseY, baseZ);
96 const nR = fbm3(baseX + eps, baseY, baseZ);
97 const nD = fbm3(baseX, baseY - eps, baseZ);
98 const nU = fbm3(baseX, baseY + eps, baseZ);
99 const h = nC * p.fbmAmp;
100 const ndotl = clamp(
101 (-(nL - nR) * p.lightDirX + -(nD - nU) * p.lightDirY + p.normalZ * p.lightDirZ)
102 / Math.hypot(nL - nR, nD - nU, p.normalZ),
103 0,
104 1
105 );
106 const wave = clamp(h * p.waveGain + 0.5, 0, 1);
107 const crest = smoothstep(p.crestLo, Math.max(p.crestHi, p.crestLo + 0.01), wave) ** Math.max(p.crestPow, 0.01);
108 let glitter = (ndotl ** Math.max(p.glitterPow, 0.01)) * crest;
109 glitter = Math.max(glitter, (crest ** 2.5) * p.crestGlitter);
110 return { wave, glitter, ndotl };
111}
112
113function rgbBytes (r, g, b)
114{
115 return [
116 Math.round(clamp(r, 0, 1) * 255),
117 Math.round(clamp(g, 0, 1) * 255),
118 Math.round(clamp(b, 0, 1) * 255),
119 255
120 ];
121}
122
123function paintWaterPixel (worldX, worldY, deepAmt, p)
124{
125 const { wave, glitter, ndotl } = sampleHeight(worldX, worldY, p, TIME);
126 const darkW = clamp(p.deepDark, 0, 1);
127 const deepCol = [
128 mix(0.12, mix(0.05, 0.015, darkW), deepAmt),
129 mix(0.34, mix(0.16, 0.055, darkW), deepAmt),
130 mix(0.54, mix(0.34, 0.14, darkW), deepAmt)
131 ];
132 const midCol = [
133 mix(0.24, mix(0.10, 0.04, darkW), deepAmt),
134 mix(0.52, mix(0.30, 0.14, darkW), deepAmt),
135 mix(0.70, mix(0.50, 0.28, darkW), deepAmt)
136 ];
137 const litCol = [
138 mix(0.52, mix(0.26, 0.12, darkW), deepAmt),
139 mix(0.78, mix(0.46, 0.28, darkW), deepAmt),
140 mix(0.90, mix(0.66, 0.46, darkW), deepAmt)
141 ];
142 const sparkCol = [
143 mix(0.98, mix(0.72, 0.48, darkW), deepAmt),
144 mix(1.0, mix(0.88, 0.68, darkW), deepAmt),
145 mix(1.0, mix(0.98, 0.86, darkW), deepAmt)
146 ];
147 const body = smoothstep(p.bodyLo, Math.max(p.bodyHi, p.bodyLo + 0.01), wave);
148 const litAmt = smoothstep(p.litLo, Math.max(p.litHi, p.litLo + 0.01), wave) * p.litMix;
149 let r = mix(deepCol[0], midCol[0], body);
150 let g = mix(deepCol[1], midCol[1], body);
151 let b = mix(deepCol[2], midCol[2], body);
152 r = mix(r, litCol[0], litAmt);
153 g = mix(g, litCol[1], litAmt);
154 b = mix(b, litCol[2], litAmt);
155 const shade = mix(p.shadeLo, p.shadeHi, ndotl);
156 r *= shade;
157 g *= shade;
158 b *= shade;
159 const spark = Math.min(glitter, p.glitterCap) * p.glitterMix;
160 r = mix(r, sparkCol[0], spark);
161 g = mix(g, sparkCol[1], spark);
162 b = mix(b, sparkCol[2], spark);
163 return rgbBytes(r, g, b);
164}
165
166function paintLavaPixel (worldX, worldY, p)
167{
168 const { wave, glitter, ndotl } = sampleHeight(worldX, worldY, p, TIME);
169 let heat = smoothstep(p.bodyLo, Math.max(p.bodyHi, p.bodyLo + 0.01), wave);
170 heat = mix(heat, 1, smoothstep(p.litLo, Math.max(p.litHi, p.litLo + 0.01), wave) * p.litMix * 0.35);
171 heat = clamp(heat + Math.min(glitter, p.glitterCap) * p.glitterMix * 0.45, 0, 1);
172 let r = mix(0.16, 0.78, smoothstep(0, 0.38, heat));
173 let g = mix(0.015, 0.08, smoothstep(0, 0.38, heat));
174 let b = mix(0.01, 0.02, smoothstep(0, 0.38, heat));
175 r = mix(r, 0.98, smoothstep(0.28, 0.68, heat));
176 g = mix(g, 0.38, smoothstep(0.28, 0.68, heat));
177 b = mix(b, 0.04, smoothstep(0.28, 0.68, heat));
178 const yellowAmt = smoothstep(0.55, 0.98, heat);
179 r = mix(r, 1.0, yellowAmt);
180 g = mix(g, 0.9, yellowAmt);
181 b = mix(b, 0.28, yellowAmt);
182 const shade = mix(p.shadeLo, p.shadeHi, ndotl);
183 return rgbBytes(r * shade, g * shade, b * shade);
184}
185
186function bakeCenterTile (paintPixel)
187{
188 const full = makeRgba(BAKE, BAKE, [0, 0, 0, 255]);
189 const origin = 1;
190 for (let py = 0; py < BAKE; py++)
191 {
192 for (let px = 0; px < BAKE; px++)
193 {
194 const worldX = origin + px / TILE;
195 const worldY = origin + py / TILE;
196 full.pixels.set(paintPixel(worldX, worldY), (py * BAKE + px) * 4);
197 }
198 }
199 const out = makeRgba(TILE, TILE, [0, 0, 0, 255]);
200 for (let y = 0; y < TILE; y++)
201 {
202 for (let x = 0; x < TILE; x++)
203 {
204 const sx = TILE + x;
205 const sy = TILE + y;
206 const src = (sy * BAKE + sx) * 4;
207 out.pixels.set(full.pixels.subarray(src, src + 4), (y * TILE + x) * 4);
208 }
209 }
210 return out;
211}
212
213const waterP = { ...DEFAULT_WATER_DEBUG };
214const lavaP = { ...DEFAULT_LAVA_DEBUG };
215
216const waterIcon = bakeCenterTile((x, y) => paintWaterPixel(x, y, 0, waterP));
217writeRgbaPng(join(root, "water", "water-preview.png"), TILE, TILE, waterIcon.pixels);
218
219const deepIcon = bakeCenterTile((x, y) => paintWaterPixel(x, y, Math.pow(1, waterP.deepAbrupt), waterP));
220writeRgbaPng(join(root, "deep-water", "deep-water-preview.png"), TILE, TILE, deepIcon.pixels);
221
222const lavaIcon = bakeCenterTile((x, y) => paintLavaPixel(x, y, lavaP));
223writeRgbaPng(join(root, "lava", "lava-preview.png"), TILE, TILE, lavaIcon.pixels);
224
225console.log("Wrote water / deep-water / lava preview icons (3×3 center crop).");
client/src/editor/paletteModal.js +3 −2
@@ -1,6 +1,6 @@
1 1 import { listPlaceableGrounds, listPlaceableBlockPaletteEntries } from "/shared/definitions/tiles.js";
2 2 import { listSpawnableMobTypes, mobSpriteName } from "/shared/definitions/mobs.js";
3 import { defaultStateForType, resolveState, spriteImageName } from "/shared/definitions/tileSprites.js";
3 import { defaultStateForType, resolveState, spriteImageName, palettePreviewImageName } from "/shared/definitions/tileSprites.js";
4 4
5 5 /**
6 6 * Select-tool modal: Ground / Blocks / Spawners, auto-built from definitions.
@@ -58,9 +58,10 @@ export function initPaletteModal ({ onSelect, catalog, imageUrlFor })
58 58 catalog.grounds?.[def.key]?.states ?? [],
59 59 state
60 60 ));
61 const previewName = palettePreviewImageName("ground", def.key);
61 62 grid.append(tileCard({
62 63 label: def.displayName,
63 url: imageUrlFor?.(name),
64 url: imageUrlFor?.(previewName) ?? imageUrlFor?.(name),
64 65 onClick ()
65 66 {
66 67 onSelect({ kind: "ground", typeId: def.id });
@@ -1,6 +1,6 @@
1import { listPlaceableGrounds, listPlaceableBlockPaletteEntries } from "/shared/definitions/tiles.js";
1import { listPlaceableGrounds, listPlaceableBlockPaletteEntries } from "/shared/definitions/tiles.js";
2import { listSpawnableMobTypes, mobSpriteName } from "/shared/definitions/mobs.js";
2import { listSpawnableMobTypes, mobSpriteName } from "/shared/definitions/mobs.js";
3import { defaultStateForType, resolveState, spriteImageName } from "/shared/definitions/tileSprites.js";
3import { defaultStateForType, resolveState, spriteImageName, palettePreviewImageName } from "/shared/definitions/tileSprites.js";
4
4
5/**
5/**
6 * Select-tool modal: Ground / Blocks / Spawners, auto-built from definitions.
6 * Select-tool modal: Ground / Blocks / Spawners, auto-built from definitions.
@@ -58,9 +58,10 @@ export function initPaletteModal ({ onSelect, catalog, imageUrlFor })
58 catalog.grounds?.[def.key]?.states ?? [],
58 catalog.grounds?.[def.key]?.states ?? [],
59 state
59 state
60 ));
60 ));
61 const previewName = palettePreviewImageName("ground", def.key);
61 grid.append(tileCard({
62 grid.append(tileCard({
62 label: def.displayName,
63 label: def.displayName,
63 url: imageUrlFor?.(name),
64 url: imageUrlFor?.(previewName) ?? imageUrlFor?.(name),
64 onClick ()
65 onClick ()
65 {
66 {
66 onSelect({ kind: "ground", typeId: def.id });
67 onSelect({ kind: "ground", typeId: def.id });
client/src/play/waterDebug.js +2 −2
@@ -64,13 +64,13 @@ export const DEFAULT_LAVA_DEBUG = Object.freeze({
64 64 litLo: 0.59,
65 65 litHi: 0.74,
66 66 litMix: 1,
67 edgeDark: 1,
67 edgeDark: 0.55,
68 68 lightDirX: -0.48,
69 69 lightDirY: -0.63,
70 70 lightDirZ: 0.78,
71 71 normalEps: 0.09,
72 72 bloomStrength: 0.9,
73 shoreClip: 0.54
73 shoreClip: 0.4
74 74 });
75 75
76 76 const WATER_SLIDERS = [
@@ -64,13 +64,13 @@ export const DEFAULT_LAVA_DEBUG = Object.freeze({
64 litLo: 0.59,
64 litLo: 0.59,
65 litHi: 0.74,
65 litHi: 0.74,
66 litMix: 1,
66 litMix: 1,
67 edgeDark: 1,
67 edgeDark: 0.55,
68 lightDirX: -0.48,
68 lightDirX: -0.48,
69 lightDirY: -0.63,
69 lightDirY: -0.63,
70 lightDirZ: 0.78,
70 lightDirZ: 0.78,
71 normalEps: 0.09,
71 normalEps: 0.09,
72 bloomStrength: 0.9,
72 bloomStrength: 0.9,
73 shoreClip: 0.54
73 shoreClip: 0.4
74});
74});
75
75
76const WATER_SLIDERS = [
76const WATER_SLIDERS = [
client/src/render/worldView.js +16 −6
@@ -493,7 +493,7 @@ const LAVA_GROUND_FRAG = [
493 493 " if (u_edgeSW > 0.5) {",
494 494 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
495 495 " }",
496 " float waveBody = wave * (1.0 - edgeProx * 0.55);",
496 " float waveBody = wave * (1.0 - edgeProx * 0.72);",
497 497 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
498 498 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
499 499 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
@@ -508,9 +508,16 @@ const LAVA_GROUND_FRAG = [
508 508 " float shade = mix(u_shadeLo, u_shadeHi, ndotl);",
509 509 " rgb *= shade;",
510 510 " rgb = mix(rgb, darkRed, edgeProx * u_edgeDark);",
511 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
511 " float darkAmt = 1.0 - smoothstep(0.12, 0.48, waveBody);",
512 512 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
513 " float shoreMask = step(u_shoreClip, retreat);",
513 " float hasEdge = max(max(u_edgeN, u_edgeE), max(u_edgeS, u_edgeW));",
514 " hasEdge = max(hasEdge, max(max(u_edgeNE, u_edgeNW), max(u_edgeSE, u_edgeSW)));",
515 " float shoreW = step(0.5, hasEdge);",
516 " float shoreClip = u_shoreClip;",
517 " float shoreMask = step(shoreClip, retreat) * shoreW;",
518 " float crustAmt = (1.0 - shoreMask) * smoothstep(shoreClip - 0.24, shoreClip - 0.08, retreat)",
519 " * (1.0 - smoothstep(shoreClip - 0.08, shoreClip, retreat));",
520 " rgb = mix(rgb, vec3(0.04, 0.01, 0.0), crustAmt);",
514 521 " rgb = mix(rgb, vec3(0.0), shoreMask);",
515 522 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
516 523 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
@@ -605,13 +612,16 @@ const LAVA_BLOOM_FRAG = [
605 612 " if (u_edgeSW > 0.5) {",
606 613 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
607 614 " }",
608 " float waveBody = wave * (1.0 - edgeProx * 0.55);",
615 " float waveBody = wave * (1.0 - edgeProx * 0.72);",
609 616 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
610 617 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
611 618 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
612 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
619 " float darkAmt = 1.0 - smoothstep(0.12, 0.48, waveBody);",
613 620 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
614 " float shoreMask = step(u_shoreClip, retreat);",
621 " float hasEdge = max(max(u_edgeN, u_edgeE), max(u_edgeS, u_edgeW));",
622 " hasEdge = max(hasEdge, max(max(u_edgeNE, u_edgeNW), max(u_edgeSE, u_edgeSW)));",
623 " float shoreW = step(0.5, hasEdge);",
624 " float shoreMask = step(u_shoreClip, retreat) * shoreW;",
615 625 " float yellowAmt = smoothstep(0.55, 0.98, heat) * (1.0 - edgeProx * 0.85) * (1.0 - shoreMask);",
616 626 " float bloom = yellowAmt * max(u_bloomStrength, 0.0);",
617 627 " vec3 glow = vec3(1.0, 0.82, 0.28) * bloom;",
@@ -493,7 +493,7 @@ const LAVA_GROUND_FRAG = [
493 " if (u_edgeSW > 0.5) {",
493 " if (u_edgeSW > 0.5) {",
494 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
494 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
495 " }",
495 " }",
496 " float waveBody = wave * (1.0 - edgeProx * 0.55);",
496 " float waveBody = wave * (1.0 - edgeProx * 0.72);",
497 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
497 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
498 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
498 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
499 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
499 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
@@ -508,9 +508,16 @@ const LAVA_GROUND_FRAG = [
508 " float shade = mix(u_shadeLo, u_shadeHi, ndotl);",
508 " float shade = mix(u_shadeLo, u_shadeHi, ndotl);",
509 " rgb *= shade;",
509 " rgb *= shade;",
510 " rgb = mix(rgb, darkRed, edgeProx * u_edgeDark);",
510 " rgb = mix(rgb, darkRed, edgeProx * u_edgeDark);",
511 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
511 " float darkAmt = 1.0 - smoothstep(0.12, 0.48, waveBody);",
512 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
512 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
513 " float shoreMask = step(u_shoreClip, retreat);",
513 " float hasEdge = max(max(u_edgeN, u_edgeE), max(u_edgeS, u_edgeW));",
514 " hasEdge = max(hasEdge, max(max(u_edgeNE, u_edgeNW), max(u_edgeSE, u_edgeSW)));",
515 " float shoreW = step(0.5, hasEdge);",
516 " float shoreClip = u_shoreClip;",
517 " float shoreMask = step(shoreClip, retreat) * shoreW;",
518 " float crustAmt = (1.0 - shoreMask) * smoothstep(shoreClip - 0.24, shoreClip - 0.08, retreat)",
519 " * (1.0 - smoothstep(shoreClip - 0.08, shoreClip, retreat));",
520 " rgb = mix(rgb, vec3(0.04, 0.01, 0.0), crustAmt);",
514 " rgb = mix(rgb, vec3(0.0), shoreMask);",
521 " rgb = mix(rgb, vec3(0.0), shoreMask);",
515 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
522 " float litTop = mix(u_litNW, u_litNE, v_texCoord.x);",
516 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
523 " float litBottom = mix(u_litSW, u_litSE, v_texCoord.x);",
@@ -605,13 +612,16 @@ const LAVA_BLOOM_FRAG = [
605 " if (u_edgeSW > 0.5) {",
612 " if (u_edgeSW > 0.5) {",
606 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
613 " edgeProx = max(edgeProx, 1.0 - smoothstep(0.0, 0.78, length(vec2(puv.x, 1.0 - puv.y))));",
607 " }",
614 " }",
608 " float waveBody = wave * (1.0 - edgeProx * 0.55);",
615 " float waveBody = wave * (1.0 - edgeProx * 0.72);",
609 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
616 " float heat = smoothstep(u_bodyLo, max(u_bodyHi, u_bodyLo + 0.01), waveBody);",
610 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
617 " heat = mix(heat, 1.0, smoothstep(u_litLo, max(u_litHi, u_litLo + 0.01), waveBody) * u_litMix * 0.35);",
611 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
618 " heat = clamp(heat + min(glitter, u_glitterCap) * u_glitterMix * 0.45, 0.0, 1.0);",
612 " float darkAmt = 1.0 - smoothstep(0.18, 0.52, waveBody);",
619 " float darkAmt = 1.0 - smoothstep(0.12, 0.48, waveBody);",
613 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
620 " float retreat = edgeProx * (0.35 + 0.65 * darkAmt);",
614 " float shoreMask = step(u_shoreClip, retreat);",
621 " float hasEdge = max(max(u_edgeN, u_edgeE), max(u_edgeS, u_edgeW));",
622 " hasEdge = max(hasEdge, max(max(u_edgeNE, u_edgeNW), max(u_edgeSE, u_edgeSW)));",
623 " float shoreW = step(0.5, hasEdge);",
624 " float shoreMask = step(u_shoreClip, retreat) * shoreW;",
615 " float yellowAmt = smoothstep(0.55, 0.98, heat) * (1.0 - edgeProx * 0.85) * (1.0 - shoreMask);",
625 " float yellowAmt = smoothstep(0.55, 0.98, heat) * (1.0 - edgeProx * 0.85) * (1.0 - shoreMask);",
616 " float bloom = yellowAmt * max(u_bloomStrength, 0.0);",
626 " float bloom = yellowAmt * max(u_bloomStrength, 0.0);",
617 " vec3 glow = vec3(1.0, 0.82, 0.28) * bloom;",
627 " vec3 glow = vec3(1.0, 0.82, 0.28) * bloom;",
server/src/assets/spriteCatalog.js +21 −3
@@ -24,6 +24,7 @@ import
24 24 equipImageName,
25 25 isCompanionSpriteStem,
26 26 parseSpriteStem,
27 palettePreviewImageName,
27 28 spriteImageName
28 29 } from "../../../shared/definitions/tileSprites.js";
29 30 import { preferredSeasonalDefaultState, typeHasSeasonalStates, isSeasonalOverlayVariant } from "../../../shared/world/season.js";
@@ -246,7 +247,7 @@ function scanLayer (layerDir, definitions, layer, urlFolder)
246 247 for (const def of Object.values(definitions))
247 248 {
248 249 const folder = join(layerDir, def.key);
249 const { states: fileStates, blooms: fileBlooms, equips, equipBlooms } = listVisualStates(folder);
250 const { states: fileStates, blooms: fileBlooms, equips, equipBlooms, previews } = listVisualStates(folder);
250 251 if (fileStates.length === 0)
251 252 { throw new Error(`No PNG states in ${folder}`); }
252 253
@@ -470,6 +471,18 @@ function scanLayer (layerDir, definitions, layer, urlFolder)
470 471 });
471 472 }
472 473 }
474 const previewStem = previews?.[def.key];
475 if (previewStem)
476 {
477 images.push({
478 name: palettePreviewImageName(layer, def.key),
479 url: `/assets/${urlFolder}/${def.key}/${previewStem}.png`,
480 subImgTotal: 1,
481 perRow: 1,
482 loop: false,
483 animationSpeed: 0
484 });
485 }
473 486 images.push(...imagesForType);
474 487 }
475 488 return { types, images };
@@ -481,6 +494,7 @@ function listVisualStates (folder)
481 494 const blooms = {};
482 495 const equips = {};
483 496 const equipBlooms = {};
497 const previews = {};
484 498 const states = [];
485 499 for (const stem of stems)
486 500 {
@@ -489,7 +503,9 @@ function listVisualStates (folder)
489 503 {
490 504 if (!parsed.base)
491 505 { continue; }
492 if (parsed.equip && parsed.bloom)
506 if (parsed.preview)
507 { previews[parsed.base] = stem; }
508 else if (parsed.equip && parsed.bloom)
493 509 { equipBlooms[parsed.base] = true; }
494 510 else if (parsed.equip)
495 511 { equips[parsed.base] = true; }
@@ -515,7 +531,9 @@ function listVisualStates (folder)
515 531 states,
516 532 blooms: filterMap(blooms),
517 533 equips: filterMap(equips),
518 equipBlooms: filterMap(equipBlooms)
534 equipBlooms: filterMap(equipBlooms),
535 /** Editor palette thumbs (`water-preview` → base `water`); not placeable states. */
536 previews
519 537 };
520 538 }
521 539
@@ -24,6 +24,7 @@ import
24 equipImageName,
24 equipImageName,
25 isCompanionSpriteStem,
25 isCompanionSpriteStem,
26 parseSpriteStem,
26 parseSpriteStem,
27 palettePreviewImageName,
27 spriteImageName
28 spriteImageName
28 } from "../../../shared/definitions/tileSprites.js";
29 } from "../../../shared/definitions/tileSprites.js";
29import { preferredSeasonalDefaultState, typeHasSeasonalStates, isSeasonalOverlayVariant } from "../../../shared/world/season.js";
30import { preferredSeasonalDefaultState, typeHasSeasonalStates, isSeasonalOverlayVariant } from "../../../shared/world/season.js";
@@ -246,7 +247,7 @@ function scanLayer (layerDir, definitions, layer, urlFolder)
246 for (const def of Object.values(definitions))
247 for (const def of Object.values(definitions))
247 {
248 {
248 const folder = join(layerDir, def.key);
249 const folder = join(layerDir, def.key);
249 const { states: fileStates, blooms: fileBlooms, equips, equipBlooms } = listVisualStates(folder);
250 const { states: fileStates, blooms: fileBlooms, equips, equipBlooms, previews } = listVisualStates(folder);
250 if (fileStates.length === 0)
251 if (fileStates.length === 0)
251 { throw new Error(`No PNG states in ${folder}`); }
252 { throw new Error(`No PNG states in ${folder}`); }
252
253
@@ -470,6 +471,18 @@ function scanLayer (layerDir, definitions, layer, urlFolder)
470 });
471 });
471 }
472 }
472 }
473 }
474 const previewStem = previews?.[def.key];
475 if (previewStem)
476 {
477 images.push({
478 name: palettePreviewImageName(layer, def.key),
479 url: `/assets/${urlFolder}/${def.key}/${previewStem}.png`,
480 subImgTotal: 1,
481 perRow: 1,
482 loop: false,
483 animationSpeed: 0
484 });
485 }
473 images.push(...imagesForType);
486 images.push(...imagesForType);
474 }
487 }
475 return { types, images };
488 return { types, images };
@@ -481,6 +494,7 @@ function listVisualStates (folder)
481 const blooms = {};
494 const blooms = {};
482 const equips = {};
495 const equips = {};
483 const equipBlooms = {};
496 const equipBlooms = {};
497 const previews = {};
484 const states = [];
498 const states = [];
485 for (const stem of stems)
499 for (const stem of stems)
486 {
500 {
@@ -489,7 +503,9 @@ function listVisualStates (folder)
489 {
503 {
490 if (!parsed.base)
504 if (!parsed.base)
491 { continue; }
505 { continue; }
492 if (parsed.equip && parsed.bloom)
506 if (parsed.preview)
507 { previews[parsed.base] = stem; }
508 else if (parsed.equip && parsed.bloom)
493 { equipBlooms[parsed.base] = true; }
509 { equipBlooms[parsed.base] = true; }
494 else if (parsed.equip)
510 else if (parsed.equip)
495 { equips[parsed.base] = true; }
511 { equips[parsed.base] = true; }
@@ -515,7 +531,9 @@ function listVisualStates (folder)
515 states,
531 states,
516 blooms: filterMap(blooms),
532 blooms: filterMap(blooms),
517 equips: filterMap(equips),
533 equips: filterMap(equips),
518 equipBlooms: filterMap(equipBlooms)
534 equipBlooms: filterMap(equipBlooms),
535 /** Editor palette thumbs (`water-preview` → base `water`); not placeable states. */
536 previews
519 };
537 };
520}
538}
521
539
server/tests/tile-states.test.js +5 −4
@@ -69,10 +69,11 @@ test("bloom companions are not visual states", () =>
69 69
70 70 test("sprite companion stems peel equip-bloom combinations", () =>
71 71 {
72 assert.deepEqual(parseSpriteStem("torch"), { base: "torch", companion: false, bloom: false, equip: false });
73 assert.deepEqual(parseSpriteStem("torch-bloom"), { base: "torch", companion: true, bloom: true, equip: false });
74 assert.deepEqual(parseSpriteStem("stick-equip"), { base: "stick", companion: true, bloom: false, equip: true });
75 assert.deepEqual(parseSpriteStem("stick-equip-bloom"), { base: "stick", companion: true, bloom: true, equip: true });
72 assert.deepEqual(parseSpriteStem("torch"), { base: "torch", companion: false, bloom: false, equip: false, preview: false });
73 assert.deepEqual(parseSpriteStem("torch-bloom"), { base: "torch", companion: true, bloom: true, equip: false, preview: false });
74 assert.deepEqual(parseSpriteStem("stick-equip"), { base: "stick", companion: true, bloom: false, equip: true, preview: false });
75 assert.deepEqual(parseSpriteStem("stick-equip-bloom"), { base: "stick", companion: true, bloom: true, equip: true, preview: false });
76 assert.deepEqual(parseSpriteStem("water-preview"), { base: "water", companion: true, bloom: false, equip: false, preview: true });
76 77 assert.equal(isCompanionSpriteStem("1-equip-bloom"), true);
77 78 assert.equal(isCompanionSpriteStem("1"), false);
78 79 assert.equal(resolveState(["1", "2"], "1-bloom"), "1");
@@ -69,10 +69,11 @@ test("bloom companions are not visual states", () =>
69
69
70test("sprite companion stems peel equip-bloom combinations", () =>
70test("sprite companion stems peel equip-bloom combinations", () =>
71{
71{
72 assert.deepEqual(parseSpriteStem("torch"), { base: "torch", companion: false, bloom: false, equip: false });
72 assert.deepEqual(parseSpriteStem("torch"), { base: "torch", companion: false, bloom: false, equip: false, preview: false });
73 assert.deepEqual(parseSpriteStem("torch-bloom"), { base: "torch", companion: true, bloom: true, equip: false });
73 assert.deepEqual(parseSpriteStem("torch-bloom"), { base: "torch", companion: true, bloom: true, equip: false, preview: false });
74 assert.deepEqual(parseSpriteStem("stick-equip"), { base: "stick", companion: true, bloom: false, equip: true });
74 assert.deepEqual(parseSpriteStem("stick-equip"), { base: "stick", companion: true, bloom: false, equip: true, preview: false });
75 assert.deepEqual(parseSpriteStem("stick-equip-bloom"), { base: "stick", companion: true, bloom: true, equip: true });
75 assert.deepEqual(parseSpriteStem("stick-equip-bloom"), { base: "stick", companion: true, bloom: true, equip: true, preview: false });
76 assert.deepEqual(parseSpriteStem("water-preview"), { base: "water", companion: true, bloom: false, equip: false, preview: true });
76 assert.equal(isCompanionSpriteStem("1-equip-bloom"), true);
77 assert.equal(isCompanionSpriteStem("1-equip-bloom"), true);
77 assert.equal(isCompanionSpriteStem("1"), false);
78 assert.equal(isCompanionSpriteStem("1"), false);
78 assert.equal(resolveState(["1", "2"], "1-bloom"), "1");
79 assert.equal(resolveState(["1", "2"], "1-bloom"), "1");
shared/definitions/tileSprites.js +11 −4
@@ -19,9 +19,9 @@ export function equipBloomImageName (layer, key, state)
19 19 }
20 20
21 21 /** Bloom companion for any registered image name (`item:stick:stick:equip` → `…:equip:bloom`). */
22 export function bloomCompanionName (imageName)
22 export function palettePreviewImageName (layer, key)
23 23 {
24 return `${imageName}:bloom`;
24 return spriteImageName(layer, key, `${key}-preview`);
25 25 }
26 26
27 27 /**
@@ -35,6 +35,12 @@ export function parseSpriteStem (stem)
35 35 let rest = String(stem ?? "");
36 36 let bloom = false;
37 37 let equip = false;
38 let preview = false;
39 if (rest.endsWith("-preview") && rest.length > "-preview".length)
40 {
41 preview = true;
42 rest = rest.slice(0, -"-preview".length);
43 }
38 44 if (rest.endsWith("-bloom") && rest.length > "-bloom".length)
39 45 {
40 46 bloom = true;
@@ -45,12 +51,13 @@ export function parseSpriteStem (stem)
45 51 equip = true;
46 52 rest = rest.slice(0, -"-equip".length);
47 53 }
48 const companion = bloom || equip;
54 const companion = bloom || equip || preview;
49 55 return {
50 56 base: companion ? rest : String(stem ?? ""),
51 57 companion,
52 58 bloom,
53 equip
59 equip,
60 preview
54 61 };
55 62 }
56 63
@@ -19,9 +19,9 @@ export function equipBloomImageName (layer, key, state)
19}
19}
20
20
21/** Bloom companion for any registered image name (`item:stick:stick:equip` → `…:equip:bloom`). */
21/** Bloom companion for any registered image name (`item:stick:stick:equip` → `…:equip:bloom`). */
22export function bloomCompanionName (imageName)
22export function palettePreviewImageName (layer, key)
23{
23{
24 return `${imageName}:bloom`;
24 return spriteImageName(layer, key, `${key}-preview`);
25}
25}
26
26
27/**
27/**
@@ -35,6 +35,12 @@ export function parseSpriteStem (stem)
35 let rest = String(stem ?? "");
35 let rest = String(stem ?? "");
36 let bloom = false;
36 let bloom = false;
37 let equip = false;
37 let equip = false;
38 let preview = false;
39 if (rest.endsWith("-preview") && rest.length > "-preview".length)
40 {
41 preview = true;
42 rest = rest.slice(0, -"-preview".length);
43 }
38 if (rest.endsWith("-bloom") && rest.length > "-bloom".length)
44 if (rest.endsWith("-bloom") && rest.length > "-bloom".length)
39 {
45 {
40 bloom = true;
46 bloom = true;
@@ -45,12 +51,13 @@ export function parseSpriteStem (stem)
45 equip = true;
51 equip = true;
46 rest = rest.slice(0, -"-equip".length);
52 rest = rest.slice(0, -"-equip".length);
47 }
53 }
48 const companion = bloom || equip;
54 const companion = bloom || equip || preview;
49 return {
55 return {
50 base: companion ? rest : String(stem ?? ""),
56 base: companion ? rest : String(stem ?? ""),
51 companion,
57 companion,
52 bloom,
58 bloom,
53 equip
59 equip,
60 preview
54 };
61 };
55}
62}
56
63