|
@@ -1,4 +1,71 @@
|
|
|
+declare module "babylonjs-loaders/glTF/dataReader" {
|
|
|
+ /**
|
|
|
+ * Interface for a data buffer
|
|
|
+ */
|
|
|
+ export interface IDataBuffer {
|
|
|
+ /**
|
|
|
+ * Reads bytes from the data buffer.
|
|
|
+ * @param byteOffset The byte offset to read
|
|
|
+ * @param byteLength The byte length to read
|
|
|
+ * @returns A promise that resolves when the bytes are read
|
|
|
+ */
|
|
|
+ readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
|
|
|
+ /**
|
|
|
+ * The byte length of the buffer.
|
|
|
+ */
|
|
|
+ readonly byteLength: number;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Utility class for reading from a data buffer
|
|
|
+ */
|
|
|
+ export class DataReader {
|
|
|
+ /**
|
|
|
+ * The data buffer associated with this data reader.
|
|
|
+ */
|
|
|
+ readonly buffer: IDataBuffer;
|
|
|
+ /**
|
|
|
+ * The current byte offset from the beginning of the data buffer.
|
|
|
+ */
|
|
|
+ byteOffset: number;
|
|
|
+ private _dataView;
|
|
|
+ private _dataByteOffset;
|
|
|
+ /**
|
|
|
+ * Constructor
|
|
|
+ * @param buffer The buffer to read
|
|
|
+ */
|
|
|
+ constructor(buffer: IDataBuffer);
|
|
|
+ /**
|
|
|
+ * Loads the given byte length.
|
|
|
+ * @param byteLength The byte length to load
|
|
|
+ * @returns A promise that resolves when the load is complete
|
|
|
+ */
|
|
|
+ loadAsync(byteLength: number): Promise<void>;
|
|
|
+ /**
|
|
|
+ * Read a unsigned 32-bit integer from the currently loaded data range.
|
|
|
+ * @returns The 32-bit integer read
|
|
|
+ */
|
|
|
+ readUint32(): number;
|
|
|
+ /**
|
|
|
+ * Read a byte array from the currently loaded data range.
|
|
|
+ * @param byteLength The byte length to read
|
|
|
+ * @returns The byte array read
|
|
|
+ */
|
|
|
+ readUint8Array(byteLength: number): Uint8Array;
|
|
|
+ /**
|
|
|
+ * Read a string from the currently loaded data range.
|
|
|
+ * @param byteLength The byte length to read
|
|
|
+ * @returns The string read
|
|
|
+ */
|
|
|
+ readString(byteLength: number): string;
|
|
|
+ /**
|
|
|
+ * Skips the given byte length the currently loaded data range.
|
|
|
+ * @param byteLength The byte length to skip
|
|
|
+ */
|
|
|
+ skipBytes(byteLength: number): void;
|
|
|
+ }
|
|
|
+}
|
|
|
declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
+ import * as GLTF2 from "babylonjs-gltf2interface";
|
|
|
import { Nullable } from "babylonjs/types";
|
|
|
import { Observable } from "babylonjs/Misc/observable";
|
|
|
import { Camera } from "babylonjs/Cameras/camera";
|
|
@@ -11,7 +78,9 @@ declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
import { ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
|
|
|
import { AssetContainer } from "babylonjs/assetContainer";
|
|
|
import { Scene, IDisposable } from "babylonjs/scene";
|
|
|
- import * as GLTF2 from "babylonjs-gltf2interface";
|
|
|
+ import { WebRequest } from "babylonjs/Misc/webRequest";
|
|
|
+ import { IFileRequest } from "babylonjs/Misc/fileRequest";
|
|
|
+ import { IDataBuffer } from "babylonjs-loaders/glTF/dataReader";
|
|
|
/**
|
|
|
* Mode that determines the coordinate system to use.
|
|
|
*/
|
|
@@ -47,13 +116,13 @@ declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
*/
|
|
|
export interface IGLTFLoaderData {
|
|
|
/**
|
|
|
- * Object that represents the glTF JSON.
|
|
|
+ * The object that represents the glTF JSON.
|
|
|
*/
|
|
|
json: Object;
|
|
|
/**
|
|
|
* The BIN chunk of a binary glTF.
|
|
|
*/
|
|
|
- bin: Nullable<ArrayBufferView>;
|
|
|
+ bin: Nullable<IDataBuffer>;
|
|
|
}
|
|
|
/**
|
|
|
* Interface for extending the loader.
|
|
@@ -153,6 +222,16 @@ declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
*/
|
|
|
transparencyAsCoverage: boolean;
|
|
|
/**
|
|
|
+ * Defines if the loader should use range requests when load binary glTF files from HTTP.
|
|
|
+ * Enabling will disable offline support and glTF validator.
|
|
|
+ * Defaults to false.
|
|
|
+ */
|
|
|
+ useRangeRequests: boolean;
|
|
|
+ /**
|
|
|
+ * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
|
|
|
+ */
|
|
|
+ createInstances: boolean;
|
|
|
+ /**
|
|
|
* Function called before loading a url referenced by the asset.
|
|
|
*/
|
|
|
preprocessUrlAsync: (url: string) => Promise<string>;
|
|
@@ -270,6 +349,28 @@ declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
/** @hidden */
|
|
|
_clear(): void;
|
|
|
/**
|
|
|
+ * The callback called when loading from a url.
|
|
|
+ * @param scene scene loading this url
|
|
|
+ * @param url url to load
|
|
|
+ * @param onSuccess callback called when the file successfully loads
|
|
|
+ * @param onProgress callback called while file is loading (if the server supports this mode)
|
|
|
+ * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
|
|
|
+ * @param onError callback called when the file fails to load
|
|
|
+ * @returns a file request object
|
|
|
+ */
|
|
|
+ requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
|
|
|
+ /**
|
|
|
+ * The callback called when loading from a file object.
|
|
|
+ * @param scene scene loading this file
|
|
|
+ * @param file defines the file to load
|
|
|
+ * @param onSuccess defines the callback to call when data is loaded
|
|
|
+ * @param onProgress defines the callback to call during loading process
|
|
|
+ * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
|
|
|
+ * @param onError defines the callback to call when an error occurs
|
|
|
+ * @returns a file request object
|
|
|
+ */
|
|
|
+ readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
|
|
|
+ /**
|
|
|
* Imports one or more meshes from the loaded glTF data and adds them to the scene
|
|
|
* @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
|
|
* @param scene the scene the meshes should be added to
|
|
@@ -294,7 +395,7 @@ declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
* @param fileName Defines the name of the file to load
|
|
|
* @returns a promise which completes when objects have been loaded to the scene
|
|
|
*/
|
|
|
- loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
|
|
|
+ loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
|
|
|
/**
|
|
|
* Load into an asset container.
|
|
|
* @param scene The scene to load into
|
|
@@ -304,17 +405,27 @@ declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
* @param fileName Defines the name of the file to load
|
|
|
* @returns The loaded asset container
|
|
|
*/
|
|
|
- loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
|
|
|
+ loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
|
|
|
/**
|
|
|
- * If the data string can be loaded directly.
|
|
|
- * @param data string contianing the file data
|
|
|
+ * The callback that returns true if the data can be directly loaded.
|
|
|
+ * @param data string containing the file data
|
|
|
* @returns if the data can be loaded directly
|
|
|
*/
|
|
|
canDirectLoad(data: string): boolean;
|
|
|
/**
|
|
|
- * Rewrites a url by combining a root url and response url.
|
|
|
+ * The callback that returns the data to pass to the plugin if the data can be directly loaded.
|
|
|
+ * @param scene scene loading this data
|
|
|
+ * @param data string containing the data
|
|
|
+ * @returns data to pass to the plugin
|
|
|
+ */
|
|
|
+ directLoad(scene: Scene, data: string): any;
|
|
|
+ /**
|
|
|
+ * The callback that allows custom handling of the root url based on the response url.
|
|
|
+ * @param rootUrl the original root url
|
|
|
+ * @param responseURL the response url if available
|
|
|
+ * @returns the new root url
|
|
|
*/
|
|
|
- rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
|
|
|
+ rewriteRootURL?(rootUrl: string, responseURL?: string): string;
|
|
|
/**
|
|
|
* Instantiates a glTF file loader plugin.
|
|
|
* @returns the created plugin
|
|
@@ -329,15 +440,14 @@ declare module "babylonjs-loaders/glTF/glTFFileLoader" {
|
|
|
* @returns a promise that resolves when the asset is completely loaded.
|
|
|
*/
|
|
|
whenCompleteAsync(): Promise<void>;
|
|
|
- private _parseAsync;
|
|
|
private _validateAsync;
|
|
|
private _getLoader;
|
|
|
- private _unpackBinary;
|
|
|
- private _unpackBinaryV1;
|
|
|
- private _unpackBinaryV2;
|
|
|
+ private _parseJson;
|
|
|
+ private _unpackBinaryAsync;
|
|
|
+ private _unpackBinaryV1Async;
|
|
|
+ private _unpackBinaryV2Async;
|
|
|
private static _parseVersion;
|
|
|
private static _compareVersion;
|
|
|
- private static _decodeBufferToText;
|
|
|
private static readonly _logSpaces;
|
|
|
private _logIndentLevel;
|
|
|
private _loggingEnabled;
|
|
@@ -1204,7 +1314,7 @@ declare module "babylonjs-loaders/glTF/2.0/glTFLoaderExtension" {
|
|
|
import { Mesh } from "babylonjs/Meshes/mesh";
|
|
|
import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
|
|
|
import { IDisposable } from "babylonjs/scene";
|
|
|
- import { IScene, INode, IMesh, ISkin, ICamera, IMeshPrimitive, IMaterial, ITextureInfo, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
|
|
|
+ import { IScene, INode, IMesh, ISkin, ICamera, IMeshPrimitive, IMaterial, ITextureInfo, IAnimation, IBufferView, IBuffer } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
|
|
|
import { IGLTFLoaderExtension as IGLTFBaseLoaderExtension } from "babylonjs-loaders/glTF/glTFFileLoader";
|
|
|
import { IProperty } from 'babylonjs-gltf2interface';
|
|
|
/**
|
|
@@ -1315,6 +1425,22 @@ declare module "babylonjs-loaders/glTF/2.0/glTFLoaderExtension" {
|
|
|
* @returns A promise that resolves with the loaded data when the load is complete or null if not handled
|
|
|
*/
|
|
|
_loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ /**
|
|
|
+ * Define this method to modify the default behavior when loading buffer views.
|
|
|
+ * @param context The context when loading the asset
|
|
|
+ * @param bufferView The glTF buffer view property
|
|
|
+ * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
|
|
|
+ */
|
|
|
+ loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ /**
|
|
|
+ * Define this method to modify the default behavior when loading buffers.
|
|
|
+ * @param context The context when loading the asset
|
|
|
+ * @param buffer The glTF buffer property
|
|
|
+ * @param byteOffset The byte offset to load
|
|
|
+ * @param byteLength The byte length to load
|
|
|
+ * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
|
|
|
+ */
|
|
|
+ loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
|
|
|
}
|
|
|
}
|
|
|
declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
|
|
@@ -1335,6 +1461,7 @@ declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
|
|
|
import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
|
|
|
import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
|
|
|
import { IAnimatable } from 'babylonjs/Animations/animatable.interface';
|
|
|
+ import { IDataBuffer } from "babylonjs-loaders/glTF/dataReader";
|
|
|
/**
|
|
|
* Helper class for working with arrays when loading the glTF asset
|
|
|
*/
|
|
@@ -1367,6 +1494,7 @@ declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
|
|
|
private _fileName;
|
|
|
private _uniqueRootUrl;
|
|
|
private _gltf;
|
|
|
+ private _bin;
|
|
|
private _babylonScene;
|
|
|
private _rootBabylonMesh;
|
|
|
private _defaultBabylonMaterialData;
|
|
@@ -1392,10 +1520,18 @@ declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
|
|
|
*/
|
|
|
readonly state: Nullable<GLTFLoaderState>;
|
|
|
/**
|
|
|
- * The glTF object parsed from the JSON.
|
|
|
+ * The object that represents the glTF JSON.
|
|
|
*/
|
|
|
readonly gltf: IGLTF;
|
|
|
/**
|
|
|
+ * The BIN chunk of a binary glTF.
|
|
|
+ */
|
|
|
+ readonly bin: Nullable<IDataBuffer>;
|
|
|
+ /**
|
|
|
+ * The parent file loader.
|
|
|
+ */
|
|
|
+ readonly parent: GLTFFileLoader;
|
|
|
+ /**
|
|
|
* The Babylon scene when loading the asset.
|
|
|
*/
|
|
|
readonly babylonScene: Scene;
|
|
@@ -1602,6 +1738,8 @@ declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
|
|
|
private _extensionsLoadAnimationAsync;
|
|
|
private _extensionsLoadSkinAsync;
|
|
|
private _extensionsLoadUriAsync;
|
|
|
+ private _extensionsLoadBufferViewAsync;
|
|
|
+ private _extensionsLoadBufferAsync;
|
|
|
/**
|
|
|
* Helper method called by a loader extension to load an glTF extension.
|
|
|
* @param context The context when loading the asset
|
|
@@ -1621,6 +1759,12 @@ declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
|
|
|
*/
|
|
|
static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
|
|
|
/**
|
|
|
+ * Checks for presence of an extension.
|
|
|
+ * @param name The name of the extension to check
|
|
|
+ * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
|
|
|
+ */
|
|
|
+ isExtensionUsed(name: string): boolean;
|
|
|
+ /**
|
|
|
* Increments the indentation level and logs a message.
|
|
|
* @param message The message to log
|
|
|
*/
|
|
@@ -1652,7 +1796,7 @@ declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based" {
|
|
|
import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
|
|
|
import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
|
|
|
/**
|
|
|
- * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
|
|
|
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
|
|
|
*/
|
|
|
export class EXT_lights_image_based implements IGLTFLoaderExtension {
|
|
|
/** The name of this extension. */
|
|
@@ -1706,7 +1850,7 @@ declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual" {
|
|
|
import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
|
|
|
import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
|
|
|
/**
|
|
|
- * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
|
|
|
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
|
|
|
*/
|
|
|
export class KHR_lights implements IGLTFLoaderExtension {
|
|
|
/** The name of this extension. */
|
|
@@ -1838,7 +1982,7 @@ declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
|
|
|
import { Material } from "babylonjs/Materials/material";
|
|
|
import { TransformNode } from "babylonjs/Meshes/transformNode";
|
|
|
import { Mesh } from "babylonjs/Meshes/mesh";
|
|
|
- import { INode, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
|
|
|
+ import { INode, IMaterial, IBuffer } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
|
|
|
import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
|
|
|
import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
|
|
|
import { IProperty } from 'babylonjs-gltf2interface';
|
|
@@ -1873,6 +2017,8 @@ declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
|
|
|
private _materialIndexLOD;
|
|
|
private _materialSignalLODs;
|
|
|
private _materialPromiseLODs;
|
|
|
+ private _indexLOD;
|
|
|
+ private _bufferLODs;
|
|
|
/** @hidden */
|
|
|
constructor(loader: GLTFLoader);
|
|
|
/** @hidden */
|
|
@@ -1885,6 +2031,9 @@ declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
|
|
|
_loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
|
|
|
/** @hidden */
|
|
|
_loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ /** @hidden */
|
|
|
+ loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ private _loadBufferLOD;
|
|
|
/**
|
|
|
* Gets an array of LOD properties from lowest to highest.
|
|
|
*/
|
|
@@ -2335,6 +2484,72 @@ declare module "babylonjs-loaders" {
|
|
|
}
|
|
|
declare module BABYLON {
|
|
|
/**
|
|
|
+ * Interface for a data buffer
|
|
|
+ */
|
|
|
+ export interface IDataBuffer {
|
|
|
+ /**
|
|
|
+ * Reads bytes from the data buffer.
|
|
|
+ * @param byteOffset The byte offset to read
|
|
|
+ * @param byteLength The byte length to read
|
|
|
+ * @returns A promise that resolves when the bytes are read
|
|
|
+ */
|
|
|
+ readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
|
|
|
+ /**
|
|
|
+ * The byte length of the buffer.
|
|
|
+ */
|
|
|
+ readonly byteLength: number;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * Utility class for reading from a data buffer
|
|
|
+ */
|
|
|
+ export class DataReader {
|
|
|
+ /**
|
|
|
+ * The data buffer associated with this data reader.
|
|
|
+ */
|
|
|
+ readonly buffer: IDataBuffer;
|
|
|
+ /**
|
|
|
+ * The current byte offset from the beginning of the data buffer.
|
|
|
+ */
|
|
|
+ byteOffset: number;
|
|
|
+ private _dataView;
|
|
|
+ private _dataByteOffset;
|
|
|
+ /**
|
|
|
+ * Constructor
|
|
|
+ * @param buffer The buffer to read
|
|
|
+ */
|
|
|
+ constructor(buffer: IDataBuffer);
|
|
|
+ /**
|
|
|
+ * Loads the given byte length.
|
|
|
+ * @param byteLength The byte length to load
|
|
|
+ * @returns A promise that resolves when the load is complete
|
|
|
+ */
|
|
|
+ loadAsync(byteLength: number): Promise<void>;
|
|
|
+ /**
|
|
|
+ * Read a unsigned 32-bit integer from the currently loaded data range.
|
|
|
+ * @returns The 32-bit integer read
|
|
|
+ */
|
|
|
+ readUint32(): number;
|
|
|
+ /**
|
|
|
+ * Read a byte array from the currently loaded data range.
|
|
|
+ * @param byteLength The byte length to read
|
|
|
+ * @returns The byte array read
|
|
|
+ */
|
|
|
+ readUint8Array(byteLength: number): Uint8Array;
|
|
|
+ /**
|
|
|
+ * Read a string from the currently loaded data range.
|
|
|
+ * @param byteLength The byte length to read
|
|
|
+ * @returns The string read
|
|
|
+ */
|
|
|
+ readString(byteLength: number): string;
|
|
|
+ /**
|
|
|
+ * Skips the given byte length the currently loaded data range.
|
|
|
+ * @param byteLength The byte length to skip
|
|
|
+ */
|
|
|
+ skipBytes(byteLength: number): void;
|
|
|
+ }
|
|
|
+}
|
|
|
+declare module BABYLON {
|
|
|
+ /**
|
|
|
* Mode that determines the coordinate system to use.
|
|
|
*/
|
|
|
export enum GLTFLoaderCoordinateSystemMode {
|
|
@@ -2369,13 +2584,13 @@ declare module BABYLON {
|
|
|
*/
|
|
|
export interface IGLTFLoaderData {
|
|
|
/**
|
|
|
- * Object that represents the glTF JSON.
|
|
|
+ * The object that represents the glTF JSON.
|
|
|
*/
|
|
|
json: Object;
|
|
|
/**
|
|
|
* The BIN chunk of a binary glTF.
|
|
|
*/
|
|
|
- bin: Nullable<ArrayBufferView>;
|
|
|
+ bin: Nullable<IDataBuffer>;
|
|
|
}
|
|
|
/**
|
|
|
* Interface for extending the loader.
|
|
@@ -2475,6 +2690,16 @@ declare module BABYLON {
|
|
|
*/
|
|
|
transparencyAsCoverage: boolean;
|
|
|
/**
|
|
|
+ * Defines if the loader should use range requests when load binary glTF files from HTTP.
|
|
|
+ * Enabling will disable offline support and glTF validator.
|
|
|
+ * Defaults to false.
|
|
|
+ */
|
|
|
+ useRangeRequests: boolean;
|
|
|
+ /**
|
|
|
+ * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
|
|
|
+ */
|
|
|
+ createInstances: boolean;
|
|
|
+ /**
|
|
|
* Function called before loading a url referenced by the asset.
|
|
|
*/
|
|
|
preprocessUrlAsync: (url: string) => Promise<string>;
|
|
@@ -2592,6 +2817,28 @@ declare module BABYLON {
|
|
|
/** @hidden */
|
|
|
_clear(): void;
|
|
|
/**
|
|
|
+ * The callback called when loading from a url.
|
|
|
+ * @param scene scene loading this url
|
|
|
+ * @param url url to load
|
|
|
+ * @param onSuccess callback called when the file successfully loads
|
|
|
+ * @param onProgress callback called while file is loading (if the server supports this mode)
|
|
|
+ * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
|
|
|
+ * @param onError callback called when the file fails to load
|
|
|
+ * @returns a file request object
|
|
|
+ */
|
|
|
+ requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
|
|
|
+ /**
|
|
|
+ * The callback called when loading from a file object.
|
|
|
+ * @param scene scene loading this file
|
|
|
+ * @param file defines the file to load
|
|
|
+ * @param onSuccess defines the callback to call when data is loaded
|
|
|
+ * @param onProgress defines the callback to call during loading process
|
|
|
+ * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
|
|
|
+ * @param onError defines the callback to call when an error occurs
|
|
|
+ * @returns a file request object
|
|
|
+ */
|
|
|
+ readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
|
|
|
+ /**
|
|
|
* Imports one or more meshes from the loaded glTF data and adds them to the scene
|
|
|
* @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
|
|
* @param scene the scene the meshes should be added to
|
|
@@ -2616,7 +2863,7 @@ declare module BABYLON {
|
|
|
* @param fileName Defines the name of the file to load
|
|
|
* @returns a promise which completes when objects have been loaded to the scene
|
|
|
*/
|
|
|
- loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
|
|
|
+ loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
|
|
|
/**
|
|
|
* Load into an asset container.
|
|
|
* @param scene The scene to load into
|
|
@@ -2626,17 +2873,27 @@ declare module BABYLON {
|
|
|
* @param fileName Defines the name of the file to load
|
|
|
* @returns The loaded asset container
|
|
|
*/
|
|
|
- loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
|
|
|
+ loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
|
|
|
/**
|
|
|
- * If the data string can be loaded directly.
|
|
|
- * @param data string contianing the file data
|
|
|
+ * The callback that returns true if the data can be directly loaded.
|
|
|
+ * @param data string containing the file data
|
|
|
* @returns if the data can be loaded directly
|
|
|
*/
|
|
|
canDirectLoad(data: string): boolean;
|
|
|
/**
|
|
|
- * Rewrites a url by combining a root url and response url.
|
|
|
+ * The callback that returns the data to pass to the plugin if the data can be directly loaded.
|
|
|
+ * @param scene scene loading this data
|
|
|
+ * @param data string containing the data
|
|
|
+ * @returns data to pass to the plugin
|
|
|
+ */
|
|
|
+ directLoad(scene: Scene, data: string): any;
|
|
|
+ /**
|
|
|
+ * The callback that allows custom handling of the root url based on the response url.
|
|
|
+ * @param rootUrl the original root url
|
|
|
+ * @param responseURL the response url if available
|
|
|
+ * @returns the new root url
|
|
|
*/
|
|
|
- rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
|
|
|
+ rewriteRootURL?(rootUrl: string, responseURL?: string): string;
|
|
|
/**
|
|
|
* Instantiates a glTF file loader plugin.
|
|
|
* @returns the created plugin
|
|
@@ -2651,15 +2908,14 @@ declare module BABYLON {
|
|
|
* @returns a promise that resolves when the asset is completely loaded.
|
|
|
*/
|
|
|
whenCompleteAsync(): Promise<void>;
|
|
|
- private _parseAsync;
|
|
|
private _validateAsync;
|
|
|
private _getLoader;
|
|
|
- private _unpackBinary;
|
|
|
- private _unpackBinaryV1;
|
|
|
- private _unpackBinaryV2;
|
|
|
+ private _parseJson;
|
|
|
+ private _unpackBinaryAsync;
|
|
|
+ private _unpackBinaryV1Async;
|
|
|
+ private _unpackBinaryV2Async;
|
|
|
private static _parseVersion;
|
|
|
private static _compareVersion;
|
|
|
- private static _decodeBufferToText;
|
|
|
private static readonly _logSpaces;
|
|
|
private _logIndentLevel;
|
|
|
private _loggingEnabled;
|
|
@@ -3580,6 +3836,22 @@ declare module BABYLON.GLTF2 {
|
|
|
* @returns A promise that resolves with the loaded data when the load is complete or null if not handled
|
|
|
*/
|
|
|
_loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ /**
|
|
|
+ * Define this method to modify the default behavior when loading buffer views.
|
|
|
+ * @param context The context when loading the asset
|
|
|
+ * @param bufferView The glTF buffer view property
|
|
|
+ * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
|
|
|
+ */
|
|
|
+ loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ /**
|
|
|
+ * Define this method to modify the default behavior when loading buffers.
|
|
|
+ * @param context The context when loading the asset
|
|
|
+ * @param buffer The glTF buffer property
|
|
|
+ * @param byteOffset The byte offset to load
|
|
|
+ * @param byteLength The byte length to load
|
|
|
+ * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
|
|
|
+ */
|
|
|
+ loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
|
|
|
}
|
|
|
}
|
|
|
declare module BABYLON.GLTF2 {
|
|
@@ -3615,6 +3887,7 @@ declare module BABYLON.GLTF2 {
|
|
|
private _fileName;
|
|
|
private _uniqueRootUrl;
|
|
|
private _gltf;
|
|
|
+ private _bin;
|
|
|
private _babylonScene;
|
|
|
private _rootBabylonMesh;
|
|
|
private _defaultBabylonMaterialData;
|
|
@@ -3640,10 +3913,18 @@ declare module BABYLON.GLTF2 {
|
|
|
*/
|
|
|
readonly state: Nullable<GLTFLoaderState>;
|
|
|
/**
|
|
|
- * The glTF object parsed from the JSON.
|
|
|
+ * The object that represents the glTF JSON.
|
|
|
*/
|
|
|
readonly gltf: IGLTF;
|
|
|
/**
|
|
|
+ * The BIN chunk of a binary glTF.
|
|
|
+ */
|
|
|
+ readonly bin: Nullable<IDataBuffer>;
|
|
|
+ /**
|
|
|
+ * The parent file loader.
|
|
|
+ */
|
|
|
+ readonly parent: GLTFFileLoader;
|
|
|
+ /**
|
|
|
* The Babylon scene when loading the asset.
|
|
|
*/
|
|
|
readonly babylonScene: Scene;
|
|
@@ -3850,6 +4131,8 @@ declare module BABYLON.GLTF2 {
|
|
|
private _extensionsLoadAnimationAsync;
|
|
|
private _extensionsLoadSkinAsync;
|
|
|
private _extensionsLoadUriAsync;
|
|
|
+ private _extensionsLoadBufferViewAsync;
|
|
|
+ private _extensionsLoadBufferAsync;
|
|
|
/**
|
|
|
* Helper method called by a loader extension to load an glTF extension.
|
|
|
* @param context The context when loading the asset
|
|
@@ -3869,6 +4152,12 @@ declare module BABYLON.GLTF2 {
|
|
|
*/
|
|
|
static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
|
|
|
/**
|
|
|
+ * Checks for presence of an extension.
|
|
|
+ * @param name The name of the extension to check
|
|
|
+ * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
|
|
|
+ */
|
|
|
+ isExtensionUsed(name: string): boolean;
|
|
|
+ /**
|
|
|
* Increments the indentation level and logs a message.
|
|
|
* @param message The message to log
|
|
|
*/
|
|
@@ -3896,7 +4185,7 @@ declare module BABYLON.GLTF2 {
|
|
|
}
|
|
|
declare module BABYLON.GLTF2.Loader.Extensions {
|
|
|
/**
|
|
|
- * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
|
|
|
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
|
|
|
*/
|
|
|
export class EXT_lights_image_based implements IGLTFLoaderExtension {
|
|
|
/** The name of this extension. */
|
|
@@ -3938,7 +4227,7 @@ declare module BABYLON.GLTF2.Loader.Extensions {
|
|
|
}
|
|
|
declare module BABYLON.GLTF2.Loader.Extensions {
|
|
|
/**
|
|
|
- * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
|
|
|
+ * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
|
|
|
*/
|
|
|
export class KHR_lights implements IGLTFLoaderExtension {
|
|
|
/** The name of this extension. */
|
|
@@ -4075,6 +4364,8 @@ declare module BABYLON.GLTF2.Loader.Extensions {
|
|
|
private _materialIndexLOD;
|
|
|
private _materialSignalLODs;
|
|
|
private _materialPromiseLODs;
|
|
|
+ private _indexLOD;
|
|
|
+ private _bufferLODs;
|
|
|
/** @hidden */
|
|
|
constructor(loader: GLTFLoader);
|
|
|
/** @hidden */
|
|
@@ -4087,6 +4378,9 @@ declare module BABYLON.GLTF2.Loader.Extensions {
|
|
|
_loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
|
|
|
/** @hidden */
|
|
|
_loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ /** @hidden */
|
|
|
+ loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
|
|
|
+ private _loadBufferLOD;
|
|
|
/**
|
|
|
* Gets an array of LOD properties from lowest to highest.
|
|
|
*/
|