Skip to content

⬅️ Back to Table of Contents

📄 RectAreaLight.js

📊 Analysis Summary

Metric Count
🔧 Functions 2
🧱 Classes 1
📦 Imports 1

📚 Table of Contents

🛠️ File Location:

📂 src/lights/RectAreaLight.js

📦 Imports

Name Source
Light ./Light.js

Functions

RectAreaLight.copy(source: any): this

Parameters:

  • source any

Returns: this

Calls:

  • super.copy
Code
copy( source ) {

        super.copy( source );

        this.width = source.width;
        this.height = source.height;

        return this;

    }

RectAreaLight.toJSON(meta: any): any

Parameters:

  • meta any

Returns: any

Calls:

  • super.toJSON
Code
toJSON( meta ) {

        const data = super.toJSON( meta );

        data.object.width = this.width;
        data.object.height = this.height;

        return data;

    }

Classes

RectAreaLight

Class Code
class RectAreaLight extends Light {

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

        super( color, intensity );

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

        this.type = 'RectAreaLight';

        /**
         * The width of the light.
         *
         * @type {number}
         * @default 10
         */
        this.width = width;

        /**
         * The height of the light.
         *
         * @type {number}
         * @default 10
         */
        this.height = height;

    }

    /**
     * The light's power. Power is the luminous power of the light measured in lumens (lm).
     * Changing the power will also change the light's intensity.
     *
     * @type {number}
     */
    get power() {

        // compute the light's luminous power (in lumens) from its intensity (in nits)
        return this.intensity * this.width * this.height * Math.PI;

    }

    set power( power ) {

        // set the light's intensity (in nits) from the desired luminous power (in lumens)
        this.intensity = power / ( this.width * this.height * Math.PI );

    }

    copy( source ) {

        super.copy( source );

        this.width = source.width;
        this.height = source.height;

        return this;

    }

    toJSON( meta ) {

        const data = super.toJSON( meta );

        data.object.width = this.width;
        data.object.height = this.height;

        return data;

    }

}

Methods

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

        super.copy( source );

        this.width = source.width;
        this.height = source.height;

        return this;

    }
toJSON(meta: any): any
Code
toJSON( meta ) {

        const data = super.toJSON( meta );

        data.object.width = this.width;
        data.object.height = this.height;

        return data;

    }