@rig-c/play 1.28.0 → 1.30.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/_play-runtime.js +57 -12
- package/dist/_play-runtime.js.map +1 -1
- package/dist/composed-camera.d.ts.map +1 -1
- package/dist/composed-take.d.ts +16 -1
- package/dist/composed-take.d.ts.map +1 -1
- package/dist/composed-take.js +392 -76
- package/dist/composed-take.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/loadModel.d.ts +7 -1
- package/dist/loadModel.d.ts.map +1 -1
- package/dist/scene-camera.d.ts.map +1 -1
- package/docs/REFERENCE.md +38 -0
- package/package.json +8 -3
package/dist/composed-take.js
CHANGED
|
@@ -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,
|
|
1
|
+
import { u as underNoSkin, f as f32, 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, e as frameOf, g as frameSource, h 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
|
}
|
|
@@ -209,44 +389,13 @@ function sceneCameraDriftEvidence(report, refuse) {
|
|
|
209
389
|
}
|
|
210
390
|
};
|
|
211
391
|
}
|
|
212
|
-
function storedFloat32(value) {
|
|
213
|
-
const rounded = Math.fround(value);
|
|
214
|
-
if (rounded === 0 || !Number.isFinite(rounded)) return rounded === 0 ? 0 : rounded;
|
|
215
|
-
const magnitude = Math.abs(rounded);
|
|
216
|
-
const sign = rounded < 0 ? "-" : "";
|
|
217
|
-
floatBits.setFloat32(0, magnitude);
|
|
218
|
-
const word = floatBits.getUint32(0);
|
|
219
|
-
const exponent = word >>> 23;
|
|
220
|
-
const significand = BigInt(word & 8388607 | (exponent === 0 ? 0 : 8388608));
|
|
221
|
-
const doubledPower = (exponent === 0 ? -149 : exponent - 150) + 1;
|
|
222
|
-
for (let digits = 1; digits <= 9; digits++) {
|
|
223
|
-
const [mantissa, power] = magnitude.toExponential(digits - 1).split("e");
|
|
224
|
-
const nearest = BigInt(mantissa.replace(".", ""));
|
|
225
|
-
const scale = Number(power) - (digits - 1);
|
|
226
|
-
const candidates = [nearest - 1n, nearest, nearest + 1n].filter(
|
|
227
|
-
(candidate) => candidate > 0n && Math.fround(Number(`${candidate}e${scale}`)) === magnitude
|
|
228
|
-
);
|
|
229
|
-
if (candidates.length === 0) continue;
|
|
230
|
-
const chosen = candidates.reduce((a, b) => {
|
|
231
|
-
let midpoint = a + b;
|
|
232
|
-
let float = significand;
|
|
233
|
-
if (scale >= 0) midpoint *= 10n ** BigInt(scale);
|
|
234
|
-
else float *= 10n ** BigInt(-scale);
|
|
235
|
-
if (doubledPower >= 0) float <<= BigInt(doubledPower);
|
|
236
|
-
else midpoint <<= BigInt(-doubledPower);
|
|
237
|
-
return midpoint < float || midpoint === float && b % 2n === 0n ? b : a;
|
|
238
|
-
});
|
|
239
|
-
return Number(`${sign}${chosen}e${scale}`);
|
|
240
|
-
}
|
|
241
|
-
return rounded;
|
|
242
|
-
}
|
|
243
392
|
function storedTime(time) {
|
|
244
|
-
const named =
|
|
393
|
+
const named = f32(time);
|
|
245
394
|
const nearest = Math.fround(time);
|
|
246
395
|
if (named === time || nearest <= time || !Number.isFinite(nearest)) return named;
|
|
247
396
|
floatBits.setFloat32(0, nearest);
|
|
248
397
|
floatBits.setUint32(0, floatBits.getUint32(0) - 1);
|
|
249
|
-
return
|
|
398
|
+
return f32(floatBits.getFloat32(0));
|
|
250
399
|
}
|
|
251
400
|
function coreSampler(keys, duration, label, refuse) {
|
|
252
401
|
const times = keys.map((key) => storedTime(key.t));
|
|
@@ -277,13 +426,13 @@ function coreSampler(keys, duration, label, refuse) {
|
|
|
277
426
|
bones: [
|
|
278
427
|
{ name: "pan", timelines: [{ name: "translate", keys: keys.map((key, i) => ({
|
|
279
428
|
time: times[i],
|
|
280
|
-
x:
|
|
281
|
-
y:
|
|
429
|
+
x: f32(key.pan[0]),
|
|
430
|
+
y: f32(key.pan[1]),
|
|
282
431
|
curve: Array.isArray(key.curve) ? key.curve.slice(0, PAN_CURVE_LENGTH) : key.curve
|
|
283
432
|
})) }] },
|
|
284
433
|
{ name: "span", timelines: [{ name: "translatex", keys: keys.map((key, i) => ({
|
|
285
434
|
time: times[i],
|
|
286
|
-
value:
|
|
435
|
+
value: f32(1 / key.zoom),
|
|
287
436
|
curve: Array.isArray(key.curve) ? key.curve.slice(PAN_CURVE_LENGTH) : key.curve
|
|
288
437
|
})) }] }
|
|
289
438
|
]
|
|
@@ -358,7 +507,7 @@ function readTrack(raw, compiled, stage, label, refuse) {
|
|
|
358
507
|
}
|
|
359
508
|
if (curve !== void 0) {
|
|
360
509
|
const validCurve = curve === "stepped" || Array.isArray(curve) && curve.length === 12 && [...curve].every(
|
|
361
|
-
(value) => finite(value) && Number.isFinite(Math.fround(value)) &&
|
|
510
|
+
(value) => finite(value) && Number.isFinite(Math.fround(value)) && f32(value) === value
|
|
362
511
|
);
|
|
363
512
|
if (!validCurve || i === raw.keys.length - 1) {
|
|
364
513
|
return refuse("SCENE_CAMERA_REPORT_INVALID", `${at} needs a nonterminal outgoing curve (stepped or twelve float32 decimals)`);
|
|
@@ -382,20 +531,29 @@ function readTrack(raw, compiled, stage, label, refuse) {
|
|
|
382
531
|
const easedSeam = loop && (easedStart || easedEnd);
|
|
383
532
|
if (start && (easedSeam || easedStart)) cameraView(stage, start, label, refuse);
|
|
384
533
|
if (end && (easedSeam || easedEnd)) cameraView(stage, end, label, refuse);
|
|
534
|
+
const compiledKeys = keys.map((key) => key.t === duration ? compiled : key.t / duration * compiled);
|
|
535
|
+
const authoredKeys = new Map(compiledKeys.map((time, i) => [time, keys[i].t]));
|
|
385
536
|
return {
|
|
386
537
|
duration,
|
|
387
538
|
compiledDuration: compiled,
|
|
388
539
|
loop,
|
|
389
|
-
|
|
540
|
+
authoredTime(time) {
|
|
541
|
+
return authoredKeys.get(time) ?? time / compiled * duration;
|
|
542
|
+
},
|
|
543
|
+
sample(time, compiledTime, backdropSteps) {
|
|
390
544
|
if (time === 0 && (easedSeam || easedStart) && start) return start;
|
|
391
545
|
if (time === duration && (easedSeam || easedEnd) && end) return end;
|
|
546
|
+
const sharedStep = (i) => i > 0 && i < keys.length - 1 && keys[i - 1].curve === "stepped" && backdropSteps?.has(Math.fround(compiledKeys[i]));
|
|
392
547
|
let low = 0, high = keys.length - 1;
|
|
393
548
|
while (low < high) {
|
|
394
549
|
const mid = Math.ceil((low + high) / 2);
|
|
395
|
-
|
|
550
|
+
const boundary = compiledTime === void 0 ? keys[mid].t : sharedStep(mid) ? Math.fround(compiledKeys[mid]) : compiledKeys[mid];
|
|
551
|
+
if (boundary <= (compiledTime ?? time)) low = mid;
|
|
396
552
|
else high = mid - 1;
|
|
397
553
|
}
|
|
398
554
|
const from = keys[low], to = keys[low + 1];
|
|
555
|
+
if (compiledTime !== void 0 && sharedStep(low)) time = Math.max(from.t, time);
|
|
556
|
+
if (from.curve === "stepped" && core && compiledTime !== void 0) return core(from.t);
|
|
399
557
|
if (from.curve !== void 0 && core) return core(time);
|
|
400
558
|
if (time === from.t || to === void 0) return from;
|
|
401
559
|
const phase = (time - from.t) / (to.t - from.t);
|
|
@@ -416,7 +574,7 @@ function cameraTimes(track, clock, refuse) {
|
|
|
416
574
|
const limit = authored ? duration : compiledDuration;
|
|
417
575
|
const otherLimit = authored ? compiledDuration : duration;
|
|
418
576
|
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;
|
|
577
|
+
const otherTime = time === limit ? otherLimit : authored ? time / limit * otherLimit : track.authoredTime(time);
|
|
420
578
|
return authored ? { authoredSeconds: time, compiledSeconds: otherTime } : { authoredSeconds: otherTime, compiledSeconds: time };
|
|
421
579
|
}
|
|
422
580
|
function bindSceneCameraReport(report, model, refuse) {
|
|
@@ -449,12 +607,13 @@ function bindSceneCameraReport(report, model, refuse) {
|
|
|
449
607
|
}
|
|
450
608
|
const output = Object.freeze({ width: stage.width, height: stage.height });
|
|
451
609
|
return Object.freeze({
|
|
452
|
-
sample(animation, clock) {
|
|
610
|
+
sample(animation, clock, backdropSteps) {
|
|
453
611
|
if (!durations.has(animation)) refuse("SCENE_CAMERA_CLIP_MISMATCH", `unknown model animation ${JSON.stringify(animation)}`);
|
|
454
612
|
const track = bound.get(animation);
|
|
455
613
|
if (!track) return null;
|
|
456
614
|
const times = cameraTimes(track, clock, refuse);
|
|
457
|
-
const
|
|
615
|
+
const compiledPhase = "basis" in clock && clock.basis === "compiled" ? times.compiledSeconds : void 0;
|
|
616
|
+
const { pan, zoom } = track.sample(times.authoredSeconds, compiledPhase, backdropSteps);
|
|
458
617
|
const viewWorld = cameraView(stage, { pan, zoom }, `scene camera track ${JSON.stringify(animation)} at ${times.authoredSeconds} s`, refuse);
|
|
459
618
|
return Object.freeze({
|
|
460
619
|
animation,
|
|
@@ -999,6 +1158,13 @@ function keyedPlaneGains(planes) {
|
|
|
999
1158
|
async function mountComposedTake(root, options) {
|
|
1000
1159
|
const initial = options.camera ?? "fixed";
|
|
1001
1160
|
checkMode(initial);
|
|
1161
|
+
const { hoverHold } = options;
|
|
1162
|
+
function checkHoverHoldMode(mode) {
|
|
1163
|
+
if (hoverHold === true && mode === "pan") {
|
|
1164
|
+
throw new ComposedTakeError("COMPOSED_HOVER_HOLD_UNSUPPORTED_MODE", "Pan does not support hover-hold");
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
checkHoverHoldMode(initial);
|
|
1002
1168
|
const { loop, sceneReportUrl } = options;
|
|
1003
1169
|
if (loop !== true && (loop !== false || sceneReportUrl === void 0)) {
|
|
1004
1170
|
throw new ComposedTakeError("COMPOSED_LOOP_REQUIRED", "declare the existing take as loop: true");
|
|
@@ -1048,8 +1214,8 @@ async function mountComposedTake(root, options) {
|
|
|
1048
1214
|
let player;
|
|
1049
1215
|
let audit;
|
|
1050
1216
|
try {
|
|
1051
|
-
let cameraFor = function(animation, animationTime, loop2) {
|
|
1052
|
-
const view = bound?.sample(animation, { basis: "compiled", seconds: animationTime }) ?? null;
|
|
1217
|
+
let cameraFor = function(animation, animationTime, loop2, backdropSteps) {
|
|
1218
|
+
const view = bound?.sample(animation, { basis: "compiled", seconds: animationTime }, backdropSteps) ?? null;
|
|
1053
1219
|
if (view && view.loop !== loop2) {
|
|
1054
1220
|
refuseSceneCamera("SCENE_CAMERA_CLIP_MISMATCH", `loop must match the authored camera track for ${JSON.stringify(animation)}`);
|
|
1055
1221
|
}
|
|
@@ -1062,6 +1228,46 @@ async function mountComposedTake(root, options) {
|
|
|
1062
1228
|
legacyPlanes.set(animation, named);
|
|
1063
1229
|
}
|
|
1064
1230
|
return named;
|
|
1231
|
+
}, requireFixedHold = function(next, binding) {
|
|
1232
|
+
if (next !== "fixed" || hoverHold !== true || binding.behavior === "hold") return;
|
|
1233
|
+
const detail = binding.behavior === "refused" ? binding.reason : "the take needs a digest-bound scene_driven binding";
|
|
1234
|
+
throw new ComposedTakeError("COMPOSED_HOVER_HOLD_UNAVAILABLE", detail);
|
|
1235
|
+
}, configureScene = function(next, animation, loop2, time, reset = false, selecting = false) {
|
|
1236
|
+
if (!reset && scene.mode === next && scene.animation === animation && scene.loop === loop2) {
|
|
1237
|
+
if (selecting) requireFixedHold(next, scene.binding);
|
|
1238
|
+
return false;
|
|
1239
|
+
}
|
|
1240
|
+
const wasHolding = scene.clock !== null;
|
|
1241
|
+
let binding = { behavior: "additive" };
|
|
1242
|
+
if (next !== "pan" && (hoverHold ?? next === "parallax") && animation !== null) {
|
|
1243
|
+
const key = JSON.stringify([animation, loop2]);
|
|
1244
|
+
binding = bindings.get(key) ?? bindSceneHold(
|
|
1245
|
+
report,
|
|
1246
|
+
assets.document.doc,
|
|
1247
|
+
animation,
|
|
1248
|
+
bound?.sample(animation, { basis: "compiled", seconds: 0 }) ?? null,
|
|
1249
|
+
loop2,
|
|
1250
|
+
driftEvidence?.backdrop,
|
|
1251
|
+
dialBones
|
|
1252
|
+
);
|
|
1253
|
+
bindings.set(key, binding);
|
|
1254
|
+
if (composedTracks && binding.behavior === "hold") {
|
|
1255
|
+
binding = { behavior: "refused", reason: "scene hold requires a single unmixed animation track" };
|
|
1256
|
+
} else if (skin !== void 0 && binding.behavior === "hold") {
|
|
1257
|
+
binding = { behavior: "refused", reason: `backdrop depends on unverified skin ${JSON.stringify(skin)}` };
|
|
1258
|
+
} else if (externalAdjust && binding.behavior === "hold") {
|
|
1259
|
+
binding = { behavior: "refused", reason: "backdrop depends on an external player local adjustment" };
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
if (selecting) requireFixedHold(next, binding);
|
|
1263
|
+
scene = {
|
|
1264
|
+
mode: next,
|
|
1265
|
+
animation,
|
|
1266
|
+
loop: loop2,
|
|
1267
|
+
binding,
|
|
1268
|
+
clock: binding.behavior === "hold" ? createSceneClock(time, transitionSeconds, hover !== void 0) : null
|
|
1269
|
+
};
|
|
1270
|
+
return wasHolding || scene.clock !== null;
|
|
1065
1271
|
}, syncTurn = function(next) {
|
|
1066
1272
|
if (!dials.length) return;
|
|
1067
1273
|
const weight = mode === "parallax" && next === mode ? handoff.weight : 0;
|
|
@@ -1069,6 +1275,20 @@ async function mountComposedTake(root, options) {
|
|
|
1069
1275
|
if (weight !== turnInput.weight || pointer.x !== turnInput.pointer.x || pointer.y !== turnInput.pointer.y) {
|
|
1070
1276
|
turnInput = { weight, pointer };
|
|
1071
1277
|
}
|
|
1278
|
+
}, changedExternalAdjust = function(player2) {
|
|
1279
|
+
const current = player2.adjust !== null && player2.adjust !== adjustTurn;
|
|
1280
|
+
if (current === externalAdjust) return false;
|
|
1281
|
+
externalAdjust = current;
|
|
1282
|
+
return true;
|
|
1283
|
+
}, syncAdjust = function(player2, changed) {
|
|
1284
|
+
if (!hasSceneDeclaration) {
|
|
1285
|
+
if (player2.adjust === adjustTurn && posedTurnInput !== turnInput) player2.repose();
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
const needsHook = dials.length > 0 || scene.clock !== null;
|
|
1289
|
+
if (needsHook && player2.adjust === null) player2.adjust = adjustTurn;
|
|
1290
|
+
else if (!needsHook && player2.adjust === adjustTurn) player2.adjust = null;
|
|
1291
|
+
else if (changed || posedTurnInput !== turnInput) player2.repose();
|
|
1072
1292
|
}, createCoverageChecks = function() {
|
|
1073
1293
|
const renderer2 = audit = new CanvasRenderer(doc.createElement("div"), assets.pageImages);
|
|
1074
1294
|
renderer2.backend = backend;
|
|
@@ -1176,9 +1396,19 @@ async function mountComposedTake(root, options) {
|
|
|
1176
1396
|
if (nonOpaque) {
|
|
1177
1397
|
throw plateCoverageError(backdrop, next, `${nonOpaque} stage pixels have alpha below 255 at ${layout.width} × ${layout.height} backing px`);
|
|
1178
1398
|
}
|
|
1179
|
-
},
|
|
1399
|
+
}, syncPose = function(next, selecting = false) {
|
|
1400
|
+
const entry = poser.entry();
|
|
1401
|
+
const changed = configureScene(
|
|
1402
|
+
next,
|
|
1403
|
+
entry?.animation ?? null,
|
|
1404
|
+
entry?.loop ?? false,
|
|
1405
|
+
entry?.trackTime ?? 0,
|
|
1406
|
+
changedExternalAdjust(poser),
|
|
1407
|
+
selecting
|
|
1408
|
+
);
|
|
1180
1409
|
syncTurn(next);
|
|
1181
|
-
|
|
1410
|
+
syncAdjust(poser, changed);
|
|
1411
|
+
}, currentFrame = function(named, keyed) {
|
|
1182
1412
|
const frame = poser.posedFrame(null);
|
|
1183
1413
|
return { frame, backdrop: checkFrame(frame, planes, named?.backdrop, keyed) };
|
|
1184
1414
|
}, requireKeyedCoverage = function(view, next, excursion) {
|
|
@@ -1256,26 +1486,33 @@ async function mountComposedTake(root, options) {
|
|
|
1256
1486
|
if (next === "parallax" && hover !== void 0) handoff.enter();
|
|
1257
1487
|
}
|
|
1258
1488
|
mode = next;
|
|
1489
|
+
if (!namedInput && mode !== "parallax") hover = void 0;
|
|
1259
1490
|
if (!namedInput && switching && mode === "fixed") camera = target = NEUTRAL;
|
|
1260
1491
|
offsets = displayed;
|
|
1261
1492
|
if (namedInput && mode === "parallax") handoff.painted();
|
|
1262
1493
|
canvas.style.visibility = "";
|
|
1263
1494
|
Object.assign(canvas.style, { width: "100%", height: "100%", transform: "none", pointerEvents: "auto" });
|
|
1264
1495
|
}, select = function(next, switching, allowFallback) {
|
|
1496
|
+
syncPose(next, switching);
|
|
1265
1497
|
const entry = bound && poser.entry();
|
|
1266
|
-
const
|
|
1498
|
+
const backdropSteps = scene.binding.behavior === "hold" ? scene.binding.backdropSteps : void 0;
|
|
1499
|
+
const view = entry?.animation ? cameraFor(entry.animation, scene.clock?.phase ?? entry.animationTime, entry.loop, backdropSteps) : null;
|
|
1267
1500
|
drawingKeyed = view !== null;
|
|
1268
1501
|
const named = view ? void 0 : planesFor(entry?.animation ?? initialAnimation);
|
|
1269
|
-
const { frame, backdrop } = currentFrame(
|
|
1502
|
+
const { frame, backdrop } = currentFrame(named, drawingKeyed);
|
|
1270
1503
|
try {
|
|
1271
1504
|
drawMode(frame, backdrop, next, switching, view, named);
|
|
1272
1505
|
} catch (error) {
|
|
1273
1506
|
if (!(error instanceof ComposedTakeError) || error.code !== "COMPOSED_BACKDROP_COVERAGE" || next === "fixed" || !named && !view && !allowFallback) throw error;
|
|
1274
1507
|
try {
|
|
1275
|
-
|
|
1276
|
-
|
|
1508
|
+
syncPose("fixed", true);
|
|
1509
|
+
const fixed = currentFrame(named, drawingKeyed);
|
|
1510
|
+
const fixedSteps = scene.binding.behavior === "hold" ? scene.binding.backdropSteps : void 0;
|
|
1511
|
+
const fixedView = entry?.animation ? cameraFor(entry.animation, scene.clock?.phase ?? entry.animationTime, entry.loop, fixedSteps) : null;
|
|
1512
|
+
drawMode(fixed.frame, fixed.backdrop, "fixed", true, fixedView, named);
|
|
1277
1513
|
} catch (fixedError) {
|
|
1278
1514
|
canvas.style.visibility = "hidden";
|
|
1515
|
+
if (fixedError instanceof ComposedTakeError && fixedError.code === "COMPOSED_HOVER_HOLD_UNAVAILABLE") throw error;
|
|
1279
1516
|
throw fixedError;
|
|
1280
1517
|
}
|
|
1281
1518
|
refusal = error;
|
|
@@ -1295,12 +1532,13 @@ async function mountComposedTake(root, options) {
|
|
|
1295
1532
|
if (disposed || stopped) return;
|
|
1296
1533
|
try {
|
|
1297
1534
|
checkMode(next);
|
|
1535
|
+
checkHoverHoldMode(next);
|
|
1298
1536
|
measure();
|
|
1299
1537
|
select(next, true, false);
|
|
1300
1538
|
refusal = null;
|
|
1301
1539
|
} catch (error) {
|
|
1302
1540
|
if (error instanceof ComposedTakeError) refusal = error;
|
|
1303
|
-
if ((namedInput || drawingKeyed) && next === "fixed") canvas.style.visibility = "hidden";
|
|
1541
|
+
if ((namedInput || drawingKeyed) && next === "fixed" && (!(error instanceof ComposedTakeError) || error.code !== "COMPOSED_HOVER_HOLD_UNAVAILABLE")) canvas.style.visibility = "hidden";
|
|
1304
1542
|
throw error;
|
|
1305
1543
|
}
|
|
1306
1544
|
}, advanceCamera = function(elapsed) {
|
|
@@ -1325,9 +1563,10 @@ async function mountComposedTake(root, options) {
|
|
|
1325
1563
|
if (autoStart) syncCamera(window.performance.now());
|
|
1326
1564
|
hover = void 0;
|
|
1327
1565
|
target = NEUTRAL;
|
|
1566
|
+
scene.clock?.aim(false);
|
|
1328
1567
|
if (mode === "parallax") handoff.leave();
|
|
1329
1568
|
};
|
|
1330
|
-
const bound = digest === null ? null :
|
|
1569
|
+
const bound = digest === null ? null : bindSceneCameraReport(report, { sha256, stage: assets.stage, animations: assets.animations }, refuseSceneCamera);
|
|
1331
1570
|
const driftEvidence = bound && sceneCameraDriftEvidence(report, refuseSceneCamera);
|
|
1332
1571
|
const initialView = cameraFor(options.animation, 0, loop);
|
|
1333
1572
|
if (!initialView && loop !== true) throw new ComposedTakeError("COMPOSED_LOOP_REQUIRED", "declare the existing take as loop: true");
|
|
@@ -1345,11 +1584,25 @@ async function mountComposedTake(root, options) {
|
|
|
1345
1584
|
let keyedGains = initialView ? keyedPlaneGains(options.planes) : void 0;
|
|
1346
1585
|
const dials = namedInput && options.pointerTurn !== false ? discoverTurnDials(assets.document.parsed, assets.animations) : [];
|
|
1347
1586
|
const handoff = createCameraHandoff(transitionSeconds);
|
|
1587
|
+
const hasSceneDeclaration = typeof report === "object" && report !== null && Object.hasOwn(report, "scene_driven");
|
|
1348
1588
|
let mode = initial;
|
|
1589
|
+
let hover;
|
|
1590
|
+
let scene = { mode: initial, animation: null, loop: false, binding: { behavior: "additive" }, clock: null };
|
|
1591
|
+
const dialBones = new Set(dials.map((dial) => dial.bone));
|
|
1592
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
1593
|
+
let replaying = false;
|
|
1594
|
+
let composedTracks = false;
|
|
1595
|
+
let skin;
|
|
1596
|
+
let externalAdjust = false;
|
|
1597
|
+
configureScene(initial, initialAnimation, loop, 0, true, true);
|
|
1349
1598
|
let turnInput = { weight: 0, pointer: NEUTRAL };
|
|
1350
1599
|
let posedTurnInput = turnInput;
|
|
1351
1600
|
let turnValues = [];
|
|
1352
|
-
const adjustTurn = (bones) => {
|
|
1601
|
+
const adjustTurn = (bones, ctx) => {
|
|
1602
|
+
if (!replaying && scene.binding.behavior === "hold" && scene.clock && ctx.animation === scene.animation && ctx.trackTime !== null) {
|
|
1603
|
+
scene.clock.advance(ctx.trackTime);
|
|
1604
|
+
scene.binding.apply(bones, scene.clock.phase);
|
|
1605
|
+
}
|
|
1353
1606
|
const { weight, pointer } = turnInput;
|
|
1354
1607
|
turnValues = dials.map((dial) => {
|
|
1355
1608
|
const { axis, bone, channel, min, max } = dial;
|
|
@@ -1371,7 +1624,64 @@ async function mountComposedTake(root, options) {
|
|
|
1371
1624
|
aspectRatio: `${stage.width} / ${stage.height}`
|
|
1372
1625
|
});
|
|
1373
1626
|
root.appendChild(surface);
|
|
1374
|
-
const poser = player = new RigPlayer(surface, assets, { mode: "canvas", adjust: dials.length ? adjustTurn : null });
|
|
1627
|
+
const poser = player = new RigPlayer(surface, assets, { mode: "canvas", adjust: dials.length || scene.clock ? adjustTurn : null });
|
|
1628
|
+
if (hasSceneDeclaration) {
|
|
1629
|
+
let resetSceneAtEntry = function() {
|
|
1630
|
+
changedExternalAdjust(poser);
|
|
1631
|
+
const entry = poser.entry();
|
|
1632
|
+
const changed = configureScene(mode, entry?.animation ?? null, entry?.loop ?? false, entry?.trackTime ?? 0, true);
|
|
1633
|
+
syncAdjust(poser, changed);
|
|
1634
|
+
}, replay = function(operation) {
|
|
1635
|
+
replaying = true;
|
|
1636
|
+
try {
|
|
1637
|
+
operation();
|
|
1638
|
+
} finally {
|
|
1639
|
+
replaying = false;
|
|
1640
|
+
}
|
|
1641
|
+
}, composeWithoutScene = function(operation) {
|
|
1642
|
+
replay(operation);
|
|
1643
|
+
composedTracks = true;
|
|
1644
|
+
resetSceneAtEntry();
|
|
1645
|
+
};
|
|
1646
|
+
const base = RigPlayer.prototype;
|
|
1647
|
+
const methods = {
|
|
1648
|
+
play(name, options2 = {}) {
|
|
1649
|
+
const { track = 0, mix = 0, alpha = 1, additive = false } = options2;
|
|
1650
|
+
replay(() => base.play.call(poser, name, options2));
|
|
1651
|
+
composedTracks ||= track !== 0 || mix !== 0 || alpha !== 1 || additive;
|
|
1652
|
+
resetSceneAtEntry();
|
|
1653
|
+
},
|
|
1654
|
+
seek(...args) {
|
|
1655
|
+
replay(() => base.seek.call(poser, ...args));
|
|
1656
|
+
resetSceneAtEntry();
|
|
1657
|
+
},
|
|
1658
|
+
queue(...args) {
|
|
1659
|
+
composeWithoutScene(() => base.queue.call(poser, ...args));
|
|
1660
|
+
},
|
|
1661
|
+
clear(...args) {
|
|
1662
|
+
composeWithoutScene(() => base.clear.call(poser, ...args));
|
|
1663
|
+
},
|
|
1664
|
+
queueClear(...args) {
|
|
1665
|
+
composeWithoutScene(() => base.queueClear.call(poser, ...args));
|
|
1666
|
+
},
|
|
1667
|
+
setAlpha(...args) {
|
|
1668
|
+
composeWithoutScene(() => base.setAlpha.call(poser, ...args));
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
for (const [name, value] of Object.entries(methods)) {
|
|
1672
|
+
Object.defineProperty(poser, name, { value, configurable: true, writable: true });
|
|
1673
|
+
}
|
|
1674
|
+
const skinProperty = Object.getOwnPropertyDescriptor(base, "skin");
|
|
1675
|
+
Object.defineProperty(poser, "skin", {
|
|
1676
|
+
...skinProperty,
|
|
1677
|
+
set(name) {
|
|
1678
|
+
if (name === poser.skin) return;
|
|
1679
|
+
replay(() => skinProperty.set.call(poser, name));
|
|
1680
|
+
skin = poser.skin;
|
|
1681
|
+
resetSceneAtEntry();
|
|
1682
|
+
}
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1375
1685
|
const renderer = poser.renderer;
|
|
1376
1686
|
const backend = options.backend ?? "webgl";
|
|
1377
1687
|
renderer.backend = backend;
|
|
@@ -1382,7 +1692,6 @@ async function mountComposedTake(root, options) {
|
|
|
1382
1692
|
let offsets = planeOffsets(NEUTRAL, "fixed");
|
|
1383
1693
|
let camera = NEUTRAL;
|
|
1384
1694
|
let target = NEUTRAL;
|
|
1385
|
-
let hover;
|
|
1386
1695
|
let layout;
|
|
1387
1696
|
let keyedAdmission;
|
|
1388
1697
|
let legacyLayoutPending = true;
|
|
@@ -1401,7 +1710,7 @@ async function mountComposedTake(root, options) {
|
|
|
1401
1710
|
const boundaryEvent = (event) => event.target === root || event.bubbles;
|
|
1402
1711
|
const aim = (event) => {
|
|
1403
1712
|
if (!event.isPrimary || stopped) return;
|
|
1404
|
-
if (namedInput) {
|
|
1713
|
+
if (namedInput || scene.clock) {
|
|
1405
1714
|
if (event.pointerType === "touch" || event.type === "pointerenter" && !boundaryEvent(event) || hover !== void 0 && hover !== event.pointerId) return;
|
|
1406
1715
|
if (event.pointerType === "pen" && event.buttons !== 0) {
|
|
1407
1716
|
leave();
|
|
@@ -1411,33 +1720,37 @@ async function mountComposedTake(root, options) {
|
|
|
1411
1720
|
if (!Number.isFinite(event.clientX) || !Number.isFinite(event.clientY)) return;
|
|
1412
1721
|
const box = surface.getBoundingClientRect();
|
|
1413
1722
|
if (!(box.width > 0 && box.height > 0)) return;
|
|
1414
|
-
if (namedInput) {
|
|
1415
|
-
if (autoStart) syncCamera(window.performance.now());
|
|
1416
|
-
if (hover === void 0
|
|
1723
|
+
if (namedInput || scene.clock) {
|
|
1724
|
+
if (namedInput && autoStart) syncCamera(window.performance.now());
|
|
1725
|
+
if (hover === void 0) {
|
|
1726
|
+
if (namedInput && mode === "parallax") handoff.enter();
|
|
1727
|
+
scene.clock?.aim(true);
|
|
1728
|
+
}
|
|
1417
1729
|
hover = event.pointerId;
|
|
1418
1730
|
}
|
|
1419
1731
|
target = pointerTarget(event.clientX, event.clientY, box);
|
|
1420
1732
|
};
|
|
1421
1733
|
const recenter = (event) => {
|
|
1422
1734
|
if (!event.isPrimary) return;
|
|
1423
|
-
if (!namedInput) {
|
|
1424
|
-
target = NEUTRAL;
|
|
1425
|
-
return;
|
|
1426
|
-
}
|
|
1427
1735
|
if (event.pointerType !== "touch" && hover === event.pointerId && (event.type !== "pointerleave" || boundaryEvent(event))) leave();
|
|
1736
|
+
else if (!namedInput && !scene.clock) target = NEUTRAL;
|
|
1428
1737
|
};
|
|
1429
1738
|
const contact = (event) => {
|
|
1430
1739
|
if (event.pointerType === "pen" && event.isPrimary && hover === event.pointerId) leave();
|
|
1431
1740
|
};
|
|
1741
|
+
const hoverEnter = (event) => {
|
|
1742
|
+
if (namedInput || scene.clock) aim(event);
|
|
1743
|
+
};
|
|
1744
|
+
const hoverLost = (event) => {
|
|
1745
|
+
if (namedInput || scene.clock || hover !== void 0) recenter(event);
|
|
1746
|
+
};
|
|
1432
1747
|
root.addEventListener("pointermove", aim, true);
|
|
1433
1748
|
root.addEventListener("pointerleave", recenter, true);
|
|
1434
1749
|
root.addEventListener("pointercancel", recenter, true);
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
window.addEventListener("blur", leave);
|
|
1440
|
-
}
|
|
1750
|
+
root.addEventListener("pointerenter", hoverEnter, true);
|
|
1751
|
+
root.addEventListener("pointerdown", contact, true);
|
|
1752
|
+
root.addEventListener("lostpointercapture", hoverLost, true);
|
|
1753
|
+
window.addEventListener("blur", leave);
|
|
1441
1754
|
const observer = new ResizeObserver(() => {
|
|
1442
1755
|
try {
|
|
1443
1756
|
render();
|
|
@@ -1474,6 +1787,11 @@ async function mountComposedTake(root, options) {
|
|
|
1474
1787
|
get mode() {
|
|
1475
1788
|
return mode;
|
|
1476
1789
|
},
|
|
1790
|
+
get sceneHandoff() {
|
|
1791
|
+
if (scene.clock) return { behavior: "hold", phase: scene.clock.phase };
|
|
1792
|
+
if (scene.binding.behavior === "refused") return { behavior: "refused", phase: null, reason: scene.binding.reason };
|
|
1793
|
+
return { behavior: "additive", phase: null };
|
|
1794
|
+
},
|
|
1477
1795
|
get offsets() {
|
|
1478
1796
|
return offsets;
|
|
1479
1797
|
},
|
|
@@ -1505,12 +1823,10 @@ async function mountComposedTake(root, options) {
|
|
|
1505
1823
|
root.removeEventListener("pointermove", aim, true);
|
|
1506
1824
|
root.removeEventListener("pointerleave", recenter, true);
|
|
1507
1825
|
root.removeEventListener("pointercancel", recenter, true);
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
window.removeEventListener("blur", leave);
|
|
1513
|
-
}
|
|
1826
|
+
root.removeEventListener("pointerenter", hoverEnter, true);
|
|
1827
|
+
root.removeEventListener("pointerdown", contact, true);
|
|
1828
|
+
root.removeEventListener("lostpointercapture", hoverLost, true);
|
|
1829
|
+
window.removeEventListener("blur", leave);
|
|
1514
1830
|
poser.dispose();
|
|
1515
1831
|
audit?.dispose();
|
|
1516
1832
|
surface.remove();
|