Class TerrainRenderer

Per-chunk canvas-backed terrain renderer.

Each chunk gets its own <canvas> element of size chunkSize × chunkSize, registered with Phaser's TextureManager via addCanvas, and shown by a Phaser Image GameObject placed at the chunk's world position. Repaints update the canvas's ImageData and call texture.refresh() so the GPU re-uploads the changed pixels.

One canvas per chunk (rather than a single world-spanning canvas) keeps each upload bounded to chunk size — chunks that are clean don't pay any GPU cost. The cost is N extra Phaser Image game objects, one per chunk; for the v1 default of 32 chunks per typical world this is negligible.

Constructors

Methods

  • Re-paints every chunk whose visualDirty flag is set, then clears the flag. Call from the scene's update() (or a postUpdate hook); cheap when nothing is dirty.

    Returns number