Skip to content

Commit

Permalink
Light flicker animation
Browse files Browse the repository at this point in the history
Documentation
  • Loading branch information
jasonsturges committed Nov 24, 2024
1 parent ecebdb3 commit 77c941a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/animators/LightFlickerAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,39 @@ export interface LightFlickerAnimationOptions {
jitterZ: number;
}

/**
* Create a light flicker animation that will randomly change the intensity and position of a light.
* Effect resembles a flickering flame of candlelight.
*
* Example usage:
* ```
* // Create a candle
* const candle = new Candle({
* height: 1,
* flameHeight: 0.25,
* });
* scene.add(candle);
*
* // Create a point light
* const candleLight = new THREE.PointLight(0xffa500, 1, 5);
* scene.add(candleLight);
*
* // Apply the animator to the light
* const lightAnimation = new LightFlickerAnimation({
* light: candleLight,
* maxIntensity: 2.2,
* x: 0,
* y: 1.125,
* z: 0,
* });
* animations.push(lightAnimation);
*
* // Update the light animation in the render loop
* renderer.setAnimationLoop(() => {
* lightAnimation.update();
* });
* ```
*/
export class LightFlickerAnimation {
private light?: Light;
public minIntensity: number;
Expand Down

0 comments on commit 77c941a

Please sign in to comment.