@@ -11,13 +11,38 @@ import { drawFrame, drawPanel } from '/src/engine/debug/index.js';
1111const theme = new Theme ( ThemeTokens ) ;
1212
1313export default class Phase18FoundationScene extends Scene {
14- constructor ( ) {
14+ constructor ( { coreServices = null } = { } ) {
1515 super ( ) ;
1616 this . elapsed = 0 ;
17+ this . coreServices = coreServices ;
18+ this . lastHeartbeatTick = 0 ;
19+ this . lastHeartbeatTime = 0 ;
20+ this . unsubscribeHeartbeat = null ;
21+ }
22+
23+ enter ( engine ) {
24+ if ( ! this . coreServices ) return ;
25+ const channel = this . coreServices . get ( 'phase18.channel' ) ;
26+ if ( channel && typeof channel . subscribe === 'function' ) {
27+ this . unsubscribeHeartbeat = channel . subscribe ( 'phase18.heartbeat' , ( payload ) => {
28+ this . lastHeartbeatTick = Number ( payload ?. tick ) || 0 ;
29+ this . lastHeartbeatTime = Number ( payload ?. t ) || 0 ;
30+ } ) ;
31+ }
32+ this . coreServices . start ( { engine, scene : this } ) ;
1733 }
1834
1935 update ( dtSeconds ) {
2036 this . elapsed += dtSeconds ;
37+ this . coreServices ?. update ( dtSeconds , { scene : this } ) ;
38+ }
39+
40+ exit ( ) {
41+ if ( typeof this . unsubscribeHeartbeat === 'function' ) {
42+ this . unsubscribeHeartbeat ( ) ;
43+ this . unsubscribeHeartbeat = null ;
44+ }
45+ this . coreServices ?. stop ( { scene : this } ) ;
2146 }
2247
2348 render ( renderer ) {
@@ -42,7 +67,8 @@ export default class Phase18FoundationScene extends Scene {
4267 'Status: initialized' ,
4368 'Folder: samples/phase-18' ,
4469 'Entry sample: 1801' ,
45- 'Next: scoped Level 18 slices' ,
70+ `Services: ${ this . coreServices ?. listServiceIds ( ) . length ?? 0 } ` ,
71+ `Heartbeat tick: ${ this . lastHeartbeatTick } @ ${ this . lastHeartbeatTime . toFixed ( 2 ) } s` ,
4672 ] ) ;
4773 }
4874}
0 commit comments