@threlte/extras

<ContactShadows>

This component is a port of drei’s <ContactShadows> component.

A contact shadow implementation, facing upwards (positive Y) by default. scale can be a positive number or a 2D array (x: number, y: number]).

<ContactShadows
  opacity={1}
  scale={10}
  blur={1}
  far={10}
  resolution={256}
  color="#000000"
/>

Since this is a rather expensive effect you can limit the amount of frames it renders when your objects are static. For instance making it render only once:

<ContactShadows frames={1} />

Use the binding refresh to manually refresh the shadows:

<script>
  let refresh

  const onSomeEvent = () => {
    if (refresh) refresh()
  }
</script>

<ContactShadows
  bind:refresh
  frames={0}
/>

Currently it has the same limitations of drei’s version: It yields unexpected results if moved on the x or the z axis.

Example

<script lang="ts">
  import { ContactShadows } from 'threlte/extras'
</script>

<ContactShadows
  scale={10}
  blur={2}
  far={2.5}
  opacity={0.5}
/>

Component Signature

<ContactShadows> extends <T . Group> and supports all its props, slot props, bindings and events.

Props

name
type
required

blur
number
no

color
THREE.ColorRepresentation
no

depthWrite
boolean
no

far
number
no

frames
number
no

height
number
no

opacity
number
no

resolution
number
no

scale
number | [x: number, y: number]
no

smooth
boolean
no

width
number
no

Bindings

name
type

refresh
() => void