@@ -5,7 +5,14 @@ David Quesenberry
55EngineCoreBoundaryBaseline.test.mjs
66*/
77import assert from 'node:assert/strict' ;
8- import * as core from '../../src/engine/core/index.js' ;
8+ import Engine from '../../src/engine/core/Engine.js' ;
9+ import FrameClock from '../../src/engine/core/FrameClock.js' ;
10+ import FixedTicker from '../../src/engine/core/FixedTicker.js' ;
11+ import RuntimeMetrics from '../../src/engine/core/RuntimeMetrics.js' ;
12+ import EventBus from '../../src/engine/events/EventBus.js' ;
13+ import Camera2D from '../../src/engine/camera/Camera2D.js' ;
14+ import Camera3D from '../../src/engine/camera/Camera3D.js' ;
15+ import { followCameraTarget , worldRectToScreen } from '../../src/engine/camera/CameraSystem.js' ;
916import Scene from '../../src/engine/scene/Scene.js' ;
1017import SceneManager from '../../src/engine/scene/SceneManager.js' ;
1118import CanvasRenderer from '../../src/engine/rendering/CanvasRenderer.js' ;
@@ -23,51 +30,51 @@ import { stepWorldPhysics3D } from '../../src/engine/systems/PhysicsSystem.js';
2330
2431export function run ( ) {
2532 // Core boot/timing boundaries.
26- assert . equal ( typeof core . Engine , 'function' ) ;
27- assert . equal ( typeof core . FrameClock , 'function' ) ;
28- assert . equal ( typeof core . FixedTicker , 'function' ) ;
29- assert . equal ( typeof core . RuntimeMetrics , 'function' ) ;
33+ assert . equal ( typeof Engine , 'function' ) ;
34+ assert . equal ( typeof FrameClock , 'function' ) ;
35+ assert . equal ( typeof FixedTicker , 'function' ) ;
36+ assert . equal ( typeof RuntimeMetrics , 'function' ) ;
3037
3138 // Scene/render/input/physics/audio/systems public homes.
32- assert . equal ( typeof scene . Scene , 'function' ) ;
33- assert . equal ( typeof scene . SceneManager , 'function' ) ;
34- assert . equal ( typeof rendering . CanvasRenderer , 'function' ) ;
35- assert . equal ( typeof rendering . renderByLayers , 'function' ) ;
39+ assert . equal ( typeof Scene , 'function' ) ;
40+ assert . equal ( typeof SceneManager , 'function' ) ;
41+ assert . equal ( typeof CanvasRenderer , 'function' ) ;
42+ assert . equal ( typeof renderByLayers , 'function' ) ;
3643 assert . equal ( typeof InputService , 'function' ) ;
3744 assert . equal ( typeof ActionInputService , 'function' ) ;
38- assert . equal ( typeof physics . stepArcadeBody , 'function' ) ;
39- assert . equal ( typeof physics . applyDrag , 'function' ) ;
40- assert . equal ( typeof physics . integrateVelocity3D , 'function' ) ;
41- assert . equal ( typeof physics . isAabbColliding3D , 'function' ) ;
42- assert . equal ( typeof physics . resolveAabbCollision3D , 'function' ) ;
43- assert . equal ( typeof physics . stepSceneBodies3D , 'function' ) ;
45+ assert . equal ( typeof stepArcadeBody , 'function' ) ;
46+ assert . equal ( typeof applyDrag , 'function' ) ;
47+ assert . equal ( typeof integrateVelocity3D , 'function' ) ;
48+ assert . equal ( typeof isAabbColliding3D , 'function' ) ;
49+ assert . equal ( typeof resolveAabbCollision3D , 'function' ) ;
50+ assert . equal ( typeof stepSceneBodies3D , 'function' ) ;
4451 assert . equal ( typeof AudioService , 'function' ) ;
4552 assert . equal ( typeof moveEntities , 'function' ) ;
4653 assert . equal ( typeof moveEntities3D , 'function' ) ;
4754 assert . equal ( typeof stepArcadeBody , 'function' ) ;
4855 assert . equal ( typeof stepWorldPhysics3D , 'function' ) ;
4956
5057 // Combined service cluster contracts: timing/frame, event routing, camera.
51- const frameClock = new core . FrameClock ( { now : ( ) => 100 , maxDeltaMs : 100 } ) ;
58+ const frameClock = new FrameClock ( { now : ( ) => 100 , maxDeltaMs : 100 } ) ;
5259 frameClock . reset ( 100 ) ;
5360 const tick = frameClock . tick ( 116 ) ;
5461 assert . equal ( tick . deltaMs , 16 ) ;
5562
56- const ticker = new core . FixedTicker ( { stepMs : 10 , maxCatchUpSteps : 5 } ) ;
63+ const ticker = new FixedTicker ( { stepMs : 10 , maxCatchUpSteps : 5 } ) ;
5764 const steps = [ ] ;
5865 const tickerResult = ticker . advance ( 25 , ( stepSeconds ) => steps . push ( stepSeconds ) ) ;
5966 assert . equal ( tickerResult . steps , 2 ) ;
6067 assert . deepEqual ( steps , [ 0.01 , 0.01 ] ) ;
6168
62- const bus = new core . EventBus ( ) ;
69+ const bus = new EventBus ( ) ;
6370 let eventSeen = 0 ;
6471 bus . on ( 'engine.core.boundary' , ( ) => {
6572 eventSeen += 1 ;
6673 } ) ;
6774 assert . equal ( bus . emit ( 'engine.core.boundary' , { ok : true } ) , 1 ) ;
6875 assert . equal ( eventSeen , 1 ) ;
6976
70- const camera = new core . Camera2D ( {
77+ const camera = new Camera2D ( {
7178 x : 0 ,
7279 y : 0 ,
7380 viewportWidth : 100 ,
@@ -76,14 +83,14 @@ export function run() {
7683 worldHeight : 300 ,
7784 } ) ;
7885 const target = { x : 80 , y : 50 , width : 20 , height : 20 } ;
79- core . followCameraTarget ( camera , target , true ) ;
80- const rect = core . worldRectToScreen ( camera , { x : 100 , y : 100 , width : 10 , height : 10 } ) ;
86+ followCameraTarget ( camera , target , true ) ;
87+ const rect = worldRectToScreen ( camera , { x : 100 , y : 100 , width : 10 , height : 10 } ) ;
8188 assert . equal ( typeof rect . x , 'number' ) ;
8289 assert . equal ( typeof rect . y , 'number' ) ;
8390 assert . equal ( rect . width , 10 ) ;
8491 assert . equal ( rect . height , 10 ) ;
8592
86- const camera3D = new core . Camera3D ( {
93+ const camera3D = new Camera3D ( {
8794 position : { x : 1 , y : 2 , z : 3 } ,
8895 rotation : { x : 0.1 , y : 0.2 , z : 0.3 } ,
8996 } ) ;
@@ -117,11 +124,11 @@ export function run() {
117124 depth : 2 ,
118125 } ;
119126
120- physics . integrateVelocity3D ( movingBody , 0.5 ) ;
127+ integrateVelocity3D ( movingBody , 0.5 ) ;
121128 assert . equal ( movingBody . x , 3 ) ;
122- assert . equal ( physics . isAabbColliding3D ( movingBody , wallBody ) , true ) ;
129+ assert . equal ( isAabbColliding3D ( movingBody , wallBody ) , true ) ;
123130
124- const resolveResult = physics . resolveAabbCollision3D ( movingBody , wallBody ) ;
131+ const resolveResult = resolveAabbCollision3D ( movingBody , wallBody ) ;
125132 assert . equal ( resolveResult . collided , true ) ;
126133 assert . equal ( resolveResult . axis , 'x' ) ;
127134 assert . equal ( movingBody . x , 2 ) ;
@@ -143,7 +150,7 @@ export function run() {
143150 ] ,
144151 staticColliders3D : [ ] ,
145152 } ;
146- const stepSummary = physics . stepSceneBodies3D ( scene3D , 0.5 ) ;
153+ const stepSummary = stepSceneBodies3D ( scene3D , 0.5 ) ;
147154 assert . equal ( stepSummary . movedBodies , 1 ) ;
148155 assert . equal ( stepSummary . resolvedCollisions , 0 ) ;
149156 assert . equal ( scene3D . bodies3D [ 0 ] . x , 1 ) ;
@@ -152,7 +159,7 @@ export function run() {
152159 const before3D = world3D . getComponent ( movingEntity , 'transform3D' ) ;
153160 assert . equal ( before3D . x , 0 ) ;
154161 assert . equal ( before3D . z , 8 ) ;
155- const physics3DSummary = systems . stepWorldPhysics3D ( world3D , 1 ) ;
162+ const physics3DSummary = stepWorldPhysics3D ( world3D , 1 ) ;
156163 const after3D = world3D . getComponent ( movingEntity , 'transform3D' ) ;
157164 const velocity3D = world3D . getComponent ( movingEntity , 'velocity3D' ) ;
158165 assert . equal ( physics3DSummary . movedEntities , 1 ) ;
0 commit comments