spine-html 1.25.0 → 1.26.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/NOTICE.md +1 -1
- package/README.md +7 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +197 -117
- package/dist/index.js.map +1 -1
- package/dist/turnDials.d.ts +26 -0
- package/dist/turnDials.d.ts.map +1 -0
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -160,7 +160,7 @@ const DEFORM_CURVE_END = 0.99999999;
|
|
|
160
160
|
const SEQUENCE_MODES = ["hold", "once", "loop", "pingpong", "onceReverse", "loopReverse", "pingpongReverse"];
|
|
161
161
|
const SEQUENCE_EPSILON = 1e-5;
|
|
162
162
|
const isRecord$a = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
163
|
-
const finite$
|
|
163
|
+
const finite$3 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
164
164
|
function deformLength(vertices) {
|
|
165
165
|
return vertices.weighted ? 2 * vertices.bindings.reduce((n, b) => n + b.length, 0) : vertices.xy.length;
|
|
166
166
|
}
|
|
@@ -169,9 +169,9 @@ function keyTimes(list, at, problems) {
|
|
|
169
169
|
list.forEach((k, i) => {
|
|
170
170
|
if (!isRecord$a(k)) return;
|
|
171
171
|
const t = k.time;
|
|
172
|
-
if (!finite$
|
|
172
|
+
if (!finite$3(t) || t < 0) problems.push(`${at}[${i}]: time is ${JSON.stringify(t)}, not a finite time at or after 0`);
|
|
173
173
|
else if (t <= last) problems.push(`${at}[${i}]: time ${t} is not after the key before it — the writer refuses key times that do not strictly increase`);
|
|
174
|
-
if (finite$
|
|
174
|
+
if (finite$3(t)) last = Math.max(last, t);
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
function readDeformKeys(value, at, vertices, problems) {
|
|
@@ -192,7 +192,7 @@ function readDeformKeys(value, at, vertices, problems) {
|
|
|
192
192
|
const run = k.vertices;
|
|
193
193
|
let vertexRun = [];
|
|
194
194
|
if (run !== void 0) {
|
|
195
|
-
if (!Array.isArray(run) || run.length === 0 || !run.every(finite$
|
|
195
|
+
if (!Array.isArray(run) || run.length === 0 || !run.every(finite$3)) problems.push(`${kat}: vertices is not a non-empty list of finite numbers (omit it for the setup geometry)`);
|
|
196
196
|
else vertexRun = run;
|
|
197
197
|
}
|
|
198
198
|
let offset = 0;
|
|
@@ -206,10 +206,10 @@ function readDeformKeys(value, at, vertices, problems) {
|
|
|
206
206
|
if (k.curve !== void 0) {
|
|
207
207
|
if (i === value.length - 1) problems.push(`${kat}: the last key carries a curve, which eases to no key — the writer refuses it`);
|
|
208
208
|
else if (k.curve === "stepped") curve = "stepped";
|
|
209
|
-
else if (Array.isArray(k.curve) && k.curve.length === 4 && k.curve.every(finite$
|
|
209
|
+
else if (Array.isArray(k.curve) && k.curve.length === 4 && k.curve.every(finite$3)) curve = k.curve;
|
|
210
210
|
else problems.push(`${kat}: curve is ${JSON.stringify(k.curve)}, not "stepped" nor 4 finite numbers (a deform key's curve is one channel)`);
|
|
211
211
|
}
|
|
212
|
-
const time = finite$
|
|
212
|
+
const time = finite$3(k.time) ? k.time : 0;
|
|
213
213
|
out.push({ time: Math.fround(time), stated: time, curve, offset, vertices: vertexRun });
|
|
214
214
|
});
|
|
215
215
|
return out;
|
|
@@ -241,10 +241,10 @@ function readSequenceKeys(value, at, count, problems) {
|
|
|
241
241
|
}
|
|
242
242
|
let delay = out.length === 0 ? 0 : out[out.length - 1].delay;
|
|
243
243
|
if (k.delay !== void 0) {
|
|
244
|
-
if (!finite$
|
|
244
|
+
if (!finite$3(k.delay) || k.delay < 0) problems.push(`${kat}: delay is ${JSON.stringify(k.delay)}, not a finite number of seconds at or above 0`);
|
|
245
245
|
else delay = Math.fround(k.delay);
|
|
246
246
|
}
|
|
247
|
-
out.push({ time: Math.fround(finite$
|
|
247
|
+
out.push({ time: Math.fround(finite$3(k.time) ? k.time : 0), mode, index, delay });
|
|
248
248
|
});
|
|
249
249
|
return out;
|
|
250
250
|
}
|
|
@@ -285,18 +285,18 @@ function readAttachmentTimelines(value, label, skins, problems) {
|
|
|
285
285
|
return;
|
|
286
286
|
}
|
|
287
287
|
for (const key of Object.keys(attEntry)) if (!["name", "deform", "sequence"].includes(key)) problems.push(`${aat}: field "${key}" is not one this reader knows; it reads [name, deform, sequence]`);
|
|
288
|
-
const
|
|
288
|
+
const record2 = skin?.attachments[slot]?.[attEntry.name];
|
|
289
289
|
const label2 = `${aat} "${skinEntry.name}/${slot}/${attEntry.name}"`;
|
|
290
|
-
if (skin !== void 0 &&
|
|
290
|
+
if (skin !== void 0 && record2 === void 0) problems.push(`${label2}: skin "${skin.name}" files no attachment "${attEntry.name}" under slot "${slot}"`);
|
|
291
291
|
const timeline = { skin: skinEntry.name, slot, attachment: attEntry.name, deform: null, sequence: null };
|
|
292
|
-
if (attEntry.deform !== void 0 &&
|
|
293
|
-
const g =
|
|
294
|
-
if (g === void 0 || g.kind !== "mesh" && g.kind !== "clipping" && g.kind !== "boundingbox" && g.kind !== "path") problems.push(`${label2}: a deform keys the vertices of a mesh, bounding box, clipping or path attachment, and this one is a ${
|
|
292
|
+
if (attEntry.deform !== void 0 && record2 !== void 0) {
|
|
293
|
+
const g = record2.geometry;
|
|
294
|
+
if (g === void 0 || g.kind !== "mesh" && g.kind !== "clipping" && g.kind !== "boundingbox" && g.kind !== "path") problems.push(`${label2}: a deform keys the vertices of a mesh, bounding box, clipping or path attachment, and this one is a ${record2.kind}`);
|
|
295
295
|
else timeline.deform = readDeformKeys(attEntry.deform, `${label2}.deform`, g.vertices, problems);
|
|
296
296
|
}
|
|
297
|
-
if (attEntry.sequence !== void 0 &&
|
|
298
|
-
const count =
|
|
299
|
-
if (count === void 0) problems.push(`${label2}: a sequence timeline steps a series, and this ${
|
|
297
|
+
if (attEntry.sequence !== void 0 && record2 !== void 0) {
|
|
298
|
+
const count = record2.sequenceCount;
|
|
299
|
+
if (count === void 0) problems.push(`${label2}: a sequence timeline steps a series, and this ${record2.kind} carries no sequence`);
|
|
300
300
|
else timeline.sequence = readSequenceKeys(attEntry.sequence, `${label2}.sequence`, count, problems);
|
|
301
301
|
}
|
|
302
302
|
if (attEntry.deform === void 0 && attEntry.sequence === void 0) problems.push(`${label2}: carries neither a deform nor a sequence timeline`);
|
|
@@ -1174,7 +1174,7 @@ function deformedWorldVertices(vertices, deform, bone2, world) {
|
|
|
1174
1174
|
return compiledDeformedWorldVertices(compiledWeightedOf(vertices), deform, world);
|
|
1175
1175
|
}
|
|
1176
1176
|
const isRecord$7 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1177
|
-
const finite$
|
|
1177
|
+
const finite$2 = (v) => typeof v === "number" && Number.isFinite(v);
|
|
1178
1178
|
const RECT_FIELDS = ["width", "height", "offsetX", "offsetY", "originalWidth", "originalHeight"];
|
|
1179
1179
|
function readRect(value, where, problems) {
|
|
1180
1180
|
if (!isRecord$7(value)) {
|
|
@@ -1183,7 +1183,7 @@ function readRect(value, where, problems) {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
const before = problems.length;
|
|
1185
1185
|
for (const key of Object.keys(value)) if (!RECT_FIELDS.includes(key)) problems.push(`${where}: field "${key}" is not one this reader knows; it reads [${RECT_FIELDS.join(", ")}]`);
|
|
1186
|
-
for (const key of RECT_FIELDS) if (!finite$
|
|
1186
|
+
for (const key of RECT_FIELDS) if (!finite$2(value[key])) problems.push(`${where}: ${key} is ${JSON.stringify(value[key]) ?? "absent"}, not a finite number`);
|
|
1187
1187
|
return problems.length === before ? value : void 0;
|
|
1188
1188
|
}
|
|
1189
1189
|
function readVertices(value, where, bones, problems) {
|
|
@@ -1194,7 +1194,7 @@ function readVertices(value, where, bones, problems) {
|
|
|
1194
1194
|
const before = problems.length;
|
|
1195
1195
|
if (!value.weighted) {
|
|
1196
1196
|
const xy = value.xy;
|
|
1197
|
-
if (!Array.isArray(xy) || xy.length % 2 !== 0 || !xy.every(finite$
|
|
1197
|
+
if (!Array.isArray(xy) || xy.length % 2 !== 0 || !xy.every(finite$2)) problems.push(`${where}.xy is not an even-length list of finite numbers`);
|
|
1198
1198
|
return problems.length === before ? { weighted: false, xy } : void 0;
|
|
1199
1199
|
}
|
|
1200
1200
|
const bindings = value.bindings;
|
|
@@ -1214,7 +1214,7 @@ function readVertices(value, where, bones, problems) {
|
|
|
1214
1214
|
return;
|
|
1215
1215
|
}
|
|
1216
1216
|
if (typeof b.bone !== "string" || !bones.has(b.bone)) problems.push(`${at}: bone ${JSON.stringify(b.bone)} is not a bone of this document`);
|
|
1217
|
-
for (const key of ["x", "y", "weight"]) if (!finite$
|
|
1217
|
+
for (const key of ["x", "y", "weight"]) if (!finite$2(b[key])) problems.push(`${at}: ${key} is ${JSON.stringify(b[key]) ?? "absent"}, not a finite number`);
|
|
1218
1218
|
});
|
|
1219
1219
|
});
|
|
1220
1220
|
if (problems.length !== before) return void 0;
|
|
@@ -1226,8 +1226,8 @@ function readGeometry(raw, kind, where, bones, slots, problems) {
|
|
|
1226
1226
|
const before = problems.length;
|
|
1227
1227
|
switch (kind) {
|
|
1228
1228
|
case "region": {
|
|
1229
|
-
for (const key of ["x", "y", "rotation", "scaleX", "scaleY"]) if (raw[key] !== void 0 && !finite$
|
|
1230
|
-
for (const key of ["width", "height"]) if (!finite$
|
|
1229
|
+
for (const key of ["x", "y", "rotation", "scaleX", "scaleY"]) if (raw[key] !== void 0 && !finite$2(raw[key])) problems.push(`${where}: ${key} is ${JSON.stringify(raw[key])}, not a finite number`);
|
|
1230
|
+
for (const key of ["width", "height"]) if (!finite$2(raw[key])) problems.push(`${where}: ${key} is ${JSON.stringify(raw[key]) ?? "absent"}, not a finite number`);
|
|
1231
1231
|
const hasRect = raw.atlas !== void 0;
|
|
1232
1232
|
const hasSequence = raw.sequence !== void 0;
|
|
1233
1233
|
let atlas;
|
|
@@ -1288,7 +1288,7 @@ function readMeshTriangles(raw, vertices, where, problems) {
|
|
|
1288
1288
|
const count = vertices.weighted ? vertices.bindings.length : vertices.xy.length / 2;
|
|
1289
1289
|
const uvs = raw.uvs;
|
|
1290
1290
|
const triangles = raw.triangles;
|
|
1291
|
-
if (!Array.isArray(uvs) || !uvs.every(finite$
|
|
1291
|
+
if (!Array.isArray(uvs) || !uvs.every(finite$2) || uvs.length !== 2 * count) problems.push(`${where}.uvs is not ${2 * count} finite numbers, one pair per vertex`);
|
|
1292
1292
|
if (!Array.isArray(triangles) || triangles.length % 3 !== 0 || !triangles.every((i) => Number.isInteger(i) && i >= 0 && i < count)) problems.push(`${where}.triangles is not a list of whole indices below ${count}, in threes`);
|
|
1293
1293
|
const hull = raw.hull;
|
|
1294
1294
|
if (hull !== void 0 && !(typeof hull === "number" && Number.isInteger(hull) && hull >= 0 && hull <= count)) problems.push(`${where}.hull is ${JSON.stringify(hull)}, not a whole number of vertices from 0 to ${count}`);
|
|
@@ -1301,7 +1301,7 @@ function readPathGeometry(raw, vertices, where, problems) {
|
|
|
1301
1301
|
if (raw.vertexCount !== count) problems.push(`${where}: vertexCount is ${JSON.stringify(raw.vertexCount) ?? "absent"}, and the vertices hold ${count} point(s)`);
|
|
1302
1302
|
else if (count % 3 !== 0 || count < (raw.closed === true ? 3 : 6)) problems.push(`${where}: vertexCount is ${count}, not a multiple of 3 of at least ${raw.closed === true ? 3 : 6} — the curve walk reads knots and handles in threes`);
|
|
1303
1303
|
const lengths = raw.lengths;
|
|
1304
|
-
if (!Array.isArray(lengths) || !lengths.every(finite$
|
|
1304
|
+
if (!Array.isArray(lengths) || !lengths.every(finite$2)) problems.push(`${where}: lengths is not a list of finite numbers`);
|
|
1305
1305
|
else if (lengths.length !== count / 3) problems.push(`${where}: lengths has ${lengths.length} entry(ies) where the vertices make ${count / 3}`);
|
|
1306
1306
|
if (problems.length !== before) return void 0;
|
|
1307
1307
|
return { kind: "path", vertices, closed: raw.closed === true, constantSpeed: raw.constantSpeed !== false, lengths };
|
|
@@ -1458,7 +1458,7 @@ function readPathRecord(raw, name, where, bones, slots, problems) {
|
|
|
1458
1458
|
if (slotBone === void 0) problems.push(`${where}: slot is ${JSON.stringify(raw.slot)}, not a slot of this document`);
|
|
1459
1459
|
if (raw.skin !== void 0 && typeof raw.skin !== "boolean") problems.push(`${where}: skin is ${JSON.stringify(raw.skin)}, not a boolean`);
|
|
1460
1460
|
const mixX = num$1(raw, "mixX", 1, where, problems);
|
|
1461
|
-
const
|
|
1461
|
+
const record2 = {
|
|
1462
1462
|
kind: "path",
|
|
1463
1463
|
name,
|
|
1464
1464
|
bones: list,
|
|
@@ -1479,10 +1479,10 @@ function readPathRecord(raw, name, where, bones, slots, problems) {
|
|
|
1479
1479
|
unresolved: null,
|
|
1480
1480
|
slotDeps: []
|
|
1481
1481
|
};
|
|
1482
|
-
return problems.length === before ?
|
|
1482
|
+
return problems.length === before ? record2 : void 0;
|
|
1483
1483
|
}
|
|
1484
1484
|
const PATH_TIMELINES = { position: ["value"], spacing: ["value"], mix: ["mixRotate", "mixX", "mixY"] };
|
|
1485
|
-
function keyCurve$1(raw,
|
|
1485
|
+
function keyCurve$1(raw, channels2, last, at, problems) {
|
|
1486
1486
|
const curve = raw.curve;
|
|
1487
1487
|
if (curve === void 0) return "linear";
|
|
1488
1488
|
if (last) {
|
|
@@ -1490,8 +1490,8 @@ function keyCurve$1(raw, channels, last, at, problems) {
|
|
|
1490
1490
|
return "linear";
|
|
1491
1491
|
}
|
|
1492
1492
|
if (curve === "stepped") return "stepped";
|
|
1493
|
-
if (!Array.isArray(curve) || curve.length !==
|
|
1494
|
-
problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${
|
|
1493
|
+
if (!Array.isArray(curve) || curve.length !== channels2 * 4 || !curve.every((n) => typeof n === "number" && Number.isFinite(n))) {
|
|
1494
|
+
problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${channels2 * 4} finite numbers (four per channel)`);
|
|
1495
1495
|
return "linear";
|
|
1496
1496
|
}
|
|
1497
1497
|
return curve;
|
|
@@ -1519,7 +1519,7 @@ function readPathTimelines(value, label, declared, problems) {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
const kind = tl.name;
|
|
1521
1521
|
if (tls[kind] !== void 0) problems.push(`${tat}: "${kind}" is keyed twice on path constraint "${entry.name}"`);
|
|
1522
|
-
const
|
|
1522
|
+
const channels2 = PATH_TIMELINES[kind];
|
|
1523
1523
|
const rawKeys = tl.keys;
|
|
1524
1524
|
if (!Array.isArray(rawKeys) || rawKeys.length === 0) {
|
|
1525
1525
|
problems.push(`${tat}: keys is not a non-empty list`);
|
|
@@ -1533,7 +1533,7 @@ function readPathTimelines(value, label, declared, problems) {
|
|
|
1533
1533
|
problems.push(`${kat} is not an object`);
|
|
1534
1534
|
return;
|
|
1535
1535
|
}
|
|
1536
|
-
for (const f of Object.keys(k)) if (f !== "time" && f !== "curve" && !
|
|
1536
|
+
for (const f of Object.keys(k)) if (f !== "time" && f !== "curve" && !channels2.includes(f)) problems.push(`${kat}: field "${f}" is not one this reader knows; it reads [time, ${channels2.join(", ")}, curve]`);
|
|
1537
1537
|
const time = k.time;
|
|
1538
1538
|
if (typeof time !== "number" || !Number.isFinite(time) || time < 0) {
|
|
1539
1539
|
problems.push(`${kat}: time is ${JSON.stringify(time)}, not a finite time at or after 0`);
|
|
@@ -1541,11 +1541,11 @@ function readPathTimelines(value, label, declared, problems) {
|
|
|
1541
1541
|
}
|
|
1542
1542
|
if (time <= last) problems.push(`${kat}: time ${time} is not after the key before it — the writer refuses key times that do not strictly increase`);
|
|
1543
1543
|
last = Math.max(last, time);
|
|
1544
|
-
const stated =
|
|
1544
|
+
const stated = channels2.map((c) => {
|
|
1545
1545
|
if (c === "mixY" && k.mixY === void 0) return num$1(k, "mixX", 1, kat, problems);
|
|
1546
1546
|
return num$1(k, c, kind === "mix" ? 1 : 0, kat, problems);
|
|
1547
1547
|
});
|
|
1548
|
-
keys.push({ time: Math.fround(time), values: stated.map(Math.fround), stated: { time, values: stated }, curve: keyCurve$1(k,
|
|
1548
|
+
keys.push({ time: Math.fround(time), values: stated.map(Math.fround), stated: { time, values: stated }, curve: keyCurve$1(k, channels2.length, n === rawKeys.length - 1, kat, problems) });
|
|
1549
1549
|
});
|
|
1550
1550
|
tls[kind] = keys;
|
|
1551
1551
|
});
|
|
@@ -2412,7 +2412,7 @@ function readSliderRecord(raw, name, where, bones, animations, problems) {
|
|
|
2412
2412
|
const b = byName.get(target.name);
|
|
2413
2413
|
if (b !== void 0) setup.set(b.name, b);
|
|
2414
2414
|
}
|
|
2415
|
-
const
|
|
2415
|
+
const record2 = {
|
|
2416
2416
|
kind: "slider",
|
|
2417
2417
|
name,
|
|
2418
2418
|
animation: anim?.name ?? "",
|
|
@@ -2432,7 +2432,7 @@ function readSliderRecord(raw, name, where, bones, animations, problems) {
|
|
|
2432
2432
|
skin: flag2("skin"),
|
|
2433
2433
|
listedBySkin: false
|
|
2434
2434
|
};
|
|
2435
|
-
return problems.length === before ?
|
|
2435
|
+
return problems.length === before ? record2 : void 0;
|
|
2436
2436
|
}
|
|
2437
2437
|
function readSliderTimelines(value, label, declared, problems) {
|
|
2438
2438
|
const out = [];
|
|
@@ -2717,8 +2717,8 @@ const CONSTRAINT_FIELDS = {
|
|
|
2717
2717
|
transform: ["bones", "source", "properties", "localSource", "localTarget", "additive", "clamp", "rotation", "x", "y", "scaleX", "scaleY", "shearY", "mixRotate", "mixX", "mixY", "mixScaleX", "mixScaleY", "mixShearY", "skin"]
|
|
2718
2718
|
};
|
|
2719
2719
|
const isRecord$4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2720
|
-
function unknownFields$1(
|
|
2721
|
-
for (const key of Object.keys(
|
|
2720
|
+
function unknownFields$1(record2, known, where, problems) {
|
|
2721
|
+
for (const key of Object.keys(record2)) if (!known.includes(key)) problems.push(`${where}: field "${key}" is not one this reader knows; it reads [${known.join(", ")}]`);
|
|
2722
2722
|
}
|
|
2723
2723
|
function num(raw, key, dflt, where, problems) {
|
|
2724
2724
|
const v = raw[key];
|
|
@@ -2786,7 +2786,7 @@ function readConstraintRecord(raw, kind, name, where, bones, parents, problems)
|
|
|
2786
2786
|
if (mode === void 0) problems.push(`${where}: scaleY is ${JSON.stringify(raw.scaleY)}, none of ${IK_SCALE_Y_MODES.join(", ")}`);
|
|
2787
2787
|
else scaleY = mode;
|
|
2788
2788
|
}
|
|
2789
|
-
const
|
|
2789
|
+
const record22 = {
|
|
2790
2790
|
kind,
|
|
2791
2791
|
name,
|
|
2792
2792
|
bones: list,
|
|
@@ -2800,7 +2800,7 @@ function readConstraintRecord(raw, kind, name, where, bones, parents, problems)
|
|
|
2800
2800
|
compress: flag(raw, "compress", false, where, problems),
|
|
2801
2801
|
stretch: flag(raw, "stretch", false, where, problems)
|
|
2802
2802
|
};
|
|
2803
|
-
return problems.length === before ?
|
|
2803
|
+
return problems.length === before ? record22 : void 0;
|
|
2804
2804
|
}
|
|
2805
2805
|
const source = boneRef(raw, "source", bones, where, problems);
|
|
2806
2806
|
const properties = [];
|
|
@@ -2847,7 +2847,7 @@ function readConstraintRecord(raw, kind, name, where, bones, parents, problems)
|
|
|
2847
2847
|
offsets[p] = num(raw, TRANSFORM_OFFSETS[p], 0, where, problems);
|
|
2848
2848
|
mixes[p] = resolvedMix(raw, p, driven, where, problems);
|
|
2849
2849
|
}
|
|
2850
|
-
const
|
|
2850
|
+
const record2 = {
|
|
2851
2851
|
kind,
|
|
2852
2852
|
name,
|
|
2853
2853
|
bones: list,
|
|
@@ -2862,11 +2862,11 @@ function readConstraintRecord(raw, kind, name, where, bones, parents, problems)
|
|
|
2862
2862
|
additive: flag(raw, "additive", false, where, problems),
|
|
2863
2863
|
clamp: flag(raw, "clamp", false, where, problems)
|
|
2864
2864
|
};
|
|
2865
|
-
return problems.length === before ?
|
|
2865
|
+
return problems.length === before ? record2 : void 0;
|
|
2866
2866
|
}
|
|
2867
2867
|
const IK_KEY_CHANNELS = ["mix", "softness"];
|
|
2868
2868
|
const TRANSFORM_KEY_CHANNELS = ["mixRotate", "mixX", "mixY", "mixScaleX", "mixScaleY", "mixShearY"];
|
|
2869
|
-
function keyCurve(raw,
|
|
2869
|
+
function keyCurve(raw, channels2, last, at, problems) {
|
|
2870
2870
|
const curve = raw.curve;
|
|
2871
2871
|
if (curve === void 0) return "linear";
|
|
2872
2872
|
if (last) {
|
|
@@ -2874,8 +2874,8 @@ function keyCurve(raw, channels, last, at, problems) {
|
|
|
2874
2874
|
return "linear";
|
|
2875
2875
|
}
|
|
2876
2876
|
if (curve === "stepped") return "stepped";
|
|
2877
|
-
if (!Array.isArray(curve) || curve.length !==
|
|
2878
|
-
problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${
|
|
2877
|
+
if (!Array.isArray(curve) || curve.length !== channels2 * 4 || !curve.every((n) => typeof n === "number" && Number.isFinite(n))) {
|
|
2878
|
+
problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${channels2 * 4} finite numbers (four per channel)`);
|
|
2879
2879
|
return "linear";
|
|
2880
2880
|
}
|
|
2881
2881
|
return curve;
|
|
@@ -2902,7 +2902,7 @@ function readConstraintTimelines(value, label, declared, problems) {
|
|
|
2902
2902
|
problems.push(`${at}: keys is not a non-empty list`);
|
|
2903
2903
|
return;
|
|
2904
2904
|
}
|
|
2905
|
-
const
|
|
2905
|
+
const channels2 = kind === "ik" ? IK_KEY_CHANNELS : TRANSFORM_KEY_CHANNELS;
|
|
2906
2906
|
const known = kind === "ik" ? ["time", ...IK_KEY_CHANNELS, "bendPositive", "compress", "stretch", "curve"] : ["time", ...TRANSFORM_KEY_CHANNELS, "curve"];
|
|
2907
2907
|
let last = -Infinity;
|
|
2908
2908
|
const keys = [];
|
|
@@ -2920,7 +2920,7 @@ function readConstraintTimelines(value, label, declared, problems) {
|
|
|
2920
2920
|
}
|
|
2921
2921
|
if (time <= last) problems.push(`${kat}: time ${time} is not after the key before it — the writer refuses key times that do not strictly increase`);
|
|
2922
2922
|
last = Math.max(last, time);
|
|
2923
|
-
const stated =
|
|
2923
|
+
const stated = channels2.map((c) => {
|
|
2924
2924
|
if (kind === "transform" && c === "mixY" && k.mixY === void 0) return num(k, "mixX", 1, kat, problems);
|
|
2925
2925
|
return num(k, c, c === "softness" ? 0 : 1, kat, problems);
|
|
2926
2926
|
});
|
|
@@ -2928,7 +2928,7 @@ function readConstraintTimelines(value, label, declared, problems) {
|
|
|
2928
2928
|
time: Math.fround(time),
|
|
2929
2929
|
values: stated.map(Math.fround),
|
|
2930
2930
|
stated: { time, values: stated },
|
|
2931
|
-
curve: keyCurve(k,
|
|
2931
|
+
curve: keyCurve(k, channels2.length, j === rawKeys.length - 1, kat, problems),
|
|
2932
2932
|
flags: { bendPositive: flag(k, "bendPositive", true, kat, problems), compress: flag(k, "compress", false, kat, problems), stretch: flag(k, "stretch", false, kat, problems) }
|
|
2933
2933
|
});
|
|
2934
2934
|
});
|
|
@@ -3762,7 +3762,7 @@ function keyList(value, where, problems) {
|
|
|
3762
3762
|
function unknownKeyFields(raw, known, at, problems) {
|
|
3763
3763
|
for (const key of Object.keys(raw)) if (!known.includes(key)) problems.push(`${at}: field "${key}" is not one this timeline's keys carry; they carry [${known.join(", ")}]`);
|
|
3764
3764
|
}
|
|
3765
|
-
function readCurve(raw,
|
|
3765
|
+
function readCurve(raw, channels2, last, at, problems) {
|
|
3766
3766
|
const curve = raw.curve;
|
|
3767
3767
|
if (curve === void 0) return "linear";
|
|
3768
3768
|
if (last) {
|
|
@@ -3770,8 +3770,8 @@ function readCurve(raw, channels, last, at, problems) {
|
|
|
3770
3770
|
return "linear";
|
|
3771
3771
|
}
|
|
3772
3772
|
if (curve === "stepped") return "stepped";
|
|
3773
|
-
if (!Array.isArray(curve) || curve.length !==
|
|
3774
|
-
problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${
|
|
3773
|
+
if (!Array.isArray(curve) || curve.length !== channels2 * 4 || !curve.every((n) => typeof n === "number" && Number.isFinite(n))) {
|
|
3774
|
+
problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${channels2 * 4} finite numbers (four per channel)`);
|
|
3775
3775
|
return "linear";
|
|
3776
3776
|
}
|
|
3777
3777
|
return curve;
|
|
@@ -3785,9 +3785,9 @@ function readBoneTimeline(kind, keysValue, where, problems) {
|
|
|
3785
3785
|
if (mode === null) problems.push(`${at}: inherit is ${JSON.stringify(raw.inherit)}, which folds to no inherit mode`);
|
|
3786
3786
|
return { time: Math.fround(time), values: [], stated: { time, values: [] }, curve: "stepped", mode: mode ?? "normal" };
|
|
3787
3787
|
}
|
|
3788
|
-
const
|
|
3789
|
-
unknownKeyFields(raw, ["time", ...
|
|
3790
|
-
const values2 =
|
|
3788
|
+
const channels2 = BONE_TIMELINE_CHANNELS[kind];
|
|
3789
|
+
unknownKeyFields(raw, ["time", ...channels2, "curve"], at, problems);
|
|
3790
|
+
const values2 = channels2.map((c) => {
|
|
3791
3791
|
const v = raw[c];
|
|
3792
3792
|
if (typeof v !== "number" || !Number.isFinite(v)) {
|
|
3793
3793
|
problems.push(`${at}: ${c} is ${JSON.stringify(v)}, not a finite number — the writer states every channel on every key`);
|
|
@@ -3795,7 +3795,7 @@ function readBoneTimeline(kind, keysValue, where, problems) {
|
|
|
3795
3795
|
}
|
|
3796
3796
|
return v;
|
|
3797
3797
|
});
|
|
3798
|
-
return { time: Math.fround(time), values: values2.map(Math.fround), stated: { time, values: values2 }, curve: readCurve(raw,
|
|
3798
|
+
return { time: Math.fround(time), values: values2.map(Math.fround), stated: { time, values: values2 }, curve: readCurve(raw, channels2.length, i === listed.length - 1, at, problems) };
|
|
3799
3799
|
});
|
|
3800
3800
|
}
|
|
3801
3801
|
function hexChannels(hex, count) {
|
|
@@ -4158,8 +4158,8 @@ function posedSlots(doc, timelines, t, plant = {}, sliders = [], placeholders) {
|
|
|
4158
4158
|
continue;
|
|
4159
4159
|
}
|
|
4160
4160
|
const v = valuesAt(tl.keys, t, plant);
|
|
4161
|
-
const
|
|
4162
|
-
|
|
4161
|
+
const channels2 = SLOT_COLOUR_TIMELINES[tl.kind].channels;
|
|
4162
|
+
channels2.forEach((name, i) => {
|
|
4163
4163
|
const at = { r: 0, g: 1, b: 2, a: 3, r2: 4, g2: 5, b2: 6 }[name];
|
|
4164
4164
|
if (at < 4) light[at] = v === null ? setupLight[at] : clamp01$2(v[i]);
|
|
4165
4165
|
else if (dark !== null && setupDark !== null) dark[at - 4] = v === null ? setupDark[at - 4] : clamp01$2(v[i]);
|
|
@@ -4477,8 +4477,8 @@ function foldInheritMode(value) {
|
|
|
4477
4477
|
const folded = value.length === 0 ? value : value[0].toLowerCase() + value.slice(1);
|
|
4478
4478
|
return CORE_INHERIT_MODES.find((m) => m === folded) ?? null;
|
|
4479
4479
|
}
|
|
4480
|
-
function unknownFields(
|
|
4481
|
-
for (const key of Object.keys(
|
|
4480
|
+
function unknownFields(record2, known, where, problems) {
|
|
4481
|
+
for (const key of Object.keys(record2)) {
|
|
4482
4482
|
if (!known.includes(key)) problems.push(`${where}: field "${key}" is not one this reader knows; it reads [${known.join(", ")}]`);
|
|
4483
4483
|
}
|
|
4484
4484
|
}
|
|
@@ -4582,36 +4582,36 @@ function readAttachments(value, bones, slots, label, problems) {
|
|
|
4582
4582
|
continue;
|
|
4583
4583
|
}
|
|
4584
4584
|
unknownFields(raw, CORE_ATTACHMENT_FIELDS[kind], where, problems);
|
|
4585
|
-
const
|
|
4585
|
+
const record2 = { kind };
|
|
4586
4586
|
for (const key of ["name", "path"]) {
|
|
4587
4587
|
const v = raw[key];
|
|
4588
4588
|
if (v === void 0) continue;
|
|
4589
4589
|
if (typeof v !== "string" || v === "") problems.push(`${where}: ${key} is ${JSON.stringify(v)}, not a non-empty string`);
|
|
4590
|
-
else
|
|
4590
|
+
else record2[key] = v;
|
|
4591
4591
|
}
|
|
4592
4592
|
if (kind === "region" && raw.atlas !== void 0) {
|
|
4593
4593
|
const rect = readAtlasRect(raw.atlas, `${where}.atlas`, problems);
|
|
4594
|
-
if (rect !== void 0)
|
|
4594
|
+
if (rect !== void 0) record2.atlas = rect;
|
|
4595
4595
|
}
|
|
4596
4596
|
const geometry = readGeometry(raw, kind, where, bones, slots, problems);
|
|
4597
|
-
if (geometry !== void 0)
|
|
4597
|
+
if (geometry !== void 0) record2.geometry = geometry;
|
|
4598
4598
|
if (isRecord$2(raw.sequence)) {
|
|
4599
4599
|
const count = raw.sequence.count;
|
|
4600
|
-
if (typeof count === "number" && Number.isInteger(count) && count >= 1)
|
|
4600
|
+
if (typeof count === "number" && Number.isInteger(count) && count >= 1) record2.sequenceCount = count;
|
|
4601
4601
|
else if (kind !== "region") problems.push(`${where}.sequence: count is ${JSON.stringify(count)}, not a whole number of at least 1`);
|
|
4602
4602
|
const setupFrame = raw.sequence.setup ?? 0;
|
|
4603
|
-
if (typeof setupFrame === "number" && Number.isInteger(setupFrame) && setupFrame >= 0 && (typeof count !== "number" || setupFrame < count))
|
|
4603
|
+
if (typeof setupFrame === "number" && Number.isInteger(setupFrame) && setupFrame >= 0 && (typeof count !== "number" || setupFrame < count)) record2.sequenceSetup = setupFrame;
|
|
4604
4604
|
else if (kind !== "region") problems.push(`${where}.sequence: setup is ${JSON.stringify(raw.sequence.setup)}, not a frame of the ${JSON.stringify(count)}`);
|
|
4605
4605
|
}
|
|
4606
4606
|
if (raw.color !== void 0) {
|
|
4607
4607
|
if (typeof raw.color !== "string" || !HEX_COLOUR.test(raw.color)) problems.push(`${where}: color is ${JSON.stringify(raw.color)}, not six or eight hex digits`);
|
|
4608
|
-
else
|
|
4608
|
+
else record2.color = raw.color;
|
|
4609
4609
|
}
|
|
4610
4610
|
if (kind === "linkedmesh") {
|
|
4611
4611
|
if (typeof raw.timelines !== "boolean") problems.push(`${where}: timelines is ${JSON.stringify(raw.timelines) ?? "absent"}, not a boolean — the writer states whether the link plays its source's timelines`);
|
|
4612
|
-
else
|
|
4612
|
+
else record2.timelines = raw.timelines;
|
|
4613
4613
|
}
|
|
4614
|
-
entries[placeholder] =
|
|
4614
|
+
entries[placeholder] = record2;
|
|
4615
4615
|
}
|
|
4616
4616
|
out[slot] = entries;
|
|
4617
4617
|
}
|
|
@@ -4723,14 +4723,14 @@ function readConstraints(value, animations, bones, slots, referenceScale, proble
|
|
|
4723
4723
|
if (typeof raw.name !== "string" || raw.name === "") problems.push(`${where}: name is ${JSON.stringify(raw.name)}, not a non-empty string`);
|
|
4724
4724
|
if (raw.declaredIn !== "rig" && raw.declaredIn !== "motion") problems.push(`${where}: declaredIn is ${JSON.stringify(raw.declaredIn)}, not "rig" or "motion"`);
|
|
4725
4725
|
const at = `${where} "${String(raw.name)}"`;
|
|
4726
|
-
let
|
|
4726
|
+
let record2;
|
|
4727
4727
|
if (typeof raw.name === "string") {
|
|
4728
|
-
if (kind === "ik" || kind === "transform")
|
|
4729
|
-
else if (kind === "path")
|
|
4730
|
-
else if (kind === "physics")
|
|
4731
|
-
else if (kind === "slider")
|
|
4728
|
+
if (kind === "ik" || kind === "transform") record2 = readConstraintRecord(raw, kind, raw.name, at, names, parents, problems);
|
|
4729
|
+
else if (kind === "path") record2 = readPathRecord(raw, raw.name, at, names, slotBones, problems);
|
|
4730
|
+
else if (kind === "physics") record2 = readPhysicsRecord(raw, raw.name, at, names, referenceScale, problems);
|
|
4731
|
+
else if (kind === "slider") record2 = readSliderRecord(raw, raw.name, at, bones, animations, problems);
|
|
4732
4732
|
}
|
|
4733
|
-
if (kind !== void 0 && typeof raw.name === "string") out.push({ kind, name: raw.name, ...kind === "slider" && typeof raw.animation === "string" ? { animation: raw.animation } : {}, ...
|
|
4733
|
+
if (kind !== void 0 && typeof raw.name === "string") out.push({ kind, name: raw.name, ...kind === "slider" && typeof raw.animation === "string" ? { animation: raw.animation } : {}, ...record2 !== void 0 ? { record: record2 } : {} });
|
|
4734
4734
|
});
|
|
4735
4735
|
return out;
|
|
4736
4736
|
}
|
|
@@ -4825,8 +4825,8 @@ function resolveSkinView(doc) {
|
|
|
4825
4825
|
}
|
|
4826
4826
|
const deps = [];
|
|
4827
4827
|
for (const skin of lookupSkins(doc)) {
|
|
4828
|
-
for (const
|
|
4829
|
-
const g =
|
|
4828
|
+
for (const record2 of Object.values(skin.attachments[r.slot] ?? {})) {
|
|
4829
|
+
const g = record2.geometry;
|
|
4830
4830
|
if (g?.kind !== "path") continue;
|
|
4831
4831
|
for (const b of g.vertices.weighted ? g.vertices.bindings.flatMap((v) => v.map((x) => x.bone)) : [r.slotBone]) if (!deps.includes(b)) deps.push(b);
|
|
4832
4832
|
}
|
|
@@ -4838,8 +4838,8 @@ function linkProblems(skins) {
|
|
|
4838
4838
|
const out = [];
|
|
4839
4839
|
skins.forEach((skin, i) => {
|
|
4840
4840
|
for (const [slot, table] of Object.entries(skin.attachments)) {
|
|
4841
|
-
for (const [placeholder,
|
|
4842
|
-
const g =
|
|
4841
|
+
for (const [placeholder, record2] of Object.entries(table)) {
|
|
4842
|
+
const g = record2.geometry;
|
|
4843
4843
|
if (g?.kind !== "linkedmesh") continue;
|
|
4844
4844
|
const why = sourceProblem(skins, g.skin, g.slot, g.source);
|
|
4845
4845
|
if (why !== null) out.push(`skins[${i}] "${skin.name}".attachments["${slot}"]["${placeholder}"]: ${why}`);
|
|
@@ -4851,9 +4851,9 @@ function linkProblems(skins) {
|
|
|
4851
4851
|
function sourceProblem(skins, skin, slot, source) {
|
|
4852
4852
|
const found = skins.find((k) => k.name === skin);
|
|
4853
4853
|
if (found === void 0) return `the linked mesh's skin "${skin}" is not a skin of this document`;
|
|
4854
|
-
const
|
|
4855
|
-
if (
|
|
4856
|
-
if (
|
|
4854
|
+
const record2 = found.attachments[slot]?.[source];
|
|
4855
|
+
if (record2 === void 0) return `the linked mesh's source "${source}" is not in skin "${skin}" slot "${slot}"`;
|
|
4856
|
+
if (record2.kind !== "mesh") return `the linked mesh's source "${source}" in skin "${skin}" slot "${slot}" is a ${record2.kind}, not a mesh`;
|
|
4857
4857
|
return null;
|
|
4858
4858
|
}
|
|
4859
4859
|
function gridRound(v) {
|
|
@@ -4940,15 +4940,15 @@ function shownAttachment(doc, slot, placeholder = slot.setup) {
|
|
|
4940
4940
|
function resolveShown(doc, slotName, placeholder) {
|
|
4941
4941
|
if (doc.skin !== CORE_ALL_SKINS) {
|
|
4942
4942
|
for (const skin of lookupSkins(doc)) {
|
|
4943
|
-
const
|
|
4944
|
-
if (
|
|
4943
|
+
const record2 = skin.attachments[slotName]?.[placeholder];
|
|
4944
|
+
if (record2 !== void 0) return { skin: skin.name, placeholder, record: record2 };
|
|
4945
4945
|
}
|
|
4946
4946
|
return null;
|
|
4947
4947
|
}
|
|
4948
4948
|
const filling = [];
|
|
4949
4949
|
for (const skin of doc.skins) {
|
|
4950
|
-
const
|
|
4951
|
-
if (
|
|
4950
|
+
const record2 = skin.attachments[slotName]?.[placeholder];
|
|
4951
|
+
if (record2 !== void 0) filling.push({ skin: skin.name, placeholder, record: record2 });
|
|
4952
4952
|
}
|
|
4953
4953
|
if (filling.length === 0) return null;
|
|
4954
4954
|
const rows = filling.map((f) => ({ skin: f.skin, ...shownRow(f) }));
|
|
@@ -5085,7 +5085,7 @@ function drawOrderOf(shown, order) {
|
|
|
5085
5085
|
const rank = new Map(order.map((n, r) => [n, r]));
|
|
5086
5086
|
return [...shown].sort((a, b) => (rank.get(a.slot) ?? 0) - (rank.get(b.slot) ?? 0));
|
|
5087
5087
|
}
|
|
5088
|
-
function finite(v, what) {
|
|
5088
|
+
function finite$1(v, what) {
|
|
5089
5089
|
if (v === null) throw new CoreInputError(`the raw pose computed a non-finite ${what}`);
|
|
5090
5090
|
return v;
|
|
5091
5091
|
}
|
|
@@ -5093,7 +5093,7 @@ const RAW_MODE = { loop: false, keep: false };
|
|
|
5093
5093
|
const keptNumber = (v) => v;
|
|
5094
5094
|
const roundPlant = (mode) => ({ round: mode.keep ? keptNumber : rawNumber });
|
|
5095
5095
|
function numberOf(v, what, mode) {
|
|
5096
|
-
return mode.keep ? v === null ? Number.NaN : v : finite(v, what);
|
|
5096
|
+
return mode.keep ? v === null ? Number.NaN : v : finite$1(v, what);
|
|
5097
5097
|
}
|
|
5098
5098
|
const NO_CLIPPED_ROWS = () => null;
|
|
5099
5099
|
function rawBones(doc, world) {
|
|
@@ -5149,8 +5149,8 @@ function rawDrawn(doc, shown, world, order, plant, mode = RAW_MODE) {
|
|
|
5149
5149
|
if (g.kind !== "region" && g.kind !== "mesh" && g.kind !== "linkedmesh") continue;
|
|
5150
5150
|
const row = rows[k++];
|
|
5151
5151
|
if (row === void 0 || row[0] !== s.slot) throw new CoreInputError(`slot "${s.slot}": the attachment rows are not in the shown records' order`);
|
|
5152
|
-
const
|
|
5153
|
-
const read =
|
|
5152
|
+
const record2 = doc.skins.find((x) => x.name === s.skin)?.attachments[s.slot]?.[s.placeholder];
|
|
5153
|
+
const read = record2?.color === void 0 ? WHITE : stated(record2.color);
|
|
5154
5154
|
const colour = [read[0], read[1], read[2], read[3]];
|
|
5155
5155
|
let uvs;
|
|
5156
5156
|
let triangles;
|
|
@@ -5164,7 +5164,7 @@ function rawDrawn(doc, shown, world, order, plant, mode = RAW_MODE) {
|
|
|
5164
5164
|
({ uvs, triangles } = (plant.meshArrays ?? meshArraysOf)(source));
|
|
5165
5165
|
hull = source.hull ?? null;
|
|
5166
5166
|
}
|
|
5167
|
-
const sequenceIndex = s.frame ??
|
|
5167
|
+
const sequenceIndex = s.frame ?? record2?.sequenceSetup ?? 0;
|
|
5168
5168
|
drawn.push({ slot: s.slot, attachment: row[1], kind: row[2], vertices: numbersOf(row[3], `vertex of slot "${s.slot}"`, mode), uvs, triangles, hull, sequenceIndex, colour });
|
|
5169
5169
|
}
|
|
5170
5170
|
const clips = geometry.clips.map((c) => [c[0], c[1], c[2], numbersOf(c[3], `clip vertex of slot "${c[0]}"`, mode)]);
|
|
@@ -5360,7 +5360,7 @@ function poseStepFrom(doc, plant, resolve, shape, mode, ctx, first, trackTime, a
|
|
|
5360
5360
|
const rank = new Map(drawOrder.map((n, r) => [n, r]));
|
|
5361
5361
|
const shown = [...states.shown].sort((a, b) => (rank.get(a.slot) ?? 0) - (rank.get(b.slot) ?? 0));
|
|
5362
5362
|
if (stage !== void 0) stage.end("readout");
|
|
5363
|
-
const events = () => posers.events().map((e) => [e[0], finite(e[1], "event time"), e[2], finite(e[3], "event float"), e[4]]);
|
|
5363
|
+
const events = () => posers.events().map((e) => [e[0], finite$1(e[1], "event time"), e[2], finite$1(e[3], "event float"), e[4]]);
|
|
5364
5364
|
return shape.step(doc, { trackTime, animationTime, world, slots: slots.rows, drawOrder, shown, events }, plant, mode);
|
|
5365
5365
|
}
|
|
5366
5366
|
function openRawTracksPath(doc, plant) {
|
|
@@ -5426,10 +5426,10 @@ class LivePhysicsParameters {
|
|
|
5426
5426
|
this.overrides.delete(name);
|
|
5427
5427
|
}
|
|
5428
5428
|
/** Called only for an active constraint, after the sliders and immediately before its step. */
|
|
5429
|
-
apply(
|
|
5430
|
-
const patch = this.overrides.get(
|
|
5431
|
-
const posed = patch === void 0 ?
|
|
5432
|
-
this.evaluated.set(
|
|
5429
|
+
apply(record2) {
|
|
5430
|
+
const patch = this.overrides.get(record2.name);
|
|
5431
|
+
const posed = patch === void 0 ? record2 : { ...record2, ...patch };
|
|
5432
|
+
this.evaluated.set(record2.name, values(posed));
|
|
5433
5433
|
return posed;
|
|
5434
5434
|
}
|
|
5435
5435
|
}
|
|
@@ -6216,7 +6216,7 @@ class Mixer {
|
|
|
6216
6216
|
for (let k = 0; k < 4; k++) l[k] = clamp01$1(l[k]);
|
|
6217
6217
|
};
|
|
6218
6218
|
const v = this.values(tl.keys, time);
|
|
6219
|
-
const
|
|
6219
|
+
const channels2 = SLOT_COLOUR_TIMELINES[tl.kind].channels.length;
|
|
6220
6220
|
switch (tl.kind) {
|
|
6221
6221
|
case "rgba": {
|
|
6222
6222
|
if (v === null) {
|
|
@@ -6272,7 +6272,7 @@ class Mixer {
|
|
|
6272
6272
|
return;
|
|
6273
6273
|
}
|
|
6274
6274
|
const light = v.slice(0, lightN);
|
|
6275
|
-
const dark = v.slice(lightN,
|
|
6275
|
+
const dark = v.slice(lightN, channels2);
|
|
6276
6276
|
if (withAlpha) {
|
|
6277
6277
|
if (alpha === 1) for (let k = 0; k < 4; k++) l[k] = light[k];
|
|
6278
6278
|
else if (from === SETUP) {
|
|
@@ -6655,10 +6655,10 @@ function readUvSequences(document2) {
|
|
|
6655
6655
|
if (!isRecord$1(skin) || typeof skin.name !== "string" || !isRecord$1(skin.attachments)) return;
|
|
6656
6656
|
for (const [slot, table] of Object.entries(skin.attachments)) {
|
|
6657
6657
|
if (!isRecord$1(table)) continue;
|
|
6658
|
-
for (const [placeholder,
|
|
6659
|
-
if (!isRecord$1(
|
|
6658
|
+
for (const [placeholder, record2] of Object.entries(table)) {
|
|
6659
|
+
if (!isRecord$1(record2) || record2.sequence === void 0) continue;
|
|
6660
6660
|
const where = `skins[${k}] "${skin.name}".attachments["${slot}"]["${placeholder}"].sequence`;
|
|
6661
|
-
const seq =
|
|
6661
|
+
const seq = record2.sequence;
|
|
6662
6662
|
if (!isRecord$1(seq)) {
|
|
6663
6663
|
problems.push(`${where} is not an object`);
|
|
6664
6664
|
continue;
|
|
@@ -6689,9 +6689,9 @@ function drawnRegions(doc, shown, order, source) {
|
|
|
6689
6689
|
if (s === void 0) continue;
|
|
6690
6690
|
const g = s.geometry;
|
|
6691
6691
|
if (g.kind !== "region" && g.kind !== "mesh" && g.kind !== "linkedmesh") continue;
|
|
6692
|
-
const
|
|
6693
|
-
if (
|
|
6694
|
-
const path =
|
|
6692
|
+
const record2 = doc.skins.find((k) => k.name === s.skin)?.attachments[s.slot]?.[s.placeholder];
|
|
6693
|
+
if (record2 === void 0) throw new CoreInputError(`slot "${s.slot}": skin "${s.skin}" files no record under placeholder "${s.placeholder}" (readModel refuses it first)`);
|
|
6694
|
+
const path = record2.path ?? s.name;
|
|
6695
6695
|
const sequence = source.sequences.get(`${s.skin}/${s.slot}/${s.placeholder}`);
|
|
6696
6696
|
if (g.kind === "linkedmesh" && sequence !== void 0 && s.frame !== void 0) {
|
|
6697
6697
|
const sourceCount = doc.skins.find((k) => k.name === g.skin)?.attachments[g.slot]?.[g.source]?.sequenceCount;
|
|
@@ -9302,17 +9302,17 @@ const CURVE_LINEAR = 0;
|
|
|
9302
9302
|
const CURVE_STEPPED = 1;
|
|
9303
9303
|
const CURVE_BEZIER = 2;
|
|
9304
9304
|
const POLYLINE = 2 * (BEZIER_PIECES + 1);
|
|
9305
|
-
function compileCurve(keys,
|
|
9305
|
+
function compileCurve(keys, channels2) {
|
|
9306
9306
|
const n = keys.length;
|
|
9307
9307
|
const times2 = new Float64Array(n);
|
|
9308
|
-
const values2 = new Float64Array(n *
|
|
9308
|
+
const values2 = new Float64Array(n * channels2);
|
|
9309
9309
|
const kinds = new Uint8Array(n);
|
|
9310
|
-
const polylines = new Float64Array(n *
|
|
9310
|
+
const polylines = new Float64Array(n * channels2 * POLYLINE);
|
|
9311
9311
|
for (let i = 0; i < n; i++) {
|
|
9312
9312
|
const a = keys[i];
|
|
9313
9313
|
times2[i] = a.time;
|
|
9314
9314
|
const av = a.values;
|
|
9315
|
-
if (av !== void 0) for (let c = 0; c <
|
|
9315
|
+
if (av !== void 0) for (let c = 0; c < channels2; c++) values2[i * channels2 + c] = av[c];
|
|
9316
9316
|
const curve = a.curve ?? "stepped";
|
|
9317
9317
|
kinds[i] = curve === "linear" ? CURVE_LINEAR : curve === "stepped" ? CURVE_STEPPED : CURVE_BEZIER;
|
|
9318
9318
|
if (typeof curve === "string" || i + 1 >= n) continue;
|
|
@@ -9320,9 +9320,9 @@ function compileCurve(keys, channels) {
|
|
|
9320
9320
|
const aStated = a.stated;
|
|
9321
9321
|
const bStated = b.stated;
|
|
9322
9322
|
const bValues = b.values;
|
|
9323
|
-
for (let c = 0; c <
|
|
9323
|
+
for (let c = 0; c < channels2; c++) {
|
|
9324
9324
|
const inner = bezierPolyline(aStated.time, aStated.values[c], curve[c * 4], curve[c * 4 + 1], curve[c * 4 + 2], curve[c * 4 + 3], bStated.time, bStated.values[c]);
|
|
9325
|
-
const o = (i *
|
|
9325
|
+
const o = (i * channels2 + c) * POLYLINE;
|
|
9326
9326
|
polylines[o] = a.time;
|
|
9327
9327
|
polylines[o + 1] = av[c];
|
|
9328
9328
|
for (let q = 0; q < inner.length; q++) polylines[o + 2 + q] = inner[q];
|
|
@@ -9330,7 +9330,7 @@ function compileCurve(keys, channels) {
|
|
|
9330
9330
|
polylines[o + POLYLINE - 1] = bValues[c];
|
|
9331
9331
|
}
|
|
9332
9332
|
}
|
|
9333
|
-
return { keys: n, channels, times: times2, values: values2, kinds, polylines };
|
|
9333
|
+
return { keys: n, channels: channels2, times: times2, values: values2, kinds, polylines };
|
|
9334
9334
|
}
|
|
9335
9335
|
function keyAt(curve, cursors, slot, t) {
|
|
9336
9336
|
const times2 = curve.times;
|
|
@@ -9909,8 +9909,8 @@ function compileAnimation(anim, refusals, ignoreEvents, boneIndex2, slotIndex, s
|
|
|
9909
9909
|
const ids = Int32Array.from(t.keys.map((k) => resolve(si, k.name ?? null)));
|
|
9910
9910
|
slotTimelines.push({ slot: si, curve: compileCurve(t.keys, 0), cursor: cursors++, attachments: ids, channels: null });
|
|
9911
9911
|
} else {
|
|
9912
|
-
const
|
|
9913
|
-
slotTimelines.push({ slot: si, curve: compileCurve(t.keys,
|
|
9912
|
+
const channels2 = COLOUR_CHANNELS[t.kind];
|
|
9913
|
+
slotTimelines.push({ slot: si, curve: compileCurve(t.keys, channels2.length), cursor: cursors++, attachments: null, channels: Int32Array.from(channels2) });
|
|
9914
9914
|
}
|
|
9915
9915
|
}
|
|
9916
9916
|
}
|
|
@@ -11597,11 +11597,11 @@ class RuntimePose {
|
|
|
11597
11597
|
if (next !== this.shown[tl.slot] && next >= 0) this.deformed[next] = 0;
|
|
11598
11598
|
this.shown[tl.slot] = next;
|
|
11599
11599
|
} else {
|
|
11600
|
-
const
|
|
11600
|
+
const channels2 = tl.channels;
|
|
11601
11601
|
const slot = this.model.slots[tl.slot];
|
|
11602
11602
|
const o = tl.slot * 4, d = tl.slot * 3;
|
|
11603
|
-
for (let f = 0; f <
|
|
11604
|
-
const at =
|
|
11603
|
+
for (let f = 0; f < channels2.length; f++) {
|
|
11604
|
+
const at = channels2[f], v = channelValue(tl.curve, i, f, t);
|
|
11605
11605
|
if (at < 4) {
|
|
11606
11606
|
const n = o + at;
|
|
11607
11607
|
this.light[n] = clamp01(alpha === 1 ? v : this.light[n] + (v - this.light[n]) * alpha);
|
|
@@ -12168,14 +12168,14 @@ class RuntimePose {
|
|
|
12168
12168
|
this.shown[tl.slot] = i < 0 ? slots[tl.slot].setupAttachment : attachments[i];
|
|
12169
12169
|
continue;
|
|
12170
12170
|
}
|
|
12171
|
-
const
|
|
12171
|
+
const channels2 = tl.channels;
|
|
12172
12172
|
const slot = slots[tl.slot];
|
|
12173
12173
|
const setup = slot.light;
|
|
12174
12174
|
const setupDark = slot.dark;
|
|
12175
12175
|
const o = tl.slot * 4;
|
|
12176
12176
|
const d = tl.slot * 3;
|
|
12177
|
-
for (let c = 0; c <
|
|
12178
|
-
const at =
|
|
12177
|
+
for (let c = 0; c < channels2.length; c++) {
|
|
12178
|
+
const at = channels2[c];
|
|
12179
12179
|
if (at < 4) {
|
|
12180
12180
|
light[o + at] = i < 0 ? setup[at] : clamp01(channelValue(tl.curve, i, c, t));
|
|
12181
12181
|
} else if (setupDark !== null && !this.model.omitDarkColour) {
|
|
@@ -14885,12 +14885,92 @@ class RigPlayer {
|
|
|
14885
14885
|
}
|
|
14886
14886
|
}
|
|
14887
14887
|
}
|
|
14888
|
+
const canonicalBones = {
|
|
14889
|
+
yaw: "yaw_dial",
|
|
14890
|
+
pitch: "pitch_dial",
|
|
14891
|
+
body: "body_yaw_dial"
|
|
14892
|
+
};
|
|
14893
|
+
const channels = /* @__PURE__ */ new Map([
|
|
14894
|
+
["rotate", "rotation"],
|
|
14895
|
+
["x", "x"],
|
|
14896
|
+
["y", "y"],
|
|
14897
|
+
["scaleX", "scaleX"],
|
|
14898
|
+
["scaleY", "scaleY"],
|
|
14899
|
+
["shearY", "shearY"]
|
|
14900
|
+
]);
|
|
14901
|
+
function record(value) {
|
|
14902
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
14903
|
+
}
|
|
14904
|
+
function unprefixed(name) {
|
|
14905
|
+
const separator = name.indexOf(":");
|
|
14906
|
+
return separator > 0 ? name.slice(separator + 1) : name;
|
|
14907
|
+
}
|
|
14908
|
+
function finite(value) {
|
|
14909
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
14910
|
+
}
|
|
14911
|
+
function discoverTurnDials(model, durations) {
|
|
14912
|
+
const doc = record(model);
|
|
14913
|
+
if (!doc || !Array.isArray(doc.bones) || !Array.isArray(doc.constraints)) return [];
|
|
14914
|
+
const bones = new Set(doc.bones.map((row) => record(row)?.name));
|
|
14915
|
+
const sliders = doc.constraints.flatMap((row) => {
|
|
14916
|
+
const constraint = record(row);
|
|
14917
|
+
if (constraint?.kind !== "slider") return [];
|
|
14918
|
+
const { name, bone: bone2, animation } = constraint;
|
|
14919
|
+
if (typeof name !== "string" || typeof bone2 !== "string" || !bones.has(bone2)) return [];
|
|
14920
|
+
return [{ constraint, name, bone: bone2, animation }];
|
|
14921
|
+
});
|
|
14922
|
+
const animationRows = durations ?? (Array.isArray(doc.animations) ? doc.animations : []);
|
|
14923
|
+
const animations = animationRows.map(record);
|
|
14924
|
+
const result = [];
|
|
14925
|
+
for (const axis of ["yaw", "pitch", "body"]) {
|
|
14926
|
+
const canonical = canonicalBones[axis];
|
|
14927
|
+
const candidates = sliders.filter(({ bone: bone22, animation: animation2 }) => unprefixed(bone22) === canonical || axis === "body" && typeof animation2 === "string" && unprefixed(animation2) === "body_turn");
|
|
14928
|
+
if (candidates.length !== 1) continue;
|
|
14929
|
+
const { constraint, name, bone: bone2, animation } = candidates[0];
|
|
14930
|
+
if (!constraint.local || constraint.loop || typeof animation !== "string") continue;
|
|
14931
|
+
const property = constraint.property ?? "rotate";
|
|
14932
|
+
const channel2 = typeof property === "string" ? channels.get(property) : void 0;
|
|
14933
|
+
const duration = animations.find((row) => row?.name === animation)?.duration;
|
|
14934
|
+
const from = constraint.from ?? 0;
|
|
14935
|
+
const to = constraint.to ?? 0;
|
|
14936
|
+
const scale = constraint.scale ?? 1;
|
|
14937
|
+
if (!channel2 || !finite(duration) || duration <= 0 || !finite(from) || !finite(to) || !finite(scale) || scale === 0) continue;
|
|
14938
|
+
const start = from - to / scale;
|
|
14939
|
+
const end = from + (duration - to) / scale;
|
|
14940
|
+
const min = Math.min(start, end);
|
|
14941
|
+
const max = Math.max(start, end);
|
|
14942
|
+
if (!finite(min) || !finite(max) || min === max || min > 0 || max < 0) continue;
|
|
14943
|
+
if (result.some((dial) => dial.bone === bone2 && dial.channel === channel2)) continue;
|
|
14944
|
+
const binding = unprefixed(bone2) === canonical ? "" : " (compiled body_turn binding)";
|
|
14945
|
+
result.push({
|
|
14946
|
+
axis,
|
|
14947
|
+
bone: bone2,
|
|
14948
|
+
slider: name,
|
|
14949
|
+
channel: channel2,
|
|
14950
|
+
min,
|
|
14951
|
+
max,
|
|
14952
|
+
provenance: `model slider ${name} → bone ${bone2}, ${property}, animation ${animation}${binding}`
|
|
14953
|
+
});
|
|
14954
|
+
}
|
|
14955
|
+
return result;
|
|
14956
|
+
}
|
|
14957
|
+
function clamp(value, min, max) {
|
|
14958
|
+
return Math.max(min, Math.min(max, value)) || 0;
|
|
14959
|
+
}
|
|
14960
|
+
function normalizedDial(value, range) {
|
|
14961
|
+
const input = clamp(value, -1, 1);
|
|
14962
|
+
const neutral = clamp(0, range.min, range.max);
|
|
14963
|
+
const endpoint = input < 0 ? range.min : range.max;
|
|
14964
|
+
return clamp(neutral + Math.abs(input) * (endpoint - neutral), range.min, range.max);
|
|
14965
|
+
}
|
|
14888
14966
|
export {
|
|
14889
14967
|
CanvasRenderer,
|
|
14890
14968
|
DomRenderer,
|
|
14891
14969
|
RigPlayer,
|
|
14892
14970
|
createAtlasRegions,
|
|
14971
|
+
discoverTurnDials,
|
|
14893
14972
|
loadModel,
|
|
14973
|
+
normalizedDial,
|
|
14894
14974
|
readSetupMesh,
|
|
14895
14975
|
revokeRegions,
|
|
14896
14976
|
unpackRegions
|