0.10.7: fire scripts at play-start + right-click duplicate script frame
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0bbef66192
commit
34d1a89d56
6 files changed
+313
-15
No files matched your search
+15
-7
@@ -10,7 +10,7 @@ function isProject(p: ExportPayload): p is Project {
|
||||
return Array.isArray((p as Partial<Project>).scenes)
|
||||
}
|
||||
|
||||
const RUNTIME_VERSION = '26'
|
||||
const RUNTIME_VERSION = '27'
|
||||
|
||||
const ENGINE_SOURCE = `(function(){
|
||||
if (window.AnimatrPlayer && window.AnimatrPlayer.__v === '${RUNTIME_VERSION}') return;
|
||||
@@ -588,13 +588,15 @@ const ENGINE_SOURCE = `(function(){
|
||||
}
|
||||
}
|
||||
}
|
||||
function fireFrames(prev, next){
|
||||
if(next<=prev) return;
|
||||
function fireFrames(prev, next, includeStart){
|
||||
if(next<prev) return;
|
||||
if(next===prev && !includeStart) return;
|
||||
var frames=scene.scriptFrames||[];
|
||||
var toFire=[];
|
||||
for(var ffi=0; ffi<frames.length; ffi++){
|
||||
var fr=frames[ffi];
|
||||
if(fr.time>prev && fr.time<=next) toFire.push(fr);
|
||||
var passesLeft = includeStart ? fr.time>=prev : fr.time>prev;
|
||||
if(passesLeft && fr.time<=next) toFire.push(fr);
|
||||
}
|
||||
toFire.sort(function(a,b){return a.time-b.time;});
|
||||
for(var ffj=0; ffj<toFire.length; ffj++){
|
||||
@@ -605,6 +607,10 @@ const ENGINE_SOURCE = `(function(){
|
||||
var currentT=rangeIn;
|
||||
var paused=false;
|
||||
var lastNow=0;
|
||||
// First tick after a play-start fires scripts at currentT too —
|
||||
// otherwise frame-0 (or wherever the playhead sits) scripts are
|
||||
// silently skipped by the open-left passage firing.
|
||||
var playStartPending=true;
|
||||
var rafId=0;
|
||||
var onFrame=opts.onFrame||null;
|
||||
var onJumpToScene=opts.onJumpToScene||null;
|
||||
@@ -625,17 +631,19 @@ const ENGINE_SOURCE = `(function(){
|
||||
if(!paused){
|
||||
var prev=currentT;
|
||||
var nextT=currentT+dt;
|
||||
var includeStart=playStartPending;
|
||||
playStartPending=false;
|
||||
if(nextT>=rangeOut){
|
||||
fireFrames(prev, rangeOut);
|
||||
fireFrames(prev, rangeOut, includeStart);
|
||||
currentT = loop ? rangeIn : rangeOut;
|
||||
} else {
|
||||
currentT=nextT;
|
||||
fireFrames(prev, currentT);
|
||||
fireFrames(prev, currentT, includeStart);
|
||||
}
|
||||
}
|
||||
if(runtime.jumpTo!=null){ currentT=runtime.jumpTo; runtime.jumpTo=null; }
|
||||
if(runtime.forcePause){ paused=true; runtime.forcePause=false; }
|
||||
if(runtime.forcePlay){ paused=false; runtime.forcePlay=false; lastNow=0; }
|
||||
if(runtime.forcePlay){ paused=false; runtime.forcePlay=false; lastNow=0; playStartPending=true; }
|
||||
draw(currentT);
|
||||
syncBgVideo(currentT);
|
||||
syncAudio(currentT, !paused);
|
||||
|
||||
Reference in new issue
Block a user