@holtjs/craft 0.0.0-stage → 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.
- package/CHANGELOG.md +24 -0
- package/LICENSE +201 -0
- package/NOTICE +10 -0
- package/README.md +91 -2
- package/dist/atlas-Pc12eQsg.js +112 -0
- package/dist/atlas.d.ts +75 -0
- package/dist/atlas.js +1 -0
- package/dist/hd3d-BozZnINB.js +1871 -0
- package/dist/hd3d.d.ts +112 -0
- package/dist/hd3d.js +1 -0
- package/dist/index.d.ts +187 -0
- package/dist/index.js +17 -0
- package/dist/inspect-NzY8Ac1j.js +466 -0
- package/dist/inspect.d.ts +36 -0
- package/dist/inspect.js +1 -0
- package/dist/pixel-D3jgByB5.js +728 -0
- package/dist/pixel.d.ts +79 -0
- package/dist/pixel.js +1 -0
- package/dist/rig-render-DZBV9u2H.js +6163 -0
- package/dist/rig-render-DoPVKQAF.d.ts +537 -0
- package/dist/rig3d-CPw8F6V2.js +1096 -0
- package/dist/rig3d-DeeG_PJj.d.ts +70 -0
- package/dist/rig3d.d.ts +3 -0
- package/dist/rig3d.js +3 -0
- package/dist/tilemap-BFH4_JLe.js +266 -0
- package/dist/tilemap.d.ts +61 -0
- package/dist/tilemap.js +1 -0
- package/llms.txt +18 -0
- package/package.json +77 -4
- package/skills/craft/SKILL.md +98 -0
- package/skills/craft/references/subpaths.md +39 -0
|
@@ -0,0 +1,1871 @@
|
|
|
1
|
+
import { u as __exportAll } from "./pixel-D3jgByB5.js";
|
|
2
|
+
import { D as rigClipFrameCount, E as evaluateRigClip, G as createRigState, S as compileCustomBodySpec, Y as mat4Mul, _ as parseHexRgb, d as buildBodyPrimitives, f as GRP, g as mixRgb, h as intersectPrimLocal, m as evalSurfaceMark, nt as quatFromEuler, q as mat4Compose, t as DEFAULT_RIG_COLORS, u as addDeclarativePrimitives, v as BUILTIN_ANIM_FRAMES, y as evaluateBuiltinPose } from "./rig-render-DZBV9u2H.js";
|
|
3
|
+
import { n as bakeNormalMapRgba } from "./tilemap-BFH4_JLe.js";
|
|
4
|
+
// src/hd3d.ts
|
|
5
|
+
var hd3d_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
KRAFTEERS_PRESETS: () => KRAFTEERS_PRESETS,
|
|
7
|
+
bakeHdCharacterSheet: () => bakeHdCharacterSheet,
|
|
8
|
+
bakeHdDualGridSheet: () => bakeHdDualGridSheet,
|
|
9
|
+
renderHdCharacterCell: () => renderHdCharacterCell,
|
|
10
|
+
renderHdPropSheet: () => renderHdPropSheet,
|
|
11
|
+
renderHdPropSprite: () => renderHdPropSprite
|
|
12
|
+
});
|
|
13
|
+
function evalPrimLocalGradient(pr, lx, ly, lz, out) {
|
|
14
|
+
switch (pr.shape) {
|
|
15
|
+
case "ellipsoid":
|
|
16
|
+
out[0] = lx;
|
|
17
|
+
out[1] = ly;
|
|
18
|
+
out[2] = lz;
|
|
19
|
+
return;
|
|
20
|
+
case "super": {
|
|
21
|
+
const p = Math.max(2, pr.sq ?? 2.6) - 1;
|
|
22
|
+
out[0] = Math.sign(lx) * Math.abs(lx) ** p;
|
|
23
|
+
out[1] = Math.sign(ly) * Math.abs(ly) ** p;
|
|
24
|
+
out[2] = Math.sign(lz) * Math.abs(lz) ** p;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
case "box":
|
|
28
|
+
out[0] = Math.sign(lx) * Math.abs(lx) ** 7;
|
|
29
|
+
out[1] = Math.sign(ly) * Math.abs(ly) ** 7;
|
|
30
|
+
out[2] = Math.sign(lz) * Math.abs(lz) ** 7;
|
|
31
|
+
return;
|
|
32
|
+
case "capsule": {
|
|
33
|
+
const L = (pr.capLen ?? 1) * 2;
|
|
34
|
+
const cy = Math.max(-L, Math.min(0, ly));
|
|
35
|
+
out[0] = lx;
|
|
36
|
+
out[1] = ly - cy;
|
|
37
|
+
out[2] = lz;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
case "cylinder":
|
|
41
|
+
if (Math.abs(ly) > .96) {
|
|
42
|
+
out[0] = lx * .18;
|
|
43
|
+
out[1] = Math.sign(ly);
|
|
44
|
+
out[2] = lz * .18;
|
|
45
|
+
} else {
|
|
46
|
+
const rim = Math.max(0, (Math.abs(ly) - .84) / .12);
|
|
47
|
+
out[0] = lx;
|
|
48
|
+
out[1] = Math.sign(ly) * rim * .65;
|
|
49
|
+
out[2] = lz;
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
case "cone":
|
|
53
|
+
if (ly < -.97) {
|
|
54
|
+
out[0] = 0;
|
|
55
|
+
out[1] = -1;
|
|
56
|
+
out[2] = 0;
|
|
57
|
+
} else {
|
|
58
|
+
out[0] = lx;
|
|
59
|
+
out[1] = .25 * Math.max(.05, 1 - ly);
|
|
60
|
+
out[2] = lz;
|
|
61
|
+
}
|
|
62
|
+
return;
|
|
63
|
+
case "torus": {
|
|
64
|
+
const f = 1 - (pr.torusR ?? 2.5) / (Math.hypot(lx, lz) || 1e-6);
|
|
65
|
+
out[0] = lx * f;
|
|
66
|
+
out[1] = ly;
|
|
67
|
+
out[2] = lz * f;
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function buildHdBaseColorTable(colors) {
|
|
73
|
+
const t = new Array(256);
|
|
74
|
+
t[1] = { rgb: colors.fur.fur };
|
|
75
|
+
t[2] = { rgb: colors.belly };
|
|
76
|
+
t[3] = { rgb: colors.scarf ?? [
|
|
77
|
+
214,
|
|
78
|
+
69,
|
|
79
|
+
53
|
|
80
|
+
] };
|
|
81
|
+
t[4] = { rgb: [
|
|
82
|
+
34,
|
|
83
|
+
26,
|
|
84
|
+
44
|
|
85
|
+
] };
|
|
86
|
+
t[5] = {
|
|
87
|
+
rgb: [
|
|
88
|
+
255,
|
|
89
|
+
255,
|
|
90
|
+
255
|
|
91
|
+
],
|
|
92
|
+
emissive: true
|
|
93
|
+
};
|
|
94
|
+
t[6] = { rgb: [
|
|
95
|
+
148,
|
|
96
|
+
130,
|
|
97
|
+
190
|
|
98
|
+
] };
|
|
99
|
+
t[7] = { rgb: [
|
|
100
|
+
247,
|
|
101
|
+
138,
|
|
102
|
+
152
|
|
103
|
+
] };
|
|
104
|
+
t[8] = { rgb: mixRgb(colors.fur.shade, [
|
|
105
|
+
28,
|
|
106
|
+
18,
|
|
107
|
+
28
|
|
108
|
+
], .5) };
|
|
109
|
+
t[9] = { rgb: mixRgb(colors.fur.fur, [
|
|
110
|
+
235,
|
|
111
|
+
145,
|
|
112
|
+
155
|
|
113
|
+
], .4) };
|
|
114
|
+
t[11] = { rgb: colors.fur.shade };
|
|
115
|
+
t[12] = { rgb: colors.belly };
|
|
116
|
+
t[13] = { rgb: [
|
|
117
|
+
52,
|
|
118
|
+
28,
|
|
119
|
+
36
|
|
120
|
+
] };
|
|
121
|
+
t[14] = { rgb: [
|
|
122
|
+
252,
|
|
123
|
+
205,
|
|
124
|
+
84
|
|
125
|
+
] };
|
|
126
|
+
t[15] = { rgb: [
|
|
127
|
+
240,
|
|
128
|
+
128,
|
|
129
|
+
150
|
|
130
|
+
] };
|
|
131
|
+
t[16] = { rgb: [
|
|
132
|
+
247,
|
|
133
|
+
172,
|
|
134
|
+
182
|
|
135
|
+
] };
|
|
136
|
+
t[17] = {
|
|
137
|
+
rgb: [
|
|
138
|
+
56,
|
|
139
|
+
189,
|
|
140
|
+
248
|
|
141
|
+
],
|
|
142
|
+
emissive: true
|
|
143
|
+
};
|
|
144
|
+
t[18] = { rgb: colors.belly };
|
|
145
|
+
t[19] = { rgb: colors.fur.fur };
|
|
146
|
+
t[41] = {
|
|
147
|
+
rgb: [
|
|
148
|
+
224,
|
|
149
|
+
247,
|
|
150
|
+
255
|
|
151
|
+
],
|
|
152
|
+
emissive: true
|
|
153
|
+
};
|
|
154
|
+
return t;
|
|
155
|
+
}
|
|
156
|
+
function resolveMaterialRgb(matId, palette, baseTable) {
|
|
157
|
+
const entry = baseTable[matId];
|
|
158
|
+
if (entry) return {
|
|
159
|
+
rgb: entry.rgb,
|
|
160
|
+
emissive: Boolean(entry.emissive)
|
|
161
|
+
};
|
|
162
|
+
const p = palette[matId];
|
|
163
|
+
if (!p) return {
|
|
164
|
+
rgb: [
|
|
165
|
+
148,
|
|
166
|
+
163,
|
|
167
|
+
184
|
|
168
|
+
],
|
|
169
|
+
emissive: false
|
|
170
|
+
};
|
|
171
|
+
if (p.fixed) return {
|
|
172
|
+
rgb: p.fixed,
|
|
173
|
+
emissive: !p.ol
|
|
174
|
+
};
|
|
175
|
+
if (p.ramp) return {
|
|
176
|
+
rgb: p.ramp[1],
|
|
177
|
+
emissive: false
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
rgb: [
|
|
181
|
+
148,
|
|
182
|
+
163,
|
|
183
|
+
184
|
|
184
|
+
],
|
|
185
|
+
emissive: false
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const SUN_DIR = (() => {
|
|
189
|
+
const x = -.46, y = .75, z = .48;
|
|
190
|
+
const l = Math.hypot(x, y, z);
|
|
191
|
+
return [
|
|
192
|
+
x / l,
|
|
193
|
+
y / l,
|
|
194
|
+
z / l
|
|
195
|
+
];
|
|
196
|
+
})();
|
|
197
|
+
function rasterizeSmoothHd(prims, palette, baseTable, opts) {
|
|
198
|
+
const nw = opts.width;
|
|
199
|
+
const nh = opts.height;
|
|
200
|
+
const ss = Math.max(1, Math.min(4, Math.floor(opts.ss)));
|
|
201
|
+
const W = nw * ss;
|
|
202
|
+
const totalSS = W * (nh * ss);
|
|
203
|
+
const scalePx = opts.worldScalePx;
|
|
204
|
+
const cosE = opts.cosE;
|
|
205
|
+
const sinE = opts.sinE;
|
|
206
|
+
const ssR = new Float32Array(totalSS);
|
|
207
|
+
const ssG = new Float32Array(totalSS);
|
|
208
|
+
const ssB = new Float32Array(totalSS);
|
|
209
|
+
const ssA = new Float32Array(totalSS);
|
|
210
|
+
const ssNx = new Float32Array(totalSS);
|
|
211
|
+
const ssNy = new Float32Array(totalSS);
|
|
212
|
+
const ssNz = new Float32Array(totalSS);
|
|
213
|
+
const ssGrp = new Uint8Array(totalSS);
|
|
214
|
+
const ssTau = new Float32Array(totalSS).fill(-1e9);
|
|
215
|
+
const vx = 0, vy = sinE, vz = cosE;
|
|
216
|
+
const hx0 = SUN_DIR[0] + vx, hy0 = SUN_DIR[1] + vy, hz0 = SUN_DIR[2] + vz;
|
|
217
|
+
const hLen = Math.hypot(hx0, hy0, hz0) || 1;
|
|
218
|
+
const hx = hx0 / hLen, hy = hy0 / hLen, hz = hz0 / hLen;
|
|
219
|
+
const gradLocal = [
|
|
220
|
+
0,
|
|
221
|
+
1,
|
|
222
|
+
0
|
|
223
|
+
];
|
|
224
|
+
for (let pi = 0; pi < prims.length; pi++) {
|
|
225
|
+
const pr = prims[pi];
|
|
226
|
+
const m = pr.invWorld;
|
|
227
|
+
const ldx = m[4] * vy + m[8] * vz;
|
|
228
|
+
const ldy = m[5] * vy + m[9] * vz;
|
|
229
|
+
const ldz = m[6] * vy + m[10] * vz;
|
|
230
|
+
for (let py = pr.minY; py <= pr.maxY; py++) {
|
|
231
|
+
const sy = (opts.groundY - (py + .5) / ss) / scalePx;
|
|
232
|
+
const woy = sy * cosE;
|
|
233
|
+
const woz = -sy * sinE;
|
|
234
|
+
const baseRow = py * W;
|
|
235
|
+
const loyBase = m[4] * woy + m[8] * woz + m[12];
|
|
236
|
+
const lmyBase = m[5] * woy + m[9] * woz + m[13];
|
|
237
|
+
const lnzBase = m[6] * woy + m[10] * woz + m[14];
|
|
238
|
+
for (let px = pr.minX; px <= pr.maxX; px++) {
|
|
239
|
+
const wox = ((px + .5) / ss - nw * .5) / scalePx;
|
|
240
|
+
const lox = m[0] * wox + loyBase;
|
|
241
|
+
const loy = m[1] * wox + lmyBase;
|
|
242
|
+
const loz = m[2] * wox + lnzBase;
|
|
243
|
+
const tau = intersectPrimLocal(pr, lox, loy, loz, ldx, ldy, ldz);
|
|
244
|
+
if (tau <= -1e8) continue;
|
|
245
|
+
const idx = baseRow + px;
|
|
246
|
+
if (tau <= ssTau[idx]) continue;
|
|
247
|
+
const hitLx = lox + tau * ldx;
|
|
248
|
+
const hitLy = loy + tau * ldy;
|
|
249
|
+
const hitLz = loz + tau * ldz;
|
|
250
|
+
const { rgb: albedo, emissive } = resolveMaterialRgb(pr.headMark || pr.torsoMark ? evalSurfaceMark(pr, hitLx, hitLy, hitLz) : pr.mat, palette, baseTable);
|
|
251
|
+
ssTau[idx] = tau;
|
|
252
|
+
ssGrp[idx] = pr.grp;
|
|
253
|
+
ssA[idx] = 1;
|
|
254
|
+
evalPrimLocalGradient(pr, hitLx, hitLy, hitLz, gradLocal);
|
|
255
|
+
let nx = m[0] * gradLocal[0] + m[1] * gradLocal[1] + m[2] * gradLocal[2];
|
|
256
|
+
let ny = m[4] * gradLocal[0] + m[5] * gradLocal[1] + m[6] * gradLocal[2];
|
|
257
|
+
let nz = m[8] * gradLocal[0] + m[9] * gradLocal[1] + m[10] * gradLocal[2];
|
|
258
|
+
const nLen = Math.hypot(nx, ny, nz) || 1;
|
|
259
|
+
nx /= nLen;
|
|
260
|
+
ny /= nLen;
|
|
261
|
+
nz /= nLen;
|
|
262
|
+
const cnx = nx;
|
|
263
|
+
const cny = ny * cosE - nz * sinE;
|
|
264
|
+
const cnz = Math.max(.08, ny * sinE + nz * cosE);
|
|
265
|
+
const cnLen = Math.hypot(cnx, cny, cnz) || 1;
|
|
266
|
+
ssNx[idx] = cnx / cnLen;
|
|
267
|
+
ssNy[idx] = cny / cnLen;
|
|
268
|
+
ssNz[idx] = cnz / cnLen;
|
|
269
|
+
if (emissive || pr.flat) {
|
|
270
|
+
ssR[idx] = Math.min(255, albedo[0] * 1.06);
|
|
271
|
+
ssG[idx] = Math.min(255, albedo[1] * 1.06);
|
|
272
|
+
ssB[idx] = Math.min(255, albedo[2] * 1.06);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const ndotl = nx * SUN_DIR[0] + ny * SUN_DIR[1] + nz * SUN_DIR[2];
|
|
276
|
+
const wrap = Math.max(0, Math.min(1, (ndotl + .38) / 1.38));
|
|
277
|
+
const smoothDiff = wrap * wrap * (3 - 2 * wrap);
|
|
278
|
+
const hemi = .5 + .5 * ny;
|
|
279
|
+
const spec = Math.max(0, nx * hx + ny * hy + nz * hz) ** 20 * .24;
|
|
280
|
+
const rim = (1 - Math.max(0, nx * vx + ny * vy + nz * vz)) ** 3 * .14 * Math.max(0, ny + .3);
|
|
281
|
+
const shadowR = albedo[0] * .46 + 10;
|
|
282
|
+
const shadowG = albedo[1] * .44 + 8;
|
|
283
|
+
const shadowB = Math.min(255, albedo[2] * .54 + 22);
|
|
284
|
+
const litR = Math.min(255, albedo[0] * 1.14 + 14 * hemi);
|
|
285
|
+
const litG = Math.min(255, albedo[1] * 1.11 + 10 * hemi);
|
|
286
|
+
const litB = Math.min(255, albedo[2] * 1.05 + 6 * hemi);
|
|
287
|
+
const r = shadowR + (litR - shadowR) * smoothDiff + (spec + rim) * 255;
|
|
288
|
+
const g = shadowG + (litG - shadowG) * smoothDiff + (spec * .96 + rim * .9) * 255;
|
|
289
|
+
const b = shadowB + (litB - shadowB) * smoothDiff + (spec * .88 + rim * 1.05) * 255;
|
|
290
|
+
ssR[idx] = Math.max(0, Math.min(255, r));
|
|
291
|
+
ssG[idx] = Math.max(0, Math.min(255, g));
|
|
292
|
+
ssB[idx] = Math.max(0, Math.min(255, b));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const pxCount = nw * nh;
|
|
297
|
+
const baseR = new Float32Array(pxCount);
|
|
298
|
+
const baseG = new Float32Array(pxCount);
|
|
299
|
+
const baseB = new Float32Array(pxCount);
|
|
300
|
+
const baseA = new Float32Array(pxCount);
|
|
301
|
+
const baseNx = new Float32Array(pxCount);
|
|
302
|
+
const baseNy = new Float32Array(pxCount);
|
|
303
|
+
const baseNz = new Float32Array(pxCount).fill(1);
|
|
304
|
+
const topTau = new Float32Array(pxCount).fill(-1e9);
|
|
305
|
+
const topGrp = new Uint8Array(pxCount);
|
|
306
|
+
const invSamples = 1 / (ss * ss);
|
|
307
|
+
for (let y = 0; y < nh; y++) for (let x = 0; x < nw; x++) {
|
|
308
|
+
let sr = 0, sg = 0, sb = 0, sa = 0;
|
|
309
|
+
let snx = 0, sny = 0, snz = 0;
|
|
310
|
+
let maxTau = -1e9, grp = 0;
|
|
311
|
+
const y0 = y * ss, x0 = x * ss;
|
|
312
|
+
for (let sy = 0; sy < ss; sy++) {
|
|
313
|
+
const row = (y0 + sy) * W + x0;
|
|
314
|
+
for (let sx = 0; sx < ss; sx++) {
|
|
315
|
+
const i = row + sx;
|
|
316
|
+
if (ssA[i] > 0) {
|
|
317
|
+
sr += ssR[i];
|
|
318
|
+
sg += ssG[i];
|
|
319
|
+
sb += ssB[i];
|
|
320
|
+
sa += ssA[i];
|
|
321
|
+
snx += ssNx[i];
|
|
322
|
+
sny += ssNy[i];
|
|
323
|
+
snz += ssNz[i];
|
|
324
|
+
if (ssTau[i] > maxTau) {
|
|
325
|
+
maxTau = ssTau[i];
|
|
326
|
+
grp = ssGrp[i];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const k = y * nw + x;
|
|
332
|
+
if (sa > 0) {
|
|
333
|
+
baseR[k] = sr / sa;
|
|
334
|
+
baseG[k] = sg / sa;
|
|
335
|
+
baseB[k] = sb / sa;
|
|
336
|
+
baseA[k] = sa * invSamples;
|
|
337
|
+
const nl = Math.hypot(snx, sny, snz) || 1;
|
|
338
|
+
baseNx[k] = snx / nl;
|
|
339
|
+
baseNy[k] = sny / nl;
|
|
340
|
+
baseNz[k] = snz / nl;
|
|
341
|
+
topTau[k] = maxTau;
|
|
342
|
+
topGrp[k] = grp;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const out = new Uint8ClampedArray(pxCount * 4);
|
|
346
|
+
const normOut = new Uint8ClampedArray(pxCount * 4);
|
|
347
|
+
const ow = Math.max(0, opts.outlineWidthPx);
|
|
348
|
+
const searchR = Math.ceil(ow + 1);
|
|
349
|
+
const olR = opts.outlineRgb[0], olG = opts.outlineRgb[1], olB = opts.outlineRgb[2];
|
|
350
|
+
const shadowRx = opts.shadowRadiusWorld * scalePx;
|
|
351
|
+
const shadowRy = shadowRx * sinE;
|
|
352
|
+
for (let y = 0; y < nh; y++) for (let x = 0; x < nw; x++) {
|
|
353
|
+
const k = y * nw + x;
|
|
354
|
+
let cov = baseA[k];
|
|
355
|
+
let r = baseR[k];
|
|
356
|
+
let g = baseG[k];
|
|
357
|
+
let b = baseB[k];
|
|
358
|
+
if (cov > .6 && ow > 0) {
|
|
359
|
+
let crease = 0;
|
|
360
|
+
const myTau = topTau[k];
|
|
361
|
+
const myGrp = topGrp[k];
|
|
362
|
+
for (const [dx, dy] of [
|
|
363
|
+
[1, 0],
|
|
364
|
+
[-1, 0],
|
|
365
|
+
[0, 1],
|
|
366
|
+
[0, -1]
|
|
367
|
+
]) {
|
|
368
|
+
const nx = x + dx, ny = y + dy;
|
|
369
|
+
if (nx < 0 || ny < 0 || nx >= nw || ny >= nh) continue;
|
|
370
|
+
const nk = ny * nw + nx;
|
|
371
|
+
if (baseA[nk] > .5 && topGrp[nk] !== myGrp && topTau[nk] > myTau + 2.2) crease = Math.max(crease, .52);
|
|
372
|
+
}
|
|
373
|
+
if (crease > 0) {
|
|
374
|
+
r = r * (1 - crease) + olR * crease;
|
|
375
|
+
g = g * (1 - crease) + olG * crease;
|
|
376
|
+
b = b * (1 - crease) + olB * crease;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
let strokeAlpha = 0;
|
|
380
|
+
if (ow > 0 && cov < .999) {
|
|
381
|
+
let minDist = 1e9;
|
|
382
|
+
for (let dy = -searchR; dy <= searchR; dy++) {
|
|
383
|
+
const ny = y + dy;
|
|
384
|
+
if (ny < 0 || ny >= nh) continue;
|
|
385
|
+
for (let dx = -searchR; dx <= searchR; dx++) {
|
|
386
|
+
const nx = x + dx;
|
|
387
|
+
if (nx < 0 || nx >= nw) continue;
|
|
388
|
+
const na = baseA[ny * nw + nx];
|
|
389
|
+
if (na <= .15) continue;
|
|
390
|
+
const d = Math.hypot(dx, dy) - (na - .5) * .85;
|
|
391
|
+
if (d < minDist) minDist = d;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (minDist < ow + .65) strokeAlpha = Math.max(0, Math.min(1, ow + .5 - minDist));
|
|
395
|
+
}
|
|
396
|
+
let shadowAlpha = 0;
|
|
397
|
+
if (opts.groundShadow && shadowRx > 1 && shadowRy > 1) {
|
|
398
|
+
const sx = (x + .5 - nw * .5) / shadowRx;
|
|
399
|
+
const sy = (y + .5 - opts.groundY) / shadowRy;
|
|
400
|
+
const d2 = sx * sx + sy * sy;
|
|
401
|
+
if (d2 < 1) shadowAlpha = (1 - d2) ** 1.8 * .42;
|
|
402
|
+
}
|
|
403
|
+
let pr = r * cov;
|
|
404
|
+
let pg = g * cov;
|
|
405
|
+
let pb = b * cov;
|
|
406
|
+
let pa = cov;
|
|
407
|
+
if (strokeAlpha > 0) {
|
|
408
|
+
const rem = 1 - pa;
|
|
409
|
+
pr += olR * strokeAlpha * rem;
|
|
410
|
+
pg += olG * strokeAlpha * rem;
|
|
411
|
+
pb += olB * strokeAlpha * rem;
|
|
412
|
+
pa += strokeAlpha * rem;
|
|
413
|
+
}
|
|
414
|
+
if (shadowAlpha > 0) {
|
|
415
|
+
const rem = 1 - pa;
|
|
416
|
+
pr += 12 * shadowAlpha * rem;
|
|
417
|
+
pg += 15 * shadowAlpha * rem;
|
|
418
|
+
pb += 24 * shadowAlpha * rem;
|
|
419
|
+
pa += shadowAlpha * rem;
|
|
420
|
+
}
|
|
421
|
+
const o = k * 4;
|
|
422
|
+
if (pa > 1e-4) {
|
|
423
|
+
out[o] = Math.round(Math.min(255, pr / pa));
|
|
424
|
+
out[o + 1] = Math.round(Math.min(255, pg / pa));
|
|
425
|
+
out[o + 2] = Math.round(Math.min(255, pb / pa));
|
|
426
|
+
out[o + 3] = Math.round(Math.min(255, pa * 255));
|
|
427
|
+
}
|
|
428
|
+
if (cov > .001) {
|
|
429
|
+
normOut[o] = Math.round((baseNx[k] * .5 + .5) * 255);
|
|
430
|
+
normOut[o + 1] = Math.round((baseNy[k] * .5 + .5) * 255);
|
|
431
|
+
normOut[o + 2] = Math.round((baseNz[k] * .5 + .5) * 255);
|
|
432
|
+
normOut[o + 3] = Math.round(Math.min(255, Math.max(cov, strokeAlpha) * 255));
|
|
433
|
+
} else {
|
|
434
|
+
normOut[o] = 128;
|
|
435
|
+
normOut[o + 1] = 128;
|
|
436
|
+
normOut[o + 2] = 255;
|
|
437
|
+
normOut[o + 3] = 0;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
width: nw,
|
|
442
|
+
height: nh,
|
|
443
|
+
rgba: out,
|
|
444
|
+
normalRgba: normOut
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
function reprojectPrimsForHd(prims, width, height, groundY, scalePx, cosE, sinE, ss) {
|
|
448
|
+
const W = width * ss;
|
|
449
|
+
const H = height * ss;
|
|
450
|
+
const out = [];
|
|
451
|
+
for (const p of prims) {
|
|
452
|
+
const world = invert4x4(p.invWorld);
|
|
453
|
+
if (!world) continue;
|
|
454
|
+
const bx = p.shape === "torus" ? (p.torusR ?? 2) + 1.2 : 1.1;
|
|
455
|
+
const by = p.shape === "capsule" ? (p.capLen ?? 1) + 1.15 : p.shape === "torus" ? 1.2 : 1.1;
|
|
456
|
+
const bz = p.shape === "torus" ? (p.torusR ?? 2) + 1.2 : 1.1;
|
|
457
|
+
const yMinL = p.shape === "capsule" ? -((p.capLen ?? 1) * 2 + 1.15) : -by;
|
|
458
|
+
const yMaxL = p.shape === "capsule" ? 1.15 : by;
|
|
459
|
+
let minX = 1e9, maxX = -1e9, minY = 1e9, maxY = -1e9;
|
|
460
|
+
for (let ix = 0; ix < 2; ix++) {
|
|
461
|
+
const lx = ix ? bx : -bx;
|
|
462
|
+
for (let iy = 0; iy < 2; iy++) {
|
|
463
|
+
const ly = iy ? yMaxL : yMinL;
|
|
464
|
+
for (let iz = 0; iz < 2; iz++) {
|
|
465
|
+
const lz = iz ? bz : -bz;
|
|
466
|
+
const wx = world[0] * lx + world[4] * ly + world[8] * lz + world[12];
|
|
467
|
+
const wy = world[1] * lx + world[5] * ly + world[9] * lz + world[13];
|
|
468
|
+
const wz = world[2] * lx + world[6] * ly + world[10] * lz + world[14];
|
|
469
|
+
const sx = (width * .5 + wx * scalePx) * ss;
|
|
470
|
+
const sy = (groundY - (wy * cosE - wz * sinE) * scalePx) * ss;
|
|
471
|
+
if (sx < minX) minX = sx;
|
|
472
|
+
if (sx > maxX) maxX = sx;
|
|
473
|
+
if (sy < minY) minY = sy;
|
|
474
|
+
if (sy > maxY) maxY = sy;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
const x0 = Math.max(0, Math.floor(minX) - 2);
|
|
479
|
+
const x1 = Math.min(W - 1, Math.ceil(maxX) + 2);
|
|
480
|
+
const y0 = Math.max(0, Math.floor(minY) - 2);
|
|
481
|
+
const y1 = Math.min(H - 1, Math.ceil(maxY) + 2);
|
|
482
|
+
if (x0 <= x1 && y0 <= y1) out.push({
|
|
483
|
+
...p,
|
|
484
|
+
minX: x0,
|
|
485
|
+
maxX: x1,
|
|
486
|
+
minY: y0,
|
|
487
|
+
maxY: y1
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
return out;
|
|
491
|
+
}
|
|
492
|
+
function invert4x4(m) {
|
|
493
|
+
const inv = /* @__PURE__ */ new Float64Array(16);
|
|
494
|
+
const a00 = m[0], a01 = m[1], a02 = m[2], a03 = m[3];
|
|
495
|
+
const a10 = m[4], a11 = m[5], a12 = m[6], a13 = m[7];
|
|
496
|
+
const a20 = m[8], a21 = m[9], a22 = m[10], a23 = m[11];
|
|
497
|
+
const a30 = m[12], a31 = m[13], a32 = m[14], a33 = m[15];
|
|
498
|
+
const b00 = a00 * a11 - a01 * a10, b01 = a00 * a12 - a02 * a10, b02 = a00 * a13 - a03 * a10;
|
|
499
|
+
const b03 = a01 * a12 - a02 * a11, b04 = a01 * a13 - a03 * a11, b05 = a02 * a13 - a03 * a12;
|
|
500
|
+
const b06 = a20 * a31 - a21 * a30, b07 = a20 * a32 - a22 * a30, b08 = a20 * a33 - a23 * a30;
|
|
501
|
+
const b09 = a21 * a32 - a22 * a31, b10 = a21 * a33 - a23 * a31, b11 = a22 * a33 - a23 * a32;
|
|
502
|
+
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
503
|
+
if (Math.abs(det) < 1e-12) return null;
|
|
504
|
+
det = 1 / det;
|
|
505
|
+
inv[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
506
|
+
inv[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
507
|
+
inv[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
508
|
+
inv[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
|
509
|
+
inv[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
510
|
+
inv[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
511
|
+
inv[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
512
|
+
inv[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
|
513
|
+
inv[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
514
|
+
inv[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
515
|
+
inv[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
516
|
+
inv[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
|
517
|
+
inv[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
|
518
|
+
inv[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
|
519
|
+
inv[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
|
520
|
+
inv[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
521
|
+
return inv;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Render a single smooth high-resolution (`cellSize x cellSize`, default `96x96`) 2:1 isometric 3D character cell
|
|
525
|
+
* with 3x3 SSAA anti-aliasing, analytical surface normals, and smooth dark ink outlines.
|
|
526
|
+
*/
|
|
527
|
+
function renderHdCharacterCell(bodyOrCustom, animOrClip, frame = 0, yawRad = Math.PI * .25, opts = {}) {
|
|
528
|
+
const isCustomSpec = typeof bodyOrCustom === "object" && "base" in bodyOrCustom;
|
|
529
|
+
const body = isCustomSpec ? compileCustomBodySpec(bodyOrCustom) : bodyOrCustom;
|
|
530
|
+
const cellSize = Math.max(32, Math.floor(opts.cellSize ?? 96));
|
|
531
|
+
const ss = opts.ss ?? 3;
|
|
532
|
+
const elevRad = (opts.elevDeg ?? 30) * Math.PI / 180;
|
|
533
|
+
const cosE = Math.cos(elevRad);
|
|
534
|
+
const sinE = Math.sin(elevRad);
|
|
535
|
+
const scalePx = cellSize / 32 * .86;
|
|
536
|
+
const groundY = cellSize * .84;
|
|
537
|
+
const colors = opts.colors ?? (isCustomSpec && bodyOrCustom.defaultColors ? {
|
|
538
|
+
fur: bodyOrCustom.defaultColors.fur ? {
|
|
539
|
+
fur: parseHexRgb(bodyOrCustom.defaultColors.fur),
|
|
540
|
+
shade: DEFAULT_RIG_COLORS.fur.shade
|
|
541
|
+
} : DEFAULT_RIG_COLORS.fur,
|
|
542
|
+
belly: bodyOrCustom.defaultColors.belly ? parseHexRgb(bodyOrCustom.defaultColors.belly) : DEFAULT_RIG_COLORS.belly,
|
|
543
|
+
scarf: bodyOrCustom.defaultColors.scarf === null ? null : bodyOrCustom.defaultColors.scarf ? parseHexRgb(bodyOrCustom.defaultColors.scarf) : DEFAULT_RIG_COLORS.scarf
|
|
544
|
+
} : DEFAULT_RIG_COLORS);
|
|
545
|
+
let state = typeof animOrClip === "string" ? evaluateBuiltinPose(body, animOrClip, frame, 0) : evaluateRigClip(body, animOrClip, frame, 0);
|
|
546
|
+
const rootState = createRigState(body, yawRad);
|
|
547
|
+
state.bones.root.quat = rootState.bones.root.quat;
|
|
548
|
+
const localTmp = /* @__PURE__ */ new Float64Array(16);
|
|
549
|
+
const order = [
|
|
550
|
+
"root",
|
|
551
|
+
"hips",
|
|
552
|
+
"chest",
|
|
553
|
+
"neck",
|
|
554
|
+
"head",
|
|
555
|
+
"armL",
|
|
556
|
+
"armR",
|
|
557
|
+
"legL",
|
|
558
|
+
"legR",
|
|
559
|
+
"tail0",
|
|
560
|
+
"tail1",
|
|
561
|
+
"tail2"
|
|
562
|
+
];
|
|
563
|
+
const parents = {
|
|
564
|
+
root: null,
|
|
565
|
+
hips: "root",
|
|
566
|
+
chest: "hips",
|
|
567
|
+
neck: "chest",
|
|
568
|
+
head: "neck",
|
|
569
|
+
armL: "chest",
|
|
570
|
+
armR: "chest",
|
|
571
|
+
legL: "hips",
|
|
572
|
+
legR: "hips",
|
|
573
|
+
tail0: "hips",
|
|
574
|
+
tail1: "tail0",
|
|
575
|
+
tail2: "tail1"
|
|
576
|
+
};
|
|
577
|
+
for (const bName of order) {
|
|
578
|
+
const b = state.bones[bName];
|
|
579
|
+
mat4Compose(b.pos, b.quat, b.scale, localTmp);
|
|
580
|
+
const pName = parents[bName];
|
|
581
|
+
if (!pName) b.world.set(localTmp);
|
|
582
|
+
else mat4Mul(state.bones[pName].world, localTmp, b.world);
|
|
583
|
+
}
|
|
584
|
+
const palette = new Array(256);
|
|
585
|
+
const baseTable = buildHdBaseColorTable(colors);
|
|
586
|
+
if (state.body.customColors?.eye) {
|
|
587
|
+
const eyeEntry = {
|
|
588
|
+
rgb: parseHexRgb(state.body.customColors.eye),
|
|
589
|
+
emissive: true
|
|
590
|
+
};
|
|
591
|
+
baseTable[4] = eyeEntry;
|
|
592
|
+
baseTable[17] = eyeEntry;
|
|
593
|
+
}
|
|
594
|
+
const hdPrims = reprojectPrimsForHd(buildBodyPrimitives(state, colors, opts.cosmetics ?? [], palette, 256, 1), cellSize, cellSize, groundY, scalePx, cosE, sinE, ss);
|
|
595
|
+
const outlineRgb = opts.outlineColor ? typeof opts.outlineColor === "string" ? parseHexRgb(opts.outlineColor) : opts.outlineColor : [
|
|
596
|
+
26,
|
|
597
|
+
22,
|
|
598
|
+
34
|
|
599
|
+
];
|
|
600
|
+
return rasterizeSmoothHd(hdPrims, palette, baseTable, {
|
|
601
|
+
width: cellSize,
|
|
602
|
+
height: cellSize,
|
|
603
|
+
groundY,
|
|
604
|
+
worldScalePx: scalePx,
|
|
605
|
+
cosE,
|
|
606
|
+
sinE,
|
|
607
|
+
ss,
|
|
608
|
+
outlineWidthPx: opts.outlineWidthPx ?? Math.max(1.85, cellSize / 46),
|
|
609
|
+
outlineRgb: opts.outlineColor ? outlineRgb : [
|
|
610
|
+
20,
|
|
611
|
+
16,
|
|
612
|
+
28
|
|
613
|
+
],
|
|
614
|
+
groundShadow: opts.groundShadow !== false,
|
|
615
|
+
shadowRadiusWorld: 9.2
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Bake a multi-direction 2:1 isometric (`45°, 135°, 225°, 315°` or 8-dir) smooth pre-rendered 3D character spritesheet!
|
|
620
|
+
*/
|
|
621
|
+
function bakeHdCharacterSheet(bodyOrCustom, opts = {}) {
|
|
622
|
+
const cellSize = Math.max(32, Math.floor(opts.cellSize ?? 96));
|
|
623
|
+
const dirs = opts.dirs ?? 4;
|
|
624
|
+
const baseYawRad = (opts.baseYawDeg ?? 45) * Math.PI / 180;
|
|
625
|
+
const rowsSpec = opts.rows ?? [{
|
|
626
|
+
clip: "walk",
|
|
627
|
+
name: "walk"
|
|
628
|
+
}];
|
|
629
|
+
let maxFrames = 1;
|
|
630
|
+
const resolved = rowsSpec.map((r) => {
|
|
631
|
+
const fc = typeof r.clip === "string" ? BUILTIN_ANIM_FRAMES[r.clip]?.frames ?? 4 : rigClipFrameCount(r.clip);
|
|
632
|
+
if (fc > maxFrames) maxFrames = fc;
|
|
633
|
+
return {
|
|
634
|
+
clip: r.clip,
|
|
635
|
+
frameCount: fc
|
|
636
|
+
};
|
|
637
|
+
});
|
|
638
|
+
const rowCount = resolved.length * dirs;
|
|
639
|
+
const width = maxFrames * cellSize;
|
|
640
|
+
const height = rowCount * cellSize;
|
|
641
|
+
const rgba = new Uint8ClampedArray(width * height * 4);
|
|
642
|
+
const normalRgba = opts.bakeNormals ? new Uint8ClampedArray(width * height * 4) : void 0;
|
|
643
|
+
if (normalRgba) for (let i = 0; i < normalRgba.length; i += 4) {
|
|
644
|
+
normalRgba[i] = 128;
|
|
645
|
+
normalRgba[i + 1] = 128;
|
|
646
|
+
normalRgba[i + 2] = 255;
|
|
647
|
+
normalRgba[i + 3] = 0;
|
|
648
|
+
}
|
|
649
|
+
let rowIdx = 0;
|
|
650
|
+
for (const row of resolved) for (let d = 0; d < dirs; d++) {
|
|
651
|
+
const yaw = baseYawRad + d / dirs * Math.PI * 2;
|
|
652
|
+
for (let f = 0; f < row.frameCount; f++) {
|
|
653
|
+
const arg = typeof row.clip === "string" ? f : row.clip.loop ? f / row.frameCount : row.frameCount > 1 ? f / (row.frameCount - 1) : 0;
|
|
654
|
+
const cell = renderHdCharacterCell(bodyOrCustom, row.clip, arg, yaw, opts);
|
|
655
|
+
const ox = f * cellSize;
|
|
656
|
+
const oy = rowIdx * cellSize;
|
|
657
|
+
for (let y = 0; y < cellSize; y++) {
|
|
658
|
+
const srcOff = y * cellSize * 4;
|
|
659
|
+
const dstOff = ((oy + y) * width + ox) * 4;
|
|
660
|
+
rgba.set(cell.rgba.subarray(srcOff, srcOff + cellSize * 4), dstOff);
|
|
661
|
+
if (normalRgba) normalRgba.set(cell.normalRgba.subarray(srcOff, srcOff + cellSize * 4), dstOff);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
rowIdx++;
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
width,
|
|
668
|
+
height,
|
|
669
|
+
cellSize,
|
|
670
|
+
columns: maxFrames,
|
|
671
|
+
rowCount,
|
|
672
|
+
rgba,
|
|
673
|
+
...normalRgba ? { normalRgba } : {}
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Render a smooth high-resolution 2:1 isometric (`elev = 30°`, `yaw = 45° + dir4 * 90°`) pre-rendered 3D world prop
|
|
678
|
+
* (turrets, tombs, walls, chests, trees, rocks) with anti-aliased dark ink outlines and ground AO shadow.
|
|
679
|
+
*/
|
|
680
|
+
function renderHdPropSprite(spec, dir4 = 0, opts = {}) {
|
|
681
|
+
const resScale = Math.max(1, opts.resolutionScale ?? 2.25);
|
|
682
|
+
const w = Math.max(32, Math.round(spec.frameW * resScale));
|
|
683
|
+
const h = Math.max(32, Math.round(spec.frameH * resScale));
|
|
684
|
+
const ss = opts.ss ?? 3;
|
|
685
|
+
const elevRad = (opts.elevDeg ?? 30) * Math.PI / 180;
|
|
686
|
+
const cosE = Math.cos(elevRad);
|
|
687
|
+
const sinE = Math.sin(elevRad);
|
|
688
|
+
const yaw = (opts.baseYawDeg ?? 45) * Math.PI / 180 + (Math.floor(dir4) % 4 + 4) % 4 * Math.PI * .5;
|
|
689
|
+
const sc = (spec.scale ?? 1) * resScale * .88;
|
|
690
|
+
const off = spec.offset ?? [
|
|
691
|
+
0,
|
|
692
|
+
0,
|
|
693
|
+
0
|
|
694
|
+
];
|
|
695
|
+
const groundY = Math.max(8, Math.min(h - 6, Math.round(spec.baseY * resScale * .94)));
|
|
696
|
+
const palette = new Array(256);
|
|
697
|
+
const baseTable = buildHdBaseColorTable(DEFAULT_RIG_COLORS);
|
|
698
|
+
const nextMatRef = { id: 180 };
|
|
699
|
+
const colorCache = /* @__PURE__ */ new Map();
|
|
700
|
+
const proj = {
|
|
701
|
+
width: w,
|
|
702
|
+
height: h,
|
|
703
|
+
groundY,
|
|
704
|
+
cosE,
|
|
705
|
+
sinE
|
|
706
|
+
};
|
|
707
|
+
const rootM = mat4Compose([
|
|
708
|
+
0,
|
|
709
|
+
0,
|
|
710
|
+
0
|
|
711
|
+
], quatFromEuler(0, yaw, 0, "XYZ"), [
|
|
712
|
+
sc,
|
|
713
|
+
sc,
|
|
714
|
+
sc
|
|
715
|
+
]);
|
|
716
|
+
const offM = mat4Compose(off, [
|
|
717
|
+
0,
|
|
718
|
+
0,
|
|
719
|
+
0,
|
|
720
|
+
1
|
|
721
|
+
], [
|
|
722
|
+
1,
|
|
723
|
+
1,
|
|
724
|
+
1
|
|
725
|
+
]);
|
|
726
|
+
const worldM = mat4Mul(rootM, offM);
|
|
727
|
+
const prims = [];
|
|
728
|
+
if (spec.primitives?.length) addDeclarativePrimitives(prims, worldM, spec.primitives, palette, nextMatRef, colorCache, GRP.prop, Math.max(w, h), ss, proj);
|
|
729
|
+
const outlineRgb = opts.outlineColor ? typeof opts.outlineColor === "string" ? parseHexRgb(opts.outlineColor) : opts.outlineColor : [
|
|
730
|
+
26,
|
|
731
|
+
22,
|
|
732
|
+
34
|
|
733
|
+
];
|
|
734
|
+
return rasterizeSmoothHd(prims, palette, baseTable, {
|
|
735
|
+
width: w,
|
|
736
|
+
height: h,
|
|
737
|
+
groundY,
|
|
738
|
+
worldScalePx: 1,
|
|
739
|
+
cosE,
|
|
740
|
+
sinE,
|
|
741
|
+
ss,
|
|
742
|
+
outlineWidthPx: opts.outlineWidthPx ?? Math.max(1.85, Math.min(w, h) / 46),
|
|
743
|
+
outlineRgb: opts.outlineColor ? outlineRgb : [
|
|
744
|
+
20,
|
|
745
|
+
16,
|
|
746
|
+
28
|
|
747
|
+
],
|
|
748
|
+
groundShadow: opts.groundShadow !== false,
|
|
749
|
+
shadowRadiusWorld: Math.max(spec.tilesW, spec.tilesD) * 9.5 * resScale
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
/** Compile all `1` or `4` isometric directions of a prop into a horizontal smooth HD spritesheet. */
|
|
753
|
+
function renderHdPropSheet(spec, opts = {}) {
|
|
754
|
+
const dirs = spec.dirs;
|
|
755
|
+
const first = renderHdPropSprite(spec, 0, opts);
|
|
756
|
+
const fw = first.width;
|
|
757
|
+
const fh = first.height;
|
|
758
|
+
const width = fw * dirs;
|
|
759
|
+
const rgba = new Uint8ClampedArray(width * fh * 4);
|
|
760
|
+
const normalRgba = new Uint8ClampedArray(width * fh * 4);
|
|
761
|
+
for (let d = 0; d < dirs; d++) {
|
|
762
|
+
const cell = d === 0 ? first : renderHdPropSprite(spec, d, opts);
|
|
763
|
+
for (let y = 0; y < fh; y++) {
|
|
764
|
+
const srcOff = y * fw * 4;
|
|
765
|
+
const dstOff = (y * width + d * fw) * 4;
|
|
766
|
+
rgba.set(cell.rgba.subarray(srcOff, srcOff + fw * 4), dstOff);
|
|
767
|
+
normalRgba.set(cell.normalRgba.subarray(srcOff, srcOff + fw * 4), dstOff);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return {
|
|
771
|
+
width,
|
|
772
|
+
height: fh,
|
|
773
|
+
frameW: fw,
|
|
774
|
+
frameH: fh,
|
|
775
|
+
dirs,
|
|
776
|
+
rgba,
|
|
777
|
+
normalRgba
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
function hashFloat(ix, iy, seed) {
|
|
781
|
+
let h = ix * 374761393 + iy * 668265263 + seed * 0x55fdc781 | 0;
|
|
782
|
+
h = Math.imul(h ^ h >>> 13, 0x4bf19f61);
|
|
783
|
+
return ((h ^ h >>> 16) >>> 0) / 4294967296;
|
|
784
|
+
}
|
|
785
|
+
function smoothNoise(x, y, period, seed) {
|
|
786
|
+
const px = (x % period + period) % period;
|
|
787
|
+
const py = (y % period + period) % period;
|
|
788
|
+
const x0 = Math.floor(px), y0 = Math.floor(py);
|
|
789
|
+
const x1 = (x0 + 1) % period, y1 = (y0 + 1) % period;
|
|
790
|
+
const fx = px - x0, fy = py - y0;
|
|
791
|
+
const ux = fx * fx * (3 - 2 * fx);
|
|
792
|
+
const uy = fy * fy * (3 - 2 * fy);
|
|
793
|
+
const a = hashFloat(x0, y0, seed), b = hashFloat(x1, y0, seed);
|
|
794
|
+
const c = hashFloat(x0, y1, seed), d = hashFloat(x1, y1, seed);
|
|
795
|
+
return (a * (1 - ux) + b * ux) * (1 - uy) + (c * (1 - ux) + d * ux) * uy;
|
|
796
|
+
}
|
|
797
|
+
function evalSmoothDualGridSdf(mask, u, v) {
|
|
798
|
+
const tl = mask & 1 ? 1 : 0;
|
|
799
|
+
const tr = mask & 2 ? 1 : 0;
|
|
800
|
+
const bl = mask & 4 ? 1 : 0;
|
|
801
|
+
const br = mask & 8 ? 1 : 0;
|
|
802
|
+
const top = tl * (1 - u) + tr * u;
|
|
803
|
+
const bot = bl * (1 - u) + br * u;
|
|
804
|
+
return top * (1 - v) + bot * v - .5;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Bake a smooth, anti-aliased high-resolution (`64x64` default) 16-tile Dual-Grid terrain spritesheet
|
|
808
|
+
* with seamless procedural hand-painted gradients, soft sunlit lip bevels, and dark ink borders.
|
|
809
|
+
*/
|
|
810
|
+
function bakeHdDualGridSheet(spec) {
|
|
811
|
+
const ts = Math.max(32, Math.floor(spec.tileSize ?? 64));
|
|
812
|
+
const cols = 4, rows = 4;
|
|
813
|
+
const width = ts * cols, height = ts * rows;
|
|
814
|
+
const rgba = new Uint8ClampedArray(width * height * 4);
|
|
815
|
+
const base = parseHexRgb(spec.baseColor);
|
|
816
|
+
const accent = spec.accentColor ? parseHexRgb(spec.accentColor) : mixRgb(base, [
|
|
817
|
+
255,
|
|
818
|
+
248,
|
|
819
|
+
210
|
|
820
|
+
], .24);
|
|
821
|
+
const shadow = mixRgb(base, [
|
|
822
|
+
32,
|
|
823
|
+
24,
|
|
824
|
+
48
|
|
825
|
+
], .34);
|
|
826
|
+
const ink = [
|
|
827
|
+
28,
|
|
828
|
+
24,
|
|
829
|
+
36
|
|
830
|
+
];
|
|
831
|
+
const seed = spec.seed ?? 777;
|
|
832
|
+
const ow = (spec.outlineWidthPx ?? 2) / ts;
|
|
833
|
+
for (let mask = 0; mask < 16; mask++) {
|
|
834
|
+
const ox = mask % cols * ts;
|
|
835
|
+
const oy = Math.floor(mask / cols) * ts;
|
|
836
|
+
for (let ly = 0; ly < ts; ly++) {
|
|
837
|
+
const v = (ly + .5) / ts;
|
|
838
|
+
for (let lx = 0; lx < ts; lx++) {
|
|
839
|
+
const u = (lx + .5) / ts;
|
|
840
|
+
const n1 = smoothNoise(u * 8, v * 8, 8, seed);
|
|
841
|
+
const n2 = smoothNoise(u * 16, v * 16, 16, seed + 41);
|
|
842
|
+
const fbm = n1 * .65 + n2 * .35;
|
|
843
|
+
const sdf = evalSmoothDualGridSdf(mask, u, v) + (mask === 0 || mask === 15 ? 0 : (fbm - .5) * .08);
|
|
844
|
+
const aaWidth = 1.15 / ts;
|
|
845
|
+
const fillCov = Math.max(0, Math.min(1, (sdf + aaWidth) / (2 * aaWidth)));
|
|
846
|
+
const strokeCov = mask === 0 ? 0 : Math.max(0, Math.min(1, (sdf + ow + aaWidth) / (2 * aaWidth)));
|
|
847
|
+
if (strokeCov <= 0 && fillCov <= 0) continue;
|
|
848
|
+
let surf = mixRgb(shadow, accent, Math.max(0, Math.min(1, fbm * 1.15)));
|
|
849
|
+
if (spec.style === "cobble" || spec.style === "stone_brick") {
|
|
850
|
+
const gx = (u * 4 + (Math.floor(v * 4) & 1) * .5) % 1;
|
|
851
|
+
const gy = v * 4 % 1;
|
|
852
|
+
const edgeDist = Math.min(gx, 1 - gx, gy, 1 - gy);
|
|
853
|
+
const groove = Math.max(0, Math.min(1, (edgeDist - .05) / .09));
|
|
854
|
+
surf = mixRgb(shadow, surf, groove);
|
|
855
|
+
}
|
|
856
|
+
const sdfUpLeft = evalSmoothDualGridSdf(mask, Math.max(0, u - .06), Math.max(0, v - .06));
|
|
857
|
+
if (sdf > 0 && sdfUpLeft < .04) surf = mixRgb(surf, [
|
|
858
|
+
255,
|
|
859
|
+
252,
|
|
860
|
+
232
|
|
861
|
+
], .32);
|
|
862
|
+
const pa = Math.max(fillCov, strokeCov);
|
|
863
|
+
const r = surf[0] * fillCov + ink[0] * (pa - fillCov);
|
|
864
|
+
const g = surf[1] * fillCov + ink[1] * (pa - fillCov);
|
|
865
|
+
const b = surf[2] * fillCov + ink[2] * (pa - fillCov);
|
|
866
|
+
const o = ((oy + ly) * width + (ox + lx)) * 4;
|
|
867
|
+
rgba[o] = Math.round(r / pa);
|
|
868
|
+
rgba[o + 1] = Math.round(g / pa);
|
|
869
|
+
rgba[o + 2] = Math.round(b / pa);
|
|
870
|
+
rgba[o + 3] = Math.round(pa * 255);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
const normalRgba = spec.bakeNormals !== false ? bakeNormalMapRgba(rgba, width, height, { strength: 2 }) : void 0;
|
|
875
|
+
return {
|
|
876
|
+
id: spec.id,
|
|
877
|
+
width,
|
|
878
|
+
height,
|
|
879
|
+
tileSize: ts,
|
|
880
|
+
columns: cols,
|
|
881
|
+
rows,
|
|
882
|
+
tileCount: 16,
|
|
883
|
+
rgba,
|
|
884
|
+
...normalRgba ? { normalRgba } : {}
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
const KRAFTEERS_PRESETS = {
|
|
888
|
+
explorerBody: {
|
|
889
|
+
id: "craft:krafteers:explorer",
|
|
890
|
+
name: "Tomb Explorer",
|
|
891
|
+
base: "A",
|
|
892
|
+
category: "character",
|
|
893
|
+
head: {
|
|
894
|
+
c: [
|
|
895
|
+
0,
|
|
896
|
+
7,
|
|
897
|
+
.3
|
|
898
|
+
],
|
|
899
|
+
r: [
|
|
900
|
+
8.8,
|
|
901
|
+
7.8,
|
|
902
|
+
8.2
|
|
903
|
+
],
|
|
904
|
+
sq: 2.3
|
|
905
|
+
},
|
|
906
|
+
torso: {
|
|
907
|
+
c: [
|
|
908
|
+
0,
|
|
909
|
+
7.3,
|
|
910
|
+
-.1
|
|
911
|
+
],
|
|
912
|
+
r: [
|
|
913
|
+
6.8,
|
|
914
|
+
6.2,
|
|
915
|
+
6
|
|
916
|
+
],
|
|
917
|
+
sq: 2.4
|
|
918
|
+
},
|
|
919
|
+
belly: {
|
|
920
|
+
c: [
|
|
921
|
+
0,
|
|
922
|
+
6.6,
|
|
923
|
+
2.5
|
|
924
|
+
],
|
|
925
|
+
r: [
|
|
926
|
+
4.8,
|
|
927
|
+
4.5,
|
|
928
|
+
3.8
|
|
929
|
+
]
|
|
930
|
+
},
|
|
931
|
+
muzzle: {
|
|
932
|
+
c: [
|
|
933
|
+
0,
|
|
934
|
+
-2.8,
|
|
935
|
+
6.8
|
|
936
|
+
],
|
|
937
|
+
r: [
|
|
938
|
+
3.2,
|
|
939
|
+
1.8,
|
|
940
|
+
1.8
|
|
941
|
+
]
|
|
942
|
+
},
|
|
943
|
+
nose: [
|
|
944
|
+
0,
|
|
945
|
+
-1.2,
|
|
946
|
+
8.5
|
|
947
|
+
],
|
|
948
|
+
ear: { hidden: true },
|
|
949
|
+
blush: {
|
|
950
|
+
x: 5.8,
|
|
951
|
+
y: -1.8
|
|
952
|
+
},
|
|
953
|
+
tail: { hidden: true },
|
|
954
|
+
eye: {
|
|
955
|
+
x: 3.5,
|
|
956
|
+
y: 1,
|
|
957
|
+
style: "dot"
|
|
958
|
+
},
|
|
959
|
+
colors: {
|
|
960
|
+
head: "#f8cba6",
|
|
961
|
+
muzzle: "#f8cba6",
|
|
962
|
+
nose: "#e6a87c",
|
|
963
|
+
torso: "#0ea5e9",
|
|
964
|
+
belly: "#eab308",
|
|
965
|
+
arm: "#0284c7",
|
|
966
|
+
feet: "#78350f"
|
|
967
|
+
},
|
|
968
|
+
defaultColors: { scarf: "#ef4444" },
|
|
969
|
+
extras: [{
|
|
970
|
+
bone: "head",
|
|
971
|
+
primitives: [
|
|
972
|
+
{
|
|
973
|
+
shape: "ellipsoid",
|
|
974
|
+
pos: [
|
|
975
|
+
0,
|
|
976
|
+
4.6,
|
|
977
|
+
-.2
|
|
978
|
+
],
|
|
979
|
+
size: [
|
|
980
|
+
10.4,
|
|
981
|
+
3.2,
|
|
982
|
+
9.8
|
|
983
|
+
],
|
|
984
|
+
color: "#f59e0b"
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
shape: "ellipsoid",
|
|
988
|
+
pos: [
|
|
989
|
+
0,
|
|
990
|
+
6.8,
|
|
991
|
+
-.2
|
|
992
|
+
],
|
|
993
|
+
size: [
|
|
994
|
+
8.2,
|
|
995
|
+
4.8,
|
|
996
|
+
7.8
|
|
997
|
+
],
|
|
998
|
+
color: "#fbbf24"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
shape: "cylinder",
|
|
1002
|
+
pos: [
|
|
1003
|
+
-3.2,
|
|
1004
|
+
5.4,
|
|
1005
|
+
7.6
|
|
1006
|
+
],
|
|
1007
|
+
size: [
|
|
1008
|
+
2.2,
|
|
1009
|
+
1.8,
|
|
1010
|
+
2.2
|
|
1011
|
+
],
|
|
1012
|
+
rot: [
|
|
1013
|
+
Math.PI * .5,
|
|
1014
|
+
0,
|
|
1015
|
+
0
|
|
1016
|
+
],
|
|
1017
|
+
color: "#38bdf8",
|
|
1018
|
+
shade: "flat"
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
shape: "cylinder",
|
|
1022
|
+
pos: [
|
|
1023
|
+
3.2,
|
|
1024
|
+
5.4,
|
|
1025
|
+
7.6
|
|
1026
|
+
],
|
|
1027
|
+
size: [
|
|
1028
|
+
2.2,
|
|
1029
|
+
1.8,
|
|
1030
|
+
2.2
|
|
1031
|
+
],
|
|
1032
|
+
rot: [
|
|
1033
|
+
Math.PI * .5,
|
|
1034
|
+
0,
|
|
1035
|
+
0
|
|
1036
|
+
],
|
|
1037
|
+
color: "#38bdf8",
|
|
1038
|
+
shade: "flat"
|
|
1039
|
+
}
|
|
1040
|
+
]
|
|
1041
|
+
}, {
|
|
1042
|
+
bone: "chest",
|
|
1043
|
+
primitives: [{
|
|
1044
|
+
shape: "box",
|
|
1045
|
+
pos: [
|
|
1046
|
+
0,
|
|
1047
|
+
-2.5,
|
|
1048
|
+
-6.5
|
|
1049
|
+
],
|
|
1050
|
+
size: [
|
|
1051
|
+
5.2,
|
|
1052
|
+
4.8,
|
|
1053
|
+
2.8
|
|
1054
|
+
],
|
|
1055
|
+
color: "#b45309"
|
|
1056
|
+
}, {
|
|
1057
|
+
shape: "cylinder",
|
|
1058
|
+
pos: [
|
|
1059
|
+
0,
|
|
1060
|
+
2.6,
|
|
1061
|
+
-6.5
|
|
1062
|
+
],
|
|
1063
|
+
size: [
|
|
1064
|
+
2,
|
|
1065
|
+
10.6,
|
|
1066
|
+
2
|
|
1067
|
+
],
|
|
1068
|
+
rot: [
|
|
1069
|
+
0,
|
|
1070
|
+
0,
|
|
1071
|
+
Math.PI * .5
|
|
1072
|
+
],
|
|
1073
|
+
color: "#16a34a"
|
|
1074
|
+
}]
|
|
1075
|
+
}]
|
|
1076
|
+
},
|
|
1077
|
+
tombMummyBody: {
|
|
1078
|
+
id: "craft:krafteers:tomb-mummy",
|
|
1079
|
+
name: "Cursed Tomb Guardian",
|
|
1080
|
+
base: "A",
|
|
1081
|
+
category: "character",
|
|
1082
|
+
head: {
|
|
1083
|
+
c: [
|
|
1084
|
+
0,
|
|
1085
|
+
6.8,
|
|
1086
|
+
.6
|
|
1087
|
+
],
|
|
1088
|
+
r: [
|
|
1089
|
+
8.8,
|
|
1090
|
+
7.6,
|
|
1091
|
+
8
|
|
1092
|
+
],
|
|
1093
|
+
sq: 2.4
|
|
1094
|
+
},
|
|
1095
|
+
torso: {
|
|
1096
|
+
c: [
|
|
1097
|
+
0,
|
|
1098
|
+
7.2,
|
|
1099
|
+
.1
|
|
1100
|
+
],
|
|
1101
|
+
r: [
|
|
1102
|
+
7.2,
|
|
1103
|
+
6.2,
|
|
1104
|
+
5.8
|
|
1105
|
+
],
|
|
1106
|
+
sq: 2.4
|
|
1107
|
+
},
|
|
1108
|
+
belly: {
|
|
1109
|
+
c: [
|
|
1110
|
+
0,
|
|
1111
|
+
6.5,
|
|
1112
|
+
2.4
|
|
1113
|
+
],
|
|
1114
|
+
r: [
|
|
1115
|
+
5,
|
|
1116
|
+
4.5,
|
|
1117
|
+
3.8
|
|
1118
|
+
]
|
|
1119
|
+
},
|
|
1120
|
+
muzzle: {
|
|
1121
|
+
c: [
|
|
1122
|
+
0,
|
|
1123
|
+
-2.6,
|
|
1124
|
+
6.5
|
|
1125
|
+
],
|
|
1126
|
+
r: [
|
|
1127
|
+
3.4,
|
|
1128
|
+
1.8,
|
|
1129
|
+
1.8
|
|
1130
|
+
]
|
|
1131
|
+
},
|
|
1132
|
+
nose: null,
|
|
1133
|
+
ear: { hidden: true },
|
|
1134
|
+
blush: { hidden: true },
|
|
1135
|
+
tail: { hidden: true },
|
|
1136
|
+
eye: {
|
|
1137
|
+
x: 3.4,
|
|
1138
|
+
y: .8,
|
|
1139
|
+
style: "dot"
|
|
1140
|
+
},
|
|
1141
|
+
colors: {
|
|
1142
|
+
head: "#d6c9ab",
|
|
1143
|
+
muzzle: "#bfb192",
|
|
1144
|
+
eye: "#22d3ee",
|
|
1145
|
+
torso: "#c7b99b",
|
|
1146
|
+
belly: "#7c3aed",
|
|
1147
|
+
arm: "#d6c9ab",
|
|
1148
|
+
feet: "#78350f"
|
|
1149
|
+
},
|
|
1150
|
+
defaultColors: { scarf: "#eab308" },
|
|
1151
|
+
extras: [{
|
|
1152
|
+
bone: "head",
|
|
1153
|
+
primitives: [
|
|
1154
|
+
{
|
|
1155
|
+
shape: "torus",
|
|
1156
|
+
pos: [
|
|
1157
|
+
0,
|
|
1158
|
+
2.8,
|
|
1159
|
+
.4
|
|
1160
|
+
],
|
|
1161
|
+
size: [
|
|
1162
|
+
7.9,
|
|
1163
|
+
1.35,
|
|
1164
|
+
7.9
|
|
1165
|
+
],
|
|
1166
|
+
rot: [
|
|
1167
|
+
.12,
|
|
1168
|
+
0,
|
|
1169
|
+
.08
|
|
1170
|
+
],
|
|
1171
|
+
color: "#ede4cf"
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
shape: "torus",
|
|
1175
|
+
pos: [
|
|
1176
|
+
0,
|
|
1177
|
+
-1.6,
|
|
1178
|
+
.6
|
|
1179
|
+
],
|
|
1180
|
+
size: [
|
|
1181
|
+
7.5,
|
|
1182
|
+
1.25,
|
|
1183
|
+
7.5
|
|
1184
|
+
],
|
|
1185
|
+
rot: [
|
|
1186
|
+
-.08,
|
|
1187
|
+
0,
|
|
1188
|
+
-.08
|
|
1189
|
+
],
|
|
1190
|
+
color: "#e2d7be"
|
|
1191
|
+
},
|
|
1192
|
+
{
|
|
1193
|
+
shape: "box",
|
|
1194
|
+
pos: [
|
|
1195
|
+
0,
|
|
1196
|
+
6.2,
|
|
1197
|
+
5.8
|
|
1198
|
+
],
|
|
1199
|
+
size: [
|
|
1200
|
+
2.2,
|
|
1201
|
+
3,
|
|
1202
|
+
1.8
|
|
1203
|
+
],
|
|
1204
|
+
color: "#eab308"
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
shape: "ellipsoid",
|
|
1208
|
+
pos: [
|
|
1209
|
+
0,
|
|
1210
|
+
6.8,
|
|
1211
|
+
7.3
|
|
1212
|
+
],
|
|
1213
|
+
size: [
|
|
1214
|
+
1.3,
|
|
1215
|
+
1.5,
|
|
1216
|
+
1.1
|
|
1217
|
+
],
|
|
1218
|
+
color: "#22d3ee",
|
|
1219
|
+
shade: "flat"
|
|
1220
|
+
}
|
|
1221
|
+
]
|
|
1222
|
+
}, {
|
|
1223
|
+
bone: "chest",
|
|
1224
|
+
primitives: [{
|
|
1225
|
+
shape: "torus",
|
|
1226
|
+
pos: [
|
|
1227
|
+
0,
|
|
1228
|
+
-.8,
|
|
1229
|
+
.2
|
|
1230
|
+
],
|
|
1231
|
+
size: [
|
|
1232
|
+
6.2,
|
|
1233
|
+
1.25,
|
|
1234
|
+
6.2
|
|
1235
|
+
],
|
|
1236
|
+
rot: [
|
|
1237
|
+
.1,
|
|
1238
|
+
0,
|
|
1239
|
+
-.12
|
|
1240
|
+
],
|
|
1241
|
+
color: "#ede4cf"
|
|
1242
|
+
}]
|
|
1243
|
+
}]
|
|
1244
|
+
},
|
|
1245
|
+
cosmetics: {
|
|
1246
|
+
goldenPickaxe: {
|
|
1247
|
+
id: "craft:krafteers:pickaxe",
|
|
1248
|
+
name: "Golden Steel Pickaxe",
|
|
1249
|
+
slot: "hand",
|
|
1250
|
+
socket: "handR",
|
|
1251
|
+
rot: [
|
|
1252
|
+
1.15,
|
|
1253
|
+
0,
|
|
1254
|
+
0
|
|
1255
|
+
],
|
|
1256
|
+
primitives: [
|
|
1257
|
+
{
|
|
1258
|
+
shape: "cylinder",
|
|
1259
|
+
pos: [
|
|
1260
|
+
0,
|
|
1261
|
+
4.8,
|
|
1262
|
+
0
|
|
1263
|
+
],
|
|
1264
|
+
size: [
|
|
1265
|
+
1.05,
|
|
1266
|
+
13,
|
|
1267
|
+
1.05
|
|
1268
|
+
],
|
|
1269
|
+
color: "#92400e"
|
|
1270
|
+
},
|
|
1271
|
+
{
|
|
1272
|
+
shape: "box",
|
|
1273
|
+
pos: [
|
|
1274
|
+
0,
|
|
1275
|
+
10.2,
|
|
1276
|
+
0
|
|
1277
|
+
],
|
|
1278
|
+
size: [
|
|
1279
|
+
2.2,
|
|
1280
|
+
1.8,
|
|
1281
|
+
2.2
|
|
1282
|
+
],
|
|
1283
|
+
color: "#eab308"
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
shape: "cone",
|
|
1287
|
+
pos: [
|
|
1288
|
+
0,
|
|
1289
|
+
10,
|
|
1290
|
+
5
|
|
1291
|
+
],
|
|
1292
|
+
size: [
|
|
1293
|
+
1.5,
|
|
1294
|
+
4.6,
|
|
1295
|
+
1.5
|
|
1296
|
+
],
|
|
1297
|
+
rot: [
|
|
1298
|
+
Math.PI * .52,
|
|
1299
|
+
0,
|
|
1300
|
+
0
|
|
1301
|
+
],
|
|
1302
|
+
color: "#38bdf8"
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
shape: "cone",
|
|
1306
|
+
pos: [
|
|
1307
|
+
0,
|
|
1308
|
+
10,
|
|
1309
|
+
-5
|
|
1310
|
+
],
|
|
1311
|
+
size: [
|
|
1312
|
+
1.5,
|
|
1313
|
+
4.6,
|
|
1314
|
+
1.5
|
|
1315
|
+
],
|
|
1316
|
+
rot: [
|
|
1317
|
+
-Math.PI * .52,
|
|
1318
|
+
0,
|
|
1319
|
+
0
|
|
1320
|
+
],
|
|
1321
|
+
color: "#38bdf8"
|
|
1322
|
+
}
|
|
1323
|
+
]
|
|
1324
|
+
},
|
|
1325
|
+
expeditionTorch: {
|
|
1326
|
+
id: "craft:krafteers:torch",
|
|
1327
|
+
name: "Expedition Brazier Torch",
|
|
1328
|
+
slot: "hand",
|
|
1329
|
+
socket: "handL",
|
|
1330
|
+
rot: [
|
|
1331
|
+
1.65,
|
|
1332
|
+
0,
|
|
1333
|
+
-.25
|
|
1334
|
+
],
|
|
1335
|
+
primitives: [
|
|
1336
|
+
{
|
|
1337
|
+
shape: "cylinder",
|
|
1338
|
+
pos: [
|
|
1339
|
+
0,
|
|
1340
|
+
4.2,
|
|
1341
|
+
0
|
|
1342
|
+
],
|
|
1343
|
+
size: [
|
|
1344
|
+
1.05,
|
|
1345
|
+
10.5,
|
|
1346
|
+
1.05
|
|
1347
|
+
],
|
|
1348
|
+
color: "#78350f"
|
|
1349
|
+
},
|
|
1350
|
+
{
|
|
1351
|
+
shape: "cylinder",
|
|
1352
|
+
pos: [
|
|
1353
|
+
0,
|
|
1354
|
+
9,
|
|
1355
|
+
0
|
|
1356
|
+
],
|
|
1357
|
+
size: [
|
|
1358
|
+
2.1,
|
|
1359
|
+
2.6,
|
|
1360
|
+
2.1
|
|
1361
|
+
],
|
|
1362
|
+
color: "#475569"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
shape: "ellipsoid",
|
|
1366
|
+
pos: [
|
|
1367
|
+
0,
|
|
1368
|
+
12,
|
|
1369
|
+
0
|
|
1370
|
+
],
|
|
1371
|
+
size: [
|
|
1372
|
+
3,
|
|
1373
|
+
4.2,
|
|
1374
|
+
3
|
|
1375
|
+
],
|
|
1376
|
+
color: "#f97316",
|
|
1377
|
+
shade: "flat",
|
|
1378
|
+
outline: false
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
shape: "ellipsoid",
|
|
1382
|
+
pos: [
|
|
1383
|
+
0,
|
|
1384
|
+
12.8,
|
|
1385
|
+
0
|
|
1386
|
+
],
|
|
1387
|
+
size: [
|
|
1388
|
+
1.8,
|
|
1389
|
+
2.6,
|
|
1390
|
+
1.8
|
|
1391
|
+
],
|
|
1392
|
+
color: "#fde047",
|
|
1393
|
+
shade: "flat",
|
|
1394
|
+
outline: false
|
|
1395
|
+
}
|
|
1396
|
+
]
|
|
1397
|
+
}
|
|
1398
|
+
},
|
|
1399
|
+
clips: {
|
|
1400
|
+
swing: {
|
|
1401
|
+
id: "craft:krafteers:swing",
|
|
1402
|
+
name: "Mine / Chop Swing",
|
|
1403
|
+
durationMs: 480,
|
|
1404
|
+
fps: 8,
|
|
1405
|
+
dirs: 16,
|
|
1406
|
+
loop: true,
|
|
1407
|
+
keyframes: [
|
|
1408
|
+
{
|
|
1409
|
+
at: 0,
|
|
1410
|
+
ease: "easeOut",
|
|
1411
|
+
bones: { chest: { rot: [
|
|
1412
|
+
-.18,
|
|
1413
|
+
0,
|
|
1414
|
+
0
|
|
1415
|
+
] } },
|
|
1416
|
+
reach: { armR: { target: [
|
|
1417
|
+
-4.5,
|
|
1418
|
+
8.5,
|
|
1419
|
+
2
|
|
1420
|
+
] } }
|
|
1421
|
+
},
|
|
1422
|
+
{
|
|
1423
|
+
at: .45,
|
|
1424
|
+
ease: "easeInOut",
|
|
1425
|
+
bones: { chest: { rot: [
|
|
1426
|
+
.28,
|
|
1427
|
+
0,
|
|
1428
|
+
0
|
|
1429
|
+
] } },
|
|
1430
|
+
reach: { armR: { target: [
|
|
1431
|
+
-2,
|
|
1432
|
+
-4.5,
|
|
1433
|
+
10.5
|
|
1434
|
+
] } }
|
|
1435
|
+
},
|
|
1436
|
+
{
|
|
1437
|
+
at: 1,
|
|
1438
|
+
ease: "easeOut",
|
|
1439
|
+
bones: { chest: { rot: [
|
|
1440
|
+
-.18,
|
|
1441
|
+
0,
|
|
1442
|
+
0
|
|
1443
|
+
] } },
|
|
1444
|
+
reach: { armR: { target: [
|
|
1445
|
+
-4.5,
|
|
1446
|
+
8.5,
|
|
1447
|
+
2
|
|
1448
|
+
] } }
|
|
1449
|
+
}
|
|
1450
|
+
]
|
|
1451
|
+
},
|
|
1452
|
+
shamble: {
|
|
1453
|
+
id: "craft:krafteers:shamble",
|
|
1454
|
+
name: "Mummy Raid Shamble",
|
|
1455
|
+
durationMs: 800,
|
|
1456
|
+
fps: 6,
|
|
1457
|
+
dirs: 16,
|
|
1458
|
+
loop: true,
|
|
1459
|
+
keyframes: [{
|
|
1460
|
+
at: 0,
|
|
1461
|
+
bones: {
|
|
1462
|
+
chest: { rot: [
|
|
1463
|
+
.26,
|
|
1464
|
+
0,
|
|
1465
|
+
-.1
|
|
1466
|
+
] },
|
|
1467
|
+
head: { rot: [
|
|
1468
|
+
.12,
|
|
1469
|
+
0,
|
|
1470
|
+
.14
|
|
1471
|
+
] },
|
|
1472
|
+
legL: { rot: [
|
|
1473
|
+
-.45,
|
|
1474
|
+
0,
|
|
1475
|
+
0
|
|
1476
|
+
] },
|
|
1477
|
+
legR: { rot: [
|
|
1478
|
+
.45,
|
|
1479
|
+
0,
|
|
1480
|
+
0
|
|
1481
|
+
] }
|
|
1482
|
+
},
|
|
1483
|
+
reach: {
|
|
1484
|
+
armL: { target: [
|
|
1485
|
+
4.2,
|
|
1486
|
+
-.5,
|
|
1487
|
+
10.5
|
|
1488
|
+
] },
|
|
1489
|
+
armR: { target: [
|
|
1490
|
+
-4.2,
|
|
1491
|
+
-1.2,
|
|
1492
|
+
9.8
|
|
1493
|
+
] }
|
|
1494
|
+
}
|
|
1495
|
+
}, {
|
|
1496
|
+
at: .5,
|
|
1497
|
+
bones: {
|
|
1498
|
+
chest: { rot: [
|
|
1499
|
+
.3,
|
|
1500
|
+
0,
|
|
1501
|
+
.1
|
|
1502
|
+
] },
|
|
1503
|
+
head: { rot: [
|
|
1504
|
+
.15,
|
|
1505
|
+
0,
|
|
1506
|
+
-.14
|
|
1507
|
+
] },
|
|
1508
|
+
legL: { rot: [
|
|
1509
|
+
.45,
|
|
1510
|
+
0,
|
|
1511
|
+
0
|
|
1512
|
+
] },
|
|
1513
|
+
legR: { rot: [
|
|
1514
|
+
-.45,
|
|
1515
|
+
0,
|
|
1516
|
+
0
|
|
1517
|
+
] }
|
|
1518
|
+
},
|
|
1519
|
+
reach: {
|
|
1520
|
+
armL: { target: [
|
|
1521
|
+
4.2,
|
|
1522
|
+
-1.2,
|
|
1523
|
+
9.8
|
|
1524
|
+
] },
|
|
1525
|
+
armR: { target: [
|
|
1526
|
+
-4.2,
|
|
1527
|
+
-.5,
|
|
1528
|
+
10.5
|
|
1529
|
+
] }
|
|
1530
|
+
}
|
|
1531
|
+
}]
|
|
1532
|
+
}
|
|
1533
|
+
},
|
|
1534
|
+
props: {
|
|
1535
|
+
pharaohObelisk: {
|
|
1536
|
+
id: "craft:krafteers:obelisk",
|
|
1537
|
+
name: "Ancient Tomb Obelisk",
|
|
1538
|
+
group: "game",
|
|
1539
|
+
tilesW: 2,
|
|
1540
|
+
tilesD: 2,
|
|
1541
|
+
frameW: 44,
|
|
1542
|
+
frameH: 58,
|
|
1543
|
+
dirs: 4,
|
|
1544
|
+
baseY: 50,
|
|
1545
|
+
solidMask: 15,
|
|
1546
|
+
primitives: [
|
|
1547
|
+
{
|
|
1548
|
+
shape: "box",
|
|
1549
|
+
pos: [
|
|
1550
|
+
0,
|
|
1551
|
+
3,
|
|
1552
|
+
0
|
|
1553
|
+
],
|
|
1554
|
+
size: [
|
|
1555
|
+
13.5,
|
|
1556
|
+
3,
|
|
1557
|
+
13.5
|
|
1558
|
+
],
|
|
1559
|
+
color: "#d97706"
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
shape: "box",
|
|
1563
|
+
pos: [
|
|
1564
|
+
0,
|
|
1565
|
+
8,
|
|
1566
|
+
0
|
|
1567
|
+
],
|
|
1568
|
+
size: [
|
|
1569
|
+
10.5,
|
|
1570
|
+
2.5,
|
|
1571
|
+
10.5
|
|
1572
|
+
],
|
|
1573
|
+
color: "#f59e0b"
|
|
1574
|
+
},
|
|
1575
|
+
{
|
|
1576
|
+
shape: "box",
|
|
1577
|
+
pos: [
|
|
1578
|
+
0,
|
|
1579
|
+
22.5,
|
|
1580
|
+
0
|
|
1581
|
+
],
|
|
1582
|
+
size: [
|
|
1583
|
+
6.8,
|
|
1584
|
+
12.5,
|
|
1585
|
+
6.8
|
|
1586
|
+
],
|
|
1587
|
+
color: "#fbbf24"
|
|
1588
|
+
},
|
|
1589
|
+
{
|
|
1590
|
+
shape: "cone",
|
|
1591
|
+
pos: [
|
|
1592
|
+
0,
|
|
1593
|
+
39.5,
|
|
1594
|
+
0
|
|
1595
|
+
],
|
|
1596
|
+
size: [
|
|
1597
|
+
7.6,
|
|
1598
|
+
9.5,
|
|
1599
|
+
7.6
|
|
1600
|
+
],
|
|
1601
|
+
color: "#eab308"
|
|
1602
|
+
},
|
|
1603
|
+
{
|
|
1604
|
+
shape: "ellipsoid",
|
|
1605
|
+
pos: [
|
|
1606
|
+
0,
|
|
1607
|
+
22,
|
|
1608
|
+
6.9
|
|
1609
|
+
],
|
|
1610
|
+
size: [
|
|
1611
|
+
2.6,
|
|
1612
|
+
5.2,
|
|
1613
|
+
1.2
|
|
1614
|
+
],
|
|
1615
|
+
color: "#06b6d4",
|
|
1616
|
+
shade: "flat",
|
|
1617
|
+
outline: false
|
|
1618
|
+
}
|
|
1619
|
+
]
|
|
1620
|
+
},
|
|
1621
|
+
ballistaTurret: {
|
|
1622
|
+
id: "craft:krafteers:ballista",
|
|
1623
|
+
name: " Twin-Arm Defense Ballista",
|
|
1624
|
+
group: "game",
|
|
1625
|
+
tilesW: 2,
|
|
1626
|
+
tilesD: 2,
|
|
1627
|
+
frameW: 46,
|
|
1628
|
+
frameH: 52,
|
|
1629
|
+
dirs: 4,
|
|
1630
|
+
baseY: 44,
|
|
1631
|
+
solidMask: 15,
|
|
1632
|
+
primitives: [
|
|
1633
|
+
{
|
|
1634
|
+
shape: "cylinder",
|
|
1635
|
+
pos: [
|
|
1636
|
+
0,
|
|
1637
|
+
5,
|
|
1638
|
+
0
|
|
1639
|
+
],
|
|
1640
|
+
size: [
|
|
1641
|
+
13,
|
|
1642
|
+
10,
|
|
1643
|
+
13
|
|
1644
|
+
],
|
|
1645
|
+
color: "#64748b"
|
|
1646
|
+
},
|
|
1647
|
+
{
|
|
1648
|
+
shape: "cylinder",
|
|
1649
|
+
pos: [
|
|
1650
|
+
0,
|
|
1651
|
+
12,
|
|
1652
|
+
0
|
|
1653
|
+
],
|
|
1654
|
+
size: [
|
|
1655
|
+
9.5,
|
|
1656
|
+
6,
|
|
1657
|
+
9.5
|
|
1658
|
+
],
|
|
1659
|
+
color: "#b45309"
|
|
1660
|
+
},
|
|
1661
|
+
{
|
|
1662
|
+
shape: "box",
|
|
1663
|
+
pos: [
|
|
1664
|
+
0,
|
|
1665
|
+
18.5,
|
|
1666
|
+
2
|
|
1667
|
+
],
|
|
1668
|
+
size: [
|
|
1669
|
+
3.2,
|
|
1670
|
+
2.6,
|
|
1671
|
+
11.5
|
|
1672
|
+
],
|
|
1673
|
+
color: "#d97706"
|
|
1674
|
+
},
|
|
1675
|
+
{
|
|
1676
|
+
shape: "box",
|
|
1677
|
+
pos: [
|
|
1678
|
+
0,
|
|
1679
|
+
19.2,
|
|
1680
|
+
8.5
|
|
1681
|
+
],
|
|
1682
|
+
size: [
|
|
1683
|
+
13.5,
|
|
1684
|
+
1.8,
|
|
1685
|
+
2.2
|
|
1686
|
+
],
|
|
1687
|
+
color: "#475569"
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
shape: "cylinder",
|
|
1691
|
+
pos: [
|
|
1692
|
+
0,
|
|
1693
|
+
20.8,
|
|
1694
|
+
5.5
|
|
1695
|
+
],
|
|
1696
|
+
size: [
|
|
1697
|
+
1.1,
|
|
1698
|
+
14,
|
|
1699
|
+
1.1
|
|
1700
|
+
],
|
|
1701
|
+
rot: [
|
|
1702
|
+
Math.PI * .5,
|
|
1703
|
+
0,
|
|
1704
|
+
0
|
|
1705
|
+
],
|
|
1706
|
+
color: "#e2e8f0"
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
shape: "cone",
|
|
1710
|
+
pos: [
|
|
1711
|
+
0,
|
|
1712
|
+
20.8,
|
|
1713
|
+
13.5
|
|
1714
|
+
],
|
|
1715
|
+
size: [
|
|
1716
|
+
2.2,
|
|
1717
|
+
4.5,
|
|
1718
|
+
2.2
|
|
1719
|
+
],
|
|
1720
|
+
rot: [
|
|
1721
|
+
Math.PI * .5,
|
|
1722
|
+
0,
|
|
1723
|
+
0
|
|
1724
|
+
],
|
|
1725
|
+
color: "#ef4444"
|
|
1726
|
+
}
|
|
1727
|
+
]
|
|
1728
|
+
},
|
|
1729
|
+
fortressWall: {
|
|
1730
|
+
id: "craft:krafteers:wall",
|
|
1731
|
+
name: "Reinforced Bastion Wall",
|
|
1732
|
+
group: "game",
|
|
1733
|
+
tilesW: 1,
|
|
1734
|
+
tilesD: 1,
|
|
1735
|
+
frameW: 40,
|
|
1736
|
+
frameH: 46,
|
|
1737
|
+
dirs: 4,
|
|
1738
|
+
baseY: 39,
|
|
1739
|
+
solidMask: 1,
|
|
1740
|
+
primitives: [
|
|
1741
|
+
{
|
|
1742
|
+
shape: "box",
|
|
1743
|
+
pos: [
|
|
1744
|
+
0,
|
|
1745
|
+
10.5,
|
|
1746
|
+
0
|
|
1747
|
+
],
|
|
1748
|
+
size: [
|
|
1749
|
+
11.5,
|
|
1750
|
+
10.5,
|
|
1751
|
+
9.5
|
|
1752
|
+
],
|
|
1753
|
+
color: "#94a3b8"
|
|
1754
|
+
},
|
|
1755
|
+
{
|
|
1756
|
+
shape: "box",
|
|
1757
|
+
pos: [
|
|
1758
|
+
0,
|
|
1759
|
+
21.5,
|
|
1760
|
+
0
|
|
1761
|
+
],
|
|
1762
|
+
size: [
|
|
1763
|
+
12.5,
|
|
1764
|
+
2.4,
|
|
1765
|
+
10.5
|
|
1766
|
+
],
|
|
1767
|
+
color: "#cbd5e1"
|
|
1768
|
+
},
|
|
1769
|
+
{
|
|
1770
|
+
shape: "cylinder",
|
|
1771
|
+
pos: [
|
|
1772
|
+
-9.2,
|
|
1773
|
+
13,
|
|
1774
|
+
7.5
|
|
1775
|
+
],
|
|
1776
|
+
size: [
|
|
1777
|
+
3.2,
|
|
1778
|
+
26,
|
|
1779
|
+
3.2
|
|
1780
|
+
],
|
|
1781
|
+
color: "#b45309"
|
|
1782
|
+
},
|
|
1783
|
+
{
|
|
1784
|
+
shape: "cylinder",
|
|
1785
|
+
pos: [
|
|
1786
|
+
9.2,
|
|
1787
|
+
13,
|
|
1788
|
+
7.5
|
|
1789
|
+
],
|
|
1790
|
+
size: [
|
|
1791
|
+
3.2,
|
|
1792
|
+
26,
|
|
1793
|
+
3.2
|
|
1794
|
+
],
|
|
1795
|
+
color: "#b45309"
|
|
1796
|
+
}
|
|
1797
|
+
]
|
|
1798
|
+
},
|
|
1799
|
+
stylizedTree: {
|
|
1800
|
+
id: "craft:krafteers:tree",
|
|
1801
|
+
name: "Lush Island Canopy Tree",
|
|
1802
|
+
group: "nature",
|
|
1803
|
+
tilesW: 1,
|
|
1804
|
+
tilesD: 1,
|
|
1805
|
+
frameW: 46,
|
|
1806
|
+
frameH: 58,
|
|
1807
|
+
dirs: 1,
|
|
1808
|
+
baseY: 50,
|
|
1809
|
+
solidMask: 1,
|
|
1810
|
+
primitives: [
|
|
1811
|
+
{
|
|
1812
|
+
shape: "cylinder",
|
|
1813
|
+
pos: [
|
|
1814
|
+
0,
|
|
1815
|
+
9,
|
|
1816
|
+
0
|
|
1817
|
+
],
|
|
1818
|
+
size: [
|
|
1819
|
+
3.8,
|
|
1820
|
+
18,
|
|
1821
|
+
3.8
|
|
1822
|
+
],
|
|
1823
|
+
color: "#92400e"
|
|
1824
|
+
},
|
|
1825
|
+
{
|
|
1826
|
+
shape: "ellipsoid",
|
|
1827
|
+
pos: [
|
|
1828
|
+
-6.5,
|
|
1829
|
+
23,
|
|
1830
|
+
2
|
|
1831
|
+
],
|
|
1832
|
+
size: [
|
|
1833
|
+
9.5,
|
|
1834
|
+
8.2,
|
|
1835
|
+
9
|
|
1836
|
+
],
|
|
1837
|
+
color: "#16a34a"
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
shape: "ellipsoid",
|
|
1841
|
+
pos: [
|
|
1842
|
+
6.8,
|
|
1843
|
+
24,
|
|
1844
|
+
1.5
|
|
1845
|
+
],
|
|
1846
|
+
size: [
|
|
1847
|
+
9.2,
|
|
1848
|
+
8,
|
|
1849
|
+
8.8
|
|
1850
|
+
],
|
|
1851
|
+
color: "#22c55e"
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
shape: "ellipsoid",
|
|
1855
|
+
pos: [
|
|
1856
|
+
0,
|
|
1857
|
+
31,
|
|
1858
|
+
0
|
|
1859
|
+
],
|
|
1860
|
+
size: [
|
|
1861
|
+
11.2,
|
|
1862
|
+
10.2,
|
|
1863
|
+
10.8
|
|
1864
|
+
],
|
|
1865
|
+
color: "#4ade80"
|
|
1866
|
+
}
|
|
1867
|
+
]
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
};
|
|
1871
|
+
export { renderHdCharacterCell as a, hd3d_exports as i, bakeHdCharacterSheet as n, renderHdPropSheet as o, bakeHdDualGridSheet as r, renderHdPropSprite as s, KRAFTEERS_PRESETS as t };
|