Skip to content

⬅️ Back to Table of Contents

📄 DirectionalLight.js

📊 Analysis Summary

Metric Count
🔧 Functions 2
🧱 Classes 1
📦 Imports 3

📚 Table of Contents

🛠️ File Location:

📂 src/lights/DirectionalLight.js

📦 Imports

Name Source
Light ./Light.js
DirectionalLightShadow ./DirectionalLightShadow.js
Object3D ../core/Object3D.js

Functions

DirectionalLight.dispose(): void

Returns: void

Calls:

  • this.shadow.dispose
Code
dispose() {

        this.shadow.dispose();

    }

DirectionalLight.copy(source: any): this

Parameters:

  • source any

Returns: this

Calls:

  • super.copy
  • source.target.clone
  • source.shadow.clone
Code
copy( source ) {

        super.copy( source );

        this.target = source.target.clone();
        this.shadow = source.shadow.clone();

        return this;

    }

Classes

DirectionalLight

Class Code
class DirectionalLight extends Light {

    /**
     * Constructs a new directional light.
     *
     * @param {(number|Color|string)} [color=0xffffff] - The light's color.
     * @param {number} [intensity=1] - The light's strength/intensity.
     */
    constructor( color, intensity ) {

        super( color, intensity );

        /**
         * This flag can be used for type testing.
         *
         * @type {boolean}
         * @readonly
         * @default true
         */
        this.isDirectionalLight = true;

        this.type = 'DirectionalLight';

        this.position.copy( Object3D.DEFAULT_UP );
        this.updateMatrix();

        /**
         * The directional light points from its position to the
         * target's position.
         *
         * For the target's position to be changed to anything other
         * than the default, it must be added to the scene.
         *
         * It is also possible to set the target to be another 3D object
         * in the scene. The light will now track the target object.
         *
         * @type {Object3D}
         */
        this.target = new Object3D();

        /**
         * This property holds the light's shadow configuration.
         *
         * @type {DirectionalLightShadow}
         */
        this.shadow = new DirectionalLightShadow();

    }

    dispose() {

        this.shadow.dispose();

    }

    copy( source ) {

        super.copy( source );

        this.target = source.target.clone();
        this.shadow = source.shadow.clone();

        return this;

    }

}

Methods

dispose(): void
Code
dispose() {

        this.shadow.dispose();

    }
copy(source: any): this
Code
copy( source ) {

        super.copy( source );

        this.target = source.target.clone();
        this.shadow = source.shadow.clone();

        return this;

    }