Home Reference Source
public class | source

GLTFLoader

This is a loader class of glTF file format. You can see more detail of glTF format at https://github.com/KhronosGroup/glTF .

Static Member Summary

Static Public Members
public static

Static Method Summary

Static Public Methods
public static

The static method to get singleton instance of this class.

Static Private Methods
private static

Constructor Summary

Public Constructor
public

constructor(enforcer: Symbol)

The constructor of GLTFLoader class.

Member Summary

Private Members
private

_materials: *[]

Method Summary

Public Methods
public

checkArrayBufferOfGltf(arrayBuffer: *, url: *, options: *, defaultOptions: *, glBoostContext: *, resolve: *)

public

getDefaultShader(options: *): *

public

getOptions(defaultOptions: *, json: *, options: *): *

public

isTargetMatch(statesInfo: *, element: *, target: *): *

public

loadAsBinaryJson(dataView: *, isLittleEndian: *, arrayBuffer: *, options: *, defaultOptions: *, glBoostContext: *, resolve: *): {"options": *, "defaultShader": *}

public

loadAsTextJson(arrayBuffer: *, url: *, options: *, defaultOptions: *, glBoostContext: *, resolve: *): {"options": *, "defaultShader": *}

public

loadGLTF(glBoostContext: glBoostContext, url: string, options: Object): Promise

the method to load glTF file.

Private Methods
private

_IterateNodeOfScene(glBoostContext: *, buffers: *, json: *, defaultShader: *, shaders: *, textures: *, glTFVer: *, resolve: *, options: *)

private

_accessArrayBufferAsImage(arrayBuffer: *, imageType: *): *

private

_accessBinary(accessorStr: *, json: *, buffers: *, quaternionIfVec4: *, toGetAsTypedArray: *): *

private

_accessBinaryAsImage(bufferViewStr: *, json: *, arrayBuffer: *, mimeType: *): *

private

_accessBinaryAsShader(bufferViewStr: *, json: *, arrayBuffer: *): *

private

_adjustByteAlign(typedArrayClass: *, arrayBuffer: *, alignSize: *, byteOffset: *, length: *): *

private

_checkBytesPerComponent(accessorStr: *, json: *): *

private

_checkComponentNumber(accessorStr: *, json: *): *

private

_checkDataViewMethod(accessorStr: *, json: *): *

private

_checkGLTFVersion(json: *): *

private

_getDataType(accessorStr: *, json: *): *

private

_isKHRMaterialsCommon(materialJson: *): boolean

private

_loadAnimation(element: *, buffers: *, json: *, glTFVer: *, options: *)

private

_loadMaterial(glBoostContext: *, buffers: *, json: *, vertexData: *, indices: *, material: *, materialStr: *, positions: *, dataViewMethodDic: *, additional: *, texcoords: *, texcoords0AccessorStr: *, geometry: *, defaultShader: *, shaders: *, textures: *, idx: *, glTFVer: *, group: *, options: *): *

private

_loadMesh(glBoostContext: *, meshJson: *, meshStr: *, buffers: *, json: *, defaultShader: *, rootJointStr: *, skinStr: *, shaders: *, textures: *, glTFVer: *, group: *, options: *): *

private

_loadProgram(glBoostContext: *, json: *, programStr: *, material: *, shaders: *, attributes: *, uniforms: *, textureNames: *)

private

_loadResourcesAndScene(glBoostContext: *, arrayBufferBinary: *, basePath: *, json: *, defaultShader: *, glTFVer: *, resolve: *, options: *)

private

_loadTechnique(glBoostContext: *, json: *, techniqueStr: *, material: *, materialJson: *, shaders: *, glTFVer: *)

private

_recursiveIterateNode(glBoostContext: *, nodeStr: *, buffers: *, json: *, defaultShader: *, shaders: *, textures: *, glTFVer: *, options: *): *

private

_setTransform(element: *, nodeJson: *)

private

_sliceBufferViewToArrayBuffer(json: *, bufferViewStr: *, arrayBuffer: *): *

Static Public Members

public static [singleton]: * source

Static Public Methods

public static getInstance(): GLTFLoader source

The static method to get singleton instance of this class.

Return:

GLTFLoader

The singleton instance of GLTFLoader class

Static Private Methods

private static _isSystemLittleEndian(): * source

Return:

*

Public Constructors

public constructor(enforcer: Symbol) source

The constructor of GLTFLoader class. But you cannot use this constructor directly because of this class is a singleton class. Use getInstance() static method.

Params:

NameTypeAttributeDescription
enforcer Symbol

a Symbol to forbid calling this constructor directly

Private Members

private _materials: *[] source

Public Methods

public checkArrayBufferOfGltf(arrayBuffer: *, url: *, options: *, defaultOptions: *, glBoostContext: *, resolve: *) source

Params:

NameTypeAttributeDescription
arrayBuffer *
url *
options *
defaultOptions *
glBoostContext *
resolve *

public getDefaultShader(options: *): * source

Params:

NameTypeAttributeDescription
options *

Return:

*

public getOptions(defaultOptions: *, json: *, options: *): * source

Params:

NameTypeAttributeDescription
defaultOptions *
json *
options *

Return:

*

public isTargetMatch(statesInfo: *, element: *, target: *): * source

Params:

NameTypeAttributeDescription
statesInfo *
element *
target *

Return:

*

public loadAsBinaryJson(dataView: *, isLittleEndian: *, arrayBuffer: *, options: *, defaultOptions: *, glBoostContext: *, resolve: *): {"options": *, "defaultShader": *} source

Params:

NameTypeAttributeDescription
dataView *
isLittleEndian *
arrayBuffer *
options *
defaultOptions *
glBoostContext *
resolve *

Return:

{"options": *, "defaultShader": *}

public loadAsTextJson(arrayBuffer: *, url: *, options: *, defaultOptions: *, glBoostContext: *, resolve: *): {"options": *, "defaultShader": *} source

Params:

NameTypeAttributeDescription
arrayBuffer *
url *
options *
defaultOptions *
glBoostContext *
resolve *

Return:

{"options": *, "defaultShader": *}

public loadGLTF(glBoostContext: glBoostContext, url: string, options: Object): Promise source

the method to load glTF file.

Params:

NameTypeAttributeDescription
glBoostContext glBoostContext

glBoostContext instance

url string

url of glTF file

options Object

option data for loading

Return:

Promise

a promise object

Private Methods

private _IterateNodeOfScene(glBoostContext: *, buffers: *, json: *, defaultShader: *, shaders: *, textures: *, glTFVer: *, resolve: *, options: *) source

Params:

NameTypeAttributeDescription
glBoostContext *
buffers *
json *
defaultShader *
shaders *
textures *
glTFVer *
resolve *
options *

private _accessArrayBufferAsImage(arrayBuffer: *, imageType: *): * source

Params:

NameTypeAttributeDescription
arrayBuffer *
imageType *

Return:

*

private _accessBinary(accessorStr: *, json: *, buffers: *, quaternionIfVec4: *, toGetAsTypedArray: *): * source

Params:

NameTypeAttributeDescription
accessorStr *
json *
buffers *
quaternionIfVec4 *
  • optional
  • default: undefined
toGetAsTypedArray *
  • optional
  • default: undefined

Return:

*

private _accessBinaryAsImage(bufferViewStr: *, json: *, arrayBuffer: *, mimeType: *): * source

Params:

NameTypeAttributeDescription
bufferViewStr *
json *
arrayBuffer *
mimeType *

Return:

*

private _accessBinaryAsShader(bufferViewStr: *, json: *, arrayBuffer: *): * source

Params:

NameTypeAttributeDescription
bufferViewStr *
json *
arrayBuffer *

Return:

*

private _adjustByteAlign(typedArrayClass: *, arrayBuffer: *, alignSize: *, byteOffset: *, length: *): * source

Params:

