> 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-5367cb41c363e65a52e8beaf39559643751a7b1f%2F01-3d-essentials-banner%20\(1\).png?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 文件中的模型，然后进入 文件 - 导出 - glTF 2.0

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-30e38513ce59831ac027cf1787af061bfdb7c267%2F02-export-glt-from-blender%20\(1\).png?alt=media) ![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-86db9dd94033fbf82446265353dce37915351452%2F03-exporting-options%20\(1\).png?alt=media)

*在侧边栏中勾选“Selected Objects”，如果你只想导出场景中选中的对象。然后在 Mesh 下拉菜单中选择 Apply Modifiers（如果有的话），再导出。*

### **从 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. 按照以下方法使用该插件导出 glTF 文件 [这些说明](http://doc.babylonjs.com/resources/3dsmax_to_gltf).

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

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

1. 按照以下说明安装插件 [这些说明](http://doc.babylonjs.com/resources/maya).
2. 按照以下方法使用该插件导出 glTF 文件 [这些说明](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 转换为 glTF 的一种简单方法，是使用 Blender 将 .fbx 导入场景，然后再从那里导出。
* [**Facebook 的 CLI 工具**](https://github.com/facebookincubator/FBX2glTF)：这是最稳妥的替代方案，但需要使用命令行。
* [**Blackthread**](https://blackthread.io/gltf-converter)：这是最完整的基于 Web 的工具。虽然不如 CLI 稳妥，但使用起来容易得多。
* [**Modelconverter**](https://modelconverter.com/convert.html)：另一个易于使用的基于 Web 的工具。

## **预览 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-bf9bd765a4a99705f7649909c74acd6dddb860d1%2F04-preview-gltf%20\(1\).png?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-9d1b28696f55191432bb5c9c315c7497f91b970c%2F05-gltf-sample-viewer%20\(1\).png?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-ca94129743df645c2e758d463f7837dea3dd03d0%2F05-gltf-report%20\(1\).png?alt=media)

## **优化 glTF**

以下工具提供了一些优化，可使 3D 模型更轻、更快地供你场景中的玩家下载。

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

其中包括将 *.gltf* 格式转换为 *.glb*，它是二进制格式，因此占用空间更小。它还会把纹理文件放在 3D 模型之外，这样你就可以在多个模型上使用同一纹理。

{% hint style="warning" %}
**📔 注意**: *.glb* 格式默认总是将纹理嵌入文件中。引擎无法将两个嵌入式纹理识别为相同，它们需要是共享同一哈希值的外部文件。
{% endhint %}

## 另请参阅

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

* [网格](/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/meshes.md)
* [材质](/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/materials.md)
* [纹理](/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/textures.md)
* [碰撞体](/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/colliders.md)
* [动画](/creator/content-creator-zh/3d-jian-mo-yu-dong-hua/animations.md)
* [实用资源](/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.
