Documentation
    Preparing search index...

    Interface FrameStats

    §84's eleven runtime counters for one frame, mutated in place.

    Obtain one from createFrameStats — or, in an application, from app.stats, which is null until statistics are switched on. Fields are mutable because producers write them from several packages and none of them may allocate (see the module header); treat them as read-only from application code.

    A field reading NaN was not measured this frame. See the module header for which producers write which fields.

    interface FrameStats {
        activeBodies: number;
        bufferMemory: number;
        contacts: number;
        cpuFrameTime: number;
        drawCalls: number;
        gpuFrameTime: number;
        instances: number;
        physicsStepTime: number;
        simulationTime: number;
        textureMemory: number;
        triangles: number;
    }
    Index
    activeBodies: number

    Rigid bodies the solver is integrating — §32's awake bodies, excluding sleeping ones. Written by recordSolverStatistics.

    bufferMemory: number

    Bytes of vertex and index buffer memory the engine holds — every live geometry, from §83's resource accounting (A-5). Written by recordResourceMemory.

    A level rather than a per-frame quantity; see FrameStats.textureMemory.

    contacts: number

    Contact points the solver resolved — narrow-phase manifold count after the last step. Written by recordSolverStatistics when the adapter implements DebugBodyAccess.countContacts; otherwise NaN.

    cpuFrameTime: number

    Wall-clock seconds the CPU spent producing the frame — the whole of the §10 loop for one step: fixed steps, systems, update/render listeners, and the draw submission.

    Submission, not completion: the GPU is still working when this stops (that is gpuFrameTime, when the backend measured one). Measured with the monotonic clock the application was given.

    drawCalls: number

    Draw calls submitted for the frame, summed over every view and every pass.

    NaN when no renderer counted (a headless application, or a backend that does not report statistics); 0 when a counting backend drew nothing.

    gpuFrameTime: number

    Seconds the GPU spent on the most recently completed frame.

    Written from Renderer.lastGpuFrameTimeSeconds when that number is finite (A-1). NaN when the backend does not measure, the first armed frame has not landed a query, or the last sample was disjoint.

    instances: number

    Primitive-set instances submitted for the frame. A non-instanced draw contributes 1 (GL's own model: drawArrays is drawArraysInstanced with one instance), an instanced draw contributes its instance count — so instances - drawCalls is what instancing bought, and FrameStats.triangles stays consistent with both.

    physicsStepTime: number

    Seconds spent in the physics solver's step, the subset of FrameStats.simulationTime the solver owns — summed over the frame's fixed steps, like its neighbour.

    Written by whoever calls PhysicsWorld.step; in an application that is four's Application, and only when a world is attached to it (ApplicationOptions.physics, A-6). Without one the field stays NaN: a frame with no solver did not spend zero seconds solving, it did not measure.

    simulationTime: number

    Wall-clock seconds this frame spent inside its §10 fixed steps — systems, fixedUpdate listeners, and everything else the accumulator ran, summed over the 0..maximumSubSteps steps of the frame.

    A duration, not §9's clock. §9 also has a simulationTime — total simulated time since start, which is what app.time.simulationTime reads — and the two are different quantities with one name. This field takes the duration reading because its three neighbours in §84's own list (cpuFrameTime, gpuFrameTime, physicsStepTime) are all durations, and because the §9 clock is already exposed on the time record: reporting it again in a statistics block would be duplication rather than measurement (decision, A-1). A frame that ran no fixed step reports 0.

    textureMemory: number

    Bytes of texture memory the engine holds — every live (constructed, undisposed) texture and render target, from §83's resource accounting (A-5). Written by recordResourceMemory.

    A level, not a per-frame quantity: unlike every other counter here it describes the engine at the end of the frame rather than something the frame did. Two frames that draw the same scene report the same value; a value that climbs across identical frames is §83's "leaked textures".

    triangles: number

    Triangles submitted for the frame — per-instance primitive count times the instance count, so an instanced draw contributes all of its triangles. Line and point primitives contribute none.