一个用于 glTF 2.0 的导出器。
[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
资产可以包含一个或多个场景,包括网格、材质、纹理、蒙皮、骨骼、变形目标、动画、灯光和/或相机。
[name] 是一个附加组件,必须显式导入。请参阅 [link:#manual/introduction/Installation Installation / Addons]。
import { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';
[name] 支持以下 [link:https://github.com/KhronosGroup/glTF/tree/master/extensions/ glTF 2.0 扩展]:
以下 glTF 2.0 扩展由外部用户插件支持
// 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
);
[example:misc_exporter_gltf]
创建一个新的 [name] 实例。
[page:Object input] — 要导出的场景或对象。有效选项:
exporter.parse( scene1, ... )
exporter.parse( [ scene1, scene2 ], ... )
exporter.parse( object1, ... )
exporter.parse( [ object1, object2 ], ... )
exporter.parse( [ scene1, object1, object2, scene2 ], ... )
从输入(场景或对象)生成一个 .gltf(JSON)或 .glb(二进制)输出。
[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/exporters/GLTFExporter.js examples/jsm/exporters/GLTFExporter.js]