<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [Light](./server.light.md)

## Light class

Represents a light in a world. Lights can be point lights or spotlights.

**Signature:**

```typescript
export default class Light extends EventRouter implements protocol.Serializable 
```
**Extends:** [EventRouter](./server.eventrouter.md)

**Implements:** protocol.Serializable

## Remarks

Lights are created directly as instances. They support a variety of configuration options through the [LightOptions](./server.lightoptions.md) constructor argument.

<h2>Events</h2>

This class is an EventRouter, and instances of it emit events with payloads listed under [LightEventPayloads](./server.lighteventpayloads.md)

## Example


```typescript
const light = new Light({
  attachedToEntity: playerEntity,
  color: { r: 255, g: 0, b: 0 },
  intensity: 5,
  offset: { x: 0, y: 1, z: 0 },
});

light.spawn(world);
```

## Constructors

<table><thead><tr><th>

Constructor


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[(constructor)(options)](./server.light._constructor_.md)


</td><td>


</td><td>

Constructs a new instance of the `Light` class


</td></tr>
</tbody></table>

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[angle](./server.light.angle.md)


</td><td>

`readonly`


</td><td>

number \| undefined


</td><td>

If type is spotlight, the angle of the spotlight.


</td></tr>
<tr><td>

[attachedToEntity](./server.light.attachedtoentity.md)


</td><td>

`readonly`


</td><td>

[Entity](./server.entity.md) \| undefined


</td><td>

The entity to which the Light is attached if explicitly set.


</td></tr>
<tr><td>

[color](./server.light.color.md)


</td><td>

`readonly`


</td><td>

[RgbColor](./server.rgbcolor.md)


</td><td>

The color of the light.


</td></tr>
<tr><td>

[distance](./server.light.distance.md)


</td><td>

`readonly`


</td><td>

number \| undefined


</td><td>

The maximum distance the light will illuminate. 0 does not limit distance. Defaults to 0.


</td></tr>
<tr><td>

[id](./server.light.id.md)


</td><td>

`readonly`


</td><td>

number \| undefined


</td><td>

The unique identifier for the Light.


</td></tr>
<tr><td>

[intensity](./server.light.intensity.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The intensity of the light in candela (cd). Defaults to 1


</td></tr>
<tr><td>

[isSpawned](./server.light.isspawned.md)


</td><td>

`readonly`


</td><td>

boolean


</td><td>

Whether the Light is spawned into the world.


</td></tr>
<tr><td>

[offset](./server.light.offset.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md) \| undefined


</td><td>

The offset of the light from the attached entity or position.


</td></tr>
<tr><td>

[penumbra](./server.light.penumbra.md)


</td><td>

`readonly`


</td><td>

number \| undefined


</td><td>

If type is spotlight, the penumbra of the spotlight.


</td></tr>
<tr><td>

[position](./server.light.position.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md) \| undefined


</td><td>

The position of the light in the world if explicitly set.


</td></tr>
<tr><td>

[trackedEntity](./server.light.trackedentity.md)


</td><td>

`readonly`


</td><td>

[Entity](./server.entity.md) \| undefined


</td><td>

If type is spotlight, the entity the spotlight will constantly point at.


</td></tr>
<tr><td>

[trackedPosition](./server.light.trackedposition.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md) \| undefined


</td><td>

If type is spotlight, the position the spotlight will constantly point at.


</td></tr>
<tr><td>

[type](./server.light.type.md)


</td><td>

`readonly`


</td><td>

[LightType](./server.lighttype.md)


</td><td>

The type of light. Defaults to point light.


</td></tr>
<tr><td>

[world](./server.light.world.md)


</td><td>

`readonly`


</td><td>

[World](./server.world.md) \| undefined


</td><td>

The world the Light is spawned into.


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[despawn()](./server.light.despawn.md)


</td><td>


</td><td>

Despawns the Light from the world.


</td></tr>
<tr><td>

[setAngle(angle)](./server.light.setangle.md)


</td><td>


</td><td>

Sets the angle of the spotlight if the light type is spotlight.


</td></tr>
<tr><td>

[setAttachedToEntity(entity)](./server.light.setattachedtoentity.md)


</td><td>


</td><td>

Sets the entity to which the Light is attached.


</td></tr>
<tr><td>

[setColor(color)](./server.light.setcolor.md)


</td><td>


</td><td>

Sets the color of the light.


</td></tr>
<tr><td>

[setDistance(distance)](./server.light.setdistance.md)


</td><td>


</td><td>

Sets the maximum distance the light will illuminate.


</td></tr>
<tr><td>

[setIntensity(intensity)](./server.light.setintensity.md)


</td><td>


</td><td>

Sets the intensity of the light.


</td></tr>
<tr><td>

[setOffset(offset)](./server.light.setoffset.md)


</td><td>


</td><td>

Sets the offset of the light from the attached entity or position.


</td></tr>
<tr><td>

[setPenumbra(penumbra)](./server.light.setpenumbra.md)


</td><td>


</td><td>

Sets the penumbra of the spotlight if the light type is spotlight.


</td></tr>
<tr><td>

[setPosition(position)](./server.light.setposition.md)


</td><td>


</td><td>

Sets the position of the light.


</td></tr>
<tr><td>

[setTrackedEntity(entity)](./server.light.settrackedentity.md)


</td><td>


</td><td>

Sets the entity the spotlight will constantly point at if the light type is spotlight.


</td></tr>
<tr><td>

[setTrackedPosition(position)](./server.light.settrackedposition.md)


</td><td>


</td><td>

Sets the position the spotlight will constantly point at if the light type is spotlight.


</td></tr>
<tr><td>

[spawn(world)](./server.light.spawn.md)


</td><td>


</td><td>

Spawns the Light into the world.


</td></tr>
</tbody></table>
