Documentation
    Preparing search index...

    Function buildRenderList

    • Builds the sorted render list for root's subtree into out, and returns out (§64).

      const list: RenderItem[] = [];        // allocated once, reused every frame
      // per frame:
      resolveWorldTransforms(scene); // §7: world matrices before §64
      buildRenderList(scene, list);

      World matrices are not resolved here. Each item's worldMatrix is a reference to the node's own matrix, so the list is only as fresh as the last resolveWorldTransforms pass — which §7 requires the frame to run before render-item generation anyway, and which the Application composition root already runs before its render listeners. Keeping resolution out of this function is what lets the two passes stay separately schedulable (§64 lists them as distinct stages) and what makes the item generation free.

      out is truncated to the number of items generated, so a list that shrinks does not leave stale items behind. The items themselves are pooled per out array: after a rebuild the array contains the same item objects, with new contents and possibly in a new order. Two consequences worth stating —

      1. an item read after the next build into the same array describes a different draw; copy anything you need to keep;
      2. two independent lists need two out arrays (they then have independent pools), which is the normal way to render several viewports.

      Allocates nothing in the steady state: no items, no matrices, no math objects. The first few frames grow the pool to the scene's item count and then stop.

      buildRenderList(scene, list, camera.layers);   // only what this camera sees
      

      Only nodes sharing a bit with layerMask generate items; their children are traversed regardless, because §46 layers do not inherit (see collect). The default is ALL_LAYERS, which makes the test true for every node whose mask is non-zero — i.e. every node that has not been explicitly removed from all layers — so a caller that omits it gets exactly the list it got before the parameter existed, in exactly the same order.

      This is the build-time half of §46 filtering, for the caller that builds one list per view. The other half is RenderItem's layers snapshot, which lets one shared list be filtered per view by view-list.ts's buildViewRenderList; the WebGL backend takes that route, because a frame that traverses the scene once and derives per view is cheaper than one that traverses per view (R-8).

      Parameters

      Returns RenderItem[]

      FourError INVALID_SCENE_GRAPH in a development build when layerMask is not an integer in [0, 0xffffffff] (§85) — a NaN mask would otherwise empty the list with no diagnostic at all. §85 lets a production build drop expensive validation, and this one costs bytes in every shipped bundle for a mistake that is an authoring error by construction, so it is gated: measured at ~115 B gzip on ui-demo, deleted entirely by __FOUR_DEV__: false (R-38, 2026-08-08). The check itself, @fourjs/scene's assertLayerMask, is unconditional there — @fourjs/scene is a §33 simulation package and may not branch on the build mode at all.