@@ -30,7 +30,6 @@ export class GameRecapCapture {
3030 private stopped = false ;
3131 private resolvedMimeType : string | null = null ;
3232 private pendingFinalCapture = false ;
33- private disableOverridesAfterCapture = false ;
3433 private memoryUsageLogged = false ;
3534
3635 constructor (
@@ -47,21 +46,19 @@ export class GameRecapCapture {
4746 start ( ) {
4847 this . stopped = false ;
4948 this . resolvedMimeType = null ;
49+ this . lastCaptureTick = null ;
5050 this . frameStore . setLoopPauseMs ( 0 ) ;
5151 this . pendingFinalCapture = false ;
52- this . disableOverridesAfterCapture = false ;
5352 this . memoryUsageLogged = false ;
54- this . setLayerCaptureOverrides ( true ) ;
5553 this . refreshViewportSize ( ) ;
54+ this . frameStore . clear ( ) ;
5655 }
5756
5857 dispose ( ) {
5958 this . stopped = true ;
6059 this . pendingFinalCapture = false ;
6160 this . surface . dispose ( ) ;
6261 this . frameStore . clear ( ) ;
63- this . setLayerCaptureOverrides ( false ) ;
64- this . disableOverridesAfterCapture = false ;
6562 this . memoryUsageLogged = false ;
6663 }
6764
@@ -114,7 +111,6 @@ export class GameRecapCapture {
114111 }
115112 this . stopped = true ;
116113 this . frameStore . setLoopPauseMs ( this . config . loopTailHoldMs ) ;
117- this . disableOverridesAfterCapture = true ;
118114 if ( this . captureInProgress ) {
119115 this . pendingFinalCapture = true ;
120116 } else {
@@ -126,6 +122,10 @@ export class GameRecapCapture {
126122 blob : Blob ;
127123 filename : string ;
128124 } > {
125+ const fpsInput = Number . isFinite ( targetFps )
126+ ? targetFps
127+ : this . config . exportFps ;
128+ const fps = Math . min ( 60 , Math . max ( 1 , Math . round ( fpsInput ) ) ) ;
129129 const frames = this . frameStore . getFrames ( ) ;
130130 if ( frames . length === 0 ) {
131131 throw new Error ( "No recap frames available for export" ) ;
@@ -153,7 +153,7 @@ export class GameRecapCapture {
153153 ) ;
154154 }
155155
156- const stream = canvas . captureStream ( targetFps ) ;
156+ const stream = canvas . captureStream ( fps ) ;
157157 const recorderOptions : MediaRecorderOptions = { mimeType } ;
158158 if ( this . config . exportVideoBitsPerSecond ) {
159159 recorderOptions . videoBitsPerSecond = this . config . exportVideoBitsPerSecond ;
@@ -210,7 +210,7 @@ export class GameRecapCapture {
210210
211211 const framesToEncode =
212212 frames . length === 1 ? [ ...frames , frames [ 0 ] ] : [ ...frames ] ;
213- const frameInterval = Math . max ( 1000 / targetFps , 16 ) ;
213+ const frameInterval = Math . max ( 1000 / fps , 16 ) ;
214214
215215 await drawFrame ( framesToEncode [ 0 ] ) ;
216216
@@ -348,9 +348,6 @@ export class GameRecapCapture {
348348 if ( this . pendingFinalCapture ) {
349349 this . pendingFinalCapture = false ;
350350 this . queueCapture ( this . game . ticks ( ) ) ;
351- } else if ( this . disableOverridesAfterCapture ) {
352- this . disableOverridesAfterCapture = false ;
353- this . setLayerCaptureOverrides ( false ) ;
354351 }
355352 } ) ;
356353 } ;
@@ -362,21 +359,6 @@ export class GameRecapCapture {
362359 }
363360 }
364361
365- private setLayerCaptureOverrides ( enabled : boolean ) {
366- for ( const layer of this . layers ) {
367- const candidate = layer as {
368- setCaptureRenderEnabled ?: (
369- capture : boolean ,
370- mode ?: "normal" | "shape" ,
371- ) => void ;
372- } ;
373- candidate . setCaptureRenderEnabled ?.(
374- enabled ,
375- enabled ? "shape" : "normal" ,
376- ) ;
377- }
378- }
379-
380362 private snapshotTransform ( ) : TransformSnapshot {
381363 const handler = this . transformHandler as unknown as TransformSnapshot ;
382364 return {
0 commit comments