spine-html 1.24.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/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$2 = (v) => typeof v === "number" && Number.isFinite(v);
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$2(t) || t < 0) problems.push(`${at}[${i}]: time is ${JSON.stringify(t)}, not a finite time at or after 0`);
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$2(t)) last = Math.max(last, t);
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$2)) problems.push(`${kat}: vertices is not a non-empty list of finite numbers (omit it for the setup geometry)`);
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$2)) curve = k.curve;
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$2(k.time) ? k.time : 0;
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$2(k.delay) || k.delay < 0) problems.push(`${kat}: delay is ${JSON.stringify(k.delay)}, not a finite number of seconds at or above 0`);
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$2(k.time) ? k.time : 0), mode, index, delay });
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 record = skin?.attachments[slot]?.[attEntry.name];
288
+ const record2 = skin?.attachments[slot]?.[attEntry.name];
289
289
  const label2 = `${aat} "${skinEntry.name}/${slot}/${attEntry.name}"`;
290
- if (skin !== void 0 && record === void 0) problems.push(`${label2}: skin "${skin.name}" files no attachment "${attEntry.name}" under slot "${slot}"`);
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 && record !== void 0) {
293
- const g = record.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 ${record.kind}`);
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 && record !== void 0) {
298
- const count = record.sequenceCount;
299
- if (count === void 0) problems.push(`${label2}: a sequence timeline steps a series, and this ${record.kind} carries no sequence`);
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$1 = (v) => typeof v === "number" && Number.isFinite(v);
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$1(value[key])) problems.push(`${where}: ${key} is ${JSON.stringify(value[key]) ?? "absent"}, not a finite number`);
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$1)) problems.push(`${where}.xy is not an even-length list of finite numbers`);
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$1(b[key])) problems.push(`${at}: ${key} is ${JSON.stringify(b[key]) ?? "absent"}, not a finite number`);
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$1(raw[key])) problems.push(`${where}: ${key} is ${JSON.stringify(raw[key])}, not a finite number`);
1230
- for (const key of ["width", "height"]) if (!finite$1(raw[key])) problems.push(`${where}: ${key} is ${JSON.stringify(raw[key]) ?? "absent"}, not a finite number`);
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$1) || uvs.length !== 2 * count) problems.push(`${where}.uvs is not ${2 * count} finite numbers, one pair per vertex`);
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$1)) problems.push(`${where}: lengths is not a list of finite numbers`);
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 record = {
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 ? record : void 0;
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, channels, last, at, problems) {
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 !== channels * 4 || !curve.every((n) => typeof n === "number" && Number.isFinite(n))) {
1494
- problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${channels * 4} finite numbers (four per channel)`);
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 channels = PATH_TIMELINES[kind];
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" && !channels.includes(f)) problems.push(`${kat}: field "${f}" is not one this reader knows; it reads [time, ${channels.join(", ")}, 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 = channels.map((c) => {
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, channels.length, n === rawKeys.length - 1, kat, problems) });
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 record = {
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 ? record : void 0;
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(record, known, where, problems) {
2721
- for (const key of Object.keys(record)) if (!known.includes(key)) problems.push(`${where}: field "${key}" is not one this reader knows; it reads [${known.join(", ")}]`);
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 record2 = {
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 ? record2 : void 0;
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 record = {
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 ? record : void 0;
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, channels, last, at, problems) {
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 !== channels * 4 || !curve.every((n) => typeof n === "number" && Number.isFinite(n))) {
2878
- problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${channels * 4} finite numbers (four per channel)`);
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 channels = kind === "ik" ? IK_KEY_CHANNELS : TRANSFORM_KEY_CHANNELS;
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 = channels.map((c) => {
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, channels.length, j === rawKeys.length - 1, kat, problems),
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, channels, last, at, problems) {
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 !== channels * 4 || !curve.every((n) => typeof n === "number" && Number.isFinite(n))) {
3774
- problems.push(`${at}: curve is ${JSON.stringify(curve)}, not "stepped" nor ${channels * 4} finite numbers (four per channel)`);
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 channels = BONE_TIMELINE_CHANNELS[kind];
3789
- unknownKeyFields(raw, ["time", ...channels, "curve"], at, problems);
3790
- const values2 = channels.map((c) => {
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, channels.length, i === listed.length - 1, at, problems) };
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 channels = SLOT_COLOUR_TIMELINES[tl.kind].channels;
4162
- channels.forEach((name, i) => {
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(record, known, where, problems) {
4481
- for (const key of Object.keys(record)) {
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 record = { kind };
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 record[key] = v;
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) record.atlas = rect;
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) record.geometry = geometry;
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) record.sequenceCount = count;
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)) record.sequenceSetup = setupFrame;
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 record.color = raw.color;
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 record.timelines = raw.timelines;
4612
+ else record2.timelines = raw.timelines;
4613
4613
  }
4614
- entries[placeholder] = record;
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 record;
4726
+ let record2;
4727
4727
  if (typeof raw.name === "string") {
4728
- if (kind === "ik" || kind === "transform") record = readConstraintRecord(raw, kind, raw.name, at, names, parents, problems);
4729
- else if (kind === "path") record = readPathRecord(raw, raw.name, at, names, slotBones, problems);
4730
- else if (kind === "physics") record = readPhysicsRecord(raw, raw.name, at, names, referenceScale, problems);
4731
- else if (kind === "slider") record = readSliderRecord(raw, raw.name, at, bones, animations, problems);
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 } : {}, ...record !== void 0 ? { record } : {} });
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 record of Object.values(skin.attachments[r.slot] ?? {})) {
4829
- const g = record.geometry;
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, record] of Object.entries(table)) {
4842
- const g = record.geometry;
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 record = found.attachments[slot]?.[source];
4855
- if (record === void 0) return `the linked mesh's source "${source}" is not in skin "${skin}" slot "${slot}"`;
4856
- if (record.kind !== "mesh") return `the linked mesh's source "${source}" in skin "${skin}" slot "${slot}" is a ${record.kind}, not a mesh`;
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 record = skin.attachments[slotName]?.[placeholder];
4944
- if (record !== void 0) return { skin: skin.name, placeholder, record };
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 record = skin.attachments[slotName]?.[placeholder];
4951
- if (record !== void 0) filling.push({ skin: skin.name, placeholder, record });
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 record = doc.skins.find((x) => x.name === s.skin)?.attachments[s.slot]?.[s.placeholder];
5153
- const read = record?.color === void 0 ? WHITE : stated(record.color);
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 ?? record?.sequenceSetup ?? 0;
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(record) {
5430
- const patch = this.overrides.get(record.name);
5431
- const posed = patch === void 0 ? record : { ...record, ...patch };
5432
- this.evaluated.set(record.name, values(posed));
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 channels = SLOT_COLOUR_TIMELINES[tl.kind].channels.length;
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, channels);
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, record] of Object.entries(table)) {
6659
- if (!isRecord$1(record) || record.sequence === void 0) continue;
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 = record.sequence;
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 record = doc.skins.find((k) => k.name === s.skin)?.attachments[s.slot]?.[s.placeholder];
6693
- if (record === 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 = record.path ?? s.name;
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;
@@ -7118,9 +7118,8 @@ class MeshGlBlitter {
7118
7118
  this.maxSize = Math.floor(side / ALIGN) * ALIGN;
7119
7119
  }
7120
7120
  /**
7121
- * Rasterizes every job and blits it onto its per-part canvas. Returns false
7122
- * only when the context is lost, so that the caller draws the batch on its
7123
- * canvas2d path; a batch's size never sends it there.
7121
+ * Rasterizes every job and blits it onto its per-part canvas. Returns null
7122
+ * on success, or the reason the caller needs to draw on its canvas2d path.
7124
7123
  *
7125
7124
  * A batch that fits one buffer is one pass, shelf-packed as it always was.
7126
7125
  * One that does not — a zoomed-in stage asks for more than the browser
@@ -7140,15 +7139,15 @@ class MeshGlBlitter {
7140
7139
  flush(jobs) {
7141
7140
  const gl = this.gl;
7142
7141
  this.stats = { jobs: jobs.length, passes: 0, pieces: 0, tiledJobs: 0 };
7143
- if (this.lost || gl.isContextLost()) return false;
7142
+ if (this.lost || gl.isContextLost()) return "context-lost";
7144
7143
  let width = Math.max(512, this.canvas.width);
7145
7144
  for (const job of jobs) width = Math.max(width, job.width + GUTTER * 2);
7146
7145
  let pieces = jobs.map((job, i) => ({ job: i, tx: 0, ty: 0, tw: job.width, th: job.height, bx: 0, by: 0, pass: 0 }));
7147
7146
  const height = shelfPack(pieces, width, Number.POSITIVE_INFINITY);
7148
7147
  if (!this.reserve(width, height)) {
7149
- if (!this.acquire(width, height)) return false;
7148
+ if (!this.acquire(width, height)) return this.bufferFallback();
7150
7149
  const planned = this.plan(jobs, this.canvas.width, this.canvas.height);
7151
- if (!planned) return false;
7150
+ if (!planned) return this.bufferFallback();
7152
7151
  pieces = planned;
7153
7152
  }
7154
7153
  const packX = this.packX = new Array(jobs.length);
@@ -7200,7 +7199,7 @@ class MeshGlBlitter {
7200
7199
  }
7201
7200
  if (gl.isContextLost()) {
7202
7201
  this.markLost();
7203
- return false;
7202
+ return "context-lost";
7204
7203
  }
7205
7204
  for (let k = start; k < end; k++) {
7206
7205
  const piece = pieces[k];
@@ -7227,7 +7226,10 @@ class MeshGlBlitter {
7227
7226
  ctx.setTransform(1, 0, 0, 1, 0, 0);
7228
7227
  ctx.clearRect(0, 0, jobs[i].canvas.width, jobs[i].canvas.height);
7229
7228
  }
7230
- return true;
7229
+ return null;
7230
+ }
7231
+ bufferFallback() {
7232
+ return this.gl.isContextLost() ? "context-lost" : "over-grant";
7231
7233
  }
7232
7234
  /**
7233
7235
  * Sets the viewport, the two uniforms and the scissor for one piece. The
@@ -7387,23 +7389,22 @@ class MeshGlBlitter {
7387
7389
  }
7388
7390
  /**
7389
7391
  * Draws one player's frame (the canvas render mode) and blits it onto
7390
- * `job.canvas`, whose full backing is cleared first. Returns false only when
7391
- * the context is lost, so the caller draws the frame on its canvas2d
7392
- * fallback. The frame is one job: drawn into one rect when the buffer holds
7393
- * it, otherwise tiled through passes exactly as flush() tiles a mesh, every
7394
- * tile re-issuing the frame's runs under its own scissor.
7392
+ * `job.canvas`, whose full backing is cleared first. Returns null on success
7393
+ * or a canvas2d fallback reason. The frame is one job, drawn into one rect
7394
+ * if it fits, otherwise tiled through passes exactly as flush() tiles a mesh.
7395
+ * Every tile re-issues the frame's runs under its own scissor.
7395
7396
  */
7396
7397
  flushFrame(job) {
7397
7398
  const gl = this.gl;
7398
7399
  this.stats = { jobs: 1, passes: 0, pieces: 0, tiledJobs: 0 };
7399
- if (this.lost || gl.isContextLost()) return false;
7400
+ if (this.lost || gl.isContextLost()) return "context-lost";
7400
7401
  let pieces;
7401
7402
  if (this.reserve(job.width + GUTTER * 2, job.height + GUTTER * 2)) {
7402
7403
  pieces = [{ job: 0, tx: 0, ty: 0, tw: job.width, th: job.height, bx: GUTTER, by: GUTTER, pass: 0 }];
7403
7404
  } else {
7404
- if (!this.acquire(job.width + GUTTER * 2, job.height + GUTTER * 2)) return false;
7405
+ if (!this.acquire(job.width + GUTTER * 2, job.height + GUTTER * 2)) return this.bufferFallback();
7405
7406
  const planned = this.plan([job], this.canvas.width, this.canvas.height);
7406
- if (!planned) return false;
7407
+ if (!planned) return this.bufferFallback();
7407
7408
  pieces = planned;
7408
7409
  }
7409
7410
  const bufH = this.canvas.height;
@@ -7443,7 +7444,7 @@ class MeshGlBlitter {
7443
7444
  }
7444
7445
  if (gl.isContextLost()) {
7445
7446
  this.markLost();
7446
- return false;
7447
+ return "context-lost";
7447
7448
  }
7448
7449
  if (ctx) {
7449
7450
  if (!cleared) {
@@ -7462,7 +7463,7 @@ class MeshGlBlitter {
7462
7463
  }
7463
7464
  this.stats.pieces = pieces.length;
7464
7465
  if (ctx && !cleared) ctx.clearRect(0, 0, job.canvas.width, job.canvas.height);
7465
- return true;
7466
+ return null;
7466
7467
  }
7467
7468
  /** The mesh tier's layout, [x, y, u, v], and its premultiplied source-over. */
7468
7469
  bindMesh() {
@@ -7617,6 +7618,9 @@ function getMeshGlBlitter() {
7617
7618
  }
7618
7619
  return shared && !shared.lost ? shared : null;
7619
7620
  }
7621
+ function meshGlUnavailableReason() {
7622
+ return shared?.lost ? "context-lost" : "creation-failed";
7623
+ }
7620
7624
  function defaultMeshSourceRect(userAgent = typeof navigator === "object" ? navigator.userAgent : "") {
7621
7625
  const linuxWebKit = /AppleWebKit/.test(userAgent) && /Linux|X11/.test(userAgent) && !/Android|Chrome|Chromium|CriOS|Edg/.test(userAgent);
7622
7626
  return linuxWebKit ? "triangle" : "page";
@@ -7792,6 +7796,8 @@ class DomRenderer {
7792
7796
  meshBackend = "webgl";
7793
7797
  /** Backend that actually rasterized the mesh tier during the last render(). */
7794
7798
  meshBackendActive = "webgl";
7799
+ /** Why the last render selected canvas2d for meshes. Null before rendering or when WebGL was selected. */
7800
+ meshBackendFallbackReason = null;
7795
7801
  views = /* @__PURE__ */ new Map();
7796
7802
  /** Counts render() calls: the stamp a view drawn this frame carries (`SlotView.drawnIn`). */
7797
7803
  frameNumber = 0;
@@ -7911,6 +7917,7 @@ class DomRenderer {
7911
7917
  const stamp = ++this.frameNumber;
7912
7918
  const blitter = this.meshBackend === "webgl" ? getMeshGlBlitter() : null;
7913
7919
  this.meshBackendActive = blitter ? "webgl" : "canvas2d";
7920
+ this.meshBackendFallbackReason = blitter ? null : this.meshBackend === "webgl" ? meshGlUnavailableReason() : "not-requested";
7914
7921
  const order = frame2.order;
7915
7922
  const first = order.length > 0 ? order[0].clip : void 0;
7916
7923
  if (first && !first.inverse && this.clipping && first.polygon.length >= 6) {
@@ -7931,8 +7938,10 @@ class DomRenderer {
7931
7938
  for (const view of this.views.values()) if (view.drawnIn !== stamp) this.hide(view);
7932
7939
  if (!this.clipOnRoot) this.releaseRootClip();
7933
7940
  if (this.pendingJobs.length) {
7934
- if (!blitter || !blitter.flush(this.pendingJobs)) {
7941
+ const reason = blitter ? blitter.flush(this.pendingJobs) : this.meshBackendFallbackReason;
7942
+ if (reason !== null) {
7935
7943
  this.meshBackendActive = "canvas2d";
7944
+ this.meshBackendFallbackReason = reason;
7936
7945
  for (let i = 0; i < this.pendingJobs.length; i++) {
7937
7946
  const job = this.pendingJobs[i];
7938
7947
  this.pendingViews[i].meshBackendDrawn = "canvas2d";
@@ -8607,6 +8616,8 @@ class CanvasRenderer {
8607
8616
  meshSourceRect = defaultMeshSourceRect();
8608
8617
  /** What drew the last frame (or would have, had it not been reused). */
8609
8618
  backendActive = "webgl";
8619
+ /** Why the last render selected canvas2d. Null before rendering or when WebGL was selected. */
8620
+ backendFallbackReason = null;
8610
8621
  /** The visible canvas — the renderer's one element in the root. */
8611
8622
  canvas;
8612
8623
  /** Draw calls issued last frame — one per run of one page under one blend. */
@@ -8675,6 +8686,7 @@ class CanvasRenderer {
8675
8686
  this.clipSkipCount = 0;
8676
8687
  const blitter = this.backend === "webgl" ? getMeshGlBlitter() : null;
8677
8688
  this.backendActive = blitter ? "webgl" : "canvas2d";
8689
+ this.backendFallbackReason = blitter ? null : this.backend === "webgl" ? meshGlUnavailableReason() : "not-requested";
8678
8690
  const order = frame2.order;
8679
8691
  const view = this.viewport;
8680
8692
  if (view) {
@@ -8704,11 +8716,13 @@ class CanvasRenderer {
8704
8716
  if (this.backingW === 0 || this.backingH === 0) return;
8705
8717
  if (blitter) {
8706
8718
  this.buildVertices(order);
8707
- if (blitter.flushFrame({ canvas: this.canvas, width: this.backingW, height: this.backingH, data: this.data, stride: this.stride, runs: this.runs })) {
8719
+ const reason = blitter.flushFrame({ canvas: this.canvas, width: this.backingW, height: this.backingH, data: this.data, stride: this.stride, runs: this.runs });
8720
+ if (reason === null) {
8708
8721
  this.blits = 1;
8709
8722
  return;
8710
8723
  }
8711
8724
  this.backendActive = "canvas2d";
8725
+ this.backendFallbackReason = reason;
8712
8726
  this.sigLength = -1;
8713
8727
  }
8714
8728
  this.draw2d(order);
@@ -9288,17 +9302,17 @@ const CURVE_LINEAR = 0;
9288
9302
  const CURVE_STEPPED = 1;
9289
9303
  const CURVE_BEZIER = 2;
9290
9304
  const POLYLINE = 2 * (BEZIER_PIECES + 1);
9291
- function compileCurve(keys, channels) {
9305
+ function compileCurve(keys, channels2) {
9292
9306
  const n = keys.length;
9293
9307
  const times2 = new Float64Array(n);
9294
- const values2 = new Float64Array(n * channels);
9308
+ const values2 = new Float64Array(n * channels2);
9295
9309
  const kinds = new Uint8Array(n);
9296
- const polylines = new Float64Array(n * channels * POLYLINE);
9310
+ const polylines = new Float64Array(n * channels2 * POLYLINE);
9297
9311
  for (let i = 0; i < n; i++) {
9298
9312
  const a = keys[i];
9299
9313
  times2[i] = a.time;
9300
9314
  const av = a.values;
9301
- if (av !== void 0) for (let c = 0; c < channels; c++) values2[i * channels + c] = av[c];
9315
+ if (av !== void 0) for (let c = 0; c < channels2; c++) values2[i * channels2 + c] = av[c];
9302
9316
  const curve = a.curve ?? "stepped";
9303
9317
  kinds[i] = curve === "linear" ? CURVE_LINEAR : curve === "stepped" ? CURVE_STEPPED : CURVE_BEZIER;
9304
9318
  if (typeof curve === "string" || i + 1 >= n) continue;
@@ -9306,9 +9320,9 @@ function compileCurve(keys, channels) {
9306
9320
  const aStated = a.stated;
9307
9321
  const bStated = b.stated;
9308
9322
  const bValues = b.values;
9309
- for (let c = 0; c < channels; c++) {
9323
+ for (let c = 0; c < channels2; c++) {
9310
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]);
9311
- const o = (i * channels + c) * POLYLINE;
9325
+ const o = (i * channels2 + c) * POLYLINE;
9312
9326
  polylines[o] = a.time;
9313
9327
  polylines[o + 1] = av[c];
9314
9328
  for (let q = 0; q < inner.length; q++) polylines[o + 2 + q] = inner[q];
@@ -9316,7 +9330,7 @@ function compileCurve(keys, channels) {
9316
9330
  polylines[o + POLYLINE - 1] = bValues[c];
9317
9331
  }
9318
9332
  }
9319
- return { keys: n, channels, times: times2, values: values2, kinds, polylines };
9333
+ return { keys: n, channels: channels2, times: times2, values: values2, kinds, polylines };
9320
9334
  }
9321
9335
  function keyAt(curve, cursors, slot, t) {
9322
9336
  const times2 = curve.times;
@@ -9895,8 +9909,8 @@ function compileAnimation(anim, refusals, ignoreEvents, boneIndex2, slotIndex, s
9895
9909
  const ids = Int32Array.from(t.keys.map((k) => resolve(si, k.name ?? null)));
9896
9910
  slotTimelines.push({ slot: si, curve: compileCurve(t.keys, 0), cursor: cursors++, attachments: ids, channels: null });
9897
9911
  } else {
9898
- const channels = COLOUR_CHANNELS[t.kind];
9899
- slotTimelines.push({ slot: si, curve: compileCurve(t.keys, channels.length), cursor: cursors++, attachments: null, channels: Int32Array.from(channels) });
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) });
9900
9914
  }
9901
9915
  }
9902
9916
  }
@@ -11583,11 +11597,11 @@ class RuntimePose {
11583
11597
  if (next !== this.shown[tl.slot] && next >= 0) this.deformed[next] = 0;
11584
11598
  this.shown[tl.slot] = next;
11585
11599
  } else {
11586
- const channels = tl.channels;
11600
+ const channels2 = tl.channels;
11587
11601
  const slot = this.model.slots[tl.slot];
11588
11602
  const o = tl.slot * 4, d = tl.slot * 3;
11589
- for (let f = 0; f < channels.length; f++) {
11590
- const at = channels[f], v = channelValue(tl.curve, i, f, t);
11603
+ for (let f = 0; f < channels2.length; f++) {
11604
+ const at = channels2[f], v = channelValue(tl.curve, i, f, t);
11591
11605
  if (at < 4) {
11592
11606
  const n = o + at;
11593
11607
  this.light[n] = clamp01(alpha === 1 ? v : this.light[n] + (v - this.light[n]) * alpha);
@@ -12154,14 +12168,14 @@ class RuntimePose {
12154
12168
  this.shown[tl.slot] = i < 0 ? slots[tl.slot].setupAttachment : attachments[i];
12155
12169
  continue;
12156
12170
  }
12157
- const channels = tl.channels;
12171
+ const channels2 = tl.channels;
12158
12172
  const slot = slots[tl.slot];
12159
12173
  const setup = slot.light;
12160
12174
  const setupDark = slot.dark;
12161
12175
  const o = tl.slot * 4;
12162
12176
  const d = tl.slot * 3;
12163
- for (let c = 0; c < channels.length; c++) {
12164
- const at = channels[c];
12177
+ for (let c = 0; c < channels2.length; c++) {
12178
+ const at = channels2[c];
12165
12179
  if (at < 4) {
12166
12180
  light[o + at] = i < 0 ? setup[at] : clamp01(channelValue(tl.curve, i, c, t));
12167
12181
  } else if (setupDark !== null && !this.model.omitDarkColour) {
@@ -13196,12 +13210,13 @@ class RigPlayer {
13196
13210
  slotFilter = null;
13197
13211
  /** `slotFilter` as a predicate; every slot when null. */
13198
13212
  draws = () => true;
13199
- /** Handed to every track the player opens; reads the current `adjust` so setting it later needs no reopen. */
13200
- adjustHook = (locals, ctx) => {
13201
- if (this.easing !== null) this.applyEase(this.easing, locals);
13213
+ /** Reads the current `adjust` and set ease during live evaluation. */
13214
+ adjustHook = (locals, ctx) => this.adjustLocals(locals, ctx, this.easing);
13215
+ adjustLocals(locals, ctx, easing) {
13216
+ if (easing !== null) this.applyEase(easing, locals);
13202
13217
  else if (this.drawnPose !== null) for (const [bone2, rotation] of this.drawnPose) locals.bone(bone2).rotation = rotation;
13203
13218
  if (this.adjustFn !== null) this.adjustFn(locals, ctx);
13204
- };
13219
+ }
13205
13220
  listeners = {
13206
13221
  event: /* @__PURE__ */ new Set(),
13207
13222
  complete: /* @__PURE__ */ new Set()
@@ -13422,11 +13437,11 @@ class RigPlayer {
13422
13437
  return tracks;
13423
13438
  }
13424
13439
  /** Stores `raw` and applies the shown set (`activeSet`, or before an ease's swap the composition it eases from). Zero work when none. */
13425
- setRawPose(raw) {
13440
+ setRawPose(raw, set = this.shownSet()) {
13441
+ const pose = set === null ? raw : applySetToPose(this.view, raw, set);
13426
13442
  this.rawPose = raw;
13427
13443
  this.heldParameters = null;
13428
- const set = this.shownSet();
13429
- this.pose = set === null ? raw : applySetToPose(this.view, raw, set);
13444
+ this.pose = pose;
13430
13445
  this.poseGeneration++;
13431
13446
  this.cachedIdentity = null;
13432
13447
  }
@@ -13483,9 +13498,9 @@ class RigPlayer {
13483
13498
  * standing value, `null` returns both to the start values, and the call
13484
13499
  * applies from the next step on, at any time, with no ramp of the player's
13485
13500
  * own — the springs are the smoothing. It is the player's, not a track's:
13486
- * every track and layer answers the same world, and a `seek` or a replay
13487
- * poses under the environment as it stands (no history is kept). Returns the
13488
- * environment now standing.
13501
+ * every track and layer answers the same world, and ordinary replays use the
13502
+ * environment as it stands (no history is kept). `seek` accepts a schedule
13503
+ * for that replay alone. Returns the environment now standing.
13489
13504
  */
13490
13505
  environment(environment) {
13491
13506
  if (environment === null) {
@@ -13637,15 +13652,20 @@ class RigPlayer {
13637
13652
  this.setRawPose(raw);
13638
13653
  }
13639
13654
  /**
13640
- * Moves a single animation on track 0 to `time`: snapshot-backed deterministic
13641
- * seek (#141) that produces the exact pose and physics state of reopening at 0
13642
- * and stepping forward in `seekStep` increments (the last one shorter) until
13643
- * `time` is reached. Events and completes crossed on the way are not fired.
13655
+ * Moves a single animation on track 0 to `time` with the pose and physics
13656
+ * state of reopening at 0 and stepping in `seekStep` increments (the last
13657
+ * one can be shorter). Ordinary seeks reuse snapshots (#141). Events and
13658
+ * completes crossed on the way are not fired.
13644
13659
  * It has a meaning for one animation on one track only — the player cannot
13645
13660
  * replay when a mix, a second track or a queue was asked for — so after any
13646
13661
  * of those it refuses by name; step the player forward instead.
13662
+ * On the oracle, `environmentAt` runs an uncached replay and supplies wind
13663
+ * and gravity at the start of each positive step, including a shorter last
13664
+ * step. On success the resulting physics state continues under the standing
13665
+ * environment. A failed replay leaves the held state in place. The runtime
13666
+ * poser seeks as usual and does not call `environmentAt`.
13647
13667
  */
13648
- seek(time) {
13668
+ seek(time, environmentAt) {
13649
13669
  if (this.animation === null) throw new Error("seek before play: no animation is open");
13650
13670
  if (!(time >= 0) || !Number.isFinite(time)) throw new Error(`seek time must be a finite time at or above 0, got ${String(time)}`);
13651
13671
  if (this.beyondBase) throw new Error("seek is defined for a single animation on track 0; after a mix, another track, a queue or a clear the player cannot replay to a time — step it forward with frame/advance instead");
@@ -13659,6 +13679,10 @@ class RigPlayer {
13659
13679
  this.applyRuntimeTime();
13660
13680
  return;
13661
13681
  }
13682
+ if (environmentAt !== void 0) {
13683
+ this.seekWithEnvironment(time, environmentAt);
13684
+ return;
13685
+ }
13662
13686
  this.easing = null;
13663
13687
  const cache = this.ensureSeekCache();
13664
13688
  const stepper = this.tracks ?? this.track;
@@ -13718,6 +13742,22 @@ class RigPlayer {
13718
13742
  });
13719
13743
  }
13720
13744
  }
13745
+ seekWithEnvironment(time, environmentAt) {
13746
+ let replaying = true;
13747
+ const { stepper, firstPose } = this.openReplay((locals, ctx) => this.adjustLocals(locals, ctx, replaying ? null : this.easing));
13748
+ const standing = stepper.environment;
13749
+ let rawPose = firstPose;
13750
+ this.replaySteps(stepper, time, (dt) => {
13751
+ stepper.setEnvironment(environmentAt(stepper.trackTime));
13752
+ rawPose = stepper.step(dt);
13753
+ });
13754
+ stepper.setEnvironment(standing);
13755
+ this.setRawPose(rawPose, this.activeSet);
13756
+ this.easing = null;
13757
+ replaying = false;
13758
+ if ("first" in stepper) this.track = stepper;
13759
+ else this.tracks = stepper;
13760
+ }
13721
13761
  clearSeekCache() {
13722
13762
  this.seekCache = null;
13723
13763
  }
@@ -13729,21 +13769,7 @@ class RigPlayer {
13729
13769
  if (this.tracks === null && this.track === null) {
13730
13770
  this.reopen();
13731
13771
  }
13732
- let frontier;
13733
- let firstPose;
13734
- if (mode === "tracks") {
13735
- const tracks = openTracks(this.view, { reset: "animation", adjust: this.adjustHook, clock: this.clockHook });
13736
- tracks.setAnimation(0, this.animation, { loop: this.loop, mixDuration: 0 });
13737
- firstPose = tracks.start();
13738
- this.applyPhysicsParameters(tracks);
13739
- this.applyEnvironment(tracks);
13740
- frontier = tracks;
13741
- } else {
13742
- const track = openTrack(this.view, this.animation, { loop: this.loop, reset: "animation", adjust: this.adjustHook, clock: this.clockHook });
13743
- firstPose = this.initializeSingle(track);
13744
- this.applyEnvironment(track);
13745
- frontier = track;
13746
- }
13772
+ const { stepper: frontier, firstPose } = this.openReplay();
13747
13773
  const grid = /* @__PURE__ */ new Map();
13748
13774
  grid.set(0, { state: captureStepperState(frontier), rawPose: firstPose, parameters: this.readParameters(frontier) });
13749
13775
  this.seekCache = {
@@ -13755,6 +13781,21 @@ class RigPlayer {
13755
13781
  };
13756
13782
  return this.seekCache;
13757
13783
  }
13784
+ /** Opens a separate stepper at pose 0 for a seek, without publishing it. */
13785
+ openReplay(adjust = this.adjustHook) {
13786
+ if (this.tracks !== null) {
13787
+ const tracks = openTracks(this.view, { reset: "animation", adjust, clock: this.clockHook });
13788
+ tracks.setAnimation(0, this.animation, { loop: this.loop, mixDuration: 0 });
13789
+ const firstPose2 = tracks.start();
13790
+ this.applyPhysicsParameters(tracks);
13791
+ this.applyEnvironment(tracks);
13792
+ return { stepper: tracks, firstPose: firstPose2 };
13793
+ }
13794
+ const track = openTrack(this.view, this.animation, { loop: this.loop, reset: "animation", adjust, clock: this.clockHook });
13795
+ const firstPose = this.initializeSingle(track);
13796
+ this.applyEnvironment(track);
13797
+ return { stepper: track, firstPose };
13798
+ }
13758
13799
  /** Whatever is open, opened again with track 0's animation as `play` last set it, at pose 0: the single track, or the tracks under `tracks: true`. */
13759
13800
  reopen() {
13760
13801
  if (this.tracks !== null) {
@@ -13783,11 +13824,16 @@ class RigPlayer {
13783
13824
  /** Steps whatever is open forward to `time` in `seekStep` increments, the last one shorter. */
13784
13825
  stepTo(time) {
13785
13826
  const stepper = this.tracks ?? this.track;
13827
+ this.replaySteps(stepper, time, (dt) => {
13828
+ this.rawPose = stepper.step(dt);
13829
+ });
13830
+ if (this.rawPose !== null) this.setRawPose(this.rawPose);
13831
+ }
13832
+ replaySteps(stepper, time, step) {
13786
13833
  const steps = Math.floor(time / this.seekStep);
13787
- for (let i = 0; i < steps; i++) this.rawPose = stepper.step(this.seekStep);
13834
+ for (let i = 0; i < steps; i++) step(this.seekStep);
13788
13835
  const rest = time - stepper.trackTime;
13789
- if (rest > 0) this.rawPose = stepper.step(rest);
13790
- if (this.rawPose !== null) this.setRawPose(this.rawPose);
13836
+ if (rest > 0) step(rest);
13791
13837
  }
13792
13838
  on(type, listener) {
13793
13839
  const set = this.listeners[type];
@@ -14839,12 +14885,92 @@ class RigPlayer {
14839
14885
  }
14840
14886
  }
14841
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
+ }
14842
14966
  export {
14843
14967
  CanvasRenderer,
14844
14968
  DomRenderer,
14845
14969
  RigPlayer,
14846
14970
  createAtlasRegions,
14971
+ discoverTurnDials,
14847
14972
  loadModel,
14973
+ normalizedDial,
14848
14974
  readSetupMesh,
14849
14975
  revokeRegions,
14850
14976
  unpackRegions