Class: FluidRenderer
renderer/fluidRenderer.FluidRenderer
Renders Fluids using a marching squares metaball algorithm.
Hierarchy
โณ
FluidRenderer
Constructors
constructor
โข new FluidRenderer()
Inherited from
Properties
circleProgram
โช Static circleProgram: WebGLProgram
Inherited from
Defined in
src/renderer/renderer.ts:58
circleProgramInfo
โช Static circleProgramInfo: ShaderProgramInfo
Inherited from
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
Defined in
src/renderer/renderer.ts:51
metaballProgram
โช Static metaballProgram: WebGLProgram
Inherited from
Defined in
src/renderer/renderer.ts:64
metaballProgramInfo
โช Static metaballProgramInfo: ShaderProgramInfo
Inherited from
Defined in
src/renderer/renderer.ts:65
opacityBuffer
โช Static opacityBuffer: WebGLBuffer
Inherited from
Defined in
src/renderer/renderer.ts:52
positionBuffer
โช Static positionBuffer: WebGLBuffer
Inherited from
Defined in
src/renderer/renderer.ts:48
queue
โช Static Protected queue: ZMap<RenderQueueItem[]> = {}
Inherited from
Defined in
src/renderer/renderer.ts:45
rectProgram
โช Static rectProgram: WebGLProgram
Inherited from
Defined in
src/renderer/renderer.ts:55
rectProgramInfo
โช Static rectProgramInfo: ShaderProgramInfo
Inherited from
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
Defined in
src/renderer/renderer.ts:43
texBuffer
โช Static texBuffer: WebGLBuffer
Inherited from
Defined in
src/renderer/renderer.ts:49
triangleProgram
โช Static triangleProgram: WebGLProgram
Inherited from
Defined in
src/renderer/renderer.ts:61
triangleProgramInfo
โช Static triangleProgramInfo: ShaderProgramInfo
Inherited from
Defined in
src/renderer/renderer.ts:62
uvBuffer
โช Static uvBuffer: WebGLBuffer
Inherited from
Defined in
src/renderer/renderer.ts:50
Methods
clear
โธ Static clear(clearColor): void
Parameters
| Name | Type |
|---|---|
clearColor | Color |
Returns
void
Inherited from
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
| Name | Type |
|---|---|
z | number |
Returns
void
Overrides
Defined in
src/renderer/fluidRenderer.ts:21
getCamera
โธ Static getCamera(): Camera
Gets the camera that is currently being used for rendering.
Returns
The camera that is currently being used for rendering
Inherited from
Defined in
src/renderer/renderer.ts:395
getFluidQueue
โธ Static getFluidQueue(): ZMap<Fluid[]>
Gets the fluid render queue.
Returns
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
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
Defined in
src/renderer/renderer.ts:377
getQueue
โธ Static getQueue(): ZMap<RenderQueueItem[]>
Gets the render queue.
Returns
ZMap<RenderQueueItem[]>
the render queue
Inherited from
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
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
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
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
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
| Name | Type | Description |
|---|---|---|
canvas | HTMLCanvasElement | The canvas to grab webgl context from |
opts? | WebGLContextAttributes | {@link WebGLContextAttributes} to pass to the getContext call |
Returns
void
Inherited from
Defined in
src/renderer/renderer.ts:77
queueFluid
โธ Static queueFluid(fluid): void
Adds a Fluid to the render queue.
Parameters
| Name | Type | Description |
|---|---|---|
fluid | Fluid | The 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
| Name | Type | Default value | Description |
|---|---|---|---|
shape | Shape | undefined | The shape to queue |
position | vec2 | undefined | The x and y position to render the rectangle at |
rotation | number | 0 | The rotation to apply to the shape |
zIndex | number | 0 | The z position of the rendered rectangle |
Returns
void
Inherited from
Defined in
src/renderer/renderer.ts:238
renderFluid
โธ Static renderFluid(fluid, quad, indices, quadDimensions): void
Renders a Fluid using a metaball shader.
Parameters
| Name | Type | Description |
|---|---|---|
fluid | Fluid | The fluid to render |
quad | Float32Array | The vertices of the quad to render to (should be size of camera's viewport) |
indices | Uint16Array | The indices of the quad to render to |
quadDimensions | vec2 | The 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
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
| Name | Type | Description |
|---|---|---|
mode | "TRIANGLES" | "LINES" | "POINTS" | The mode to use |
Returns
void
Inherited from
Defined in
src/renderer/renderer.ts:364
setQueueMax
โธ Static setQueueMax(max): void
Sets the maximum zIndex used by the queue.
Parameters
| Name | Type | Description |
|---|---|---|
max | number | The max zIndex of the queue |
Returns
void
Overrides
Defined in
src/renderer/fluidRenderer.ts:149
setQueueMin
โธ Static setQueueMin(min): void
Sets the minimum zIndex used by the queue.
Parameters
| Name | Type | Description |
|---|---|---|
min | number | The min zIndex of the queue |
Returns
void
Overrides
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
| Name | Type | Description |
|---|---|---|
resolutionScale | number | The new resolution scale to use |
Returns
void
Inherited from
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
| Name | Type | Description |
|---|---|---|
scale | vec2 | The scaling vector |
Returns
void
Inherited from
Defined in
src/renderer/renderer.ts:404
useCamera
โธ Static useCamera(camera): void
Sets the camera to use for rendering.
Parameters
| Name | Type | Description |
|---|---|---|
camera | Camera | The camera to use for rendering |
Returns
void
Inherited from
Defined in
src/renderer/renderer.ts:386