Skip to main content

Class: FluidRenderer

renderer/fluidRenderer.FluidRenderer

Renders Fluids using a marching squares metaball algorithm.

Hierarchy

Constructors

constructor

โ€ข new FluidRenderer()

Inherited from

Renderer.constructor

Properties

circleProgram

โ–ช Static circleProgram: WebGLProgram

Inherited from

Renderer.circleProgram

Defined in

src/renderer/renderer.ts:58


circleProgramInfo

โ–ช Static circleProgramInfo: ShaderProgramInfo

Inherited from

Renderer.circleProgramInfo

Defined in

src/renderer/renderer.ts:59


fluidQueue

โ–ช Static Private fluidQueue: ZMap<Fluid[]> = {}

Defined in

src/renderer/fluidRenderer.ts:14


indexBuffer

โ–ช Static indexBuffer: WebGLBuffer

Inherited from

Renderer.indexBuffer

Defined in

src/renderer/renderer.ts:51


metaballProgram

โ–ช Static metaballProgram: WebGLProgram

Inherited from

Renderer.metaballProgram

Defined in

src/renderer/renderer.ts:64


metaballProgramInfo

โ–ช Static metaballProgramInfo: ShaderProgramInfo

Inherited from

Renderer.metaballProgramInfo

Defined in

src/renderer/renderer.ts:65


opacityBuffer

โ–ช Static opacityBuffer: WebGLBuffer

Inherited from

Renderer.opacityBuffer

Defined in

src/renderer/renderer.ts:52


positionBuffer

โ–ช Static positionBuffer: WebGLBuffer

Inherited from

Renderer.positionBuffer

Defined in

src/renderer/renderer.ts:48


queue

โ–ช Static Protected queue: ZMap<RenderQueueItem[]> = {}

Inherited from

Renderer.queue

Defined in

src/renderer/renderer.ts:45


rectProgram

โ–ช Static rectProgram: WebGLProgram

Inherited from

Renderer.rectProgram

Defined in

src/renderer/renderer.ts:55


rectProgramInfo

โ–ช Static rectProgramInfo: ShaderProgramInfo

Inherited from

Renderer.rectProgramInfo

Defined in

src/renderer/renderer.ts:56


scale

โ–ช Static Protected scale: vec2

The scale applied to shape vertices to obtain their clip space vertices.

Inherited from

Renderer.scale

Defined in

src/renderer/renderer.ts:43


texBuffer

โ–ช Static texBuffer: WebGLBuffer

Inherited from

Renderer.texBuffer

Defined in

src/renderer/renderer.ts:49


triangleProgram

โ–ช Static triangleProgram: WebGLProgram

Inherited from

Renderer.triangleProgram

Defined in

src/renderer/renderer.ts:61


triangleProgramInfo

โ–ช Static triangleProgramInfo: ShaderProgramInfo

Inherited from

Renderer.triangleProgramInfo

Defined in

src/renderer/renderer.ts:62


uvBuffer

โ–ช Static uvBuffer: WebGLBuffer

Inherited from

Renderer.uvBuffer

Defined in

src/renderer/renderer.ts:50

Methods

clear

โ–ธ Static clear(clearColor): void

Parameters

NameType
clearColorColor

Returns

void

Inherited from

Renderer.clear

Defined in

src/renderer/renderer.ts:203


flush

โ–ธ Static flush(z): void

Renders all fluids in the queue and clears the queue.

If the Renderer's camera has not been set nothing will be rendered.

Parameters

NameType
znumber

Returns

void

Overrides

Renderer.flush

Defined in

src/renderer/fluidRenderer.ts:21


getCamera

โ–ธ Static getCamera(): Camera

Gets the camera that is currently being used for rendering.

Returns

Camera

The camera that is currently being used for rendering

Inherited from

Renderer.getCamera

Defined in

src/renderer/renderer.ts:395


getFluidQueue

โ–ธ Static getFluidQueue(): ZMap<Fluid[]>

Gets the fluid render queue.

Returns

ZMap<Fluid[]>

the fluid render queue

Defined in

src/renderer/fluidRenderer.ts:122


getGL

โ–ธ Static getGL(): WebGL2RenderingContext

Gets the renderer's webgl context.

Returns

WebGL2RenderingContext

The renderer's webgl context

Inherited from

Renderer.getGL

Defined in

src/renderer/renderer.ts:330


getMode

โ–ธ Static getMode(): "TRIANGLES" | "LINES" | "POINTS"

Gets the current webgl rendering mode being used by the renderer.

Returns

"TRIANGLES" | "LINES" | "POINTS"

The rendering mode

Inherited from

Renderer.getMode

Defined in

src/renderer/renderer.ts:377


getQueue

โ–ธ Static getQueue(): ZMap<RenderQueueItem[]>

Gets the render queue.

Returns

ZMap<RenderQueueItem[]>

the render queue

Inherited from

Renderer.getQueue

Defined in

src/renderer/renderer.ts:422


getQueueMax

โ–ธ Static getQueueMax(): number

