Skip to main content

Function: createTerrainRenderEcsSystem()

createTerrainRenderEcsSystem(renderContext, terrainMesh): EcsSystem<[CameraEcsComponent, PositionEcsComponent]>

Defined in: rendering/terrain/create-terrain-render-ecs-system.ts:25

Creates an ECS system that draws terrainMesh directly - a single, non-instanced gl.drawArrays call against its own geometry and material

  • rather than going through the sprite pipeline createRenderEcsSystem batches (which only knows how to draw quads). Register it before createRenderEcsSystem, with renderContext.clearStrategy set to CLEAR_STRATEGY.none, so this system's own clear is the only one each frame - createRenderEcsSystem's would otherwise wipe the terrain right before drawing sprites on top of it.

Assumes a single camera rendering straight to the canvas; a multi-camera setup would need to track which destinations have already been cleared this frame, the way createRenderEcsSystem does internally.

Parameters

renderContext

RenderContext

The render context to draw into.

terrainMesh

TerrainMesh

The terrain mesh built by createTerrainMesh.

Returns

EcsSystem<[CameraEcsComponent, PositionEcsComponent]>