> 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/3d-jian-mo-yu-dong-hua/3d-models.md).

# 3D 模型

了解外部 3D 模型支持哪些资源和组件，以及在导入到 Decentraland 之前如何进行配置。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-53d39d4a954bc59ae0ec6b47e31b8dc04d0c6a4b%2F01-3d-essentials-banner.webp?alt=media)

将 3D 模型导入 Decentraland 时，务必确保它们采用 glTF 格式。这些模型可以包含多种受支持的功能。本节将介绍如何让模型兼容 Decentraland，以及如何遵循最佳实践。

{% hint style="info" %}
**💡 提示**：安装 [Decentraland Tools Blender 插件](https://extensions.blender.org/add-ons/decentraland-tools/)。该插件包含多种实用功能，可帮助你编辑和导出 3D 模型、可穿戴物品和表情动画。
{% endhint %}

请注意，所有模型、着色器和纹理都必须符合 [**场景限制**](https://docs.decentraland.org/creator/scenes-sdk7/optimizing/scene-limitations/).

## **支持的 3D 模型格式**

Decentraland 中的所有 3D 模型都必须采用 glTF 格式。 [**glTF**](https://www.khronos.org/gltf) （GL 传输格式）是 Khronos 推出的开放项目，为 3D 资源提供一种通用且可扩展的格式，既高效，又能与现代 Web 技术高度互操作。

glTF 模型的扩展名可以是 *.gltf* 或 *.glb* 。glTF 文件可供人类阅读，你可以在文本编辑器中打开它，像阅读 JSON 文件一样查看内容。例如，这有助于确认动画是否正确关联，并查看动画名称。glb 文件是二进制文件，因此不可直接阅读，但体积小得多，有利于提升场景性能。

我们建议在制作场景时使用 *.gltf* ，上传时再转换为 *.glb* 。

3D 模型的以下内容可以嵌入 *glTF* 文件中，也可以从外部引用：

* 纹理可以嵌入文件中，也可以引用外部图像文件。
* 有关几何体、动画以及模型其他缓冲区相关内容的二进制数据，可以嵌入文件中，也可以从外部 *.bin* 文件中引用。

{% hint style="warning" %}
**📔 注意**：动画 *必须* 嵌入 *glTF* 文件中，才能在 Decentraland 中使用。此外，每个模型只能有 1 个 UV 映射。
{% endhint %}

## **为何使用 glTF**

我们使用 glTF，因为它提供了一套强大的功能，包括：

* 层级对象
* 骨骼结构与动画
* 完善的材质与着色器工作流
* 场景信息，例如光源和摄像机（可用于未来的开发）。

与 *COLLADA*相比，两者支持的功能非常相似。不过，由于 glTF 专注于提供“传输格式”，而非编辑器格式，因此它与 Web 技术的互操作性更强。

## **导出和转换 glTF**

### **从 Blender 导出为 glTF**

Blender 内置 glTF 导出器。

要导出，请先选择要包含在 .glb 文件中的模型，然后依次选择 File - Export - glTF 2.0。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-a0c73d489695d94bf1513516f3c5070882415328%2F02-export-glt-from-blender.webp?alt=media) ![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-fd4b360f85f1f67052fee21ce7e2ac5dcda0e37e%2F03-exporting-options.webp?alt=media)

*如果只想导出场景中选中的对象，请在侧边栏中勾选“Selected Objects”。此外，在 Mesh 下拉菜单中选择 Apply Modifiers（如果有修改器），然后点击 Export。*

### **从 3D Studio Max 导出为 glTF**

3D Studio Max 默认不支持导出为 glTF，但可以安装插件来启用此功能。

1. 从 [此链接](https://github.com/BabylonJS/Exporters/tree/master/3ds%20Max).
2. 下载插件，并按照 [这些说明](http://doc.babylonjs.com/resources/3dsmax#how-to-install-the-3ds-max-plugin).
3. 按照 [这些说明](http://doc.babylonjs.com/resources/3dsmax_to_gltf).

### **从 Maya 导出为 glTF**

Maya 默认不支持导出为 glTF，但你可以安装插件来启用此功能。

1. 下载插件，并按照 [这些说明](http://doc.babylonjs.com/resources/maya).
2. 按照 [这些说明](http://doc.babylonjs.com/resources/maya_to_gltf#pbr-materials).

{% hint style="warning" %}
**📔 注意**：你也可以试试 [这个其他插件](https://github.com/WonderMediaProductions/Maya2glTF) 。
{% endhint %}

### **从 Unity 导出为 glTF**

Unity 默认不支持导出为 glTF，但你可以安装插件来启用此功能。

从 [此链接](https://github.com/sketchfab/Unity-glTF-Exporter).

{% hint style="warning" %}
**📔 注意**：你也可以试试 [这个其他插件](https://assetstore.unity.com/packages/tools/utilities/collada-exporter-for-unity2017-99793) 。
{% endhint %}

### **从 SketchUp 导出为 glTF**

SketchUp 默认不支持导出为 glTF，但你可以安装插件来启用此功能。

从 [此链接](https://extensions.sketchup.com/en/content/gltf-exporter).

### **将 FBX 转换为 glTF**

*.fbx* 是非常流行的 3D 模型标准。我们的引擎不支持这种格式，但你可以轻松地将 *.fbx* 模型导出为 *.gltf* 格式。

我们推荐使用以下工具：

* [**Blender**](https://www.blender.org/download/)：将 .fbx 导入 Blender 场景，再从中导出，是把 .fbx 转换为 glTF 的简单方法。
* [**Facebook 的命令行工具**](https://github.com/facebookincubator/FBX2glTF)：这是最可靠的替代方案，但需要使用命令行。
* [**Blackthread**](https://blackthread.io/gltf-converter)：这是功能最全面的在线工具。它不如命令行工具可靠，但使用起来简单得多。
* [**Modelconverter**](https://modelconverter.com/convert.html)：另一个易于使用的在线工具。

## **预览 glTF 模型**

在将 glTF 模型导入场景之前，快速、简便地预览其内容的方法是使用 [**Babylon.js Sandbox**](https://sandbox.babylonjs.com/)。只需将 glTF 文件（以及其 *.bin* 文件，如有）拖放到画布中，即可查看模型。

你还可以在 Sandbox 中预览模型内嵌的动画，并从下拉菜单中选择要显示的动画。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-dd6c6ac291d3ab30e2b92ca08637314bc9e0aa7e%2F04-preview-gltf.webp?alt=media)

## **分析 glTF**

分析 glTF 的一款优秀工具是 [**glTF Sample Viewer**](https://github.khronos.org/glTF-Sample-Viewer-Release/)。你可以使用此工具检查通道和纹理，查看模型在不同光照环境下的效果，预览动画，以及进行更多操作！非常适合查看单个模型。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-de062d76df79a9994c05b993493256c8d454118f%2F11-analyse-gltf.webp?alt=media)

另一个实用工具是 [**gltf.report/**](https://gltf.report/)。只需将模型拖放到网站上，即可查看 glTF 包的内容，并判断模型的哪些部分可以优化。

对于包含多个模型、纹理和动画的大型文件，这款工具尤其有用。例如，按大小整理纹理后，你就能轻松找出占用资源最多的纹理。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-861b10c4194422b0788e10beb9611d655b4506a4%2F05-gltf-report.webp?alt=media)

## **优化 glTF**

以下工具提供了一些优化功能，可让 3D 模型更轻量，从而加快场景玩家的下载速度。

[glTF pipeline](https://github.com/AnalyticalGraphicsInc/gltf-pipeline)

除此之外，它还可以将 *.gltf* 格式转换为 *.glb*格式。该格式是二进制格式，因此占用的空间要小得多。它还会将纹理文件放在 3D 模型之外，因此你可以在多个模型中使用同一纹理。

{% hint style="warning" %}
**📔 备注**: *.glb* 格式默认始终会将纹理嵌入文件中。引擎无法识别两个嵌入的纹理是否相同，因此它们必须是具有相同哈希值的外部文件。
{% endhint %}

## 另请参阅

以下页面还介绍了与 Decentraland 的 3D 模型相关的主题：

* [网格](https://docs.decentraland.org/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/meshes.md)
* [材质](https://docs.decentraland.org/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/materials.md)
* [纹理](https://docs.decentraland.org/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/textures.md)
* [碰撞体](https://docs.decentraland.org/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/colliders.md)
* [动画](https://docs.decentraland.org/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/animations.md)
* [实用资源](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-sdk7/ru-men/useful-resources.md)：Blender 插件、素材库和 AI 工具，可加快 3D 工作流程


---

# 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/3d-jian-mo-yu-dong-hua/3d-models.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.
