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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 1x 1x 1x 1x 5x 17x 17x 17x 17x 10x 1x 9x 9x 5x 2x 2x 16x 9x 9x 16x 9x 9x 9x 9x 7x 7x 6x 7x 2x 1x 1x | "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EngineLoop = void 0; const parent_1 = require("./models/parent"); const frameTime_1 = require("./models/frameTime"); class EngineLoop extends parent_1.Parent { get isActive() { return this._isActive; } constructor(surfaceSettings, window) { super(); this._isActive = false; this._window = window; this._surfaceSettings = surfaceSettings; } start() { if (this._isActive) { return; } this._isActive = true; this.request(0); } stop() { this._isActive = false; } destroy() { super.destroy(); this.stop(); } request(startTime) { const requestFrame = (endTime) => { const frameTime = new frameTime_1.FrameTime(startTime, endTime); this.loop(frameTime); }; this._window.requestAnimationFrame(requestFrame); } loop(frameTime) { const surfaceSettings = this._surfaceSettings; const expectedDelta = surfaceSettings.frameLimit > 0 ? 1000 / surfaceSettings.frameLimit : frameTime.delta; const actualDelta = Math.round(expectedDelta - frameTime.delta); if (actualDelta <= 0) { this.children.forEach(scene => scene.update(frameTime)); if (this._isActive) { this.request(frameTime.end); } return; } if (this._isActive) { this.request(frameTime.start); } } } exports.EngineLoop = EngineLoop; |