Skip to content

Render Layers

Use named render layers to place custom objects within the sky and scene draw order. This avoids scattering unexplained renderOrder values throughout an application.

Sky Pro places its own backdrops (dome, stars, cirrus, clouds) this way; you use the same layers for your content.

typescript
import { RenderLayer, placeInLayer } from "threejs-sky-pro";

placeInLayer(myGlassPanel, RenderLayer.sceneTransparent);
placeInLayer(myHudSprite, RenderLayer.foreground);

RenderLayer

Named layers in draw order. Each row draws over the rows above it.

LayerListUse
backgroundopaqueA full-screen backdrop. Nothing draws behind it.
backgroundOverlaytransparentA blended backdrop that writes no depth.
worldSurfaceopaqueA depth-writing surface under the sky (water).
atmosphereOverlaytransparentAn overlay that depth-tests against worldSurface.
sceneTransparenttransparentYour own glass, particles, decals.
foregroundtransparentAlways-on-top overlays — HUD, gizmos.

Each value is a RenderLayerSpec: { list, order }.

The list Field

Each layer belongs to either the opaque or transparent draw list. material.transparent selects an object's list, while order sorts only within that list. Opaque and transparent objects never interleave based on order alone.

placeInLayer warns when material.transparent does not match the selected layer. Correct the material setting rather than trying to compensate with renderOrder.

placeInLayer(object, layer, offset?)

Assigns object to a layer.

ParamTypeRequiredDescription
objectTHREE.Object3DrequiredThe mesh (or group) to place.
layerRenderLayerSpecrequiredA member of RenderLayer.
offsetnumberoptional — default 0Added to the layer's sort key to fan several meshes across one layer. A higher offset draws later (on top). Keep it in [0, 10) so the mesh stays inside the layer's band.

Returns: void

typescript
// Two overlays in one layer; the label draws over the marker.
placeInLayer(marker, RenderLayer.foreground, 0);
placeInLayer(label, RenderLayer.foreground, 1);

Types

RenderLayerSpec

typescript
interface RenderLayerSpec {
  readonly list: "opaque" | "transparent";
  readonly order: number;
}

RenderList

typescript
type RenderList = "opaque" | "transparent";

RenderLayerName

A union of the RenderLayer keys — "background" | "backgroundOverlay" | ....

See Also

Commercial License - All Rights Reserved.