Class Light

Illuminates a portion of the scene covered by the light.

Hierarchy (view full)

Constructors

Accessors

  • get active(): boolean
  • Activates or deactivates the component.

    Returns boolean

    The returned active state also accounts for the active state of the parent SceneObject.

  • set active(value): void
  • Parameters

    • value: boolean

    Returns void

  • get attenuationRadius(): number
  • Range at which the light contribution fades out to zero. Use SetUseAutoAttenuation to provide a radius automatically dependant on light intensity. The radius will cut-off light contribution and therefore manually set very small radius can end up being very physically incorrect.

    Returns number

  • set attenuationRadius(value): void
  • Parameters

    • value: number

    Returns void

  • get castsShadow(): boolean
  • Determines does this light cast shadows when rendered.

    Returns boolean

  • set castsShadow(value): void
  • Parameters

    • value: boolean

    Returns void

  • get color(): Immutable<SRGBColor>
  • Returns the current color of the light as an RGB value. If the light color mode is set to RGB then this will return the same value as assigned to the RGB color, otherwise the color will be determined from the currently set color temperature.

    Returns Immutable<SRGBColor>

  • get colorTemperature(): number
  • Determines the color temperature of the light, in Kelvins. Reasonable range is 1000 to 12000 Kelvins, where lower values represent warmer light (orange tint) and higher values represent colder light (blue tint). Only used if light color mode is set to Temperature.

    Returns number

  • set colorTemperature(value): void
  • Parameters

    • value: number

    Returns void

  • get editorMetaData(): Settings
  • Get the editor meta data.

    Returns Settings

    The API is only valid in the editor.

  • get illuminance(): number
  • Returns number

  • get intensity(): number
  • Determines the power of the light source. Units used depend on the selected light unit and light type: - For radial, spot and rectangular lights: - Lumens (Luminous flux) if selected light unit is lumens. Value can be found on most common light bulb packaging. Reasonable values are between 200 and 800 lumens for popular light bulbs. - Watts (Radiant flux) if selected light unit in watts. Note that in this case you must also select the luminous efficacy of the light bulb this light is simulating. The default is for a tungsten incandescent lightbulb where a reasonable value range is 30 to 80 watts for popular light bulbs.

    • Nits (Luminance) if select light unit is nits. Useful if you want the surface to have a constant brightness regardless of the size, such as a computer display. Reasonable values for displays are 100 - 5000 nits. - For directional lights: - Lux (Luminance) as measured perpendicular to the light source (e.g. using a light meter on Earth perpendicular to the Sun). Reasonable values for Sun on Earth are 80 000 to 125 000 Lux, without considering participating media.

    Returns number

  • set intensity(value): void
  • Parameters

    • value: number

    Returns void

  • get isActiveSelf(): boolean
  • Determines whether the component itself is active, without accounting for the active state of the parent scene object.

    Returns boolean

  • get isDestroyed(): boolean
  • Determines if the object has been destroyed.

    Returns boolean

  • get isRunning(): boolean
  • Determines if the component is currently active, enabled and running.

    Returns boolean

  • get luminance(): number
  • Returns number

  • get luminousEfficacy(): number
  • Determines the lumens per watt. This value is only relevant if watts are used as the light intensity value. Some common values are 12-18 for incandescent light bulbs and 75-110 for LED lights. Find a more complete list here: https://en.wikipedia.org/wiki/Luminous_efficacy.

    Returns number

  • set luminousEfficacy(value): void
  • Parameters

    • value: number

    Returns void

  • get luminousFlux(): number
  • Returns number

  • get luminousIntensity(): number
  • Returns luminous intensity of the light source. Assumes all light sources are punctual. Returns zero for directional lights. Does not account for light profile intensity.

    Returns number

  • get photometricProfile(): PhotometricLightProfile
  • Profile determining light distribution, as measured by real-world sensors. This will essentially 'mask' light intensity, attenuating it in certain directions across the sphere surrounding the light.

    Returns PhotometricLightProfile

  • set photometricProfile(value): void
  • Profile determining light distribution, as measured by real-world sensors. This will essentially 'mask' light intensity, attenuating it in certain directions across the sphere surrounding the light.

    Parameters

    Returns void

  • get priority(): number
  • The signed execution priority of the component.

    Determines order of execution of this component in relation to other components, higher priorities will execute earlier. The priority value determines the order of initialize, enable and update calls. Valid priorities are in the range [-100...100], other priorities are reserved for internal use.

    The priority should not be modified after onCreate has been called.

    The default priority for user implement components is -10. BuiltInComponent have a default priority of 0. However, instances that have dependencies or are a dependency to another component might have non zero default priorities. For example, the Camera component has a default priority of 50 as other components may depend on the camera being initialized early. The RigidBody component has a default priority of 22 and Joint components have a priority of 20 as the joint depends on fully initialized rigid bodies.

    Returns number

    If two components have the same priority, the order of execution is undefined, but deterministic as the system uses identifiers such as the internal type ID and UUID to guaranteed stable ordering.

  • set priority(value): void
  • Parameters

    • value: number

    Returns void

  • get sourceRadius(): number
  • Radius of the light source. If non-zero then this light represents an area light, otherwise it is a punctual light. Area lights have different attenuation then punctual lights, and their appearance in specular reflections is realistic. Shape of the area light depends on light type: - For directional light the shape is a disc projected on the hemisphere on the sky. This parameter represents angular radius (in degrees) of the disk and should be very small (think of how much space the Sun takes on the sky - roughly 0.25 degree radius). - For radial light the shape is a sphere and the source radius is the radius of the sphere.

    • For spot lights the shape is a disc oriented in the direction of the spot light and the source radius is the radius of the disc. - For rectangular area lights this is ignored. Set the source size instead.

    Returns number

  • set sourceRadius(value): void
  • Parameters

    • value: number

    Returns void

  • get spotAngle(): rsx.Degree
  • Determines the total angle covered by a spot light.

    Returns rsx.Degree

  • set spotAngle(value): void
  • Parameters

    Returns void

  • get spotFalloffAngle(): rsx.Degree
  • Determines the falloff angle covered by a spot light. Falloff angle determines at what point does light intensity starts quadratically falling off as the angle approaches the total spot angle.

    Returns rsx.Degree

  • set spotFalloffAngle(value): void
  • Parameters

    Returns void

  • get useAutoAttenuation(): boolean
  • If enabled the attenuation radius will automatically be controlled in order to provide reasonable light radius, depending on its intensity.

    Returns boolean

  • set useAutoAttenuation(value): void
  • Parameters

    • value: boolean

    Returns void

  • get usePhotometricIntensity(): boolean
  • When enabled the light intensity will be determined from the photometric light profile. If disabled the photometric light profile will act as a mask while the actual intensity can be manually specified. Only relevant if photometric light profile is set.

    Note that photometric light profiles are measured with the assumption of punctual or very small lights, meaning their intensity will only be correct if you use such light type yourself.

    Returns boolean

  • set usePhotometricIntensity(value): void
  • Parameters

    • value: boolean

    Returns void

  • get uuid(): UUID
  • Returns a universally unique identifier that persists scene save/load.

    Returns UUID

  • get volumetricScatteringIntensity(): number
  • Determines the contribution of this light on the in-scattering effect in volumetric lighting. Value of 0 will disable light's contribution, while value of 1 will contribute the light fully. In visual terms greater values create so called 'light shafts'.

    Returns number

  • set volumetricScatteringIntensity(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Forces the light shadow map to update on the next frame.

    Returns void

  • Virtual

    Calculates bounds of the visible content for this component.

    Returns {
        box: AABox;
        sphere: Sphere;
    }

    An object with the bounding box and bounding sphere or null, if the component has no bounds.

  • Destroys the component, removing it from its scene object and stopping component updates.

    Parameters

    • Optionalimmediate: boolean

      If true the component will be fully destroyed immediately. This means that objects that are still referencing this component might fail. Normally destruction is delayed until the end of the frame to give other objects a chance to stop using it.

    Returns void

  • Calls a parameterless method with the specified name, on the component.

    Parameters

    • name: string

      Name of the method to call.

    Returns boolean

    true if the method was invoked.

  • Virtual

    Called once when the component has been created.

    Returns void

    Called regardless of the state the component is in.

  • Virtual

    Called once just before the component is destroyed.

    Returns void

    Called regardless of the state the component is in.

  • Virtual

    Called every time a component is placed into the Stopped state.

    Returns void

    This method may be called during component destruction, if the component wasn't already in ScenePlayState.Stopped state during destruction. When called during destruction, it is called before onDestroy.

  • Virtual

    Called every time a component leaves the ScenePlayState.Stopped state.

    Returns void

    This method might be called during component creation, if the requirements for leaving the stopped state are met. One such case would be a component class that has the runInEditor attribute. When called during creation it is called after onInitialize.

  • Called at fixed time intervals (e.g. 60 times per frame). Only called if the component is in ScenePlayState.Playing state.

    Returns void

    RSX uses the fixed update to perform updates to sub-systems such as physics. Only implement this method if your logic depends on fixed updates (e.g. at 30hz) for stability.

  • Virtual

    Called once when the component first leaves the ScenePlayState.Stopped state.

    Returns void

    This method might be called during component creation, if the requirements for leaving the stopped state are met. One such case would be a component class that has the runInEditor attribute. When called during creation it is called after onCreate.

  • Virtual

    Called once per frame, after all other components received their onUpdate invocation. Only called if the component is in ScenePlayState.Playing state.

    Returns void

    This method should only be implemented if your component needs logic that implements on other component or SceneObject changes performend in onUpdate. An example could be a camera controller logic that updates in response to changes to the object that is being tracked.

  • Virtual

    Called when the script domain has been refreshed or when the component is initialized. During initialization it is called after onInitialize but before onEnable.

    Returns void

    This API will not be called in a deployment build.

  • Registers the coroutine for the specified component using the provided args as arguments.

    Type Parameters

    Parameters

    • coroutine: T

      The coroutine.

    • Rest...args: Parameters<T>

    Returns boolean

    true if the coroutine was registered.

    The coroutine will be called for the first time when the coroutine subsystem runs for update events. There is no guarantee with regards to the order of how coroutines are invoked. Coroutines are a great way for time-deferred or delayed system. To implement a coroutine simply add a generator method to your component and register it as coroutine:

    		public *myCoroutine(text:string)
    {
    const endTime:number = Time.realElapsed + 3;

    while(Time.realElapsed < endTime)
    {
    yield true;
    }

    Debug.log("This code will be invoked after 3 seconds with the text=" + text);
    }

    To register the function simply call

    		this.startCoroutine(this.myCoroutine, "Hello World!");
    

    The function will be invoked once the coroutine runs. The coroutine function can yield the program control flow by using the keyword yield. The coroutine will then stop execution at that point, and pick up the execution in the next update event, right after the yield keyword that caused the coroutine to pause.

    With helper functions such as waitForSeconds or waitForAsyncOp it is easy to create coroutines that pause for a set time interval.

  • Registers the coroutine for the specified component using the provided args as arguments.

    Type Parameters

    Parameters

    • coroutine: T

      The coroutine.

    • Rest...args: Parameters<T>

    Returns boolean

    true if the coroutine was registered.

    The coroutine will be called for the first time when the coroutine subsystem runs for fixedUpdate events. There is no guarantee with regards to the order of how coroutines are invoked. Coroutines are a great way for time-deferred or delayed system. To implement a coroutine simply add a generator method to your component and register it as coroutine:

    		public *myCoroutine(text:string)
    {
    const endTime:number = Time.realElapsed + 3;

    while(Time.realElapsed < endTime)
    {
    yield true;
    }

    Debug.log("This code will be invoked after 3 seconds!");
    }

    To register the function simply call

    		this.startCoroutine(this.myCoroutine, "Hello World!");
    

    The function will be invoked once the coroutine runs. The coroutine function can yield the program control flow by using the keyword yield. The coroutine will then stop execution at that point, and pick up the execution in the next fixedUpdate event, right after the yield keyword that caused the coroutine to pause.

    With helper functions such as waitForSeconds or waitForAsyncOp it is easy to create coroutines that pause for a set time interval.

  • Stops all coroutines for the specified component.

    Returns void

    This API is only available for components that are registered in a scene.

  • Stops the coroutine for the specified component.

    Parameters

    Returns boolean

    true if the coroutine was registered.

  • Locates a rsx object by its sceneRuntimeID and UUID.

    Parameters

    • sceneRuntimeID: number

      The runtime ID of the SceneInstance of the object.

    • uuid: Const<UUID>

      The UUID of the object to retrieve.

    Returns SceneNode

    The object or null if no object with given sceneRuntimeID and uuid has been registered