NameTypeAttributeDescription
typedArrayClass *
arrayBuffer *
alignSize *
byteOffset *
length *

Return:

*

private _checkBytesPerComponent(accessorStr: *, json: *): * source

Params:

NameTypeAttributeDescription
accessorStr *
json *

Return:

*

private _checkComponentNumber(accessorStr: *, json: *): * source

Params:

NameTypeAttributeDescription
accessorStr *
json *

Return:

*

private _checkDataViewMethod(accessorStr: *, json: *): * source

Params:

NameTypeAttributeDescription
accessorStr *
json *

Return:

*

private _checkGLTFVersion(json: *): * source

Params:

NameTypeAttributeDescription
json *

Return:

*

private _getDataType(accessorStr: *, json: *): * source

Params:

NameTypeAttributeDescription
accessorStr *
json *

Return:

*

private _isKHRMaterialsCommon(materialJson: *): boolean source

Params:

NameTypeAttributeDescription
materialJson *

Return:

boolean

private _loadAnimation(element: *, buffers: *, json: *, glTFVer: *, options: *) source

Params:

NameTypeAttributeDescription
element *
buffers *
json *
glTFVer *
options *

private _loadMaterial(glBoostContext: *, buffers: *, json: *, vertexData: *, indices: *, material: *, materialStr: *, positions: *, dataViewMethodDic: *, additional: *, texcoords: *, texcoords0AccessorStr: *, geometry: *, defaultShader: *, shaders: *, textures: *, idx: *, glTFVer: *, group: *, options: *): * source

Params:

NameTypeAttributeDescription
glBoostContext *
buffers *
json *
vertexData *
indices *
material *
materialStr *
positions *
dataViewMethodDic *
additional *
texcoords *
texcoords0AccessorStr *
geometry *
defaultShader *
shaders *
textures *
idx *
glTFVer *
group *
options *

Return:

*

private _loadMesh(glBoostContext: *, meshJson: *, meshStr: *, buffers: *, json: *, defaultShader: *, rootJointStr: *, skinStr: *, shaders: *, textures: *, glTFVer: *, group: *, options: *): * source

Params:

NameTypeAttributeDescription
glBoostContext *
meshJson *
meshStr *
buffers *
json *
defaultShader *
rootJointStr *
skinStr *
shaders *
textures *
glTFVer *
group *
options *

Return:

*

private _loadProgram(glBoostContext: *, json: *, programStr: *, material: *, shaders: *, attributes: *, uniforms: *, textureNames: *) source

Params:

NameTypeAttributeDescription
glBoostContext *
json *
programStr *
material *
shaders *
attributes *
uniforms *
textureNames *

private _loadResourcesAndScene(glBoostContext: *, arrayBufferBinary: *, basePath: *, json: *, defaultShader: *, glTFVer: *, resolve: *, options: *) source

Params:

NameTypeAttributeDescription
glBoostContext *
arrayBufferBinary *
basePath *
json *
defaultShader *
glTFVer *
resolve *
options *

private _loadTechnique(glBoostContext: *, json: *, techniqueStr: *, material: *, materialJson: *, shaders: *, glTFVer: *) source

Params:

NameTypeAttributeDescription
glBoostContext *
json *
techniqueStr *
material *
materialJson *
shaders *
glTFVer *

private _recursiveIterateNode(glBoostContext: *, nodeStr: *, buffers: *, json: *, defaultShader: *, shaders: *, textures: *, glTFVer: *, options: *): * source

Params:

NameTypeAttributeDescription
glBoostContext *
nodeStr *
buffers *
json *
defaultShader *
shaders *
textures *
glTFVer *
options *

Return:

*

private _setTransform(element: *, nodeJson: *) source

Params:

NameTypeAttributeDescription
element *
nodeJson *

private _sliceBufferViewToArrayBuffer(json: *, bufferViewStr: *, arrayBuffer: *): * source

Params:

NameTypeAttributeDescription
json *
bufferViewStr *
arrayBuffer *

Return:

*