Skip to content

eulerjs API / @eulerjs/marine / WaterMesh

WaterMesh ​

Defined in: packages/marine/src/three/WaterMesh.ts:83

Renders a SumOfSines ocean: a grid of chunks around the follow target, displaced on the GPU by exactly the waves the physics uses. The centre chunks resolve the same waves as the physics (both use waves.sampleSpacing); farther chunks drop the shortest waves from the geometry and keep them only in the per-pixel normal.

Extends ​

  • BatchedMesh

Constructors ​

Constructor ​

ts
new WaterMesh(source, options?): WaterMesh;

Defined in: packages/marine/src/three/WaterMesh.ts:93

Renders an Ocean's surface, or a SumOfSines directly.

Parameters ​

ParameterType
source| SumOfSines | Ocean<SumOfSines>
options?WaterMeshOptions

Returns ​

WaterMesh

Overrides ​

ts
BatchedMesh.constructor

Properties ​

PropertyModifierTypeDefault valueDescriptionOverridesDefined in
chunkSizereadonlynumberundefined--packages/marine/src/three/WaterMesh.ts:86
followpublicObject3D<Object3DEventMap> | undefinedundefined--packages/marine/src/three/WaterMesh.ts:88
lodreadonlyWaterLodundefined--packages/marine/src/three/WaterMesh.ts:85
materialpublicMeshPhysicalMaterialTHREE.MeshBasicMaterial | new THREE.MeshBasicMaterial().An instance of material derived from the THREE.Material | Material base class or an array of materials, defining the object's appearance.BatchedMesh.materialpackages/marine/src/three/WaterMesh.ts:90
uniformsreadonlyWaterUniformsundefined--packages/marine/src/three/WaterMesh.ts:87
wavesreadonlySumOfSinesundefined--packages/marine/src/three/WaterMesh.ts:84
worldpublicWorld | undefinedundefined--packages/marine/src/three/WaterMesh.ts:89

Methods ​

onBeforeRender() ​

ts
onBeforeRender(...renderArguments): void;

Defined in: packages/marine/src/three/WaterMesh.ts:152

An optional callback that is executed immediately before a 3D object is rendered.

Parameters ​

ParameterType
...renderArguments[renderer: WebGLRenderer, scene: Scene<Object3DEventMap>, camera: Camera, geometry: BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>, material: Material<MaterialEventMap>, group: Group<Object3DEventMap>]

Returns ​

void

Remarks ​

This function is called with the following parameters: renderer, scene, camera, geometry, material, group. Please notice that this callback is only executed for renderable 3D objects. Meaning 3D objects which define their visual appearance with geometries and materials like instances of Mesh, Line, Points or Sprite. Instances of Object3D, Group or Bone are not renderable and thus this callback is not executed for such objects.

Overrides ​

ts
BatchedMesh.onBeforeRender

update() ​

ts
update(time?): void;

Defined in: packages/marine/src/three/WaterMesh.ts:140

Moves the mesh under the follow target and advances the waves to time (simulation seconds, by default the world's render time). Only needed without the world option.

Parameters ​

ParameterType
time?number

Returns ​

void

Released under the MIT License.