Skip to content
Lighting

Scene / Lighting

Lighting Class ​

illumination


Illumination refers to simulating the illumination and influence of light sources on objects in the real world.

In 3D rendering, lighting is used to calculate the shading, shadow, reflection and other effects of objects to increase the realism and stereoscopic sense of the scene.

The lighting model usually includes such factors as the type, color, intensity of the light source, and the material property of the surface of the object. Common lighting models include parallel light, point light, etc.

It includes a series of adjust property. You can use these static property and methods to change the way lighting is displayed and interacts with other objects, as outlined in Lighting property.

Usage example: You can control the real-time effects of post-processing in the editor as follows. Create a script named "LightingExample", place it in the object bar, open the script, enter the following code, run the game, and you can control the lighting brightness through the+and - keys

ts
@Component
export default class LightingExample extends mw.Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected async onStart(): Promise<void> {
        if(SystemUtil.isClient())
        {
            mw.InputUtil.onKeyDown(Keys.Add,()=>{
                // Keypad+Jian, increase lighting brightness by 1 unit
                Lighting.skyLightIntensity = Lighting.skyLightIntensity + 1;
                Lighting.directionalLightIntensity = Lighting.directionalLightIntensity + 1;
                Console.log ("brightness of current light source:"+Lighting. brightness);
                // At the same time, change the angle of the directional light, increasing by 5 (angle)
                Lighting.pitchAngle = Lighting.pitchAngle + 5;
                Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
            });
            mw.InputUtil.onKeyDown(Keys.Subtract,()=>{
                // Keypad - Jian, reduce lighting brightness by 1 unit
                Lighting.skyLightIntensity = Lighting.skyLightIntensity - 1;
                Lighting.directionalLightIntensity = Lighting.directionalLightIntensity - 1;
                // At the same time, change the angle of the directional light, and decrease by 5 (angle)
                Lighting.pitchAngle = Lighting.pitchAngle - 5;
                Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
            });
        }
    }
}
@Component
export default class LightingExample extends mw.Script {
    // When the script is instantiated, this function will be called before the first frame update
    protected async onStart(): Promise<void> {
        if(SystemUtil.isClient())
        {
            mw.InputUtil.onKeyDown(Keys.Add,()=>{
                // Keypad+Jian, increase lighting brightness by 1 unit
                Lighting.skyLightIntensity = Lighting.skyLightIntensity + 1;
                Lighting.directionalLightIntensity = Lighting.directionalLightIntensity + 1;
                Console.log ("brightness of current light source:"+Lighting. brightness);
                // At the same time, change the angle of the directional light, increasing by 5 (angle)
                Lighting.pitchAngle = Lighting.pitchAngle + 5;
                Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
            });
            mw.InputUtil.onKeyDown(Keys.Subtract,()=>{
                // Keypad - Jian, reduce lighting brightness by 1 unit
                Lighting.skyLightIntensity = Lighting.skyLightIntensity - 1;
                Lighting.directionalLightIntensity = Lighting.directionalLightIntensity - 1;
                // At the same time, change the angle of the directional light, and decrease by 5 (angle)
                Lighting.pitchAngle = Lighting.pitchAngle - 5;
                Console.log ("Current parallel light angle:"+Lighting.pitchAngle);
            });
        }
    }
}

Table of contents ​

Accessors ​

castShadowsEnabled(): boolean other
Get whether to enable shadows
directionalLightColor(): LinearColor other
Obtain parallel light color
directionalLightIntensity(): number other
Obtain parallel light intensity
ev100(): number other
Obtain exposure value
lightColor(): LinearColor other
Obtain color cast value
pitchAngle(): number other
Get pitch angle
shadowsDistance(): number other
Obtain shadow distance
skyLightColor(): LinearColor other
Obtain the color of the sky light
skyLightIntensity(): number other
Obtain the intensity of daylight
skyLightTextureId(): string other
Obtain the color of the sky light
temperature(): number other
Obtain color temperature
temperatureEnabled(): boolean other
Obtain whether to enable color temperature
yawAngle(): number other
Obtain orientation angle

Accessors ​


castShadowsEnabled ​

• Static get castShadowsEnabled(): boolean other

• Static set castShadowsEnabled(value): void other

Get whether to enable shadows

Returns ​

booleanTrue or false

Set whether to enable shadows

Parameters ​

value booleanUsage: Boolean value

directionalLightColor ​

• Static get directionalLightColor(): LinearColor other

• Static set directionalLightColor(value): void other

Obtain parallel light color

Returns ​

LinearColorParallel light color

Set parallel light color

Parameters ​

value LinearColorUsage: Parallel light color

directionalLightIntensity ​

• Static get directionalLightIntensity(): number other

• Static set directionalLightIntensity(value): void other

Obtain parallel light intensity

Returns ​

numberIntensity value

Set parallel light intensity

Parameters ​

value numberUsage: intensity value

ev100 ​

• Static get ev100(): number other

• Static set ev100(value): void other

Obtain exposure value

Returns ​

numberExposure floating point value

Set exposure value

Parameters ​

value numberUsage: Expose floating point values

lightColor ​

• Static get lightColor(): LinearColor other

• Static set lightColor(newLightColor): void other

Obtain color cast value

Returns ​

LinearColorColor deviation value

Set color deviation value

Parameters ​

newLightColor LinearColorUsage: New color deviation value

pitchAngle ​

• Static get pitchAngle(): number other

• Static set pitchAngle(value): void other

Get pitch angle

Returns ​

numberPitch angle

Set pitch angle (-90~90)

Parameters ​

value numberUsage: angle floating point value

shadowsDistance ​

• Static get shadowsDistance(): number other

• Static set shadowsDistance(value): void other

Obtain shadow distance

Returns ​

numberShadow distance (cm)

Set shadow distance

Parameters ​

value numberUsage: Distance (cm)

skyLightColor ​

• Static get skyLightColor(): LinearColor other

• Static set skyLightColor(value): void other

Obtain the color of the sky light

Returns ​

LinearColorSky Light Color

Set sky color

Parameters ​

value LinearColorUsage: Sky Light Color

skyLightIntensity ​

• Static get skyLightIntensity(): number other

• Static set skyLightIntensity(value): void other

Obtain the intensity of daylight

Returns ​

numberIntensity value

Set daylight intensity

Parameters ​

value numberUsage: intensity value

skyLightTextureId ​

• Static get skyLightTextureId(): string other

• Static set skyLightTextureId(value): void other

Obtain the color of the sky light

Returns ​

stringSky Light Color

Set lighting texture

Parameters ​

value string numberUsage: lighting texture ID

temperature ​

• Static get temperature(): number other

• Static set temperature(value): void other

Obtain color temperature

Returns ​

numberTrue or false

Set color temperature (1000~14000)

Parameters ​

value numberUsage: Color temperature floating point value

temperatureEnabled ​

• Static get temperatureEnabled(): boolean other

• Static set temperatureEnabled(value): void other

Obtain whether to enable color temperature

Returns ​

booleanTrue or false

Set whether to enable color temperature

Parameters ​

value booleanUsage: Boolean value

yawAngle ​

• Static get yawAngle(): number other

• Static set yawAngle(value): void other

Obtain orientation angle

Returns ​

numberOrientation angle

Set orientation angle (-180~180)

Parameters ​

value numberUsage: angle floating point value