Class: GpuXWater

SKUNAMI. GpuXWater

new GpuXWater(options)

GPU height field water simulation based on http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
Parameters:
Name Type Description
options object Options
Properties
Name Type Argument Default Description
renderer THREE.WebGLRenderer Three.js WebGL renderer
scene THREE.Scene Three.js scene
mesh THREE.Mesh Three.js mesh for sculpting
size number Size of mesh
res number Resolution of mesh
dampingFactor number Damping factor for the sim
multiSteps number <optional>
1 Number of full steps to take per frame, to speed up some of algorithms that are slow to propagate at high mesh resolutions
meanHeight number <optional>
0 Mean height of the water simulation
density number <optional>
1000 Density of water (kg per cubic metres)
Source:

Extends

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
Inherited From:
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
Inherited From:
Source:

addStaticObstacle(mesh)

Adds a static obstacle into the system
Parameters:
Name Type Description
mesh THREE.Mesh Mesh to use as a static obstacle
Inherited From:
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
Inherited From:
Source:

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
Inherited From:
Source:

getMeanHeight() → {number}

Gets mean height
Inherited From:
Source:
Returns:
Mean height
Type
number

getObstaclesDisplayTexture() → {THREE.WebGLRenderTarget}

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

getPixelFloatData() → {Float32Array}

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

getShouldDisplayObstaclesTexture() → {boolean}

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

getShouldDisplayWaterTexture() → {boolean}

Gets whether the water texture should be displayed
Inherited From:
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
Inherited From:
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
Inherited From:
Source:

reset()

Resets the simulation
Inherited From:
Source:

setMeanHeight(value)

Sets mean height
Parameters:
Name Type Description
value number Mean height
Inherited From:
Source:

setShouldDisplayObstaclesTexture(value)

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

setShouldDisplayWaterTexture(value)

Sets whether the water texture should be displayed
Parameters:
Name Type Description
value boolean Whether the water texture should be displayed
Inherited From:
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
Inherited From:
Source: