Class: GpuHeightFieldWater

SKUNAMI. GpuHeightFieldWater

<virtual> new GpuHeightFieldWater()

Abstract base class for GPU height field water simulations
Source:

Methods

addCallback(type, callbackFn)

Adds callback function that is executed at specific times
Parameters:
Name Type Description
type string Type of callback: 'exertForce' (only choice available now)
callbackFn function Callback function
Source:

addDynamicObstacle(mesh, mass)

Adds a dynamic obstacle into the system
Parameters:
Name Type Description
mesh THREE.Mesh Mesh to use as a dynamic obstacle
mass number Mass of the dynamic obstacle
Source:

addStaticObstacle(mesh)

Adds a static obstacle into the system
Parameters:
Name Type Description
mesh THREE.Mesh Mesh to use as a static obstacle
Source:

disturb(position, amount, radius)

Disturbs the water, causing ripples on the water surface
Parameters:
Name Type Description
position THREE.Vector3 World-space position to disturb at
amount number Amount of water to disturb
radius number Radius of disturb
Source:

<virtual> flood(volume)

Floods the scene by the given volume
Parameters:
Name Type Description
volume number Volume of water to flood the scene with, in cubic scene units
Source:

getObstaclesDisplayTexture() → {THREE.WebGLRenderTarget}

Gets the obstacle texture
Source:
Returns:
Obstacles texture
Type
THREE.WebGLRenderTarget

getPixelFloatData() → {Float32Array}

Returns the pixel float data for the water textures
NOTE: This is an expensive operation.
Source:
Returns:
Float data of the water texture
Type
Float32Array

getShouldDisplayObstaclesTexture() → {boolean}

Gets whether the obstacles texture should be displayed
Source:
Returns:
Whether the obstacles texture should be displayed
Type
boolean

getShouldDisplayWaterTexture() → {boolean}

Gets whether the water texture should be displayed
Source:
Returns:
Whether the water texture should be displayed
Type
boolean

getWaterDisplayTexture() → {THREE.WebGLRenderTarget}

Gets the water texture that is used for displacement of mesh
Source:
Returns:
Water texture that is used for displacement of mesh
Type
THREE.WebGLRenderTarget

removeObstacle(mesh)

Removes obstacle from the system
Parameters:
Name Type Description
mesh THREE.Mesh Mesh of the obstacle to remove
Source:

reset()

Resets the simulation
Source:

setShouldDisplayObstaclesTexture(value)

Sets whether the obstacles texture should be displayed
Parameters:
Name Type Description
value boolean Whether the obstacles texture should be displayed
Source:

setShouldDisplayWaterTexture(value)

Sets whether the water texture should be displayed
Parameters:
Name Type Description
value boolean Whether the water texture should be displayed
Source:

update(dt)

Updates the water simulation
NOTE: This needs to be called every frame, after renderer.clear() and before renderer.render(...)
Parameters:
Name Type Description
dt number Elapsed time since previous frame
Source: