Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GLTFLoader

This class can be used to load the glTF file format, which describes scenes and models. It handles all buffer, texture and geometry creation as well as scene generation. Per glTF scene, one SceneNode is generated which represents the hierarchy of the scene.

const loader = new GLTFLoader(this._context);
await loader.loadAsset(GltfRenderer.assetURI);
const rootNode = loader.defaultScene;

Hierarchy

  • GLTFLoader

Index

Constructors

constructor

Properties

Protected _context

_context: Context

Protected _defaultScene

_defaultScene: undefined | SceneNode

Protected _meshes

_meshes: GLTFMesh[]

Protected _nameMeshMap

_nameMeshMap: Map<string, GLTFMesh>

Protected _pbrDefaultMaterial

_pbrDefaultMaterial: Material

Protected _pbrProgram

_pbrProgram: Program

Protected _resourceManager

_resourceManager: ResourceManager

Protected _sceneName

_sceneName: string

Protected _scenes

_scenes: SceneNode[]

Protected _uriTextureMap

_uriTextureMap: Map<string, Texture2D>

Accessors

defaultScene

meshes

  • Get a list of all meshes contained in the glTF asset. The meshes are given in the order in which they appear in the glTF file.

    Returns GLTFMesh[]

pbrProgram

  • A default program, which can be used to render resources loaded with glTF. It supports physically-based rendering as described in the glTF standard.

    Returns Program

scenes

uriTextureMap

  • get uriTextureMap(): Map<string, Texture2D>
  • Returns a map, where the key is an URI referncing image data and the values are the corresponding generated texture by this loader. For textures, where no URI is available (e.g. loaded from an internal data blob), an id generated by the loader is used.

    Returns Map<string, Texture2D>

Methods

Protected generateScenes

  • generateScenes(asset: GltfAsset): Promise<void>

getMeshByName

  • getMeshByName(name: string): undefined | GLTFMesh

Protected getTexture

  • getTexture(index: number): undefined | Texture2D

Protected inferBufferUsage

  • inferBufferUsage(asset: GltfAsset, bufferViewId: number): number

loadAsset

  • loadAsset(uri: string): Promise<void>

Protected loadBuffers

  • loadBuffers(asset: GltfAsset): Promise<void>

Protected loadMaterials

  • loadMaterials(asset: GltfAsset): Promise<void>

Protected loadMeshes

  • loadMeshes(asset: GltfAsset): Promise<GLTFMesh[]>

Protected loadPrimitive

  • loadPrimitive(asset: GltfAsset, primitiveInfo: MeshPrimitive, id: number): Promise<undefined | GLTFPrimitive>

Protected loadTextures

  • loadTextures(asset: GltfAsset): Promise<void>

uninitialize

  • uninitialize(): void