Renderer · class

WaterRenderer

Vertices per side of a bounded body's sheet. A pool is not an ocean.

Explained in Hello world.

class WaterRenderer
import { WaterRenderer } from '@driftengine/core';

Constructor

new

constructor(gl: WebGL2RenderingContext, resolution?: number, nearExtent?: number, farHalfExtent?: number, reflectionFilterTaps?: import("./renderQuality.ts").WaterReflectionFilterTaps)
ParameterTypeDescription
glWebGL2RenderingContext
resolution?numbercells per side of the wave-bearing near sheet.
nearExtent?numbertotal width of that sheet, in world metres.
farHalfExtent?numberhow far the flat skirt carries the ocean out. There is no point setting this far beyond the camera's far plane — geometry past it is clipped, not drawn — so this only has to outrun the fog. See buildWaterGrid for why these are two meshes and not one.
reflectionFilterTaps?import("./renderQuality.ts").WaterReflectionFilterTaps

Methods

draw

draw(gl: WebGL2RenderingContext, camera: FrameView, timeSeconds: number, settings: WaterBody, directionalDir: Vec3, directionalColor: Vec3, ambient: Vec3, atmosphere: Atmosphere, underwaterEnabled: boolean, reflection: PlanarReflection | null, lights?: PointLightSet | null, lightFalloff?: 'smooth' | 'inverseSquare', windX?: number, windZ?: number): void

Draw the surface. Call after the sky: water writes depth and is occluded by geometry in front of it, but its far edge fades out, and that fade needs the sky already behind it to blend into.

ParameterTypeDescription
glWebGL2RenderingContext
cameraFrameView
timeSecondsnumber
settingsWaterBody
directionalDirVec3
directionalColorVec3
ambientVec3
atmosphereAtmosphere
underwaterEnabledboolean
reflectionPlanarReflection | null
lights?PointLightSet | null
lightFalloff?'smooth' | 'inverseSquare'
windX?number
windZ?number

dispose

dispose(gl: WebGL2RenderingContext): void
ParameterTypeDescription
glWebGL2RenderingContext