5.9.2

Ocean

Wrapper for the Three.js Water add-on with sky reflection support.

<Ocean /> is a wrapper for the Three.js Water add-on.

Ocean comes with a default texture, so it needs to be wrapped in a Suspense component.

Usage

<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { Ocean } from '@tresjs/cientos'
</script>

<template>
  <TresCanvas>
    <Suspense>
      <Ocean />
    </Suspense>
  </TresCanvas>
</template>

SKY

<Ocean /> works hand in hand with the Sky component, detecting the position of the sun and reflecting on the water. (<Sky /> is not required for making this component work.)

Fog

The <Ocean /> component also reacts when there's Fog or FogExp2 in your scene.

Custom Geometry

You can use custom geometry by adding it as a child.

<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { Ocean } from '@tresjs/cientos'
</script>

<template>
  <TresCanvas>
    <Suspense>
      <Ocean>
        <TresCircleGeometry :args="[50, 16]" />
      </Ocean>
    </Suspense>
  </TresCanvas>
</template>

Props

Props marked with ✅ support reactive changes at runtime. Props marked with ❌ are only read at construction time and cannot be changed after the component is mounted.
PropDescriptionDefaultReactive
textureWidthWidth of the mirror texture512❌
textureHeightHeight of the mirror texture512❌
waterNormalsURL of the water normal textureWater_1_M_Normal.jpg❌
sunDirectionSun direction to be reflected on the waterVector3(0,0,0)❌
sunColorSun color to be reflected on the water0xffffff✅
waterColorWater color0x001e0f✅
distortionScaleDistortion scale on reflected objects3.7✅
sizeSize of the water normals1✅
clipBiasClip bias for the render target0.0❌
alphaAlpha transparency of the water1.0✅
sideWhich side of the mesh renders the waterFrontSide❌
speedAnimation speed multiplier applied to the wave animation. Higher values make the water animate faster.1✅