> 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/creator/content-creator-zh/chang-jing-sdk7/xiang-mu-lei-xing/scene-files.md).

# 场景文件

在新场景中创建的默认文件。

之后 [创建新场景](/creator/content-creator-zh/chang-jing-sdk7/ru-men/sdk-101.md)，场景文件夹将包含一系列带有默认内容的文件。

## 场景中的默认文件

场景包含以下文件：

* **src/index.ts**：场景的入口点。
* **scene.json**：包含场景元数据的清单。
* **package.json** 和 **package-lock.json**：指定场景所有依赖项的版本。
* **tsconfig.json**：TypeScript 配置文件。
* **.dclignore**：列出你项目中在发布场景时不会上传的文件。
* **assets/scene/main.composite**：自动生成的文件，包含你在 Creator Hub 的场景编辑器中以可视化方式添加和配置的所有内容。它不适合人类阅读。它是一个 [复合体](/creator/content-creator-zh/chang-jing-sdk7/jia-gou/composites.md)，一个描述实体和组件树的文件。通过 CLI 创建的场景则包含一个 `main.crdt` 文件，位于根目录。

### index.ts

这是你场景自定义代码的入口点。你可以把整个场景的逻辑都放进这个文件，不过为了更清晰，在大多数情况下我们建议将代码分散到其他几个 *.ts* 文件中。

如果你只依赖场景编辑器和 [智能物件](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items.md)，则无需修改此文件。

如果你打算编写自定义代码，那么你很可能只需要编辑这个文件和其他 .ts 文件来创建你的场景。它包含生成 [实体、组件](/creator/content-creator-zh/chang-jing-sdk7/jia-gou/entities-components.md) 和 [系统](/creator/content-creator-zh/chang-jing-sdk7/jia-gou/systems.md) 的代码。

运行场景时，你的 `.ts` 文件会被编译为单个 `.js` 文件， `bin/index.js`。在构建生产版本时，此文件还会被压缩。

{% hint style="warning" %}
**📔 注意**：你可以使用除 TypeScript 之外的其他工具或语言，只要你的脚本包含在一个单独的 JavaScript 文件（bin/index.js）中即可。所有提供的类型声明都是用 TypeScript 编写的，其他语言和转译器不受官方支持。
{% endhint %}

### scene.json

该 *scene.json* 文件是一个 JSON 格式的世界场景清单。一个场景可以跨越一个或多个 LAND 地块。该 *scene.json* 清单描述场景中存在的对象、渲染它所需的资源列表、地块所有者的联系方式以及安全设置。

该文件上的大多数字段 *scene.json* 文件中的大多数字段都可以直接在场景编辑器的界面中编辑。参见 [场景设置](/creator/content-creator-zh/chang-jing-bian-ji-qi/kai-shi-shi-yong/scene-editor-essentials.md#scene-settings).

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-ce1891d01c48a1142117a2d2a4576dfa1d11796c%2Fthumbnail-image.png?alt=media)

更多信息请参见 [场景元数据](/creator/content-creator-zh/chang-jing-sdk7/xiang-mu-lei-xing/scene-metadata.md#metadata).

在本地预览场景时，这些元数据都不是必需的，但部署时其中一部分是必需的。你可以随时手动更改这些信息。

### package.json

此文件向 NPM 提供信息，使其能够识别项目，并处理项目的依赖项。Decentraland 场景需要一个主要包：

* **@dcl/sdk**：Decentraland SDK 的基础依赖项，包括引擎、组件、系统等的定义和类型。
* **@dcl/js-runtime**：一系列类型声明，使 @dcl/sdk 的集成更加顺畅。

你的场景可以包含任意数量的其他包，例如用于包含 [库](https://studios.decentraland.org/resources?sdk_version=SDK7\&resource_type=Library) ，它们可以帮助更轻松地编写代码，或启用特殊功能。

### package-lock.json

此文件列出了项目中所有其他依赖项的版本。这些版本是锁定的，这意味着编译器将严格使用此处列出的相同次要版本。

你可以通过编辑此文件手动更改任何包版本。

### tsconfig.json

包含一个 *tsconfig.json* 文件的目录是 TypeScript 项目的根目录。该 *tsconfig.json* 文件指定了将你的项目从 TypeScript 编译为 JavaScript 所需的根文件和选项。

向场景安装任何附加库时，应该会自动向此文件添加一条条目。对于安装 Decentraland utils 库，通常无需手动修改此文件。

## 推荐的文件位置

请记住，当你将场景部署到 Decentraland 时，使用场景所需的任何资源或外部库都必须打包在场景文件夹内，或者可通过远程服务器访问。

任何打算在玩家客户端中运行的内容都必须位于场景文件夹内。你不应该引用本地机器上其他位置安装的文件或库，因为它们不会在已部署的场景中可用。

我们建议始终一致地使用这些文件夹名称来存储场景可能需要的不同类型资源：

* 3D 模型： `assets/scene/models`
* 视频： `assets/scene/videos`
* 音频文件： `assets/scene/sounds`
* 纹理图像文件（glTF 模型除外）： `assets/scene/materials`
* *.ts* 组件定义 `/src/components`
* *.ts* 系统定义 `/src/systems`

{% hint style="warning" %}
**📔 注意**：glTF 模型的支持文件，例如其纹理图像文件或 *.bin* 文件，都应始终放在与模型的 *.gltf* 或 *.glb* 文件。
{% endhint %}

{% hint style="warning" %}
**📔 注意**：我们建议所有文件夹和文件名始终使用小写，以避免可能的问题。
{% endhint %}

通过场景编辑器导入任何资源时，它们会自动添加到 `assets/scene` 文件夹中。当使用场景编辑器的资源包中的任何默认资源时，它们的文件会被添加到 `assets/builder` 文件夹中。

## dclignore 文件

所有场景都包含一个 *.dclignore* 文件，该文件指定在将场景部署到 Decentraland 时要忽略场景文件夹中的哪些文件。

例如，你可能想把场景中 3D 模型的 Blender 文件保留在场景文件夹中，但又想阻止这些文件被部署到 Decentraland。在这种情况下，你可以添加 `*.blend` 为 *.dclignore* 以忽略所有具有该扩展名的文件。

| 要忽略的内容 | 示例          | 描述                             |
| ------ | ----------- | ------------------------------ |
| 特定文件   | `BACKUP.ts` | 忽略一个特定文件                       |
| 文件夹    | `drafts/`   | 忽略某个文件夹及其子文件夹中的全部内容            |
| 扩展名    | `*.blend`   | 忽略所有具有指定扩展名的文件                 |
| 名称片段   | `test*`     | 忽略所有名称匹配查询的文件。在这种情况下，即以 *test* |


---

# 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/creator/content-creator-zh/chang-jing-sdk7/xiang-mu-lei-xing/scene-files.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.
