Capítulo 595 de 859

Chapter 595: ShadowMesh

Core Idea

A Shadow Mesh that follows a shadow-casting mesh in the scene, but is confined to a single plane. This technique can be used as a very performant alternative to classic shadow mapping. However, it has serious limitations like:

  • Shadows can only be casted on flat planes.
  • No soft shadows support.

Key Concepts

  • frustumCulled : boolean: Overwritten to disable view-frustum culling by default.
  • isShadowMesh : boolean (readonly): This flag can be used for type testing.
  • matrixAutoUpdate : boolean: Overwritten to disable automatic matrix update. The local matrix is computed manually in ShadowMesh#update.
  • meshMatrix : Matrix4: Represent the world matrix of the reference mesh.

Code Examples

const cubeShadow = new ShadowMesh( cube );
scene.add( cubeShadow );
  • What it demonstrates: Typical usage of ShadowMesh.

Reference Tables

Constructor

Signature
new ShadowMesh( mesh : Mesh )

Properties

PropertyDescription
.frustumCulled : booleanOverwritten to disable view-frustum culling by default.
.isShadowMesh : boolean (readonly)This flag can be used for type testing.
.matrixAutoUpdate : booleanOverwritten to disable automatic matrix update. The local matrix is computed manually in ShadowMesh#update.
.meshMatrix : Matrix4Represent the world matrix of the reference mesh.

Methods

MethodDescription
.update( plane : Plane, lightPosition4D : Vector4 )Updates the shadow mesh so it follows its shadow-casting reference mesh.

Key Takeaways

  1. ShadowMesh extends: EventDispatcher → Object3D → Mesh
  2. Most relevant properties: frustumCulled, isShadowMesh, matrixAutoUpdate, meshMatrix.
  3. Key methods: update.

Connects To