Gets the maximum zIndex used by the queue.

Returns

number

The max zIndex of the queue

Overrides

Renderer.getQueueMax

Defined in

src/renderer/fluidRenderer.ts:131


getQueueMin

โ–ธ Static getQueueMin(): number

Gets the minimum zIndex used by the queue.

Returns

number

The min zIndex of the queue

Overrides

Renderer.getQueueMin

Defined in

src/renderer/fluidRenderer.ts:140


getResolutionScale

โ–ธ Static getResolutionScale(): number

Gets the renderer's current resolution scale.

Returns

number

The renderer's current resolution scale

Inherited from

Renderer.getResolutionScale

Defined in

src/renderer/renderer.ts:353


getScale

โ–ธ Static getScale(): vec2

Gets the scale that is applied to vertices to obtain the vertices in clip space.

Returns

vec2

The scaling vector

Inherited from

Renderer.getScale

Defined in

src/renderer/renderer.ts:413


init

โ–ธ Static init(canvas, opts?): void

Sets up the renderer to be used for rendering.

Creates the webgl2 rendering context for the canvas and clears the webgl buffer.

throws When browser does not support webgl 2.0

Parameters

NameTypeDescription
canvasHTMLCanvasElementThe canvas to grab webgl context from
opts?WebGLContextAttributes{@link WebGLContextAttributes} to pass to the getContext call

Returns

void

Inherited from

Renderer.init

Defined in

src/renderer/renderer.ts:77


queueFluid

โ–ธ Static queueFluid(fluid): void

Adds a Fluid to the render queue.

Parameters

NameTypeDescription
fluidFluidThe fluid to queue for rendering

Returns

void

Defined in

src/renderer/fluidRenderer.ts:107


queueShape

โ–ธ Static queueShape(shape, position?, rotation?, zIndex?): void

Adds a shape to the render queue.

Parameters

NameTypeDefault valueDescription
shapeShapeundefinedThe shape to queue
positionvec2undefinedThe x and y position to render the rectangle at
rotationnumber0The rotation to apply to the shape
zIndexnumber0The z position of the rendered rectangle

Returns

void

Inherited from

Renderer.queueShape

Defined in

src/renderer/renderer.ts:238


renderFluid

โ–ธ Static renderFluid(fluid, quad, indices, quadDimensions): void

Renders a Fluid using a metaball shader.

Parameters

NameTypeDescription
fluidFluidThe fluid to render
quadFloat32ArrayThe vertices of the quad to render to (should be size of camera's viewport)
indicesUint16ArrayThe indices of the quad to render to
quadDimensionsvec2The width and height of the quad

Returns

void

Defined in

src/renderer/fluidRenderer.ts:57


resizeToCanvas

โ–ธ Static resizeToCanvas(): void

Resizes the width and height of the canvas attached to gl to the canvas' clientWidth and clientHeight multiplied by the resolutionScale or 1.

Returns

void

Inherited from

Renderer.resizeToCanvas

Defined in

src/renderer/renderer.ts:191


setMode

โ–ธ Static setMode(mode): void

Sets the mode the renderer will use for drawing.

throws When the provided mode is not TRIANGLES, LINES or POINTS

Parameters

NameTypeDescription
mode"TRIANGLES" | "LINES" | "POINTS"The mode to use

Returns

void

Inherited from

Renderer.setMode

Defined in

src/renderer/renderer.ts:364


setQueueMax

โ–ธ Static setQueueMax(max): void

Sets the maximum zIndex used by the queue.

Parameters

NameTypeDescription
maxnumberThe max zIndex of the queue

Returns

void

Overrides

Renderer.setQueueMax

Defined in

src/renderer/fluidRenderer.ts:149


setQueueMin

โ–ธ Static setQueueMin(min): void

Sets the minimum zIndex used by the queue.

Parameters

NameTypeDescription
minnumberThe min zIndex of the queue

Returns

void

Overrides

Renderer.setQueueMin

Defined in

src/renderer/fluidRenderer.ts:158


setResolutionScale

โ–ธ Static setResolutionScale(resolutionScale): void

Sets the resolution scale to use when rendering.

The width and height of the renderer canvas are set to clientWidth * resolutionScale and clientHeight * resolutionScale respectively.

Parameters

NameTypeDescription
resolutionScalenumberThe new resolution scale to use

Returns

void

Inherited from

Renderer.setResolutionScale

Defined in

src/renderer/renderer.ts:341


setScale

โ–ธ Static setScale(scale): void

Set the scale that is applied to vertices to obtain the vertices in clip space.

Parameters

NameTypeDescription
scalevec2The scaling vector

Returns

void

Inherited from

Renderer.setScale

Defined in

src/renderer/renderer.ts:404


useCamera

โ–ธ Static useCamera(camera): void

Sets the camera to use for rendering.

Parameters

NameTypeDescription
cameraCameraThe camera to use for rendering

Returns

void

Inherited from

Renderer.useCamera

Defined in

src/renderer/renderer.ts:386