Capítulo 552 de 859

Chapter 552: GLTFExporter

Core Idea

An exporter for glTF 2.0.

glTF (GL Transmission Format) is an open format specification for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf) or binary (.glb) format. External files store textures (.jpg, .png) and additional binary data (.bin). A glTF asset may deliver one or more scenes, including meshes, materials, textures, skins, skeletons, morph targets, animations, lights, and/or cameras.

GLTFExporter supports the glTF 2.0 extensions:

  • KHR_lights_punctual
  • KHR_materials_clearcoat
  • KHR_materials_dispersion
  • KHR_materials_emissive_strength
  • KHR_materials_ior
  • KHR_materials_iridescence
  • KHR_materials_specular
  • KHR_materials_sheen
  • KHR_materials_transmission
  • KHR_materials_unlit
  • KHR_materials_volume
  • KHR_mesh_quantization
  • KHR_texture_transform
  • EXT_materials_bump
  • EXT_mesh_gpu_instancing
  • EXT_texture_webp

The following glTF 2.0 extension is supported by an external user plugin:

Key Concepts

  • textureUtils : WebGLTextureUtils | WebGPUTextureUtils: A reference to a texture utils module.

Code Examples

const exporter = new GLTFExporter();
const data = await exporter.parseAsync( scene, options );
  • What it demonstrates: Typical usage of GLTFExporter.

Reference Tables

Constructor

Signature
new GLTFExporter()

Properties

PropertyDescription
`.textureUtils : WebGLTextureUtilsWebGPUTextureUtils`

Methods

MethodDescription
`.parse( input : SceneArray.<Scene>, onDone : GLTFExporterOnDone, onError : GLTFExporterOnError, options : GLTFExporter~Options )`
`.parseAsync( input : SceneArray.<Scene>, options : GLTFExporter~Options ) : Promise.<(ArrayBuffer
.register( callback : function ) : GLTFExporterRegisters a plugin callback. This API is internally used to implement the various glTF extensions but can also used by third-party code to add additional logic to the exporter.
`.setTextureUtils( utils : WebGLTextureUtilsWebGPUTextureUtils ) : GLTFExporter`
.unregister( callback : function ) : GLTFExporterUnregisters a plugin callback.

Key Takeaways

  1. Most relevant properties: textureUtils.
  2. Key methods: parse, parseAsync, register, setTextureUtils.

Connects To