Skip to content

GLTFImporter

Introduction

vtkGLTFImporter can import glTF 2.0 files.

The GL Transmission Format (glTF) is an API-neutral runtime asset delivery format. A glTF asset is represented by:

  • A JSON-formatted file (.gltf) containing a full scene description: node hierarchy, materials, cameras, as well as descriptor information for meshes, animations, and other constructs
  • Binary files (.bin) containing geometry and animation data, and other buffer-based data
  • Image files (.jpg, .png) for textures

Supported extensions:

  • KHR_animation_pointer
  • KHR_draco_mesh_compression
  • KHR_lights_punctual
  • KHR_materials_anisotropy
  • KHR_materials_clearcoat
  • KHR_materials_diffuse_transmission
  • KHR_materials_dispersion
  • KHR_materials_emissive_strength
  • KHR_materials_ior
  • KHR_materials_iridescence
  • KHR_materials_pbrSpecularGlossiness
  • KHR_materials_sheen
  • KHR_materials_specular
  • KHR_materials_transmission
  • KHR_materials_unlit
  • KHR_materials_variants
  • KHR_materials_volume
  • KHR_texture_transform
  • EXT_texture_webp
  • EXT_texture_avif

Methods

createAnimationMixer

Create an animation mixer configured for this imported scene. Call after the importer is ready and actors have been imported.

extend

Method used to decorate a given object (publicAPI+model) with vtkGLTFImporter characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIGLTFImporterInitialValuesNo(default: {})

getActors

Get the actors.

getAnimationClipByName

Get animation clip by name

ArgumentTypeRequiredDescription
nameYesThe clip name

getAnimationClipNames

Get all animation clip names

getAnimationClips

Get all parsed animation clips from glTF animations

getBaseURL

Get the base url.

getCameras

Get the cameras.

getDataAccessHelper

getSkeletons

Get all parsed skeletons from glTF skins

getSkins

Get skin data for all skinned mesh nodes. Map from node ID to skin info (skinId, jointNodeIds, inverseBindMatrices).

getUrl

Get the url of the object to load.

getVariantMappings

Get the variant mappings.

getVariants

Get the variant array.

importActors

Import the actors.

importAnimations

Import the animations (DEPRECATED - use getSkeletons() and getAnimationClips()).

importCameras

Import the cameras.

importLights

Import the lights.

invokeAnimationClipLoaded

Invoke the animationClipLoaded event

ArgumentTypeRequiredDescription
eventYesEvent data with

invokeReady

Invoke the ready event.

invokeSkeletonLoaded

Invoke the skeletonLoaded event

ArgumentTypeRequiredDescription
eventYesEvent data with

loadData

Load the object data.

ArgumentTypeRequiredDescription
optionsIGLTFImporterOptionsNo

newInstance

Method used to create a new instance of vtkGLTFImporter

ArgumentTypeRequiredDescription
initialValuesIGLTFImporterInitialValuesNofor pre-setting some of its content

onAnimationClipLoaded

Listen for animation clip loaded events

ArgumentTypeRequiredDescription
callbackYesFunction to call when animation clip is loaded

onReady

ArgumentTypeRequiredDescription
callbackYes

onSkeletonLoaded

Listen for skeleton loaded events

ArgumentTypeRequiredDescription
callbackYesFunction to call when skeleton is loaded

parse

Parse data.

ArgumentTypeRequiredDescription
contentString or ArrayBufferYesThe content to parse.

parseAsArrayBuffer

Parse data as ArrayBuffer.

ArgumentTypeRequiredDescription
contentArrayBufferYesThe content to parse.

parseAsText

Parse data as text.

ArgumentTypeRequiredDescription
contentStringYesThe content to parse.

requestData

ArgumentTypeRequiredDescription
inDataYes
outDataYes

setCamera

Set the camera id.

ArgumentTypeRequiredDescription
cameraIdYesThe camera id.

setDataAccessHelper

ArgumentTypeRequiredDescription
dataAccessHelperYes

setDracoDecoder

Set the Draco decoder.

ArgumentTypeRequiredDescription
dracoDecoderYes

setRenderer

Set the vtk Renderer.

ArgumentTypeRequiredDescription
rendererYesThe vtk Renderer.

setUrl

Set the url of the object to load.

ArgumentTypeRequiredDescription
urlStringYesthe url of the object to load.
optionIGLTFImporterOptionsNoThe Draco reader options.

setWasmBinary

Load the WASM decoder from url and set the decoderModule

ArgumentTypeRequiredDescription
urlYes
binaryNameYes

switchToVariant

Switch to a variant.

ArgumentTypeRequiredDescription
variantIndexYesThe index of the variant to switch to.