Skip to content
On this page

Class: Light

WebSG.Light

The Light class represents a light source in a scene.

Table of contents

Constructors

Accessors

Constructors

constructor

new Light(props)

Creates a new Light instance.

Parameters

NameTypeDescription
propsLightPropsThe properties to create the light with.

Defined in

websg.d.ts:268

Accessors

color

get color(): RGB

Returns the color of the Light object as an RGB instance.

Example

ts
const light = world.createLight({ type: LightType.Point, color: [1, 0, 0] });
console.log(light.color); // RGB { r: 1, g: 0, b: 0 }

Returns

RGB

Defined in

websg.d.ts:297


intensity

get intensity(): number

Returns the intensity of the Light object.

Example

ts
const light = world.createLight({ type: LightType.Point });
console.log(light.intensity); // 1

Returns

number

Defined in

websg.d.ts:277

set intensity(value): void

Sets the intensity of the Light object.

Example

ts
const light = world.createLight({ type: LightType.Point });
light.intensity = 2;
console.log(light.intensity); // 2

Parameters

NameTypeDescription
valuenumberThe new intensity value for the Light object.

Returns

void

Defined in

websg.d.ts:288