0.9.1: jumpToScene action + auto-play on scene switch
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b57994c754
commit
b9f2ba9e47
9 files changed
+436
-15
No files matched your search
+18
-1
@@ -1,6 +1,6 @@
|
||||
import type { Scene } from '@/types/scene'
|
||||
|
||||
const RUNTIME_VERSION = '17'
|
||||
const RUNTIME_VERSION = '19'
|
||||
|
||||
const ENGINE_SOURCE = `(function(){
|
||||
if (window.AnimatrPlayer && window.AnimatrPlayer.__v === '${RUNTIME_VERSION}') return;
|
||||
@@ -350,6 +350,15 @@ const ENGINE_SOURCE = `(function(){
|
||||
runtime.jumpTo=Math.max(0,Math.min(runtime.duration,mt));
|
||||
return;
|
||||
}
|
||||
case 'jumpToScene': {
|
||||
// Exports only carry one scene at a time, so jumpToScene is a
|
||||
// warn-and-continue in standalone bundles. The in-editor
|
||||
// fullscreen preview passes an onJumpToScene hook which routes
|
||||
// the jump back to the store and re-mounts at the same time.
|
||||
if (onJumpToScene){ try { onJumpToScene(act.sceneId); } catch(e){ runtime.warn('jumpToScene: '+((e&&e.message)||String(e))); } return; }
|
||||
runtime.warn('jumpToScene: exported runtime does not support multi-scene playback');
|
||||
return;
|
||||
}
|
||||
case 'script': {
|
||||
var parsed=parseScriptSource(act.source);
|
||||
if(parsed.errors.length){
|
||||
@@ -381,6 +390,7 @@ const ENGINE_SOURCE = `(function(){
|
||||
var lastNow=0;
|
||||
var rafId=0;
|
||||
var onFrame=opts.onFrame||null;
|
||||
var onJumpToScene=opts.onJumpToScene||null;
|
||||
var destroyed=false;
|
||||
function frame(now){
|
||||
if(destroyed) return;
|
||||
@@ -866,6 +876,13 @@ export interface PlayerHandle {
|
||||
export interface MountOptions {
|
||||
loop?: boolean
|
||||
onFrame?: (time: number, paused: boolean) => void
|
||||
/** In-editor hook used by the fullscreen preview: a scripted (or
|
||||
* button-click) `jumpToScene` calls this instead of the runtime's
|
||||
* own warn-and-skip path. The host is responsible for swapping the
|
||||
* Scene the player renders (typically by mutating the store and
|
||||
* re-mounting with the new active page). Exported bundles omit this
|
||||
* — they carry a single scene and warn on jumpToScene. */
|
||||
onJumpToScene?: (sceneId: string) => void
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
Reference in new issue
Block a user