> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-ko/scene-runtime/execution.md).

# 실행

런타임은 [장면](https://github.com/decentraland/docs/blob/main/contributor/contributor/content/entity-types/scenes.md) 일반적인 Node 모듈처럼 취급합니다. 샌드박스가 설정되면(즉, 모든 [전역 객체](https://github.com/decentraland/docs/blob/main/contributor/globals.md) 가 주입되고 [모듈을](https://github.com/decentraland/docs/blob/main/contributor/modules.md) 로드될 준비가 되면), 씬의 코드가 평가되어 다음을 채울 수 있게 됩니다: [exports](https://github.com/decentraland/docs/blob/main/contributor/globals.md#module) 객체.

호스트는 다음에서 두 메서드를 가져옵니다 `exports`: [`onStart`](#onStart) (선택 사항) 및 [`onUpdate`](#onUpdate) (필수).

```ts
type Exports = {
  onStart?: () => Promise<void>;
  onUpdate: (deltaSeconds: number) => Promise<void>;
};
```

씬의 라이프사이클 동안, 런타임은 이러한 메서드에 대한 호출이 동시에 이루어지지 않도록 보장합니다. 반환된 `Promise` 는 씬이 새 호출을 받기 전에 항상 await됩니다.

{% @mermaid/diagram content="flowchart LR
A\[onStart] -->|await| B\[onUpdate]
B -->|await| B" %}

{% hint style="info" %}
개별 씬과 게임 렌더링 엔진 간의 효과적이고 성능 좋은 동기화는 복잡한 문제입니다. Foundation의 구현에서 얻을 수 있는 교훈은 [ADR-148](https://adr.decentraland.org/adr/ADR-148).
{% endhint %}

**`onStart`**

씬의 라이프사이클은 비동기 `onStart` 메서드로 시작합니다. 첫 번째 호출이 이루어지기 전에 완료되어야 하는 일회성 초기화를 수행하는 곳입니다. [`onUpdate`](#onUpdate) 가 이루어집니다.

```ts
onStart(): Promise<void>
```

씬은 이 호출을 사용해 런타임에서 미리 존재하는 상태(예: [기본 엔티티](https://github.com/decentraland/docs/blob/main/contributor/entities.md))를 요청하고 자체 초기 설정을 수행합니다.

내보내기 `onStart` 는 모든 씬에 권장되며(SDK를 사용할 때는 자동으로 수행됨), 프로토콜상 필수는 아닙니다. 해당 메서드는 없을 수도 있으며, 즉시 이행되는 `Promise`.

**`onUpdate`**

씬이 활발하게 실행되는 동안, 비동기 `onUpdate` 메서드는 시간이 흐르는 것을 보고하기 위해 런타임에 의해 주기적으로 호출됩니다. 이것이 씬의 핵심입니다. 각 연속 호출마다 엔티티를 업데이트하고, 입력을 처리하고, 애니메이션을 재생하고, 메시지를 보내고, UI를 표시하는 등의 작업을 할 수 있습니다.

```ts
onUpdate(deltaSeconds: number): Promise<void>
```

이 `deltaSeconds` 매개변수는 마지막 호출 이후 경과한 초의 소수 값입니다 `onUpdate` 가 런타임에 의해 시작된 시점부터의 시간입니다(반환된 `Promise` 가 이행되었는지와 무관하게).

이 값은 실행 중인 각 씬마다 고유합니다. `onUpdate` 왜냐하면 `deltaSeconds` 호출이 절대 겹치지 않기 때문에, 다음의 순서는 일관된 타임라인을 만듭니다.

이상적인 상황에서는, 씬은 실행될 기회를 얻어 `onUpdate` 각 프레임이 렌더링되기 전에 실행됩니다. 그러나 사용 가능한 리소스에 따라, 작업량이 많은 씬은 그 `Promise` 다음 프레임까지 제때 이행하지 못할 수 있습니다. 이 점에서 각 씬은 독립적입니다: 다음의 경량 구현은 `onUpdate` 다른 씬의 하나의 오래 걸리는 호출과 같은 기간 동안 여러 번 호출될 수 있습니다.

참고 [ADR-148](https://adr.decentraland.org/adr/ADR-148) 자세한 내용은.

### 여러 씬 실행

World Explorer는 여러 개의 샌드박스화된 씬 실행을 지원해야 할 뿐만 아니라, 항상 그렇게 동작해야 합니다. 이유는 두 가지입니다:

첫째, 플레이어가 월드를 탐험할 때 그들의 시야는 서 있는 씬의 지리적 경계를 넘어섭니다. 플레이어가 볼 수 있어야 하는 콘텐츠를 생성하려면 근처의 씬(임의 또는 구성 가능한 거리까지)이 실행 중이어야 합니다.

둘째, 씬은 서로 겹치지 않는 자신만의 경계 안에서만 실행되는 것이 아닙니다. 서로 위에 겹쳐질 수도 있으며, 플레이어 주변 영역에 영향을 주면서도 서로 다른 기능을 제공합니다.

특히 두 종류의 씬에서 그렇습니다: 아바타 씬과 휴대형 경험입니다.

#### 아바타 씬 <a href="#avatarscene" id="avatarscene"></a>

플레이어가 월드에 들어서는 순간부터, 다른 플레이어의 아바타를 렌더링하는 역할을 맡은 전역 씬이 실행되기 시작합니다.

이 씬은 지리적 경계의 제한을 받지 않으며, 플레이어의 위치와 관계없이 해당 엔티티(및 소통을 위한 UI 위젯)를 표시할 수 있습니다.

#### 휴대형 경험

Decentraland에서는 웨어러블이 자체 동작을 가질 수 있으며, 이는 자체 씬 컨텍스트에서 실행됩니다. 이러한 씬은 플레이어를 중심으로 하며, 엔티티를 추가하거나 UI 위젯을 표시하여 경험을 풍부하게 할 수 있습니다.

이들은 웨어러블이 착용되면 실행을 시작하고, 제거되면 중지됩니다.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/contributor/contributor-ko/scene-runtime/execution.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
