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.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IGLTFImporterInitialValues | No | (default: {}) |
getActors
Get the actors.
getAnimationClipByName
Get animation clip by name
| Argument | Type | Required | Description |
|---|---|---|---|
name | Yes | The 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
| Argument | Type | Required | Description |
|---|---|---|---|
event | Yes | Event data with |
invokeReady
Invoke the ready event.
invokeSkeletonLoaded
Invoke the skeletonLoaded event
| Argument | Type | Required | Description |
|---|---|---|---|
event | Yes | Event data with |
loadData
Load the object data.
| Argument | Type | Required | Description |
|---|---|---|---|
options | IGLTFImporterOptions | No |
newInstance
Method used to create a new instance of vtkGLTFImporter
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IGLTFImporterInitialValues | No | for pre-setting some of its content |
onAnimationClipLoaded
Listen for animation clip loaded events
| Argument | Type | Required | Description |
|---|---|---|---|
callback | Yes | Function to call when animation clip is loaded |
onReady
| Argument | Type | Required | Description |
|---|---|---|---|
callback | Yes |
onSkeletonLoaded
Listen for skeleton loaded events
| Argument | Type | Required | Description |
|---|---|---|---|
callback | Yes | Function to call when skeleton is loaded |
parse
Parse data.
| Argument | Type | Required | Description |
|---|---|---|---|
content | String or ArrayBuffer | Yes | The content to parse. |
parseAsArrayBuffer
Parse data as ArrayBuffer.
| Argument | Type | Required | Description |
|---|---|---|---|
content | ArrayBuffer | Yes | The content to parse. |
parseAsText
Parse data as text.
| Argument | Type | Required | Description |
|---|---|---|---|
content | String | Yes | The content to parse. |
requestData
| Argument | Type | Required | Description |
|---|---|---|---|
inData | Yes | ||
outData | Yes |
setCamera
Set the camera id.
| Argument | Type | Required | Description |
|---|---|---|---|
cameraId | Yes | The camera id. |
setDataAccessHelper
| Argument | Type | Required | Description |
|---|---|---|---|
dataAccessHelper | Yes |
setDracoDecoder
Set the Draco decoder.
| Argument | Type | Required | Description |
|---|---|---|---|
dracoDecoder | Yes |
setRenderer
Set the vtk Renderer.
| Argument | Type | Required | Description |
|---|---|---|---|
renderer | Yes | The vtk Renderer. |
setUrl
Set the url of the object to load.
| Argument | Type | Required | Description |
|---|---|---|---|
url | String | Yes | the url of the object to load. |
option | IGLTFImporterOptions | No | The Draco reader options. |
setWasmBinary
Load the WASM decoder from url and set the decoderModule
| Argument | Type | Required | Description |
|---|---|---|---|
url | Yes | ||
binaryName | Yes |
switchToVariant
Switch to a variant.
| Argument | Type | Required | Description |
|---|---|---|---|
variantIndex | Yes | The index of the variant to switch to. |