babylonjs-loaders
Advanced tools
Comparing version 3.2.0-alpha0 to 3.2.0-alpha10
/// <reference types="babylonjs"/> | ||
/// <reference types="babylonjs-gltf2interface"/> | ||
declare module 'babylonjs-loaders' { | ||
@@ -17,2 +19,3 @@ export = BABYLON; | ||
load(scene: Scene, data: any, rootUrl: string): boolean; | ||
loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer; | ||
private isBinary(data); | ||
@@ -84,2 +87,3 @@ private parseBinary(mesh, data); | ||
load(scene: Scene, data: string, rootUrl: string): boolean; | ||
loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer; | ||
/** | ||
@@ -131,9 +135,40 @@ * Read the OBJ file and create an Array of meshes. | ||
} | ||
interface IGLTFLoaderExtension { | ||
/** | ||
* The name of this extension. | ||
*/ | ||
readonly name: string; | ||
/** | ||
* Whether this extension is enabled. | ||
*/ | ||
enabled: boolean; | ||
} | ||
enum GLTFLoaderState { | ||
Loading = 0, | ||
Ready = 1, | ||
Complete = 2, | ||
} | ||
interface IGLTFLoader extends IDisposable { | ||
importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void; | ||
loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void; | ||
coordinateSystemMode: GLTFLoaderCoordinateSystemMode; | ||
animationStartMode: GLTFLoaderAnimationStartMode; | ||
compileMaterials: boolean; | ||
useClipPlane: boolean; | ||
compileShadowGenerators: boolean; | ||
onMeshLoadedObservable: Observable<AbstractMesh>; | ||
onTextureLoadedObservable: Observable<BaseTexture>; | ||
onMaterialLoadedObservable: Observable<Material>; | ||
onCompleteObservable: Observable<IGLTFLoader>; | ||
onDisposeObservable: Observable<IGLTFLoader>; | ||
onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>; | ||
state: Nullable<GLTFLoaderState>; | ||
importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<{ | ||
meshes: AbstractMesh[]; | ||
particleSystems: ParticleSystem[]; | ||
skeletons: Skeleton[]; | ||
}>; | ||
loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void) => Promise<void>; | ||
} | ||
class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory { | ||
static CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader; | ||
static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader; | ||
static CreateGLTFLoaderV1: () => IGLTFLoader; | ||
static CreateGLTFLoaderV2: () => IGLTFLoader; | ||
/** | ||
@@ -144,3 +179,5 @@ * Raised when the asset has been parsed. | ||
*/ | ||
onParsed: (data: IGLTFLoaderData) => void; | ||
onParsedObservable: Observable<IGLTFLoaderData>; | ||
private _onParsedObserver; | ||
onParsed: (loaderData: IGLTFLoaderData) => void; | ||
static IncrementalLoading: boolean; | ||
@@ -171,2 +208,4 @@ static HomogeneousCoordinates: boolean; | ||
*/ | ||
readonly onMeshLoadedObservable: Observable<AbstractMesh>; | ||
private _onMeshLoadedObserver; | ||
onMeshLoaded: (mesh: AbstractMesh) => void; | ||
@@ -176,7 +215,11 @@ /** | ||
*/ | ||
onTextureLoaded: (texture: BaseTexture) => void; | ||
readonly onTextureLoadedObservable: Observable<BaseTexture>; | ||
private _onTextureLoadedObserver; | ||
onTextureLoaded: (Texture: BaseTexture) => void; | ||
/** | ||
* Raised when the loader creates a material after parsing the glTF properties of the material. | ||
*/ | ||
onMaterialLoaded: (material: Material) => void; | ||
readonly onMaterialLoadedObservable: Observable<Material>; | ||
private _onMaterialLoadedObserver; | ||
onMaterialLoaded: (Material: Material) => void; | ||
/** | ||
@@ -187,3 +230,22 @@ * Raised when the asset is completely loaded, immediately before the loader is disposed. | ||
*/ | ||
readonly onCompleteObservable: Observable<GLTFFileLoader>; | ||
private _onCompleteObserver; | ||
onComplete: () => void; | ||
/** | ||
* Raised when the loader is disposed. | ||
*/ | ||
readonly onDisposeObservable: Observable<GLTFFileLoader>; | ||
private _onDisposeObserver; | ||
onDispose: () => void; | ||
/** | ||
* Raised after a loader extension is created. | ||
* Set additional options for a loader extension in this event. | ||
*/ | ||
readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>; | ||
private _onExtensionLoadedObserver; | ||
onExtensionLoaded: (extension: IGLTFLoaderExtension) => void; | ||
/** | ||
* The loader state or null if not active. | ||
*/ | ||
readonly loaderState: Nullable<GLTFLoaderState>; | ||
private _loader; | ||
@@ -196,8 +258,13 @@ name: string; | ||
dispose(): void; | ||
importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void; | ||
loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void; | ||
importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{ | ||
meshes: AbstractMesh[]; | ||
particleSystems: ParticleSystem[]; | ||
skeletons: Skeleton[]; | ||
}>; | ||
loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>; | ||
loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<AssetContainer>; | ||
canDirectLoad(data: string): boolean; | ||
rewriteRootURL: (rootUrl: string, responseURL?: string) => string; | ||
createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync; | ||
private static _parse(data); | ||
private _parse(data); | ||
private _getLoader(loaderData); | ||
@@ -606,5 +673,23 @@ private static _parseBinary(data); | ||
static RegisterExtension(extension: GLTFLoaderExtension): void; | ||
coordinateSystemMode: GLTFLoaderCoordinateSystemMode; | ||
animationStartMode: GLTFLoaderAnimationStartMode; | ||
compileMaterials: boolean; | ||
useClipPlane: boolean; | ||
compileShadowGenerators: boolean; | ||
onDisposeObservable: Observable<IGLTFLoader>; | ||
onMeshLoadedObservable: Observable<AbstractMesh>; | ||
onTextureLoadedObservable: Observable<BaseTexture>; | ||
onMaterialLoadedObservable: Observable<Material>; | ||
onCompleteObservable: Observable<IGLTFLoader>; | ||
onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>; | ||
state: Nullable<GLTFLoaderState>; | ||
dispose(): void; | ||
importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: SceneLoaderProgressEvent) => void, onError: (message: string) => void): boolean; | ||
loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: SceneLoaderProgressEvent) => void, onError: (message: string) => void): void; | ||
private _importMeshAsync(meshesNames, scene, data, rootUrl, onSuccess, onProgress, onError); | ||
importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress: (event: SceneLoaderProgressEvent) => void): Promise<{ | ||
meshes: AbstractMesh[]; | ||
particleSystems: ParticleSystem[]; | ||
skeletons: Skeleton[]; | ||
}>; | ||
private _loadAsync(scene, data, rootUrl, onSuccess, onProgress, onError); | ||
loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress: (event: SceneLoaderProgressEvent) => void): Promise<void>; | ||
private _loadShadersAsync(gltfRuntime, onload); | ||
@@ -640,12 +725,2 @@ private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?); | ||
/** | ||
* If the uri is a base64 string | ||
* @param uri: the uri to test | ||
*/ | ||
static IsBase64(uri: string): boolean; | ||
/** | ||
* Decode the base64 uri | ||
* @param uri: the uri to decode | ||
*/ | ||
static DecodeBase64(uri: string): ArrayBuffer; | ||
/** | ||
* Returns the wrap mode of the texture | ||
@@ -764,203 +839,64 @@ * @param mode: the mode value | ||
declare module BABYLON.GLTF2 { | ||
/** | ||
* Enums | ||
*/ | ||
enum EComponentType { | ||
BYTE = 5120, | ||
UNSIGNED_BYTE = 5121, | ||
SHORT = 5122, | ||
UNSIGNED_SHORT = 5123, | ||
UNSIGNED_INT = 5125, | ||
FLOAT = 5126, | ||
interface TypedArray extends ArrayBufferView { | ||
[index: number]: number; | ||
} | ||
enum EMeshPrimitiveMode { | ||
POINTS = 0, | ||
LINES = 1, | ||
LINE_LOOP = 2, | ||
LINE_STRIP = 3, | ||
TRIANGLES = 4, | ||
TRIANGLE_STRIP = 5, | ||
TRIANGLE_FAN = 6, | ||
interface IArrayItem { | ||
_index: number; | ||
} | ||
enum ETextureMagFilter { | ||
NEAREST = 9728, | ||
LINEAR = 9729, | ||
class ArrayItem { | ||
static Assign(values?: IArrayItem[]): void; | ||
} | ||
enum ETextureMinFilter { | ||
NEAREST = 9728, | ||
LINEAR = 9729, | ||
NEAREST_MIPMAP_NEAREST = 9984, | ||
LINEAR_MIPMAP_NEAREST = 9985, | ||
NEAREST_MIPMAP_LINEAR = 9986, | ||
LINEAR_MIPMAP_LINEAR = 9987, | ||
} | ||
declare module BABYLON.GLTF2 { | ||
interface ILoaderAccessor extends IAccessor, IArrayItem { | ||
_data?: Promise<TypedArray>; | ||
} | ||
enum ETextureWrapMode { | ||
CLAMP_TO_EDGE = 33071, | ||
MIRRORED_REPEAT = 33648, | ||
REPEAT = 10497, | ||
interface ILoaderAnimationChannel extends IAnimationChannel, IArrayItem { | ||
_babylonAnimationGroup: AnimationGroup; | ||
} | ||
/** | ||
* Interfaces | ||
*/ | ||
interface IGLTFProperty { | ||
extensions?: { | ||
[key: string]: any; | ||
}; | ||
extras?: any; | ||
interface ILoaderAnimationSamplerData { | ||
input: Float32Array; | ||
interpolation: AnimationSamplerInterpolation; | ||
output: Float32Array; | ||
} | ||
interface IGLTFChildRootProperty extends IGLTFProperty { | ||
name?: string; | ||
interface ILoaderAnimationSampler extends IAnimationSampler, IArrayItem { | ||
_data: Promise<ILoaderAnimationSamplerData>; | ||
} | ||
interface IGLTFAccessorSparseIndices extends IGLTFProperty { | ||
bufferView: number; | ||
byteOffset?: number; | ||
componentType: EComponentType; | ||
interface ILoaderAnimation extends IAnimation, IArrayItem { | ||
channels: ILoaderAnimationChannel[]; | ||
samplers: ILoaderAnimationSampler[]; | ||
_babylonAnimationGroup: Nullable<AnimationGroup>; | ||
} | ||
interface IGLTFAccessorSparseValues extends IGLTFProperty { | ||
bufferView: number; | ||
byteOffset?: number; | ||
interface ILoaderBuffer extends IBuffer, IArrayItem { | ||
_data?: Promise<ArrayBufferView>; | ||
} | ||
interface IGLTFAccessorSparse extends IGLTFProperty { | ||
count: number; | ||
indices: IGLTFAccessorSparseIndices; | ||
values: IGLTFAccessorSparseValues; | ||
interface ILoaderBufferView extends IBufferView, IArrayItem { | ||
_data?: Promise<ArrayBufferView>; | ||
} | ||
interface IGLTFAccessor extends IGLTFChildRootProperty { | ||
bufferView?: number; | ||
byteOffset?: number; | ||
componentType: EComponentType; | ||
normalized?: boolean; | ||
count: number; | ||
type: string; | ||
max: number[]; | ||
min: number[]; | ||
sparse?: IGLTFAccessorSparse; | ||
index: number; | ||
interface ILoaderCamera extends ICamera, IArrayItem { | ||
} | ||
interface IGLTFAnimationChannel extends IGLTFProperty { | ||
sampler: number; | ||
target: IGLTFAnimationChannelTarget; | ||
interface ILoaderImage extends IImage, IArrayItem { | ||
_objectURL?: Promise<string>; | ||
} | ||
interface IGLTFAnimationChannelTarget extends IGLTFProperty { | ||
node: number; | ||
path: string; | ||
interface ILoaderMaterial extends IMaterial, IArrayItem { | ||
_babylonMaterial?: Material; | ||
_babylonMeshes?: AbstractMesh[]; | ||
_loaded?: Promise<void>; | ||
} | ||
interface IGLTFAnimationSampler extends IGLTFProperty { | ||
input: number; | ||
interpolation?: string; | ||
output: number; | ||
interface ILoaderMesh extends IMesh, IArrayItem { | ||
primitives: ILoaderMeshPrimitive[]; | ||
} | ||
interface IGLTFAnimation extends IGLTFChildRootProperty { | ||
channels: IGLTFAnimationChannel[]; | ||
samplers: IGLTFAnimationSampler[]; | ||
index: number; | ||
targets: any[]; | ||
interface ILoaderMeshPrimitive extends IMeshPrimitive, IArrayItem { | ||
} | ||
interface IGLTFAsset extends IGLTFChildRootProperty { | ||
copyright?: string; | ||
generator?: string; | ||
version: string; | ||
minVersion?: string; | ||
interface ILoaderNode extends INode, IArrayItem { | ||
_parent: ILoaderNode; | ||
_babylonMesh?: Mesh; | ||
_primitiveBabylonMeshes?: Mesh[]; | ||
_babylonAnimationTargets?: Node[]; | ||
_numMorphTargets?: number; | ||
} | ||
interface IGLTFBuffer extends IGLTFChildRootProperty { | ||
uri?: string; | ||
byteLength: number; | ||
index: number; | ||
loadedData?: ArrayBufferView; | ||
loadedObservable?: Observable<IGLTFBuffer>; | ||
} | ||
interface IGLTFBufferView extends IGLTFChildRootProperty { | ||
buffer: number; | ||
byteOffset?: number; | ||
byteLength: number; | ||
byteStride?: number; | ||
index: number; | ||
} | ||
interface IGLTFCameraOrthographic extends IGLTFProperty { | ||
xmag: number; | ||
ymag: number; | ||
zfar: number; | ||
znear: number; | ||
} | ||
interface IGLTFCameraPerspective extends IGLTFProperty { | ||
aspectRatio: number; | ||
yfov: number; | ||
zfar: number; | ||
znear: number; | ||
} | ||
interface IGLTFCamera extends IGLTFChildRootProperty { | ||
orthographic?: IGLTFCameraOrthographic; | ||
perspective?: IGLTFCameraPerspective; | ||
type: string; | ||
} | ||
interface IGLTFImage extends IGLTFChildRootProperty { | ||
uri?: string; | ||
mimeType?: string; | ||
bufferView?: number; | ||
index: number; | ||
} | ||
interface IGLTFMaterialNormalTextureInfo extends IGLTFTextureInfo { | ||
scale: number; | ||
} | ||
interface IGLTFMaterialOcclusionTextureInfo extends IGLTFTextureInfo { | ||
strength: number; | ||
} | ||
interface IGLTFMaterialPbrMetallicRoughness { | ||
baseColorFactor: number[]; | ||
baseColorTexture: IGLTFTextureInfo; | ||
metallicFactor: number; | ||
roughnessFactor: number; | ||
metallicRoughnessTexture: IGLTFTextureInfo; | ||
} | ||
interface IGLTFMaterial extends IGLTFChildRootProperty { | ||
pbrMetallicRoughness?: IGLTFMaterialPbrMetallicRoughness; | ||
normalTexture?: IGLTFMaterialNormalTextureInfo; | ||
occlusionTexture?: IGLTFMaterialOcclusionTextureInfo; | ||
emissiveTexture?: IGLTFTextureInfo; | ||
emissiveFactor?: number[]; | ||
alphaMode?: string; | ||
alphaCutoff: number; | ||
doubleSided?: boolean; | ||
index: number; | ||
babylonMaterial: Material; | ||
} | ||
interface IGLTFMeshPrimitive extends IGLTFProperty { | ||
attributes: { | ||
[name: string]: number; | ||
}; | ||
indices?: number; | ||
material?: number; | ||
mode?: EMeshPrimitiveMode; | ||
targets?: { | ||
[name: string]: number; | ||
}[]; | ||
vertexData: VertexData; | ||
targetsVertexData: VertexData[]; | ||
} | ||
interface IGLTFMesh extends IGLTFChildRootProperty { | ||
primitives: IGLTFMeshPrimitive[]; | ||
weights?: number[]; | ||
index: number; | ||
} | ||
interface IGLTFNode extends IGLTFChildRootProperty { | ||
camera?: number; | ||
children?: number[]; | ||
skin?: number; | ||
matrix?: number[]; | ||
mesh?: number; | ||
rotation?: number[]; | ||
scale?: number[]; | ||
translation?: number[]; | ||
weights?: number[]; | ||
index: number; | ||
parent: IGLTFNode; | ||
babylonMesh: Mesh; | ||
babylonAnimationTargets?: Node[]; | ||
} | ||
interface IGLTFSampler extends IGLTFChildRootProperty { | ||
magFilter?: ETextureMagFilter; | ||
minFilter?: ETextureMinFilter; | ||
wrapS?: ETextureWrapMode; | ||
wrapT?: ETextureWrapMode; | ||
index: number; | ||
interface ILoaderSamplerData { | ||
noMipMaps: boolean; | ||
@@ -971,42 +907,27 @@ samplingMode: number; | ||
} | ||
interface IGLTFScene extends IGLTFChildRootProperty { | ||
nodes: number[]; | ||
index: number; | ||
interface ILoaderSampler extends ISampler, IArrayItem { | ||
_data?: ILoaderSamplerData; | ||
} | ||
interface IGLTFSkin extends IGLTFChildRootProperty { | ||
inverseBindMatrices?: number; | ||
skeleton?: number; | ||
joints: number[]; | ||
index: number; | ||
babylonSkeleton: Skeleton; | ||
interface ILoaderScene extends IScene, IArrayItem { | ||
} | ||
interface IGLTFTexture extends IGLTFChildRootProperty { | ||
sampler?: number; | ||
source: number; | ||
index: number; | ||
url?: string; | ||
dataReadyObservable?: Observable<IGLTFTexture>; | ||
interface ILoaderSkin extends ISkin, IArrayItem { | ||
_babylonSkeleton: Nullable<Skeleton>; | ||
_loaded?: Promise<void>; | ||
} | ||
interface IGLTFTextureInfo { | ||
index: number; | ||
texCoord?: number; | ||
interface ILoaderTexture extends ITexture, IArrayItem { | ||
} | ||
interface IGLTF extends IGLTFProperty { | ||
accessors?: IGLTFAccessor[]; | ||
animations?: IGLTFAnimation[]; | ||
asset: IGLTFAsset; | ||
buffers?: IGLTFBuffer[]; | ||
bufferViews?: IGLTFBufferView[]; | ||
cameras?: IGLTFCamera[]; | ||
extensionsUsed?: string[]; | ||
extensionsRequired?: string[]; | ||
images?: IGLTFImage[]; | ||
materials?: IGLTFMaterial[]; | ||
meshes?: IGLTFMesh[]; | ||
nodes?: IGLTFNode[]; | ||
samplers?: IGLTFSampler[]; | ||
scene?: number; | ||
scenes?: IGLTFScene[]; | ||
skins?: IGLTFSkin[]; | ||
textures?: IGLTFTexture[]; | ||
interface ILoaderGLTF extends IGLTF { | ||
accessors?: ILoaderAccessor[]; | ||
animations?: ILoaderAnimation[]; | ||
buffers?: ILoaderBuffer[]; | ||
bufferViews?: ILoaderBufferView[]; | ||
cameras?: ILoaderCamera[]; | ||
images?: ILoaderImage[]; | ||
materials?: ILoaderMaterial[]; | ||
meshes?: ILoaderMesh[]; | ||
nodes?: ILoaderNode[]; | ||
samplers?: ILoaderSampler[]; | ||
scenes?: ILoaderScene[]; | ||
skins?: ILoaderSkin[]; | ||
textures?: ILoaderTexture[]; | ||
} | ||
@@ -1018,97 +939,90 @@ } | ||
class GLTFLoader implements IGLTFLoader { | ||
_gltf: IGLTF; | ||
_gltf: ILoaderGLTF; | ||
_babylonScene: Scene; | ||
_completePromises: Promise<void>[]; | ||
private _disposed; | ||
private _parent; | ||
private _state; | ||
private _extensions; | ||
private _rootUrl; | ||
private _defaultMaterial; | ||
private _rootBabylonMesh; | ||
private _defaultSampler; | ||
private _rootNode; | ||
private _successCallback?; | ||
private _progressCallback?; | ||
private _errorCallback?; | ||
private _renderReady; | ||
private _requests; | ||
private _renderReadyObservable; | ||
private _renderPendingCount; | ||
private _loaderPendingCount; | ||
private _loaderTrackers; | ||
static Extensions: { | ||
[name: string]: GLTFLoaderExtension; | ||
}; | ||
static RegisterExtension(extension: GLTFLoaderExtension): void; | ||
constructor(parent: GLTFFileLoader); | ||
private static _Names; | ||
private static _Factories; | ||
static _Register(name: string, factory: (loader: GLTFLoader) => GLTFLoaderExtension): void; | ||
coordinateSystemMode: GLTFLoaderCoordinateSystemMode; | ||
animationStartMode: GLTFLoaderAnimationStartMode; | ||
compileMaterials: boolean; | ||
useClipPlane: boolean; | ||
compileShadowGenerators: boolean; | ||
readonly onDisposeObservable: Observable<IGLTFLoader>; | ||
readonly onMeshLoadedObservable: Observable<AbstractMesh>; | ||
readonly onTextureLoadedObservable: Observable<BaseTexture>; | ||
readonly onMaterialLoadedObservable: Observable<Material>; | ||
readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>; | ||
readonly onCompleteObservable: Observable<IGLTFLoader>; | ||
readonly state: Nullable<GLTFLoaderState>; | ||
dispose(): void; | ||
importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void; | ||
loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void; | ||
private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess?, onProgress?, onError?); | ||
private _onProgress(); | ||
_executeWhenRenderReady(func: () => void): void; | ||
private _onRenderReady(); | ||
private _onComplete(); | ||
importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{ | ||
meshes: AbstractMesh[]; | ||
particleSystems: ParticleSystem[]; | ||
skeletons: Skeleton[]; | ||
}>; | ||
loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>; | ||
private _loadAsync(nodes, scene, data, rootUrl, onProgress?); | ||
private _loadExtensions(); | ||
private _loadData(data); | ||
private _setupData(); | ||
private _checkExtensions(); | ||
private _createRootNode(); | ||
private _loadNodesAsync(nodes); | ||
_loadSceneAsync(context: string, scene: ILoaderScene): Promise<void>; | ||
private _getMeshes(); | ||
private _getSkeletons(); | ||
private _startAnimations(); | ||
private _loadDefaultScene(nodeNames); | ||
private _loadScene(context, scene, nodeNames); | ||
_loadNode(context: string, node: IGLTFNode): void; | ||
private _loadMesh(context, node, mesh); | ||
private _loadAllVertexDataAsync(context, mesh, onSuccess); | ||
/** | ||
* Converts a data bufferview into a Float4 Texture Coordinate Array, based on the accessor component type | ||
* @param {ArrayBufferView} data | ||
* @param {IGLTFAccessor} accessor | ||
*/ | ||
private _convertToFloat4TextureCoordArray(context, data, accessor); | ||
/** | ||
* Converts a data bufferview into a Float4 Color Array, based on the accessor component type | ||
* @param {ArrayBufferView} data | ||
* @param {IGLTFAccessor} accessor | ||
*/ | ||
private _convertToFloat4ColorArray(context, data, accessor); | ||
private _loadVertexDataAsync(context, mesh, primitive, onSuccess); | ||
private _createMorphTargets(context, node, mesh); | ||
private _loadMorphTargets(context, node, mesh); | ||
private _loadAllMorphTargetVertexDataAsync(context, node, mesh, onSuccess); | ||
private _loadMorphTargetVertexDataAsync(context, vertexData, attributes, onSuccess); | ||
private _loadTransform(node); | ||
private _loadSkinAsync(context, skin, onSuccess); | ||
_loadNodeAsync(context: string, node: ILoaderNode): Promise<void>; | ||
private _loadMeshAsync(context, node, mesh); | ||
private _loadPrimitiveAsync(context, node, mesh, primitive); | ||
private _loadVertexDataAsync(context, primitive, babylonMesh); | ||
private _createMorphTargets(context, node, mesh, primitive, babylonMesh); | ||
private _loadMorphTargetsAsync(context, primitive, babylonMesh, babylonVertexData); | ||
private _loadMorphTargetVertexDataAsync(context, babylonVertexData, attributes, babylonMorphTarget); | ||
private static _ConvertToFloat32Array(context, accessor, data); | ||
private static _ConvertVec3ToVec4(context, data); | ||
private static _LoadTransform(node, babylonNode); | ||
private _loadSkinAsync(context, node, mesh, skin); | ||
private _loadSkinInverseBindMatricesDataAsync(context, skin); | ||
private _createBone(node, skin, parent, localMatrix, baseMatrix, index); | ||
private _loadBones(context, skin, inverseBindMatrixData); | ||
private _loadBone(node, skin, inverseBindMatrixData, babylonBones); | ||
private _loadBones(context, skin, inverseBindMatricesData); | ||
private _loadBone(node, skin, inverseBindMatricesData, babylonBones); | ||
private _getNodeMatrix(node); | ||
private _traverseNodes(context, indices, action, parentNode); | ||
_traverseNode(context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): void; | ||
private _loadAnimations(); | ||
private _loadAnimation(context, animation); | ||
private _loadAnimationChannel(animation, channelContext, channel, samplerContext, sampler); | ||
private _loadBufferAsync(context, buffer, onSuccess); | ||
private _loadBufferViewAsync(context, bufferView, onSuccess); | ||
private _loadAccessorAsync(context, accessor, onSuccess); | ||
private _loadAnimationsAsync(); | ||
private _loadAnimationAsync(context, animation); | ||
private _loadAnimationChannelAsync(context, animationContext, animation, channel, babylonAnimationGroup); | ||
private _loadAnimationSamplerAsync(context, sampler); | ||
private _loadBufferAsync(context, buffer); | ||
_loadBufferViewAsync(context: string, bufferView: ILoaderBufferView): Promise<ArrayBufferView>; | ||
private _loadAccessorAsync(context, accessor); | ||
private _buildArrayBuffer<T>(typedArray, data, byteOffset, count, numComponents, byteStride?); | ||
_addPendingData(data: any): void; | ||
_removePendingData(data: any): void; | ||
_addLoaderPendingData(data: any): void; | ||
_removeLoaderPendingData(data: any): void; | ||
_whenAction(action: () => void, onComplete: () => void): void; | ||
private _getDefaultMaterial(); | ||
private _loadMaterialMetallicRoughnessProperties(context, material); | ||
_loadMaterial(context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): void; | ||
_createPbrMaterial(material: IGLTFMaterial): void; | ||
_loadMaterialBaseProperties(context: string, material: IGLTFMaterial): void; | ||
_loadMaterialAlphaProperties(context: string, material: IGLTFMaterial, colorFactor: number[]): void; | ||
_loadTexture(context: string, texture: IGLTFTexture, coordinatesIndex?: number): Texture; | ||
private _loadMaterialMetallicRoughnessPropertiesAsync(context, material); | ||
_loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Promise<void>; | ||
_createMaterial(material: ILoaderMaterial): PBRMaterial; | ||
_loadMaterialBasePropertiesAsync(context: string, material: ILoaderMaterial): Promise<void>; | ||
_loadMaterialAlphaProperties(context: string, material: ILoaderMaterial): void; | ||
_loadTextureAsync(context: string, textureInfo: ITextureInfo, assign: (texture: Texture) => void): Promise<void>; | ||
private _loadSampler(context, sampler); | ||
private _loadImageAsync(context, image, onSuccess); | ||
_loadUriAsync(context: string, uri: string, onSuccess: (data: ArrayBufferView) => void): void; | ||
_tryCatchOnError(handler: () => void): void; | ||
private static _AssignIndices(array?); | ||
static _GetProperty<T extends IGLTFProperty>(array?: ArrayLike<T>, index?: number): Nullable<T>; | ||
private static _GetTextureWrapMode(context, mode?); | ||
private _loadImageAsync(context, image); | ||
_loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>; | ||
private _onProgress(); | ||
static _GetProperty<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T; | ||
private static _GetTextureWrapMode(context, mode); | ||
private static _GetTextureSamplingMode(context, magFilter?, minFilter?); | ||
private static _GetNumComponents(context, type); | ||
private _compileMaterialAsync(babylonMaterial, babylonMesh, onSuccess); | ||
private _compileMaterialsAsync(onSuccess); | ||
private _compileShadowGeneratorsAsync(onSuccess); | ||
private static _ValidateUri(uri); | ||
private _compileMaterialsAsync(); | ||
private _compileShadowGeneratorsAsync(); | ||
private _clear(); | ||
_applyExtensions<T>(actionAsync: (extension: GLTFLoaderExtension) => Nullable<Promise<T>>): Nullable<Promise<T>>; | ||
} | ||
@@ -1119,17 +1033,52 @@ } | ||
declare module BABYLON.GLTF2 { | ||
/** | ||
* Utils functions for GLTF | ||
*/ | ||
class GLTFUtils { | ||
abstract class GLTFLoaderExtension implements IGLTFLoaderExtension, IDisposable { | ||
enabled: boolean; | ||
readonly abstract name: string; | ||
protected _loader: GLTFLoader; | ||
constructor(loader: GLTFLoader); | ||
dispose(): void; | ||
/** Override this method to modify the default behavior for loading scenes. */ | ||
protected _loadSceneAsync(context: string, node: ILoaderScene): Nullable<Promise<void>>; | ||
/** Override this method to modify the default behavior for loading nodes. */ | ||
protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>; | ||
/** Override this method to modify the default behavior for loading mesh primitive vertex data. */ | ||
protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>; | ||
/** Override this method to modify the default behavior for loading materials. */ | ||
protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>; | ||
/** Override this method to modify the default behavior for loading uris. */ | ||
protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>; | ||
/** Helper method called by a loader extension to load an glTF extension. */ | ||
protected _loadExtensionAsync<TProperty, TResult = void>(context: string, property: IProperty, actionAsync: (context: string, extension: TProperty) => Promise<TResult>): Nullable<Promise<TResult>>; | ||
/** Helper method called by the loader to allow extensions to override loading scenes. */ | ||
static _LoadSceneAsync(loader: GLTFLoader, context: string, scene: ILoaderScene): Nullable<Promise<void>>; | ||
/** Helper method called by the loader to allow extensions to override loading nodes. */ | ||
static _LoadNodeAsync(loader: GLTFLoader, context: string, node: ILoaderNode): Nullable<Promise<void>>; | ||
/** Helper method called by the loader to allow extensions to override loading mesh primitive vertex data. */ | ||
static _LoadVertexDataAsync(loader: GLTFLoader, context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>; | ||
/** Helper method called by the loader to allow extensions to override loading materials. */ | ||
static _LoadMaterialAsync(loader: GLTFLoader, context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>; | ||
/** Helper method called by the loader to allow extensions to override loading uris. */ | ||
static _LoadUriAsync(loader: GLTFLoader, context: string, uri: string): Nullable<Promise<ArrayBufferView>>; | ||
} | ||
} | ||
declare module BABYLON.GLTF2.Extensions { | ||
class MSFT_lod extends GLTFLoaderExtension { | ||
readonly name: string; | ||
/** | ||
* If the uri is a base64 string | ||
* @param uri: the uri to test | ||
*/ | ||
static IsBase64(uri: string): boolean; | ||
* Maximum number of LODs to load, starting from the lowest LOD. | ||
*/ | ||
maxLODsToLoad: number; | ||
private _loadingNodeLOD; | ||
private _loadNodeSignals; | ||
private _loadingMaterialLOD; | ||
private _loadMaterialSignals; | ||
protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>; | ||
protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>; | ||
protected _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>; | ||
/** | ||
* Decode the base64 uri | ||
* @param uri: the uri to decode | ||
*/ | ||
static DecodeBase64(uri: string): ArrayBuffer; | ||
static ValidateUri(uri: string): boolean; | ||
* Gets an array of LOD properties from lowest to highest. | ||
*/ | ||
private _getLODs<T>(context, property, array, ids); | ||
} | ||
@@ -1139,15 +1088,9 @@ } | ||
declare module BABYLON.GLTF2 { | ||
abstract class GLTFLoaderExtension { | ||
enabled: boolean; | ||
readonly abstract name: string; | ||
protected _traverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean; | ||
protected _loadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean; | ||
protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean; | ||
protected _loadExtension<T>(context: string, property: IGLTFProperty, action: (context: string, extension: T, onComplete: () => void) => void): boolean; | ||
static _Extensions: GLTFLoaderExtension[]; | ||
static TraverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean; | ||
static LoadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean; | ||
static LoadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean; | ||
private static _ApplyExtensions(action); | ||
declare module BABYLON.GLTF2.Extensions { | ||
class KHR_draco_mesh_compression extends GLTFLoaderExtension { | ||
readonly name: string; | ||
private _dracoCompression; | ||
constructor(loader: GLTFLoader); | ||
dispose(): void; | ||
protected _loadVertexDataAsync(context: string, primitive: ILoaderMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<VertexData>>; | ||
} | ||
@@ -1158,13 +1101,6 @@ } | ||
declare module BABYLON.GLTF2.Extensions { | ||
class MSFTLOD extends GLTFLoaderExtension { | ||
/** | ||
* Specify the minimal delay between LODs in ms (default = 250) | ||
*/ | ||
Delay: number; | ||
class KHR_materials_pbrSpecularGlossiness extends GLTFLoaderExtension { | ||
readonly name: string; | ||
protected _traverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean; | ||
protected _loadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean; | ||
private _loadNodeLOD(loader, context, nodes, index, onComplete); | ||
protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean; | ||
private _loadMaterialLOD(loader, context, materials, index, assign, onComplete); | ||
protected _loadMaterialAsync(context: string, material: ILoaderMaterial, babylonMesh: Mesh): Nullable<Promise<void>>; | ||
private _loadSpecularGlossinessPropertiesAsync(loader, context, material, properties); | ||
} | ||
@@ -1175,7 +1111,8 @@ } | ||
declare module BABYLON.GLTF2.Extensions { | ||
class KHRMaterialsPbrSpecularGlossiness extends GLTFLoaderExtension { | ||
class KHR_lights extends GLTFLoaderExtension { | ||
readonly name: string; | ||
protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean; | ||
private _loadSpecularGlossinessProperties(loader, context, material, properties); | ||
protected _loadSceneAsync(context: string, scene: ILoaderScene): Nullable<Promise<void>>; | ||
protected _loadNodeAsync(context: string, node: ILoaderNode): Nullable<Promise<void>>; | ||
private readonly _lights; | ||
} | ||
} |
@@ -7,3 +7,3 @@ { | ||
"description": "The Babylon.js file loaders library is an extension you can use to load different 3D file types into a Babylon scene.", | ||
"version": "3.2.0-alpha0", | ||
"version": "3.2.0-alpha10", | ||
"repository": { | ||
@@ -30,10 +30,11 @@ "type": "git", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"babylonjs-gltf2interface": "3.2.0-alpha10" | ||
}, | ||
"peerDependencies": { | ||
"babylonjs": ">=3.1.0-alpha" | ||
"babylonjs": ">=3.2.0-alpha" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"_id": "babylonjs-loaders@3.1.0-alpha1", | ||
"_from": "babylonjs-loaders@" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
421716
6729
2
+ Addedbabylonjs-gltf2interface@3.2.0-alpha10(transitive)