Skip to content

Contact Shadows

A contact shadow implementation is a technique used in 3D graphics to create shadows that appear where objects meet or "contact" each other. This is different from traditional shadowing techniques, which often only create shadows based on the position of a light source relative to an object.

This component is used to create and manage contact shadows in a 3D scene. It is based on the original code by @mrdoob and the implementation in pmndrs drei but adapted for Vue Composition API.


  <TresCanvas v-bind="gl">
    <TresPerspectiveCamera :position="[11, 11, 11]" />
    <OrbitControls />
    <Box ref="boxRef" :args="[0.4, 0.4, 0.4]" :position="[0, 1, 0]">
      <TresMeshNormalMaterial />
    <Icosahedron ref="icoRef" :args="[0.3]" :position="[1, 1, 1]">
      <TresMeshNormalMaterial />
    <ContactShadows :blur="0.5" :resolution="512" :opacity="0.2" />
    <Plane :args="[10, 10, 10]" :position="[0, -0.02, 0]">
      <TresMeshBasicMaterial :color="'#ffffff'" />
    <TresAmbientLight :intensity="1" />
opacityThe opacity of the shadows.1
widthThe width of the shadows.1
heightThe height of the shadows.1
blurThe blur of the shadows.1
farHow far the OrthographicCamera should be to capture the shadows.10
smoothWhether the shadows should be smooth or not.true
resolutionThe resolution of the shadows.512
framesThe number of frames to render the shadows.Infinity
scaleThe scale of the shadows. Can be a number or an array of two numbers [x, y].10
colorThe color of the shadows.'#000000'
depthWriteWhether the shadows should write to the depth buffer or not.false