> 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-he-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)：这是最完整的基于网页的工具。它不如 CLI 稳妥，但使用起来要容易得多。
* [**Modelconverter**](https://modelconverter.com/convert.html)：另一个易于使用的基于网页的工具。

## **预览 glTF 模型**

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

在沙盒中，你还可以预览模型中嵌入的动画，通过下拉菜单选择要显示的动画。

![](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-he-dong-hua/meshes.md)
* [材质](/creator/content-creator-zh/3d-jian-mo-he-dong-hua/materials.md)
* [纹理](/creator/content-creator-zh/3d-jian-mo-he-dong-hua/textures.md)
* [碰撞体](/creator/content-creator-zh/3d-jian-mo-he-dong-hua/colliders.md)
* [动画](/creator/content-creator-zh/3d-jian-mo-he-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 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/3d-jian-mo-he-dong-hua/3d-models.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.
