> For the complete documentation index, see [llms.txt](https://docs.hology.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hology.app/gameplay/world.md).

# World

The World service is used for code that needs to interact with the world like spawning actors, finding actors or controlling directional light.

Access the world by injecting it in your services, actors and component classes.

```typescript

@Service()
class Game extends GameInstance {
    private world = inject(World)
    
    onStart() {
        
    }
    
}
```

## Directional Light

By default, every scene has directional light which produces shadows. You may want to access this to update the direction or intensity at runtime.

```typescript
@Service()
class Game extends GameInstance {
    private world = inject(World)
    
    onStart() {
        this.world.directionalLight.intensity = 0.2 
        this.world.directionalLight.direction.applyAxisAngle(new THREE.Vector3(0,0,1), Math.PI / 2)

    }
    
}
```

The directional light exposes the following fields

* **direction**: Vector3 - The direction vector can be updated to change the direction of the light. This can be used to emulate a sun.
* **intensity**: number - How bright the light should be.
* **position:** Vector3 - The position of the directional light instance. This can not be changed; instead, change the direction.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hology.app/gameplay/world.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
