@@ -54,11 +54,17 @@ function pressCycleKey(scene) {
5454}
5555
5656function createRendererProbe ( width = 960 , height = 540 ) {
57+ let canvasWidth = width ;
58+ let canvasHeight = height ;
5759 const texts = [ ] ;
5860 return {
5961 texts,
6062 getCanvasSize ( ) {
61- return { width, height } ;
63+ return { width : canvasWidth , height : canvasHeight } ;
64+ } ,
65+ setCanvasSize ( nextWidth , nextHeight ) {
66+ canvasWidth = Math . max ( 1 , Number ( nextWidth ) || canvasWidth ) ;
67+ canvasHeight = Math . max ( 1 , Number ( nextHeight ) || canvasHeight ) ;
6268 } ,
6369 clear ( ) { } ,
6470 drawRect ( ) { } ,
@@ -94,8 +100,11 @@ function assertSharedStackMath() {
94100 const stack = createBottomRightDebugPanelStack ( renderer , { right : 10 , bottom : 10 , spacing : 10 } ) ;
95101 const first = getNextBottomRightDebugPanelRect ( stack , 300 , 170 ) ;
96102 const second = getNextBottomRightDebugPanelRect ( stack , 300 , 120 ) ;
103+ renderer . setCanvasSize ( 1280 , 720 ) ;
104+ const resized = getNextBottomRightDebugPanelRect ( stack , 300 , 170 ) ;
97105 assert . deepEqual ( first , { x : 650 , y : 360 , width : 300 , height : 170 } ) ;
98106 assert . deepEqual ( second , { x : 650 , y : 230 , width : 300 , height : 120 } ) ;
107+ assert . deepEqual ( resized , { x : 970 , y : 230 , width : 300 , height : 170 } ) ;
99108}
100109
101110function assertSample1701RuntimePanelPlacement ( ) {
@@ -215,6 +224,39 @@ function assertSample1713FinalRuntimePlacement() {
215224 assertBottomRightFromTitle ( runtimeTitle , 228 , 248 , 722 , 282 , 'Sample 1713 final runtime overlay' ) ;
216225}
217226
227+ function assertNoFlickerDuringSampleSwitching ( ) {
228+ const scenes = [
229+ [ new RealGameplayMiniGameScene ( ) , 'UI Layer' ] ,
230+ [ new MovementModelsLab1709Scene ( ) , 'Movement Runtime' ] ,
231+ [ new RealGameplayMiniGame1710Scene ( ) , 'UI Layer' ] ,
232+ [ new MovementModelsLab1711Scene ( ) , 'Movement Runtime' ] ,
233+ [ new GameplayMetricsTelemetryScene ( ) , 'UI Layer' ] ,
234+ [ new FinalReferenceGameScene ( ) , 'UI Layer' ] ,
235+ ] ;
236+ const overlayTitles = [
237+ 'UI Layer' ,
238+ 'Mission Feed' ,
239+ 'MISSION READY' ,
240+ 'Mini-Game Runtime' ,
241+ 'Movement Runtime' ,
242+ 'Movement Lab HUD' ,
243+ 'Telemetry Overlay' ,
244+ 'Final Reference Runtime' ,
245+ ] ;
246+ const sharedCamera = createCameraStub ( ) ;
247+ for ( let i = 0 ; i < scenes . length ; i += 1 ) {
248+ const [ scene , expectedTitle ] = scenes [ i ] ;
249+ scene . setCamera3D ?. ( sharedCamera ) ;
250+ for ( let pass = 0 ; pass < 2 ; pass += 1 ) {
251+ const renderer = createRendererProbe ( ) ;
252+ scene . render ( renderer ) ;
253+ const visibleOverlays = overlayTitles . filter ( ( title ) => Boolean ( findExactText ( renderer , title ) ) ) ;
254+ assert . equal ( visibleOverlays . length , 1 , `Sample switch pass ${ i + 1 } .${ pass + 1 } should render exactly one active overlay panel title.` ) ;
255+ assert . equal ( visibleOverlays [ 0 ] , expectedTitle , `Sample switch pass ${ i + 1 } .${ pass + 1 } should render expected default overlay without flicker.` ) ;
256+ }
257+ }
258+ }
259+
218260export function run ( ) {
219261 assertSharedStackMath ( ) ;
220262 assertSample1701RuntimePanelPlacement ( ) ;
@@ -225,4 +267,5 @@ export function run() {
225267 assertSample1711MovementOverlayPlacement ( ) ;
226268 assertSample1712TelemetryPlacement ( ) ;
227269 assertSample1713FinalRuntimePlacement ( ) ;
270+ assertNoFlickerDuringSampleSwitching ( ) ;
228271}
0 commit comments