loop() {
        if (document.hidden) { this.running = false }

        let now = Date.now(),
            delta = now - (this.lastRender || now)
        this.lastRender = now;

        if (this.running) {
            this.draw(delta)
            this.frames++
        }

        requestAnimationFrame(() => this.loop());

        // Display fps and position
        if (now - this.lastFps > 999) {
            this.fpsMeter.innerText = this.frames
            this.lastFps = now;
            this.frames = 0;
        }
    }
/**
     * Main loop, manages fps and state.
     */
Main loop, manages fps and state.
Main loop manages fps and state .
loop() {
        if (document.hidden) { this.running = false }
        let now = Date.now(),
            delta = now - (this.lastRender || now)
        this.lastRender = now;
        if (this.running) {
            this.draw(delta)
            this.frames++
        }
        requestAnimationFrame(() => this.loop());
        if (now - this.lastFps > 999) {
            this.fpsMeter.innerText = this.frames
            this.lastFps = now;
            this.frames = 0;
        }
    }
loop ( ) { if ( document . hidden ) { this . running = false } let now = Date . now ( ) , delta = now - ( this . lastRender || now ) this . lastRender = now ; if ( this . running ) { this . draw ( delta ) this . frames ++ } requestAnimationFrame ( ( ) => this . loop ( ) ) ; if ( now - this . lastFps > 999 ) { this . fpsMeter . innerText = this . frames this . lastFps = now ; this . frames = 0 ; } }
Main loop, manages fps and state.
Main loop manages fps and state .
// Display fps and position