Skip to content

resolveRenderParent

resolveRenderParent(entity, layerName, tree): DisplayContainer

Defined in: renderer/src/SortGroupComponent.ts:69

Resolve the Pixi container a visual should render into: the nearest ancestor SortGroupComponent bound to the same layer, or the layer container itself when there is no enclosing group. Walks the entity hierarchy starting at entity (inclusive), so a visual on a group-owning entity joins that group.

When layerName names a layer the scene never declared in its layers, this warns in dev (naming the entity, the missing layer, and the scene) and falls back to the scene’s default layer, so the visual still renders instead of throwing or silently disappearing.

The built-in visual components call this in their onAdd. A custom visual component (one implementing LayerRenderable) should do the same, so it joins an enclosing group on its initial add rather than only when the group next re-homes its subtree:

onAdd() {
const tree = this.use(SceneRenderTreeKey);
resolveRenderParent(this.entity, this.layerName, tree).addChild(
this.renderObject,
);
}

Entity

string

SceneRenderTree

DisplayContainer