@rig-c/play 1.28.0 → 1.29.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.
@@ -1 +1 @@
1
- {"version":3,"file":"composed-camera.d.ts","sourceRoot":"","sources":["../src/composed-camera.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACtC,KAAK,OAAO,GAAG;IAAE,UAAU,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,CAAC;AAOtD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,KAAK,CAMhG;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAOhF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAEjE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAK7D;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,MAAM;;;;;;;;;;gBA6B7C,MAAM,UAAU,KAAK;EAoBpC;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAOrE"}
1
+ {"version":3,"file":"composed-camera.d.ts","sourceRoot":"","sources":["../src/composed-camera.ts"],"names":[],"mappings":"AAAA,KAAK,KAAK,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACtC,KAAK,OAAO,GAAG;IAAE,UAAU,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,CAAC;AAOtD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,KAAK,CAMhG;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAOhF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAEjE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAK7D;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,MAAM;;;;;;;;;;gBA6B7C,MAAM,UAAU,KAAK;EAoBpC;AAwCD,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAOrE"}
@@ -97,10 +97,23 @@ type TurnReadout = TurnValue & {
97
97
  /** Whether the current pointer request reaches a limit before easing. */
98
98
  readonly clamped: boolean;
99
99
  };
100
+ export type SceneHandoff = {
101
+ readonly behavior: 'hold';
102
+ readonly phase: number;
103
+ } | {
104
+ readonly behavior: 'additive';
105
+ readonly phase: null;
106
+ } | {
107
+ readonly behavior: 'refused';
108
+ readonly phase: null;
109
+ readonly reason: string;
110
+ };
100
111
  export interface MountedTake<PlaneOffsets extends Offsets = Offsets> {
101
112
  readonly canvas: HTMLCanvasElement;
102
113
  readonly player: RigPlayer;
103
114
  readonly mode: CameraMode;
115
+ /** Active scene-clock behavior and, during hold mode, its unwrapped compiled seconds. */
116
+ readonly sceneHandoff: SceneHandoff;
104
117
  /** Displayed offsets in CSS pixels, with Y down. */
105
118
  readonly offsets: PlaneOffsets;
106
119
  readonly cameraExcursion: Point;
@@ -1 +1 @@
1
- {"version":3,"file":"composed-take.d.ts","sourceRoot":"","sources":["../src/composed-take.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAwB,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpH,OAAO,EAA0F,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE/I,OAAO,EAAE,SAAS,EAAmB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAwC,KAAK,UAAU,EAAoC,MAAM,iBAAiB,CAAC;AAC1H,OAAO,EAGL,KAAK,gBAAgB,EAAyB,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAC7F,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAElF,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE9F,KAAK,KAAK,GAAG;IAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACxD,KAAK,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAI/C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,KAAK,CAAC,EAAE;QA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QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC;IAChC,sEAAsE;IACtE,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC3C,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,KAAK,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1D,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;CACjB;AA4TD,yFAAyF;AACzF,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1C,IAAI,CAEN;AAwSD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { r as readModel, C as CORE_DOCUMENT_SPEC, p as poseRawAnimation, a as CoreInputError, l as loadModel, b as CanvasRenderer, R as RigPlayer, d as discoverTurnDials, n as normalizedDial, u as underNoSkin, c as poseRawSetup, f as frameOf, e as frameSource, g as rememberComposedClip } from "./_play-runtime.js";
1
+ import { u as underNoSkin, o as openTrack, r as readModel, C as CORE_DOCUMENT_SPEC, p as poseRawAnimation, a as CoreInputError, l as loadModel, b as CanvasRenderer, R as RigPlayer, d as discoverTurnDials, n as normalizedDial, c as poseRawSetup, f as frameOf, e as frameSource, g as rememberComposedClip } from "./_play-runtime.js";
2
2
  const ORIGIN = { x: 0, y: 0 };
3
3
  const GAINS = { background: -0.55, figure: 0, foreground: 0.55 };
4
4
  const TIME_CONSTANT = 0.12;
@@ -79,6 +79,44 @@ function createCameraHandoff(transitionSeconds) {
79
79
  }
80
80
  };
81
81
  }
82
+ function createSceneClock(time, transitionSeconds, inside) {
83
+ let phase = time;
84
+ let last = time;
85
+ let from = inside ? 0 : 1;
86
+ let to = from;
87
+ let elapsed = transitionSeconds;
88
+ const integral = (u) => u * u * u * (1 - u / 2);
89
+ const rate = () => {
90
+ const u = transitionSeconds === 0 ? 1 : Math.min(1, elapsed / transitionSeconds);
91
+ return from + (to - from) * u * u * (3 - 2 * u);
92
+ };
93
+ return {
94
+ get phase() {
95
+ return phase;
96
+ },
97
+ aim(hover) {
98
+ const target = hover ? 0 : 1;
99
+ if (target === to) return;
100
+ from = rate();
101
+ to = target;
102
+ elapsed = 0;
103
+ },
104
+ advance(time2) {
105
+ const dt = time2 - last;
106
+ if (!(dt > 0)) return;
107
+ last = time2;
108
+ const ramp = Math.min(dt, Math.max(0, transitionSeconds - elapsed));
109
+ if (ramp > 0) {
110
+ const a = elapsed / transitionSeconds;
111
+ elapsed += ramp;
112
+ const b = elapsed / transitionSeconds;
113
+ const advance = ramp * from + (to - from) * transitionSeconds * (integral(b) - integral(a));
114
+ phase += Math.min(ramp, Math.max(0, advance));
115
+ }
116
+ phase += (dt - ramp) * to;
117
+ }
118
+ };
119
+ }
82
120
  function planeOffsets(camera, mode) {
83
121
  if (mode === "fixed") return { background: ORIGIN, figure: ORIGIN, foreground: ORIGIN };
84
122
  return {
@@ -145,6 +183,148 @@ function sceneCameraModelDigest(report, refuse) {
145
183
  const camera = readCameraHeader(report, refuse);
146
184
  return camera === null ? null : requireDigest(camera.digest, refuse);
147
185
  }
186
+ const numericBoneChannels = {
187
+ translate: ["x", "y"],
188
+ translatex: ["x"],
189
+ translatey: ["y"],
190
+ scale: ["scaleX", "scaleY"],
191
+ scalex: ["scaleX"],
192
+ scaley: ["scaleY"],
193
+ shear: ["shearX", "shearY"],
194
+ shearx: ["shearX"],
195
+ sheary: ["shearY"],
196
+ rotate: ["rotation"]
197
+ };
198
+ const nameEscapes = { "%25": "%", "%20": " ", "%2E": ".", "%2F": "/" };
199
+ const encodedBone = /^bone ((?:[^%. /]|%25|%20|%2E|%2F)+)\.([a-z]+)$/;
200
+ function bindSceneHold(report, doc, name, view, loop, backdrop, dialBones) {
201
+ const reject = (reason) => ({ behavior: "refused", reason });
202
+ if (!isRecord(report) || !Object.hasOwn(report, "scene_driven")) return { behavior: "additive" };
203
+ const declaration = report.scene_driven;
204
+ if (!isRecord(declaration)) return reject("invalid scene_driven declaration");
205
+ if (!Object.hasOwn(declaration, name)) return { behavior: "additive" };
206
+ const take = declaration[name];
207
+ if (!isRecord(take) || typeof take.view !== "boolean" || !Array.isArray(take.timelines)) {
208
+ return reject(`invalid scene_driven entry for ${JSON.stringify(name)}`);
209
+ }
210
+ if (report.spec !== "spine-parts-scene-report/2") return reject("scene report /1 has no digest-bound keyed camera");
211
+ if (take.view !== (view !== null)) return reject(`scene_driven.view disagrees with keyed camera for ${JSON.stringify(name)}`);
212
+ if (!take.view) return reject(`scene_driven.view is false for ${JSON.stringify(name)}`);
213
+ if (!loop) return reject(`non-looping take ${JSON.stringify(name)}`);
214
+ const animation = doc.animations.find((row) => row.name === name);
215
+ if (animation === void 0) return reject(`unknown take ${JSON.stringify(name)}`);
216
+ const source = animation.timelines;
217
+ const selected = /* @__PURE__ */ new Map();
218
+ const channels = /* @__PURE__ */ new Map();
219
+ for (const address of take.timelines) {
220
+ const match = typeof address === "string" ? encodedBone.exec(address) : null;
221
+ if (match === null || match[0] !== address || !Object.hasOwn(numericBoneChannels, match[2])) {
222
+ return reject(`unsupported or malformed timeline address ${JSON.stringify(address)}`);
223
+ }
224
+ const bone = match[1].replace(/%25|%20|%2E|%2F/g, (escape) => nameEscapes[escape]);
225
+ const property = match[2];
226
+ const target = source.bones.find((row) => row.name === bone);
227
+ if (!target?.timelines.some((timeline) => timeline.kind === property) || selected.get(bone)?.has(property)) {
228
+ return reject(`unresolved or repeated timeline address ${JSON.stringify(address)}`);
229
+ }
230
+ const properties = selected.get(bone) ?? /* @__PURE__ */ new Set();
231
+ properties.add(property);
232
+ selected.set(bone, properties);
233
+ const fields = channels.get(bone) ?? /* @__PURE__ */ new Set();
234
+ for (const field of numericBoneChannels[property]) {
235
+ fields.add(field);
236
+ }
237
+ channels.set(bone, fields);
238
+ }
239
+ for (const target of source.bones) {
240
+ const fields = channels.get(target.name);
241
+ if (!fields) continue;
242
+ for (const { kind } of target.timelines) {
243
+ if (kind === "inherit" || selected.get(target.name)?.has(kind)) continue;
244
+ if (numericBoneChannels[kind].some((field) => fields.has(field))) {
245
+ return reject(`scene and life timelines share a local on bone ${JSON.stringify(target.name)}.${kind}`);
246
+ }
247
+ }
248
+ }
249
+ const slot = doc.slots.find((row) => row.name === backdrop);
250
+ if (!slot) return reject(`unresolved backdrop slot ${JSON.stringify(backdrop)}`);
251
+ const skin = doc.skins.find((row) => row.name === "default");
252
+ const region = slot.setup === null ? void 0 : skin?.attachments[slot.name]?.[slot.setup];
253
+ if (region?.kind !== "region") return reject(`backdrop slot ${JSON.stringify(backdrop)} needs a stable setup region`);
254
+ const ancestry = /* @__PURE__ */ new Set();
255
+ const bonesByName = new Map(doc.bones.map((bone) => [bone.name, bone]));
256
+ for (let bone = bonesByName.get(slot.bone); bone !== void 0; bone = bone.parent === void 0 ? void 0 : bonesByName.get(bone.parent)) {
257
+ ancestry.add(bone.name);
258
+ }
259
+ for (const bone of ancestry) {
260
+ const live = source.bones.find((row) => row.name === bone)?.timelines.find((timeline) => !selected.get(bone)?.has(timeline.kind));
261
+ if (live) return reject(`backdrop ${JSON.stringify(backdrop)} depends on live bone ${JSON.stringify(bone)}.${live.kind}`);
262
+ if (dialBones.has(bone)) return reject(`backdrop ${JSON.stringify(backdrop)} depends on pointer dial bone ${JSON.stringify(bone)}`);
263
+ }
264
+ const slotKey = source.slots.find((row) => row.name === backdrop)?.timelines[0];
265
+ if (slotKey) return reject(`backdrop slot ${JSON.stringify(backdrop)} has a live ${slotKey.kind} timeline`);
266
+ if (source.attachments.some((row) => row.slot === backdrop)) {
267
+ return reject(`backdrop slot ${JSON.stringify(backdrop)} has a live attachment timeline`);
268
+ }
269
+ if (source.drawOrder.length) return reject("backdrop depends on live drawOrder");
270
+ const backdropIndex = doc.slots.indexOf(slot);
271
+ for (const [index, earlier] of doc.slots.slice(0, backdropIndex).entries()) {
272
+ for (const attachment of Object.values(skin?.attachments[earlier.name] ?? {})) {
273
+ const geometry = attachment.geometry;
274
+ if (geometry?.kind !== "clipping") continue;
275
+ const end = doc.slots.findIndex((row) => row.name === geometry.end);
276
+ if (end <= index || end >= backdropIndex) {
277
+ return reject(`backdrop ${JSON.stringify(backdrop)} depends on clipping slot ${JSON.stringify(earlier.name)}`);
278
+ }
279
+ }
280
+ }
281
+ for (const { record } of doc.constraints) {
282
+ if (record === void 0) continue;
283
+ const writesBackdrop = record.kind === "slider" ? record.timelines.bones.some((row) => ancestry.has(row.name)) || record.timelines.slots.some((row) => row.name === backdrop) || record.timelines.attachments.some((row) => row.slot === backdrop) || record.timelines.drawOrder.length > 0 : record.kind === "physics" ? ancestry.has(record.bone) : record.bones.some((bone) => ancestry.has(bone));
284
+ if (writesBackdrop) return reject(`backdrop ${JSON.stringify(backdrop)} depends on ${record.kind} constraint ${JSON.stringify(record.name)}`);
285
+ }
286
+ const backdropSteps = /* @__PURE__ */ new Set();
287
+ for (const { name: name2, timelines } of source.bones) {
288
+ if (!ancestry.has(name2)) continue;
289
+ for (const { keys } of timelines) {
290
+ for (let i = 1; i < keys.length; i++) {
291
+ if (keys[i - 1].curve === "stepped") backdropSteps.add(keys[i].time);
292
+ }
293
+ }
294
+ }
295
+ const owned = [...channels].map(([name2, fields]) => ({ name: name2, fields: [...fields], values: [] }));
296
+ const sampleDoc = underNoSkin(doc);
297
+ let sampler;
298
+ const openSampler = () => openTrack(sampleDoc, name, {
299
+ loop: true,
300
+ reset: "animation",
301
+ // Read authored values before the solve. The sampler has no physics history
302
+ // to advance and its raw poses and events are discarded.
303
+ clock: () => 0,
304
+ adjust(locals) {
305
+ for (const { name: name2, fields, values } of owned) {
306
+ const local = locals.bone(name2);
307
+ for (const [i, field] of fields.entries()) values[i] = local[field];
308
+ }
309
+ }
310
+ });
311
+ return {
312
+ behavior: "hold",
313
+ backdropSteps,
314
+ apply(bones, time) {
315
+ if (owned.length === 0) return;
316
+ const previous = sampler?.trackTime ?? 0;
317
+ if (sampler === void 0 || time < previous || previous + (time - previous) !== time) {
318
+ sampler = openSampler();
319
+ }
320
+ if (time !== sampler.trackTime) sampler.step(time - sampler.trackTime);
321
+ for (const { name: name2, fields, values } of owned) {
322
+ const live = bones.bone(name2);
323
+ for (const [i, field] of fields.entries()) live[field] = values[i];
324
+ }
325
+ }
326
+ };
327
+ }
148
328
  function finiteTuple(value, length) {
149
329
  return Array.isArray(value) && value.length === length && [...value].every(finite);
150
330
  }
@@ -382,20 +562,29 @@ function readTrack(raw, compiled, stage, label, refuse) {
382
562
  const easedSeam = loop && (easedStart || easedEnd);
383
563
  if (start && (easedSeam || easedStart)) cameraView(stage, start, label, refuse);
384
564
  if (end && (easedSeam || easedEnd)) cameraView(stage, end, label, refuse);
565
+ const compiledKeys = keys.map((key) => key.t === duration ? compiled : key.t / duration * compiled);
566
+ const authoredKeys = new Map(compiledKeys.map((time, i) => [time, keys[i].t]));
385
567
  return {
386
568
  duration,
387
569
  compiledDuration: compiled,
388
570
  loop,
389
- sample(time) {
571
+ authoredTime(time) {
572
+ return authoredKeys.get(time) ?? time / compiled * duration;
573
+ },
574
+ sample(time, compiledTime, backdropSteps) {
390
575
  if (time === 0 && (easedSeam || easedStart) && start) return start;
391
576
  if (time === duration && (easedSeam || easedEnd) && end) return end;
577
+ const sharedStep = (i) => i > 0 && i < keys.length - 1 && keys[i - 1].curve === "stepped" && backdropSteps?.has(Math.fround(compiledKeys[i]));
392
578
  let low = 0, high = keys.length - 1;
393
579
  while (low < high) {
394
580
  const mid = Math.ceil((low + high) / 2);
395
- if (keys[mid].t <= time) low = mid;
581
+ const boundary = compiledTime === void 0 ? keys[mid].t : sharedStep(mid) ? Math.fround(compiledKeys[mid]) : compiledKeys[mid];
582
+ if (boundary <= (compiledTime ?? time)) low = mid;
396
583
  else high = mid - 1;
397
584
  }
398
585
  const from = keys[low], to = keys[low + 1];
586
+ if (compiledTime !== void 0 && sharedStep(low)) time = Math.max(from.t, time);
587
+ if (from.curve === "stepped" && core && compiledTime !== void 0) return core(from.t);
399
588
  if (from.curve !== void 0 && core) return core(time);
400
589
  if (time === from.t || to === void 0) return from;
401
590
  const phase = (time - from.t) / (to.t - from.t);
@@ -416,7 +605,7 @@ function cameraTimes(track, clock, refuse) {
416
605
  const limit = authored ? duration : compiledDuration;
417
606
  const otherLimit = authored ? compiledDuration : duration;
418
607
  const time = limit === 0 || clock.seconds === 0 ? 0 : loop ? clock.seconds % limit : Math.min(clock.seconds, limit);
419
- const otherTime = time === limit ? otherLimit : time / limit * otherLimit;
608
+ const otherTime = time === limit ? otherLimit : authored ? time / limit * otherLimit : track.authoredTime(time);
420
609
  return authored ? { authoredSeconds: time, compiledSeconds: otherTime } : { authoredSeconds: otherTime, compiledSeconds: time };
421
610
  }
422
611
  function bindSceneCameraReport(report, model, refuse) {
@@ -449,12 +638,13 @@ function bindSceneCameraReport(report, model, refuse) {
449
638
  }
450
639
  const output = Object.freeze({ width: stage.width, height: stage.height });
451
640
  return Object.freeze({
452
- sample(animation, clock) {
641
+ sample(animation, clock, backdropSteps) {
453
642
  if (!durations.has(animation)) refuse("SCENE_CAMERA_CLIP_MISMATCH", `unknown model animation ${JSON.stringify(animation)}`);
454
643
  const track = bound.get(animation);
455
644
  if (!track) return null;
456
645
  const times = cameraTimes(track, clock, refuse);
457
- const { pan, zoom } = track.sample(times.authoredSeconds);
646
+ const compiledPhase = "basis" in clock && clock.basis === "compiled" ? times.compiledSeconds : void 0;
647
+ const { pan, zoom } = track.sample(times.authoredSeconds, compiledPhase, backdropSteps);
458
648
  const viewWorld = cameraView(stage, { pan, zoom }, `scene camera track ${JSON.stringify(animation)} at ${times.authoredSeconds} s`, refuse);
459
649
  return Object.freeze({
460
650
  animation,
@@ -1048,8 +1238,8 @@ async function mountComposedTake(root, options) {
1048
1238
  let player;
1049
1239
  let audit;
1050
1240
  try {
1051
- let cameraFor = function(animation, animationTime, loop2) {
1052
- const view = bound?.sample(animation, { basis: "compiled", seconds: animationTime }) ?? null;
1241
+ let cameraFor = function(animation, animationTime, loop2, backdropSteps) {
1242
+ const view = bound?.sample(animation, { basis: "compiled", seconds: animationTime }, backdropSteps) ?? null;
1053
1243
  if (view && view.loop !== loop2) {
1054
1244
  refuseSceneCamera("SCENE_CAMERA_CLIP_MISMATCH", `loop must match the authored camera track for ${JSON.stringify(animation)}`);
1055
1245
  }
@@ -1062,6 +1252,38 @@ async function mountComposedTake(root, options) {
1062
1252
  legacyPlanes.set(animation, named);
1063
1253
  }
1064
1254
  return named;
1255
+ }, configureScene = function(next, animation, loop2, time, reset = false) {
1256
+ if (!reset && scene.mode === next && scene.animation === animation && scene.loop === loop2) return false;
1257
+ const wasHolding = scene.clock !== null;
1258
+ let binding = { behavior: "additive" };
1259
+ if (next === "parallax" && animation !== null) {
1260
+ const key = JSON.stringify([animation, loop2]);
1261
+ binding = bindings.get(key) ?? bindSceneHold(
1262
+ report,
1263
+ assets.document.doc,
1264
+ animation,
1265
+ bound?.sample(animation, { basis: "compiled", seconds: 0 }) ?? null,
1266
+ loop2,
1267
+ driftEvidence?.backdrop,
1268
+ dialBones
1269
+ );
1270
+ bindings.set(key, binding);
1271
+ if (composedTracks && binding.behavior === "hold") {
1272
+ binding = { behavior: "refused", reason: "scene hold requires a single unmixed animation track" };
1273
+ } else if (skin !== void 0 && binding.behavior === "hold") {
1274
+ binding = { behavior: "refused", reason: `backdrop depends on unverified skin ${JSON.stringify(skin)}` };
1275
+ } else if (externalAdjust && binding.behavior === "hold") {
1276
+ binding = { behavior: "refused", reason: "backdrop depends on an external player local adjustment" };
1277
+ }
1278
+ }
1279
+ scene = {
1280
+ mode: next,
1281
+ animation,
1282
+ loop: loop2,
1283
+ binding,
1284
+ clock: binding.behavior === "hold" ? createSceneClock(time, transitionSeconds, hover !== void 0) : null
1285
+ };
1286
+ return wasHolding || scene.clock !== null;
1065
1287
  }, syncTurn = function(next) {
1066
1288
  if (!dials.length) return;
1067
1289
  const weight = mode === "parallax" && next === mode ? handoff.weight : 0;
@@ -1069,6 +1291,20 @@ async function mountComposedTake(root, options) {
1069
1291
  if (weight !== turnInput.weight || pointer.x !== turnInput.pointer.x || pointer.y !== turnInput.pointer.y) {
1070
1292
  turnInput = { weight, pointer };
1071
1293
  }
1294
+ }, changedExternalAdjust = function(player2) {
1295
+ const current = player2.adjust !== null && player2.adjust !== adjustTurn;
1296
+ if (current === externalAdjust) return false;
1297
+ externalAdjust = current;
1298
+ return true;
1299
+ }, syncAdjust = function(player2, changed) {
1300
+ if (!hasSceneDeclaration) {
1301
+ if (player2.adjust === adjustTurn && posedTurnInput !== turnInput) player2.repose();
1302
+ return;
1303
+ }
1304
+ const needsHook = dials.length > 0 || scene.clock !== null;
1305
+ if (needsHook && player2.adjust === null) player2.adjust = adjustTurn;
1306
+ else if (!needsHook && player2.adjust === adjustTurn) player2.adjust = null;
1307
+ else if (changed || posedTurnInput !== turnInput) player2.repose();
1072
1308
  }, createCoverageChecks = function() {
1073
1309
  const renderer2 = audit = new CanvasRenderer(doc.createElement("div"), assets.pageImages);
1074
1310
  renderer2.backend = backend;
@@ -1176,9 +1412,18 @@ async function mountComposedTake(root, options) {
1176
1412
  if (nonOpaque) {
1177
1413
  throw plateCoverageError(backdrop, next, `${nonOpaque} stage pixels have alpha below 255 at ${layout.width} × ${layout.height} backing px`);
1178
1414
  }
1179
- }, currentFrame = function(next, named, keyed) {
1415
+ }, syncPose = function(next) {
1180
1416
  syncTurn(next);
1181
- if (posedTurnInput !== turnInput) poser.repose();
1417
+ const entry = poser.entry();
1418
+ const changed = configureScene(
1419
+ next,
1420
+ entry?.animation ?? null,
1421
+ entry?.loop ?? false,
1422
+ entry?.trackTime ?? 0,
1423
+ changedExternalAdjust(poser)
1424
+ );
1425
+ syncAdjust(poser, changed);
1426
+ }, currentFrame = function(named, keyed) {
1182
1427
  const frame = poser.posedFrame(null);
1183
1428
  return { frame, backdrop: checkFrame(frame, planes, named?.backdrop, keyed) };
1184
1429
  }, requireKeyedCoverage = function(view, next, excursion) {
@@ -1256,24 +1501,29 @@ async function mountComposedTake(root, options) {
1256
1501
  if (next === "parallax" && hover !== void 0) handoff.enter();
1257
1502
  }
1258
1503
  mode = next;
1504
+ if (!namedInput && mode !== "parallax") hover = void 0;
1259
1505
  if (!namedInput && switching && mode === "fixed") camera = target = NEUTRAL;
1260
1506
  offsets = displayed;
1261
1507
  if (namedInput && mode === "parallax") handoff.painted();
1262
1508
  canvas.style.visibility = "";
1263
1509
  Object.assign(canvas.style, { width: "100%", height: "100%", transform: "none", pointerEvents: "auto" });
1264
1510
  }, select = function(next, switching, allowFallback) {
1511
+ syncPose(next);
1265
1512
  const entry = bound && poser.entry();
1266
- const view = entry?.animation ? cameraFor(entry.animation, entry.animationTime, entry.loop) : null;
1513
+ const backdropSteps = scene.binding.behavior === "hold" ? scene.binding.backdropSteps : void 0;
1514
+ const view = entry?.animation ? cameraFor(entry.animation, scene.clock?.phase ?? entry.animationTime, entry.loop, backdropSteps) : null;
1267
1515
  drawingKeyed = view !== null;
1268
1516
  const named = view ? void 0 : planesFor(entry?.animation ?? initialAnimation);
1269
- const { frame, backdrop } = currentFrame(next, named, drawingKeyed);
1517
+ const { frame, backdrop } = currentFrame(named, drawingKeyed);
1270
1518
  try {
1271
1519
  drawMode(frame, backdrop, next, switching, view, named);
1272
1520
  } catch (error) {
1273
1521
  if (!(error instanceof ComposedTakeError) || error.code !== "COMPOSED_BACKDROP_COVERAGE" || next === "fixed" || !named && !view && !allowFallback) throw error;
1274
1522
  try {
1275
- const fixed = turnInput.weight === 0 ? { frame, backdrop } : currentFrame("fixed", named, drawingKeyed);
1276
- drawMode(fixed.frame, fixed.backdrop, "fixed", true, view, named);
1523
+ syncPose("fixed");
1524
+ const fixed = currentFrame(named, drawingKeyed);
1525
+ const fixedView = entry?.animation ? cameraFor(entry.animation, entry.animationTime, entry.loop) : null;
1526
+ drawMode(fixed.frame, fixed.backdrop, "fixed", true, fixedView, named);
1277
1527
  } catch (fixedError) {
1278
1528
  canvas.style.visibility = "hidden";
1279
1529
  throw fixedError;
@@ -1325,9 +1575,10 @@ async function mountComposedTake(root, options) {
1325
1575
  if (autoStart) syncCamera(window.performance.now());
1326
1576
  hover = void 0;
1327
1577
  target = NEUTRAL;
1578
+ scene.clock?.aim(false);
1328
1579
  if (mode === "parallax") handoff.leave();
1329
1580
  };
1330
- const bound = digest === null ? null : bindSceneCamera(report, { sha256, stage: assets.stage, animations: assets.animations });
1581
+ const bound = digest === null ? null : bindSceneCameraReport(report, { sha256, stage: assets.stage, animations: assets.animations }, refuseSceneCamera);
1331
1582
  const driftEvidence = bound && sceneCameraDriftEvidence(report, refuseSceneCamera);
1332
1583
  const initialView = cameraFor(options.animation, 0, loop);
1333
1584
  if (!initialView && loop !== true) throw new ComposedTakeError("COMPOSED_LOOP_REQUIRED", "declare the existing take as loop: true");
@@ -1345,11 +1596,25 @@ async function mountComposedTake(root, options) {
1345
1596
  let keyedGains = initialView ? keyedPlaneGains(options.planes) : void 0;
1346
1597
  const dials = namedInput && options.pointerTurn !== false ? discoverTurnDials(assets.document.parsed, assets.animations) : [];
1347
1598
  const handoff = createCameraHandoff(transitionSeconds);
1599
+ const hasSceneDeclaration = typeof report === "object" && report !== null && Object.hasOwn(report, "scene_driven");
1348
1600
  let mode = initial;
1601
+ let hover;
1602
+ let scene = { mode: initial, animation: null, loop: false, binding: { behavior: "additive" }, clock: null };
1603
+ const dialBones = new Set(dials.map((dial) => dial.bone));
1604
+ const bindings = /* @__PURE__ */ new Map();
1605
+ let replaying = false;
1606
+ let composedTracks = false;
1607
+ let skin;
1608
+ let externalAdjust = false;
1609
+ configureScene(initial, initialAnimation, loop, 0, true);
1349
1610
  let turnInput = { weight: 0, pointer: NEUTRAL };
1350
1611
  let posedTurnInput = turnInput;
1351
1612
  let turnValues = [];
1352
- const adjustTurn = (bones) => {
1613
+ const adjustTurn = (bones, ctx) => {
1614
+ if (!replaying && scene.binding.behavior === "hold" && scene.clock && ctx.animation === scene.animation && ctx.trackTime !== null) {
1615
+ scene.clock.advance(ctx.trackTime);
1616
+ scene.binding.apply(bones, scene.clock.phase);
1617
+ }
1353
1618
  const { weight, pointer } = turnInput;
1354
1619
  turnValues = dials.map((dial) => {
1355
1620
  const { axis, bone, channel, min, max } = dial;
@@ -1371,7 +1636,64 @@ async function mountComposedTake(root, options) {
1371
1636
  aspectRatio: `${stage.width} / ${stage.height}`
1372
1637
  });
1373
1638
  root.appendChild(surface);
1374
- const poser = player = new RigPlayer(surface, assets, { mode: "canvas", adjust: dials.length ? adjustTurn : null });
1639
+ const poser = player = new RigPlayer(surface, assets, { mode: "canvas", adjust: dials.length || scene.clock ? adjustTurn : null });
1640
+ if (hasSceneDeclaration) {
1641
+ let resetSceneAtEntry = function() {
1642
+ changedExternalAdjust(poser);
1643
+ const entry = poser.entry();
1644
+ const changed = configureScene(mode, entry?.animation ?? null, entry?.loop ?? false, entry?.trackTime ?? 0, true);
1645
+ syncAdjust(poser, changed);
1646
+ }, replay = function(operation) {
1647
+ replaying = true;
1648
+ try {
1649
+ operation();
1650
+ } finally {
1651
+ replaying = false;
1652
+ }
1653
+ }, composeWithoutScene = function(operation) {
1654
+ replay(operation);
1655
+ composedTracks = true;
1656
+ resetSceneAtEntry();
1657
+ };
1658
+ const base = RigPlayer.prototype;
1659
+ const methods = {
1660
+ play(name, options2 = {}) {
1661
+ const { track = 0, mix = 0, alpha = 1, additive = false } = options2;
1662
+ replay(() => base.play.call(poser, name, options2));
1663
+ composedTracks ||= track !== 0 || mix !== 0 || alpha !== 1 || additive;
1664
+ resetSceneAtEntry();
1665
+ },
1666
+ seek(...args) {
1667
+ replay(() => base.seek.call(poser, ...args));
1668
+ resetSceneAtEntry();
1669
+ },
1670
+ queue(...args) {
1671
+ composeWithoutScene(() => base.queue.call(poser, ...args));
1672
+ },
1673
+ clear(...args) {
1674
+ composeWithoutScene(() => base.clear.call(poser, ...args));
1675
+ },
1676
+ queueClear(...args) {
1677
+ composeWithoutScene(() => base.queueClear.call(poser, ...args));
1678
+ },
1679
+ setAlpha(...args) {
1680
+ composeWithoutScene(() => base.setAlpha.call(poser, ...args));
1681
+ }
1682
+ };
1683
+ for (const [name, value] of Object.entries(methods)) {
1684
+ Object.defineProperty(poser, name, { value, configurable: true, writable: true });
1685
+ }
1686
+ const skinProperty = Object.getOwnPropertyDescriptor(base, "skin");
1687
+ Object.defineProperty(poser, "skin", {
1688
+ ...skinProperty,
1689
+ set(name) {
1690
+ if (name === poser.skin) return;
1691
+ replay(() => skinProperty.set.call(poser, name));
1692
+ skin = poser.skin;
1693
+ resetSceneAtEntry();
1694
+ }
1695
+ });
1696
+ }
1375
1697
  const renderer = poser.renderer;
1376
1698
  const backend = options.backend ?? "webgl";
1377
1699
  renderer.backend = backend;
@@ -1382,7 +1704,6 @@ async function mountComposedTake(root, options) {
1382
1704
  let offsets = planeOffsets(NEUTRAL, "fixed");
1383
1705
  let camera = NEUTRAL;
1384
1706
  let target = NEUTRAL;
1385
- let hover;
1386
1707
  let layout;
1387
1708
  let keyedAdmission;
1388
1709
  let legacyLayoutPending = true;
@@ -1401,7 +1722,7 @@ async function mountComposedTake(root, options) {
1401
1722
  const boundaryEvent = (event) => event.target === root || event.bubbles;
1402
1723
  const aim = (event) => {
1403
1724
  if (!event.isPrimary || stopped) return;
1404
- if (namedInput) {
1725
+ if (namedInput || scene.clock) {
1405
1726
  if (event.pointerType === "touch" || event.type === "pointerenter" && !boundaryEvent(event) || hover !== void 0 && hover !== event.pointerId) return;
1406
1727
  if (event.pointerType === "pen" && event.buttons !== 0) {
1407
1728
  leave();
@@ -1411,33 +1732,37 @@ async function mountComposedTake(root, options) {
1411
1732
  if (!Number.isFinite(event.clientX) || !Number.isFinite(event.clientY)) return;
1412
1733
  const box = surface.getBoundingClientRect();
1413
1734
  if (!(box.width > 0 && box.height > 0)) return;
1414
- if (namedInput) {
1415
- if (autoStart) syncCamera(window.performance.now());
1416
- if (hover === void 0 && mode === "parallax") handoff.enter();
1735
+ if (namedInput || scene.clock) {
1736
+ if (namedInput && autoStart) syncCamera(window.performance.now());
1737
+ if (hover === void 0 && mode === "parallax") {
1738
+ if (namedInput) handoff.enter();
1739
+ scene.clock?.aim(true);
1740
+ }
1417
1741
  hover = event.pointerId;
1418
1742
  }
1419
1743
  target = pointerTarget(event.clientX, event.clientY, box);
1420
1744
  };
1421
1745
  const recenter = (event) => {
1422
1746
  if (!event.isPrimary) return;
1423
- if (!namedInput) {
1424
- target = NEUTRAL;
1425
- return;
1426
- }
1427
1747
  if (event.pointerType !== "touch" && hover === event.pointerId && (event.type !== "pointerleave" || boundaryEvent(event))) leave();
1748
+ else if (!namedInput && !scene.clock) target = NEUTRAL;
1428
1749
  };
1429
1750
  const contact = (event) => {
1430
1751
  if (event.pointerType === "pen" && event.isPrimary && hover === event.pointerId) leave();
1431
1752
  };
1753
+ const hoverEnter = (event) => {
1754
+ if (namedInput || scene.clock) aim(event);
1755
+ };
1756
+ const hoverLost = (event) => {
1757
+ if (namedInput || scene.clock || hover !== void 0) recenter(event);
1758
+ };
1432
1759
  root.addEventListener("pointermove", aim, true);
1433
1760
  root.addEventListener("pointerleave", recenter, true);
1434
1761
  root.addEventListener("pointercancel", recenter, true);
1435
- if (namedInput) {
1436
- root.addEventListener("pointerenter", aim, true);
1437
- root.addEventListener("pointerdown", contact, true);
1438
- root.addEventListener("lostpointercapture", recenter, true);
1439
- window.addEventListener("blur", leave);
1440
- }
1762
+ root.addEventListener("pointerenter", hoverEnter, true);
1763
+ root.addEventListener("pointerdown", contact, true);
1764
+ root.addEventListener("lostpointercapture", hoverLost, true);
1765
+ window.addEventListener("blur", leave);
1441
1766
  const observer = new ResizeObserver(() => {
1442
1767
  try {
1443
1768
  render();
@@ -1474,6 +1799,11 @@ async function mountComposedTake(root, options) {
1474
1799
  get mode() {
1475
1800
  return mode;
1476
1801
  },
1802
+ get sceneHandoff() {
1803
+ if (scene.clock) return { behavior: "hold", phase: scene.clock.phase };
1804
+ if (scene.binding.behavior === "refused") return { behavior: "refused", phase: null, reason: scene.binding.reason };
1805
+ return { behavior: "additive", phase: null };
1806
+ },
1477
1807
  get offsets() {
1478
1808
  return offsets;
1479
1809
  },
@@ -1505,12 +1835,10 @@ async function mountComposedTake(root, options) {
1505
1835
  root.removeEventListener("pointermove", aim, true);
1506
1836
  root.removeEventListener("pointerleave", recenter, true);
1507
1837
  root.removeEventListener("pointercancel", recenter, true);
1508
- if (namedInput) {
1509
- root.removeEventListener("pointerenter", aim, true);
1510
- root.removeEventListener("pointerdown", contact, true);
1511
- root.removeEventListener("lostpointercapture", recenter, true);
1512
- window.removeEventListener("blur", leave);
1513
- }
1838
+ root.removeEventListener("pointerenter", hoverEnter, true);
1839
+ root.removeEventListener("pointerdown", contact, true);
1840
+ root.removeEventListener("lostpointercapture", hoverLost, true);
1841
+ window.removeEventListener("blur", leave);
1514
1842
  poser.dispose();
1515
1843
  audit?.dispose();
1516
1844
  surface.remove();