All files / ts engineCore.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x         1x         1x             4x 4x 4x 4x       2x 2x       1x    
import "./extensions/extensions.js"
import { IFactoryContext } from "./factories/factoryContext.js";
import { IFactoryInput } from "./factories/factoryInput.js";
import { IFactorySurface } from "./factories/factorySurface.js";
import { IScene } from "./components/scene.js";
import { IEngineLoop, EngineLoop } from "./engineLoop.js";
import { ISurfaceSettings } from "./controller/surface/surfaceSettings.js";
import { IInputController } from "./controller/input/inputController.js";
 
export interface IEngineCore extends IEngineLoop { }
export class EngineCore extends EngineLoop implements IEngineCore {
 
    private readonly _input: IInputController;
    private readonly _contextFactory: IFactoryContext;
    private readonly _surfaceFactory: IFactorySurface;
 
    public constructor(surfaceSettings: ISurfaceSettings, surfaceFactory: IFactorySurface, contextFactory: IFactoryContext, inputFactory: IFactoryInput, window: Window) {
        super(surfaceSettings, window);
        this._contextFactory = contextFactory;
        this._surfaceFactory = surfaceFactory;
        this._input = inputFactory.create(this);
    }
 
    protected initializeChild(child: IScene): void {
        const surface = this._surfaceFactory.create(this._contextFactory);
        child.initialize(surface, this._input)
    }
 
    protected destroyChild(child: IScene): void {
        child.destroy();
    }
}