> 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/globals.md).

# 전역 객체

씬 런타임은 샌드박스된 JavaScript 환경 안에서 특정 객체와 함수의 존재를 보장하며, 다음과 같은 표준 유틸리티들에 더해 `Promise`, `Date` 또는 `Math`.

{% hint style="info" %}
아래에 설명된 전역 객체들은 일반적인 JavaScript 개념이지만, Decentrland 씬 런타임에 맞게 조정되어 있으며 브라우저나 Node 환경의 대응 항목과 정확히 동일하게 동작하지 않을 수 있습니다.
{% endhint %}

### 전역 객체

런타임은 씬의 전역 범위에 6개의 정의를 주입합니다:

1. [`console`](#console): 일반적인 것의 단순화된 버전 `console` 객체.
2. [`exports`](#module): 씬이 그 자체의 [공개 인터페이스를 추가할 수 있는 객체](https://github.com/decentraland/docs/blob/main/contributor/execution.md).
3. [`모듈`](#module): 다음을 담는 컨테이너 `exports` 객체.
4. [`require`](#module): 이름으로 런타임이 제공하는 모듈을 불러오는 함수.
5. [`fetch`](#http): 브라우저의 제한된 구현체 `fetch` 함수.
6. [`WebSocket`](#http): 브라우저의 제한된 구현체 `WebSocket` 클래스.

이들 모두는 읽기 전용 속성으로 정의되므로 재할당할 수 없습니다. 일부는 특정 [권한](https://github.com/decentraland/docs/blob/main/contributor/contributor/content/entity-types/scenes.md#permissions) 권한이 씬에 부여되지 않으면 사용 시 예외를 발생시킵니다.

### 콘솔 <a href="#console" id="console"></a>

씬은 다음에 접근할 수 있습니다: `console` 객체로, 브라우저나 Node 환경에서 제공되는 것과 비슷하지만, 일반적으로 볼 수 있는 메서드 중 일부만 사용할 수 있습니다.

```ts
type Console = {
  log(...args: any): void
  info(...args: any): void
  debug(...args: any): void
  warning(...args: any): void
  error(...args: any): void
}
```

표준 대응 항목과 마찬가지로, 각 메서드는 임의 타입의 가변 인수를 받고 이를 사람이 읽을 수 있는 메시지로 렌더링합니다. 예를 들면, 다음은 유효합니다:

```js
console.log("The thing just appeared", { thing: "foo" }, [1, 2, 3])
```

이 메서드들의 정확한 동작은 제공자에 따라 다르지만, 메시지는 자신의 코드를 디버깅하는 씬 개발자가 접근할 수 있어야 합니다.

{% hint style="info" %}
Foundation의 브라우저 기반 World Explorer에서는 로그 메시지가 개발자 도구 패널에 표시됩니다.
{% endhint %}

### 임포트 및 익스포트 <a href="#module" id="module"></a>

씬은 전통적인 [CommonJS](https://wiki.commonjs.org/wiki/Modules/1.0) 모듈 인터페이스를 사용해 객체를 임포트하고 익스포트할 수 있습니다.

```ts
exports: Object
require(moduleName: string): Object
```

이 `require` 함수는 씬이 런타임이 제공하는 모듈(예: [EngineApi](https://github.com/decentraland/docs/blob/main/contributor/modules/engine_api.md) 또는 [RestrictedActions](https://github.com/decentraland/docs/blob/main/contributor/modules/restricted_actions.md)), 그리고 그 외에는 아무것도 접근할 수 없습니다(이 함수는 **NPM 패키지나 경로 기반 모듈에 접근하지** 않습니다).

다음에 추가된 속성들은 `exports` 객체는 씬의 공개 인터페이스이며 런타임에 노출됩니다. 실제로 씬은 *반드시* 올바르게 실행되기 위해 최소한 하나의 메서드를 노출해야 합니다(참조: [실행](https://github.com/decentraland/docs/blob/main/contributor/execution.md)).

{% hint style="info" %}
TypeScript 같은 언어로 작성된 씬은 더 현대적인 `import` 및 `export` 문을 사용하며, 이는 CommonJS 호환 형식의 `require` 및 `exports`.
{% endhint %}

### HTTP 및 WebSocket <a href="#http" id="http"></a>

이 `fetch` 및 `WebSocket` 전역 객체는 널리 알려진 대응 항목과 정확히 동일하게 동작합니다(참조: [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) 및 [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) MDN), 다만 런타임이 적용하는 몇 가지 제한이 있습니다.

다음을 호출할 때: `fetch` 함수:

* URL이 다음으로 시작하지 않으면 오류가 발생합니다: `https://`.
* 씬에 다음이 없으면 오류가 발생합니다: [`USE_FETCH` 권한](https://github.com/decentraland/docs/blob/main/contributor/contributor/content/entity-types/scenes.md#permissions).
* 구현에 따라 정의된 타임아웃이 요청을 중단할 수 있습니다.

다음을 사용할 때: `WebSocket` 클래스:

* URL이 다음으로 시작하지 않으면 오류가 발생합니다: `wss:`
* 씬에 다음이 없으면 오류가 발생합니다: [`USE_WEBSOCKET` 권한](https://github.com/decentraland/docs/blob/main/contributor/contributor/content/entity-types/scenes.md#permissions).

이러한 차이점을 제외하면, 두 경우 모두 표준 동작을 따릅니다.


---

# 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/globals.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.
