> 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-zh/nei-rong/shi-ti-lei-xing/scenes.md).

# 场景

场景是 [实体](https://github.com/decentraland/docs/blob/main/contributor/entities/README.md) 它们会在 Decentraland 的不同部分产生行为。它们可以跨越多个地块，玩家在 World Explorer 中穿过它们时，会执行场景提供的特殊代码。

你可以在以下位置找到一个完整的实际示例 [此场景的 manifest](https://peer.decentraland.org/content/contents/bafkreidihplrc5cxarjkji2enmzhicpjoa2vrlqyyffnholmxb3o2xft3u) 在 Foundation 的内容服务器上。

### 指针 <a href="#pointers" id="pointers"></a>

场景有一个或多个关联的 [指针](https://github.com/decentraland/docs/blob/main/contributor/pointers/README.md) 其形式为地块坐标字符串，例如 `"0,0"`。运行该场景的每个地块都会列在 [`指针` 数组](https://github.com/decentraland/docs/blob/main/contributor/entities/README.md#properties) 中，而内容服务器会将所有这些指针解析到该场景。

换句话说，你可以选择一个地块的 x/y 坐标，并通过向内容服务器查询 `"<x>,<y>"` 指针来定位它正在运行的场景。这就是 World Explorer 在玩家浏览世界时决定是否启用某个场景行为的方式。

一个典型的 `指针` 数组看起来像这样：

```json
{
  "pointers": [
    "-113,-134",
    "-113,-133",
    "-113,-132",
  ],
  // ... 其他实体属性
}
```

这些数据也可在下面详细说明的 `metadata.scene.parcels` 字段中找到，如果你只想在 manifest 中保存场景特定的对象。

### 元数据字段

对于 [实体](https://github.com/decentraland/docs/blob/main/contributor/entities/README.md) 类型为 `场景` 的实体，在 `metadata` 顶层字段中有几个特殊属性。

| 字段     | 值                                                                                                                     |
| ------ | --------------------------------------------------------------------------------------------------------------------- |
| `所有者`  | 关于场景维护者的信息。                                                                                                           |
| `主文件`  | 该 [内部文件名](https://github.com/decentraland/docs/blob/main/contributor/entities/README.md#files) 指向该场景的主 JavaScript 文件。 |
| `标签`   | 描述此场景的字符串标签数组。                                                                                                        |
| `显示`   | 供 Explorer 向玩家展示的场景信息（见下文）。                                                                                           |
| `场景`   | 此场景生效的地块以及其中心位置（见下文）。                                                                                                 |
| `联系`   | 可联系该场景创建者或维护者的姓名和电子邮件地址（见下文）。                                                                                         |
| `出生点`  | 玩家进入此场景时的位置和摄像机角度（见下文）。                                                                                               |
| `所需权限` | 建议 Explorer 向玩家请求的权限（见下文）。                                                                                            |
| `功能开关` | 功能标志设置                                                                                                                |

{% hint style="info" %}
请记住，实体及其元数据可以包含自定义字段。你可能会发现这里未列出的一些属性。
{% endhint %}

#### 显示

在 `metadata.display`中，你会找到一些在玩家进入场景之前向其说明场景信息的实用属性。

| 字段        | 值                                                                                                                          |
| --------- | -------------------------------------------------------------------------------------------------------------------------- |
| `标题`      | 此场景的显示名称。                                                                                                                  |
| `描述`      | 此场景的详细描述。                                                                                                                  |
| `网站图标`    | *已弃用* 该 [内部文件名](https://github.com/decentraland/docs/blob/main/contributor/entities/README.md#files) 指向一个图标，该图标会在此场景激活时显示。 |
| `导航地图缩略图` | 该 [内部文件名](https://github.com/decentraland/docs/blob/main/contributor/entities/README.md#files) 指向该场景在世界地图中的缩略图。            |

例如：

```json
{
  "title": "my_cool_scene",
  "favicon": "favicon.png",
  "navmapThumbnail": "thumbnail.png"
}
```

#### 场景

该 `metadata.scene` 属性是一个对象，用于描述此场景在世界地图中的位置。

| 字段   | 值             |
| ---- | ------------- |
| `地块` | 运行此场景的地块指针数组。 |
| `基准` | 此场景原点的地块指针。   |

实际上，它看起来像这样：

```json
{
  "parcels": [
    "17,-112", 
    "17,-113"
  ],
  "base": "17,-112"
}
```

该 `基准` 字段始终包含在 `地块` 数组中。

#### 联系信息

该 `metadata.contact` 对象包含该场景所有者或维护者的联系信息。

| 字段     | 值               |
| ------ | --------------- |
| `名称`   | 此联系人的名称。        |
| `电子邮件` | （可选）可联系的电子邮件地址。 |

在 JSON 中：

```json
{
  "name": "cool_scene_maker",
  "email": "hello@decentraland.org"
}
```

虽然 `名称` 字段在每个场景中都已填写，但你会发现，在实际使用中， `电子邮件` 字段通常是空字符串。这是场景创建者出于隐私考虑所做的选择。

#### 出生点

该 `metadata.spawnPoints` 字段定义了一个点和摄像机方向数组，用于决定进入场景的玩家应出现的位置，以及他们最初应朝向的方向。必须至少定义一个出生点。

数组中的每一项都有若干属性：

| 字段             | 值                               |
| -------------- | ------------------------------- |
| `名称`           | 用于标识此出生点的标签。                    |
| `position`     | 在一个 `{ x, y, z }` 浮点坐标对象中的起始位置。 |
| `cameraTarget` | 在一个 `{ x, y, z }` 浮点坐标对象中的起始位置。 |
| `默认`           | 是否在未另行指定时使用此出生点。                |

例如：

```json
[
  {
    "name": "spawn1",
    "position": { "x": 10.02, "y": 5.27, "z": 15.23  },
    "cameraTarget": { "x": 10.02, "y": 6.27, "z": 31.23 },
    "default": true
  }
]
```

{% hint style="info" %}
**📔 注**：出生区域和摄像机目标可以通过 Creator Hub 设置。更多信息请前往 [出生区域](https://github.com/decentraland/docs/blob/main/creator/scene-editor/build/spawn-areas.md) 文档。
{% endhint %}

#### 所需权限 <a href="#permissions" id="permissions"></a>

在 `metadata.requiredPermissions` 你会找到一个由众所周知的字符串组成的数组，用于声明在 World Explorer 允许某些操作之前应向玩家请求哪些权限。这取决于 Explorer；其他为不同用途构建的客户端可以选择忽略它。

以下是当前支持的权限集：

| 权限                                  | 目的                                |
| ----------------------------------- | --------------------------------- |
| `USE_FETCH`                         | 允许场景执行外部 HTTP 请求。                 |
| `USE_WEBSOCKET`                     | 允许场景使用 WebSocket API 建立外部连接。      |
| `OPEN_EXTERNAL_LINK`                | 允许场景打开一个 URL（在浏览器标签页或 WebView 中）。 |
| `USE_WEB3_API`                      | 允许场景与钱包通信。                        |
| `ALLOW_TO_TRIGGER_AVATAR_EMOTE`     | 允许场景通过表情动作让玩家头像执行动画。              |
| `ALLOW_TO_MOVE_PLAYER_INSIDE_SCENE` | 允许场景更改玩家的位置。                      |

#### 功能开关

该 `metadata.featureToggles` 字段可让场景指明 World Explorer 的某些功能应启用还是禁用。

该字段包含一个如下形式的对象 `{ [featureName]: 'enabled' | 'disabled' }`，例如：

```json
{
  "voiceChat": "enabled"
}
```

目前， `voiceChat` 是唯一常见支持的功能标志。


---

# 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-zh/nei-rong/shi-ti-lei-xing/scenes.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.
