Skip to content

AccumulativeShadows

<AccumulativeShadows /> is a THREE.DirectionalLight-based shadow component. It displays shadows on a single shadow catcher plane, included in the component. It is based on Drei component of the same name.

Usage

vue
<script setup lang="ts">
import { AccumulativeShadows, OrbitControls } from '@tresjs/cientos'
import { TresCanvas } from '@tresjs/core'
</script>

<template>
  <TresCanvas clear-color="#fbb03b" :shadows="true">
    <OrbitControls />
    <TresMesh :position-y="0.3" :scale="0.4" :cast-shadow="true">
      <TresTorusKnotGeometry />
      <TresMeshNormalMaterial />
    </TresMesh>
    <AccumulativeShadows
      :blend="100"
      color="#fbb03b"
      once
      :position-y="-0.4"
    />
  </TresCanvas>
</template>

Props

PropDescriptionDefault
onceWhether shadow creation only happens once (resets after props change)false
accumulateWhether shadows accumulate progressively over several framestrue
framesNumber of frames to render. More yields cleaner results but takes more time. If accumulate && once, 1 frame will be consumed every update for frames updates. Otherwise, frames frames are consumed for every update.40
blendIf accumulate, controls the refresh ratio100
limitIf less than Infinity, limits the amount of frames rendered. Use this to increase performance once a movable scene has settledInfinity
scaleScale of the plane10
opacityOpacity of the plane1
alphaTestDiscards alpha pixels0.65
colorShadow color'black'
colorBlendIf less than Infinity, limits the amount of frames rendered. Use this to increase performance once a movable scene has settledInfinity
resolutionBuffer resolution1024
toneMappedTexture tonemappingtrue

Slot

You can bring your own lights to <AccumulatedShadows />, but it's designed to be used with <RandomizedLights />.

By default, there's a <RandomizedLights /> instance provided in <AccumulatedShadows />'s <slot />. You can replace it with your own <RandomizedLights /> or an alternative by passing it as a child component.