123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <!DOCTYPE html>
- <html lang="zh">
- <head>
- <meta charset="utf-8" />
- <base href="../../../" />
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- <h1>GLTF导出器([name])</h1>
- <p class="desc">
- 一个用于 glTF 2.0 的导出器。
- <br /><br />
- [link:https://www.khronos.org/gltf glTF] (GL Transmission Format) 是一个用于高效传输和加载3D内容的
- [link:https://github.com/KhronosGroup/glTF/tree/master/specification/2.0 开放格式规范]。
- 资源可以以 JSON (.gltf) 或二进制 (.glb) 格式提供。外部文件存储纹理 (.jpg, .png) 和额外的二进制数据 (.bin)。一个 glTF
- 资产可以包含一个或多个场景,包括网格、材质、纹理、蒙皮、骨骼、变形目标、动画、灯光和/或相机。
- </p>
- <h2>导入</h2>
- <p>
- [name] 是一个附加组件,必须显式导入。请参阅 [link:#manual/introduction/Installation Installation / Addons]。
- </p>
- <code>
- import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
- </code>
- <h2>扩展</h2>
- <p>
- [name] 支持以下 [link:https://github.com/KhronosGroup/glTF/tree/master/extensions/ glTF 2.0 扩展]:
- </p>
- <ul>
- <li>KHR_lights_punctual</li>
- <li>KHR_materials_clearcoat</li>
- <li>KHR_materials_dispersion</li>
- <li>KHR_materials_emissive_strength</li>
- <li>KHR_materials_ior</li>
- <li>KHR_materials_iridescence</li>
- <li>KHR_materials_specular</li>
- <li>KHR_materials_sheen</li>
- <li>KHR_materials_transmission</li>
- <li>KHR_materials_unlit</li>
- <li>KHR_materials_volume</li>
- <li>KHR_mesh_quantization</li>
- <li>KHR_texture_transform</li>
- </ul>
- <p>
- 以下 glTF 2.0 扩展由外部用户插件支持
- </p>
- <ul>
- <li>[link:https://github.com/takahirox/three-gltf-extensions KHR_materials_variants]</li>
- </ul>
- <h2>代码示例</h2>
- <code>
- // Instantiate a exporter
- const exporter = new GLTFExporter();
- // Parse the input and generate the glTF output
- exporter.parse(
- scene,
- // called when the gltf has been generated
- function ( gltf ) {
- console.log( gltf );
- downloadJSON( gltf );
- },
- // called when there is an error in the generation
- function ( error ) {
- console.log( 'An error happened' );
- },
- options
- );
- </code>
- <h2>例子</h2>
- <p>
- [example:misc_exporter_gltf]
- </p>
- <h2>构造函数</h2>
- <h3>[name]()</h3>
- <p>
- </p>
- <p>
- 创建一个新的 [name] 实例。
- </p>
- <h2>方法</h2>
- <h3>[method:undefined parse]( [param:Object3D input], [param:Function onCompleted], [param:Function onError],
- [param:Object options] )</h3>
- <p>
- [page:Object input] — 要导出的场景或对象。有效选项:<br />
- <ul>
- <li>
- 导出场景
- <code>
- exporter.parse( scene1, ... )
- exporter.parse( [ scene1, scene2 ], ... )
- </code>
- </li>
- <li>
- 导出对象(它将创建一个新场景来保存所有对象)
- <code>
- exporter.parse( object1, ... )
- exporter.parse( [ object1, object2 ], ... )
- </code>
- </li>
- <li>
- 混合场景和对象(它将像平常一样导出场景,但会创建一个新场景来保存所有单个对象)。
- <code>
- exporter.parse( [ scene1, object1, object2, scene2 ], ... )
- </code>
- </li>
- </ul>
- [page:Function onCompleted] — 导出完成时将被调用。参数将是生成的 glTF JSON 或二进制 ArrayBuffer。<br />
- [page:Function onError] — 如果在 gltf 生成过程中出现任何错误,将被调用。<br />
- [page:Options options] — 导出选项<br />
- <ul>
- <li>trs - bool. 导出每个节点的位置、旋转和缩放而不是矩阵。默认为 false。</li>
- <li>onlyVisible - bool. 仅导出可见对象。默认为 true。</li>
- <li>binary - bool. 以二进制 (.glb) 格式导出,返回 ArrayBuffer。默认为 false。</li>
- <li>maxTextureSize - int. 将图像最大尺寸(宽度和高度)限制为给定值。默认为无穷大。</li>
- <li>animations - Array<[page:AnimationClip AnimationClip]>. 要包含在导出中的动画列表。</li>
- <li>includeCustomExtensions - bool. 导出在对象属性上定义的自定义 glTF 扩展(`userData.gltfExtensions`)。默认为 false。</li>
- </ul>
- </p>
- <p>
- 从输入(场景或对象)生成一个 .gltf(JSON)或 .glb(二进制)输出。
- </p>
- <h2>源代码</h2>
- <p>
- [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/GLTFExporter.js examples/jsm/exporters/GLTFExporter.js]
- </p>
- </body>
- </html>
|