Capítulo 147 de 859

Chapter 147: SpotLightHelper

Core Idea

This displays a cone shaped helper object for a SpotLight.

When the spot light or its target are transformed or light properties are changed, it's necessary to call the update() method of the respective helper.

Key Concepts

  • color : number | Color | string: The color parameter passed in the constructor. If not set, the helper will take the color of the light.
  • light : SpotLight: The light being visualized.

Code Examples

const spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set( 10, 10, 10 );
scene.add( spotLight );
const spotLightHelper = new THREE.SpotLightHelper( spotLight );
scene.add( spotLightHelper );
  • What it demonstrates: Typical usage of SpotLightHelper.

Reference Tables

Constructor

Signature
`new SpotLightHelper( light : HemisphereLight, color : number

Properties

PropertyDescription
`.color : numberColor
.light : SpotLightThe light being visualized.

Methods

MethodDescription
.dispose()Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
.update()Updates the helper to match the position and direction of the light being visualized.

Key Takeaways

  1. SpotLightHelper extends: EventDispatcher → Object3D
  2. Most relevant properties: color, light.
  3. Key methods: dispose, update.

Connects To