5.4.0

Precipitation

Flexible infinite particle flow for rain, snow, waterfall, and beam effects.

<Precipitation /> is a fully flexible component that renders an infinite particle flow, It comes with several props that allow you customize it to create different effects like precipitation, snow, waterfall, beams, etc.

Usage

You can use <Precipitation /> component without passing any props, this will achieve a snowy effect, like the before example.

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

<template>
  <TresCanvas>
    <TresPerspectiveCamera :position="[0, 3, 5]" />
    <Precipitation />
    <TresAmbientLight />
  </TresCanvas>
</template>

Rain

By setting the randomness to 0, increase the speed and reduce the count. You can easily achieve a more rainy effect.

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

<template>
  <TresCanvas>
    <TresPerspectiveCamera :position="[0, 3, 5]" />
    <Precipitation
      :count="2000"
      :speed="0.3"
      :randomness="0"
    />
    <TresAmbientLight />
  </TresCanvas>
</template>

Storm

A storm effect? Easy just increase the randomness.

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

<template>
  <TresCanvas>
    <TresPerspectiveCamera :position="[0, 3, 5]" />
    <Precipitation
      :count="3000"
      :speed="0.5"
      :randomness="1.5"
    />
    <TresAmbientLight />
  </TresCanvas>
</template>

Beam

What about an infinite beam? Just set the area, to the axis that you need constrain.

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

<template>
  <TresCanvas>
    <TresPerspectiveCamera :position="[0, 3, 5]" />
    <Precipitation
      :area="[0.5, 0.5, 20]"
      :count="1000"
      :speed="0.2"
      :size="0.3"
      color="#00ff00"
    />
    <TresAmbientLight />
  </TresCanvas>
</template>

You can create much more! ☔

Be careful with the performance this components render infinite particles in movement

Props

PropDescriptionDefault
sizeThe size of the drops.0.1
areaThe size of the precipitation area.10, 10, 20
colorThe color of the drops.0xffffff
mapColor texture of the drops.null
alphaMapAlpha texture of the Drops.null
alphaTestEnables the WebGL to know when not to render the pixel.0.01
opacitySet the opacity of the drops.0.8
countNumber of drops.5000
speedDrops speed.0.1
randomnessAdd randomness to the drops.0.5
depthWriteWhether should write to the depth buffer or not. drops.true
transparentTransparency on the drops texturefalse
sizeAttenuationKeep the same size regardless distance. drops.true