> 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/ru-men/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\&token=37e2284f-a33b-424a-a98e-b766453771ed)

更多信息请参见 [场景元数据](/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/xiang-mu-lei-xing/scene-files.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
