123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851 |
- declare module BABYLON {
- class STLFileLoader implements ISceneLoaderPlugin {
- solidPattern: RegExp;
- facetsPattern: RegExp;
- normalPattern: RegExp;
- vertexPattern: RegExp;
- name: string;
- extensions: ISceneLoaderPluginExtensions;
- importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
- load(scene: Scene, data: any, rootUrl: string): boolean;
- loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
- private isBinary;
- private parseBinary;
- private parseASCII;
- }
- }
- declare module BABYLON {
- /**
- * Class reading and parsing the MTL file bundled with the obj file.
- */
- class MTLFileLoader {
- materials: BABYLON.StandardMaterial[];
- /**
- * This function will read the mtl file and create each material described inside
- * This function could be improve by adding :
- * -some component missing (Ni, Tf...)
- * -including the specific options available
- *
- * @param scene
- * @param data
- * @param rootUrl
- */
- parseMTL(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string): void;
- /**
- * Gets the texture for the material.
- *
- * If the material is imported from input file,
- * We sanitize the url to ensure it takes the textre from aside the material.
- *
- * @param rootUrl The root url to load from
- * @param value The value stored in the mtl
- * @return The Texture
- */
- private static _getTexture;
- }
- class OBJFileLoader implements ISceneLoaderPluginAsync {
- static OPTIMIZE_WITH_UV: boolean;
- static INVERT_Y: boolean;
- name: string;
- extensions: string;
- obj: RegExp;
- group: RegExp;
- mtllib: RegExp;
- usemtl: RegExp;
- smooth: RegExp;
- vertexPattern: RegExp;
- normalPattern: RegExp;
- uvPattern: RegExp;
- facePattern1: RegExp;
- facePattern2: RegExp;
- facePattern3: RegExp;
- facePattern4: RegExp;
- facePattern5: RegExp;
- /**
- * Calls synchronously the MTL file attached to this obj.
- * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
- * Without this function materials are not displayed in the first frame (but displayed after).
- * In consequence it is impossible to get material information in your HTML file
- *
- * @param url The URL of the MTL file
- * @param rootUrl
- * @param onSuccess Callback function to be called when the MTL file is loaded
- * @private
- */
- private _loadMTL;
- /**
- * 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
- * @param data the glTF data to load
- * @param rootUrl root url to load from
- * @param onProgress event that fires when loading progress has occured
- * @param fileName Defines the name of the file to load
- * @returns a promise containg the loaded meshes, particles, skeletons and animations
- */
- importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
- meshes: AbstractMesh[];
- particleSystems: IParticleSystem[];
- skeletons: Skeleton[];
- animationGroups: AnimationGroup[];
- }>;
- /**
- * Imports all objects from the loaded glTF data and adds them to the scene
- * @param scene the scene the objects should be added to
- * @param data the glTF data to load
- * @param rootUrl root url to load from
- * @param onProgress event that fires when loading progress has occured
- * @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, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
- /**
- * Load into an asset container.
- * @param scene The scene to load into
- * @param data The data to import
- * @param rootUrl The root url for scene and resources
- * @param onProgress The callback when the load progresses
- * @param fileName Defines the name of the file to load
- * @returns The loaded asset container
- */
- loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
- /**
- * Read the OBJ file and create an Array of meshes.
- * Each mesh contains all information given by the OBJ and the MTL file.
- * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
- *
- * @param meshesNames
- * @param scene BABYLON.Scene The scene where are displayed the data
- * @param data String The content of the obj file
- * @param rootUrl String The path to the folder
- * @returns Array<AbstractMesh>
- * @private
- */
- private _parseSolid;
- }
- }
- declare module BABYLON {
- /**
- * Mode that determines the coordinate system to use.
- */
- enum GLTFLoaderCoordinateSystemMode {
- /**
- * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
- */
- AUTO = 0,
- /**
- * Sets the useRightHandedSystem flag on the scene.
- */
- FORCE_RIGHT_HANDED = 1
- }
- /**
- * Mode that determines what animations will start.
- */
- enum GLTFLoaderAnimationStartMode {
- /**
- * No animation will start.
- */
- NONE = 0,
- /**
- * The first animation will start.
- */
- FIRST = 1,
- /**
- * All animations will start.
- */
- ALL = 2
- }
- /**
- * Interface that contains the data for the glTF asset.
- */
- interface IGLTFLoaderData {
- /**
- * Object that represents the glTF JSON.
- */
- json: Object;
- /**
- * The BIN chunk of a binary glTF.
- */
- bin: Nullable<ArrayBufferView>;
- }
- /**
- * Interface for extending the loader.
- */
- interface IGLTFLoaderExtension {
- /**
- * The name of this extension.
- */
- readonly name: string;
- /**
- * Defines whether this extension is enabled.
- */
- enabled: boolean;
- }
- /**
- * Loader state.
- */
- enum GLTFLoaderState {
- /**
- * The asset is loading.
- */
- LOADING = 0,
- /**
- * The asset is ready for rendering.
- */
- READY = 1,
- /**
- * The asset is completely loaded.
- */
- COMPLETE = 2
- }
- /** @hidden */
- interface IGLTFLoader extends IDisposable {
- readonly state: Nullable<GLTFLoaderState>;
- importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
- meshes: AbstractMesh[];
- particleSystems: IParticleSystem[];
- skeletons: Skeleton[];
- animationGroups: AnimationGroup[];
- }>;
- loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
- }
- /**
- * File loader for loading glTF files into a scene.
- */
- class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
- /** @hidden */
- static _CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
- /** @hidden */
- static _CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
- /**
- * Raised when the asset has been parsed
- */
- onParsedObservable: Observable<IGLTFLoaderData>;
- private _onParsedObserver;
- /**
- * Raised when the asset has been parsed
- */
- onParsed: (loaderData: IGLTFLoaderData) => void;
- /**
- * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
- * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
- * Defaults to true.
- * @hidden
- */
- static IncrementalLoading: boolean;
- /**
- * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
- * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
- * @hidden
- */
- static HomogeneousCoordinates: boolean;
- /**
- * The coordinate system mode. Defaults to AUTO.
- */
- coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
- /**
- * The animation start mode. Defaults to FIRST.
- */
- animationStartMode: GLTFLoaderAnimationStartMode;
- /**
- * Defines if the loader should compile materials before raising the success callback. Defaults to false.
- */
- compileMaterials: boolean;
- /**
- * Defines if the loader should also compile materials with clip planes. Defaults to false.
- */
- useClipPlane: boolean;
- /**
- * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
- */
- compileShadowGenerators: boolean;
- /**
- * Defines if the Alpha blended materials are only applied as coverage.
- * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
- * If true, no extra effects are applied to transparent pixels.
- */
- transparencyAsCoverage: boolean;
- /**
- * Function called before loading a url referenced by the asset.
- */
- preprocessUrlAsync: (url: string) => Promise<string>;
- /**
- * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
- */
- readonly onMeshLoadedObservable: Observable<AbstractMesh>;
- private _onMeshLoadedObserver;
- /**
- * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
- */
- onMeshLoaded: (mesh: AbstractMesh) => void;
- /**
- * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
- */
- readonly onTextureLoadedObservable: Observable<BaseTexture>;
- private _onTextureLoadedObserver;
- /**
- * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
- */
- onTextureLoaded: (texture: BaseTexture) => void;
- /**
- * Observable raised when the loader creates a material after parsing the glTF properties of the material.
- */
- readonly onMaterialLoadedObservable: Observable<Material>;
- private _onMaterialLoadedObserver;
- /**
- * Callback raised when the loader creates a material after parsing the glTF properties of the material.
- */
- onMaterialLoaded: (material: Material) => void;
- /**
- * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
- */
- readonly onCameraLoadedObservable: Observable<Camera>;
- private _onCameraLoadedObserver;
- /**
- * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
- */
- onCameraLoaded: (camera: Camera) => void;
- /**
- * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
- * For assets with LODs, raised when all of the LODs are complete.
- * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
- */
- readonly onCompleteObservable: Observable<void>;
- private _onCompleteObserver;
- /**
- * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
- * For assets with LODs, raised when all of the LODs are complete.
- * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
- */
- onComplete: () => void;
- /**
- * Observable raised when an error occurs.
- */
- readonly onErrorObservable: Observable<any>;
- private _onErrorObserver;
- /**
- * Callback raised when an error occurs.
- */
- onError: (reason: any) => void;
- /**
- * Observable raised after the loader is disposed.
- */
- readonly onDisposeObservable: Observable<void>;
- private _onDisposeObserver;
- /**
- * Callback raised after the loader is disposed.
- */
- onDispose: () => void;
- /**
- * Observable raised after a loader extension is created.
- * Set additional options for a loader extension in this event.
- */
- readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
- private _onExtensionLoadedObserver;
- /**
- * Callback raised after a loader extension is created.
- */
- onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
- /**
- * Defines if the loader logging is enabled.
- */
- loggingEnabled: boolean;
- /**
- * Defines if the loader should capture performance counters.
- */
- capturePerformanceCounters: boolean;
- /**
- * Defines if the loader should validate the asset.
- */
- validate: boolean;
- /**
- * Observable raised after validation when validate is set to true. The event data is the result of the validation.
- */
- readonly onValidatedObservable: Observable<IGLTFValidationResults>;
- private _onValidatedObserver;
- /**
- * Callback raised after a loader extension is created.
- */
- onValidated: (results: IGLTFValidationResults) => void;
- private _loader;
- /**
- * Name of the loader ("gltf")
- */
- name: string;
- /**
- * Supported file extensions of the loader (.gltf, .glb)
- */
- extensions: ISceneLoaderPluginExtensions;
- /**
- * Disposes the loader, releases resources during load, and cancels any outstanding requests.
- */
- dispose(): void;
- /** @hidden */
- _clear(): void;
- /**
- * 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
- * @param data the glTF data to load
- * @param rootUrl root url to load from
- * @param onProgress event that fires when loading progress has occured
- * @param fileName Defines the name of the file to load
- * @returns a promise containg the loaded meshes, particles, skeletons and animations
- */
- importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
- meshes: AbstractMesh[];
- particleSystems: IParticleSystem[];
- skeletons: Skeleton[];
- animationGroups: AnimationGroup[];
- }>;
- /**
- * Imports all objects from the loaded glTF data and adds them to the scene
- * @param scene the scene the objects should be added to
- * @param data the glTF data to load
- * @param rootUrl root url to load from
- * @param onProgress event that fires when loading progress has occured
- * @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>;
- /**
- * Load into an asset container.
- * @param scene The scene to load into
- * @param data The data to import
- * @param rootUrl The root url for scene and resources
- * @param onProgress The callback when the load progresses
- * @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>;
- /**
- * If the data string can be loaded directly.
- * @param data string contianing 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.
- */
- rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
- /**
- * Instantiates a glTF file loader plugin.
- * @returns the created plugin
- */
- createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
- /**
- * The loader state or null if the loader is not active.
- */
- readonly loaderState: Nullable<GLTFLoaderState>;
- /**
- * Returns a promise that resolves when the asset is completely loaded.
- * @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 static _parseVersion;
- private static _compareVersion;
- private static _decodeBufferToText;
- private static readonly _logSpaces;
- private _logIndentLevel;
- private _loggingEnabled;
- /** @hidden */
- _log: (message: string) => void;
- /** @hidden */
- _logOpen(message: string): void;
- /** @hidden */
- _logClose(): void;
- private _logEnabled;
- private _logDisabled;
- private _capturePerformanceCounters;
- /** @hidden */
- _startPerformanceCounter: (counterName: string) => void;
- /** @hidden */
- _endPerformanceCounter: (counterName: string) => void;
- private _startPerformanceCounterEnabled;
- private _startPerformanceCounterDisabled;
- private _endPerformanceCounterEnabled;
- private _endPerformanceCounterDisabled;
- }
- }
- declare module BABYLON.GLTF1 {
- /**
- * Enums
- */
- enum EComponentType {
- BYTE = 5120,
- UNSIGNED_BYTE = 5121,
- SHORT = 5122,
- UNSIGNED_SHORT = 5123,
- FLOAT = 5126
- }
- enum EShaderType {
- FRAGMENT = 35632,
- VERTEX = 35633
- }
- enum EParameterType {
- BYTE = 5120,
- UNSIGNED_BYTE = 5121,
- SHORT = 5122,
- UNSIGNED_SHORT = 5123,
- INT = 5124,
- UNSIGNED_INT = 5125,
- FLOAT = 5126,
- FLOAT_VEC2 = 35664,
- FLOAT_VEC3 = 35665,
- FLOAT_VEC4 = 35666,
- INT_VEC2 = 35667,
- INT_VEC3 = 35668,
- INT_VEC4 = 35669,
- BOOL = 35670,
- BOOL_VEC2 = 35671,
- BOOL_VEC3 = 35672,
- BOOL_VEC4 = 35673,
- FLOAT_MAT2 = 35674,
- FLOAT_MAT3 = 35675,
- FLOAT_MAT4 = 35676,
- SAMPLER_2D = 35678
- }
- enum ETextureWrapMode {
- CLAMP_TO_EDGE = 33071,
- MIRRORED_REPEAT = 33648,
- REPEAT = 10497
- }
- enum ETextureFilterType {
- NEAREST = 9728,
- LINEAR = 9728,
- NEAREST_MIPMAP_NEAREST = 9984,
- LINEAR_MIPMAP_NEAREST = 9985,
- NEAREST_MIPMAP_LINEAR = 9986,
- LINEAR_MIPMAP_LINEAR = 9987
- }
- enum ETextureFormat {
- ALPHA = 6406,
- RGB = 6407,
- RGBA = 6408,
- LUMINANCE = 6409,
- LUMINANCE_ALPHA = 6410
- }
- enum ECullingType {
- FRONT = 1028,
- BACK = 1029,
- FRONT_AND_BACK = 1032
- }
- enum EBlendingFunction {
- ZERO = 0,
- ONE = 1,
- SRC_COLOR = 768,
- ONE_MINUS_SRC_COLOR = 769,
- DST_COLOR = 774,
- ONE_MINUS_DST_COLOR = 775,
- SRC_ALPHA = 770,
- ONE_MINUS_SRC_ALPHA = 771,
- DST_ALPHA = 772,
- ONE_MINUS_DST_ALPHA = 773,
- CONSTANT_COLOR = 32769,
- ONE_MINUS_CONSTANT_COLOR = 32770,
- CONSTANT_ALPHA = 32771,
- ONE_MINUS_CONSTANT_ALPHA = 32772,
- SRC_ALPHA_SATURATE = 776
- }
- /**
- * Interfaces
- */
- interface IGLTFProperty {
- extensions?: {
- [key: string]: any;
- };
- extras?: Object;
- }
- interface IGLTFChildRootProperty extends IGLTFProperty {
- name?: string;
- }
- interface IGLTFAccessor extends IGLTFChildRootProperty {
- bufferView: string;
- byteOffset: number;
- byteStride: number;
- count: number;
- type: string;
- componentType: EComponentType;
- max?: number[];
- min?: number[];
- name?: string;
- }
- interface IGLTFBufferView extends IGLTFChildRootProperty {
- buffer: string;
- byteOffset: number;
- byteLength: number;
- byteStride: number;
- target?: number;
- }
- interface IGLTFBuffer extends IGLTFChildRootProperty {
- uri: string;
- byteLength?: number;
- type?: string;
- }
- interface IGLTFShader extends IGLTFChildRootProperty {
- uri: string;
- type: EShaderType;
- }
- interface IGLTFProgram extends IGLTFChildRootProperty {
- attributes: string[];
- fragmentShader: string;
- vertexShader: string;
- }
- interface IGLTFTechniqueParameter {
- type: number;
- count?: number;
- semantic?: string;
- node?: string;
- value?: number | boolean | string | Array<any>;
- source?: string;
- babylonValue?: any;
- }
- interface IGLTFTechniqueCommonProfile {
- lightingModel: string;
- texcoordBindings: Object;
- parameters?: Array<any>;
- }
- interface IGLTFTechniqueStatesFunctions {
- blendColor?: number[];
- blendEquationSeparate?: number[];
- blendFuncSeparate?: number[];
- colorMask: boolean[];
- cullFace: number[];
- }
- interface IGLTFTechniqueStates {
- enable: number[];
- functions: IGLTFTechniqueStatesFunctions;
- }
- interface IGLTFTechnique extends IGLTFChildRootProperty {
- parameters: {
- [key: string]: IGLTFTechniqueParameter;
- };
- program: string;
- attributes: {
- [key: string]: string;
- };
- uniforms: {
- [key: string]: string;
- };
- states: IGLTFTechniqueStates;
- }
- interface IGLTFMaterial extends IGLTFChildRootProperty {
- technique?: string;
- values: string[];
- }
- interface IGLTFMeshPrimitive extends IGLTFProperty {
- attributes: {
- [key: string]: string;
- };
- indices: string;
- material: string;
- mode?: number;
- }
- interface IGLTFMesh extends IGLTFChildRootProperty {
- primitives: IGLTFMeshPrimitive[];
- }
- interface IGLTFImage extends IGLTFChildRootProperty {
- uri: string;
- }
- interface IGLTFSampler extends IGLTFChildRootProperty {
- magFilter?: number;
- minFilter?: number;
- wrapS?: number;
- wrapT?: number;
- }
- interface IGLTFTexture extends IGLTFChildRootProperty {
- sampler: string;
- source: string;
- format?: ETextureFormat;
- internalFormat?: ETextureFormat;
- target?: number;
- type?: number;
- babylonTexture?: Texture;
- }
- interface IGLTFAmbienLight {
- color?: number[];
- }
- interface IGLTFDirectionalLight {
- color?: number[];
- }
- interface IGLTFPointLight {
- color?: number[];
- constantAttenuation?: number;
- linearAttenuation?: number;
- quadraticAttenuation?: number;
- }
- interface IGLTFSpotLight {
- color?: number[];
- constantAttenuation?: number;
- fallOfAngle?: number;
- fallOffExponent?: number;
- linearAttenuation?: number;
- quadraticAttenuation?: number;
- }
- interface IGLTFLight extends IGLTFChildRootProperty {
- type: string;
- }
- interface IGLTFCameraOrthographic {
- xmag: number;
- ymag: number;
- zfar: number;
- znear: number;
- }
- interface IGLTFCameraPerspective {
- aspectRatio: number;
- yfov: number;
- zfar: number;
- znear: number;
- }
- interface IGLTFCamera extends IGLTFChildRootProperty {
- type: string;
- }
- interface IGLTFAnimationChannelTarget {
- id: string;
- path: string;
- }
- interface IGLTFAnimationChannel {
- sampler: string;
- target: IGLTFAnimationChannelTarget;
- }
- interface IGLTFAnimationSampler {
- input: string;
- output: string;
- interpolation?: string;
- }
- interface IGLTFAnimation extends IGLTFChildRootProperty {
- channels?: IGLTFAnimationChannel[];
- parameters?: {
- [key: string]: string;
- };
- samplers?: {
- [key: string]: IGLTFAnimationSampler;
- };
- }
- interface IGLTFNodeInstanceSkin {
- skeletons: string[];
- skin: string;
- meshes: string[];
- }
- interface IGLTFSkins extends IGLTFChildRootProperty {
- bindShapeMatrix: number[];
- inverseBindMatrices: string;
- jointNames: string[];
- babylonSkeleton?: Skeleton;
- }
- interface IGLTFNode extends IGLTFChildRootProperty {
- camera?: string;
- children: string[];
- skin?: string;
- jointName?: string;
- light?: string;
- matrix: number[];
- mesh?: string;
- meshes?: string[];
- rotation?: number[];
- scale?: number[];
- translation?: number[];
- babylonNode?: Node;
- }
- interface IGLTFScene extends IGLTFChildRootProperty {
- nodes: string[];
- }
- /**
- * Runtime
- */
- interface IGLTFRuntime {
- extensions: {
- [key: string]: any;
- };
- accessors: {
- [key: string]: IGLTFAccessor;
- };
- buffers: {
- [key: string]: IGLTFBuffer;
- };
- bufferViews: {
- [key: string]: IGLTFBufferView;
- };
- meshes: {
- [key: string]: IGLTFMesh;
- };
- lights: {
- [key: string]: IGLTFLight;
- };
- cameras: {
- [key: string]: IGLTFCamera;
- };
- nodes: {
- [key: string]: IGLTFNode;
- };
- images: {
- [key: string]: IGLTFImage;
- };
- textures: {
- [key: string]: IGLTFTexture;
- };
- shaders: {
- [key: string]: IGLTFShader;
- };
- programs: {
- [key: string]: IGLTFProgram;
- };
- samplers: {
- [key: string]: IGLTFSampler;
- };
- techniques: {
- [key: string]: IGLTFTechnique;
- };
- materials: {
- [key: string]: IGLTFMaterial;
- };
- animations: {
- [key: string]: IGLTFAnimation;
- };
- skins: {
- [key: string]: IGLTFSkins;
- };
- currentScene?: Object;
- scenes: {
- [key: string]: IGLTFScene;
- };
- extensionsUsed: string[];
- extensionsRequired?: string[];
- buffersCount: number;
- shaderscount: number;
- scene: Scene;
- rootUrl: string;
- loadedBufferCount: number;
- loadedBufferViews: {
- [name: string]: ArrayBufferView;
- };
- loadedShaderCount: number;
- importOnlyMeshes: boolean;
- importMeshesNames?: string[];
- dummyNodes: Node[];
- }
- /**
- * Bones
- */
- interface INodeToRoot {
- bone: Bone;
- node: IGLTFNode;
- id: string;
- }
- interface IJointNode {
- node: IGLTFNode;
- id: string;
- }
- }
- declare module BABYLON.GLTF1 {
- /**
- * Implementation of the base glTF spec
- */
- class GLTFLoaderBase {
- static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
- static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
- static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
- static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
- static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
- }
- /**
- * glTF V1 Loader
- */
- class GLTFLoader implements IGLTFLoader {
- static Extensions: {
- [name: string]: GLTFLoaderExtension;
- };
- static RegisterExtension(extension: GLTFLoaderExtension): void;
- state: Nullable<GLTFLoaderState>;
- dispose(): void;
- private _importMeshAsync;
- /**
- * Imports one or more meshes from a loaded gltf file 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
- * @param data gltf data containing information of the meshes in a loaded file
- * @param rootUrl root url to load from
- * @param onProgress event that fires when loading progress has occured
- * @returns a promise containg the loaded meshes, particles, skeletons and animations
- */
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
- meshes: AbstractMesh[];
- particleSystems: IParticleSystem[];
- skeletons: Skeleton[];
- animationGroups: AnimationGroup[];
- }>;
- private _loadAsync;
- /**
- * Imports all objects from a loaded gltf file and adds them to the scene
- * @param scene the scene the objects should be added to
- * @param data gltf data containing information of the meshes in a loaded file
- * @param rootUrl root url to load from
- * @param onProgress event that fires when loading progress has occured
- * @returns a promise which completes when objects have been loaded to the scene
- */
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
- private _loadShadersAsync;
- private _loadBuffersAsync;
- private _createNodes;
- }
- }
- declare module BABYLON.GLTF1 {
- /**
- * Utils functions for GLTF
- */
- class GLTFUtils {
- /**
- * Sets the given "parameter" matrix
- * @param scene: the {BABYLON.Scene} object
- * @param source: the source node where to pick the matrix
- * @param parameter: the GLTF technique parameter
- * @param uniformName: the name of the shader's uniform
- * @param shaderMaterial: the shader material
- */
- static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
- /**
- * Sets the given "parameter" matrix
- * @param shaderMaterial: the shader material
- * @param uniform: the name of the shader's uniform
- * @param value: the value of the uniform
- * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
- */
- static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
- /**
- * Returns the wrap mode of the texture
- * @param mode: the mode value
- */
- static GetWrapMode(mode: number): number;
- /**
- * Returns the byte stride giving an accessor
- * @param accessor: the GLTF accessor objet
- */
- static GetByteStrideFromType(accessor: IGLTFAccessor): number;
- /**
- * Returns the texture filter mode giving a mode value
- * @param mode: the filter mode value
- */
- static GetTextureFilterMode(mode: number): ETextureFilterType;
- static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
- /**
- * Returns a buffer from its accessor
- * @param gltfRuntime: the GLTF runtime
- * @param accessor: the GLTF accessor
- */
- static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
- /**
- * Decodes a buffer view into a string
- * @param view: the buffer view
- */
- static DecodeBufferToText(view: ArrayBufferView): string;
- /**
- * Returns the default material of gltf. Related to
- * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
- * @param scene: the Babylon.js scene
- */
- static GetDefaultMaterial(scene: Scene): ShaderMaterial;
- private static _DefaultMaterial;
- }
- }
- declare module BABYLON.GLTF1 {
- abstract class GLTFLoaderExtension {
- private _name;
- constructor(name: string);
- readonly name: string;
- /**
- * Defines an override for loading the runtime
- * Return true to stop further extensions from loading the runtime
- */
- loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
- /**
- * Defines an onverride for creating gltf runtime
- * Return true to stop further extensions from creating the runtime
- */
- loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
- /**
- * Defines an override for loading buffers
- * Return true to stop further extensions from loading this buffer
- */
- loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
- /**
- * Defines an override for loading texture buffers
- * Return true to stop further extensions from loading this texture data
- */
- loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
- /**
- * Defines an override for creating textures
- * Return true to stop further extensions from loading this texture
- */
- createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
- /**
- * Defines an override for loading shader strings
- * Return true to stop further extensions from loading this shader data
- */
- loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
- /**
- * Defines an override for loading materials
- * Return true to stop further extensions from loading this material
- */
- loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
- static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
- static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
- static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
- static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
- static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
- static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
- private static LoadTextureBufferAsync;
- private static CreateTextureAsync;
- private static ApplyExtensions;
- }
- }
- declare module BABYLON.GLTF1 {
- class GLTFBinaryExtension extends GLTFLoaderExtension {
- private _bin;
- constructor();
- loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
- loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
- loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
- loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
- }
- }
- declare module BABYLON.GLTF1 {
- class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
- constructor();
- loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
- loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
- private _loadTexture;
- }
- }
- declare module BABYLON.GLTF2.Loader {
- /**
- * Loader interface with an index field.
- */
- interface IArrayItem {
- /**
- * The index of this item in the array.
- */
- index: number;
- }
- /**
- * Loader interface with additional members.
- */
- interface IAccessor extends GLTF2.IAccessor, IArrayItem {
- /** @hidden */
- _data?: Promise<ArrayBufferView>;
- /** @hidden */
- _babylonVertexBuffer?: Promise<VertexBuffer>;
- }
- /**
- * Loader interface with additional members.
- */
- interface IAnimationChannel extends GLTF2.IAnimationChannel, IArrayItem {
- }
- /** @hidden */
- interface _IAnimationSamplerData {
- input: Float32Array;
- interpolation: AnimationSamplerInterpolation;
- output: Float32Array;
- }
- /**
- * Loader interface with additional members.
- */
- interface IAnimationSampler extends GLTF2.IAnimationSampler, IArrayItem {
- /** @hidden */
- _data?: Promise<_IAnimationSamplerData>;
- }
- /**
- * Loader interface with additional members.
- */
- interface IAnimation extends GLTF2.IAnimation, IArrayItem {
- channels: IAnimationChannel[];
- samplers: IAnimationSampler[];
- /** @hidden */
- _babylonAnimationGroup?: AnimationGroup;
- }
- /**
- * Loader interface with additional members.
- */
- interface IBuffer extends GLTF2.IBuffer, IArrayItem {
- /** @hidden */
- _data?: Promise<ArrayBufferView>;
- }
- /**
- * Loader interface with additional members.
- */
- interface IBufferView extends GLTF2.IBufferView, IArrayItem {
- /** @hidden */
- _data?: Promise<ArrayBufferView>;
- /** @hidden */
- _babylonBuffer?: Promise<Buffer>;
- }
- /**
- * Loader interface with additional members.
- */
- interface ICamera extends GLTF2.ICamera, IArrayItem {
- }
- /**
- * Loader interface with additional members.
- */
- interface IImage extends GLTF2.IImage, IArrayItem {
- /** @hidden */
- _data?: Promise<ArrayBufferView>;
- }
- /**
- * Loader interface with additional members.
- */
- interface IMaterialNormalTextureInfo extends GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
- }
- /**
- * Loader interface with additional members.
- */
- interface IMaterialOcclusionTextureInfo extends GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
- }
- /**
- * Loader interface with additional members.
- */
- interface IMaterialPbrMetallicRoughness extends GLTF2.IMaterialPbrMetallicRoughness {
- baseColorTexture?: ITextureInfo;
- metallicRoughnessTexture?: ITextureInfo;
- }
- /**
- * Loader interface with additional members.
- */
- interface IMaterial extends GLTF2.IMaterial, IArrayItem {
- pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
- normalTexture?: IMaterialNormalTextureInfo;
- occlusionTexture?: IMaterialOcclusionTextureInfo;
- emissiveTexture?: ITextureInfo;
- /** @hidden */
- _babylonData?: {
- [drawMode: number]: {
- material: Material;
- meshes: AbstractMesh[];
- promise: Promise<void>;
- };
- };
- }
- /**
- * Loader interface with additional members.
- */
- interface IMesh extends GLTF2.IMesh, IArrayItem {
- primitives: IMeshPrimitive[];
- }
- /**
- * Loader interface with additional members.
- */
- interface IMeshPrimitive extends GLTF2.IMeshPrimitive, IArrayItem {
- }
- /**
- * Loader interface with additional members.
- */
- interface INode extends GLTF2.INode, IArrayItem {
- /**
- * The parent glTF node.
- */
- parent?: INode;
- /** @hidden */
- _babylonMesh?: Mesh;
- /** @hidden */
- _primitiveBabylonMeshes?: Mesh[];
- /** @hidden */
- _babylonBones?: Bone[];
- /** @hidden */
- _numMorphTargets?: number;
- }
- /** @hidden */
- interface _ISamplerData {
- noMipMaps: boolean;
- samplingMode: number;
- wrapU: number;
- wrapV: number;
- }
- /**
- * Loader interface with additional members.
- */
- interface ISampler extends GLTF2.ISampler, IArrayItem {
- /** @hidden */
- _data?: _ISamplerData;
- }
- /**
- * Loader interface with additional members.
- */
- interface IScene extends GLTF2.IScene, IArrayItem {
- }
- /**
- * Loader interface with additional members.
- */
- interface ISkin extends GLTF2.ISkin, IArrayItem {
- /** @hidden */
- _babylonSkeleton?: Skeleton;
- /** @hidden */
- _promise?: Promise<void>;
- }
- /**
- * Loader interface with additional members.
- */
- interface ITexture extends GLTF2.ITexture, IArrayItem {
- }
- /**
- * Loader interface with additional members.
- */
- interface ITextureInfo extends GLTF2.ITextureInfo {
- }
- /**
- * Loader interface with additional members.
- */
- interface IGLTF extends GLTF2.IGLTF {
- accessors?: IAccessor[];
- animations?: IAnimation[];
- buffers?: IBuffer[];
- bufferViews?: IBufferView[];
- cameras?: ICamera[];
- images?: IImage[];
- materials?: IMaterial[];
- meshes?: IMesh[];
- nodes?: INode[];
- samplers?: ISampler[];
- scenes?: IScene[];
- skins?: ISkin[];
- textures?: ITexture[];
- }
- }
- /**
- * Defines the module for importing and exporting glTF 2.0 assets
- */
- declare module BABYLON.GLTF2 {
- /**
- * Helper class for working with arrays when loading the glTF asset
- */
- class ArrayItem {
- /**
- * Gets an item from the given array.
- * @param context The context when loading the asset
- * @param array The array to get the item from
- * @param index The index to the array
- * @returns The array item
- */
- static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
- /**
- * Assign an `index` field to each item of the given array.
- * @param array The array of items
- */
- static Assign(array?: Loader.IArrayItem[]): void;
- }
- /**
- * The glTF 2.0 loader
- */
- class GLTFLoader implements IGLTFLoader {
- /** The glTF object parsed from the JSON. */
- gltf: Loader.IGLTF;
- /** The Babylon scene when loading the asset. */
- babylonScene: Scene;
- /** @hidden */
- _completePromises: Promise<any>[];
- private _disposed;
- private _parent;
- private _state;
- private _extensions;
- private _rootUrl;
- private _fileName;
- private _uniqueRootUrl;
- private _rootBabylonMesh;
- private _defaultBabylonMaterialData;
- private _progressCallback?;
- private _requests;
- private static readonly _DefaultSampler;
- private static _ExtensionNames;
- private static _ExtensionFactories;
- /**
- * Registers a loader extension.
- * @param name The name of the loader extension.
- * @param factory The factory function that creates the loader extension.
- */
- static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
- /**
- * Unregisters a loader extension.
- * @param name The name of the loader extenion.
- * @returns A boolean indicating whether the extension has been unregistered
- */
- static UnregisterExtension(name: string): boolean;
- /**
- * Gets the loader state.
- */
- readonly state: Nullable<GLTFLoaderState>;
- /** @hidden */
- constructor(parent: GLTFFileLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
- meshes: AbstractMesh[];
- particleSystems: IParticleSystem[];
- skeletons: Skeleton[];
- animationGroups: AnimationGroup[];
- }>;
- /** @hidden */
- loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
- private _loadAsync;
- private _loadData;
- private _setupData;
- private _loadExtensions;
- private _checkExtensions;
- private _setState;
- private _createRootNode;
- /**
- * Loads a glTF scene.
- * @param context The context when loading the asset
- * @param scene The glTF scene property
- * @returns A promise that resolves when the load is complete
- */
- loadSceneAsync(context: string, scene: Loader.IScene): Promise<void>;
- private _forEachPrimitive;
- private _getMeshes;
- private _getSkeletons;
- private _getAnimationGroups;
- private _startAnimations;
- /**
- * Loads a glTF node.
- * @param context The context when loading the asset
- * @param node The glTF node property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
- */
- loadNodeAsync(context: string, node: Loader.INode, assign?: (babylonMesh: Mesh) => void): Promise<Mesh>;
- private _loadMeshAsync;
- private _loadMeshPrimitiveAsync;
- private _loadVertexDataAsync;
- private _createMorphTargets;
- private _loadMorphTargetsAsync;
- private _loadMorphTargetVertexDataAsync;
- private static _LoadTransform;
- private _loadSkinAsync;
- private _loadBones;
- private _loadBone;
- private _loadSkinInverseBindMatricesDataAsync;
- private _updateBoneMatrices;
- private _getNodeMatrix;
- /**
- * Loads a glTF camera.
- * @param context The context when loading the asset
- * @param camera The glTF camera property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon camera when the load is complete
- */
- loadCameraAsync(context: string, camera: Loader.ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
- private _loadAnimationsAsync;
- /**
- * Loads a glTF animation.
- * @param context The context when loading the asset
- * @param animation The glTF animation property
- * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
- */
- loadAnimationAsync(context: string, animation: Loader.IAnimation): Promise<AnimationGroup>;
- private _loadAnimationChannelAsync;
- private _loadAnimationSamplerAsync;
- private _loadBufferAsync;
- /**
- * Loads a glTF buffer view.
- * @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
- */
- loadBufferViewAsync(context: string, bufferView: Loader.IBufferView): Promise<ArrayBufferView>;
- private _loadIndicesAccessorAsync;
- private _loadFloatAccessorAsync;
- private _loadVertexBufferViewAsync;
- private _loadVertexAccessorAsync;
- private _loadMaterialMetallicRoughnessPropertiesAsync;
- /** @hidden */
- _loadMaterialAsync(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
- private _createDefaultMaterial;
- /**
- * Creates a Babylon material from a glTF material.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonDrawMode The draw mode for the Babylon material
- * @returns The Babylon material
- */
- createMaterial(context: string, material: Loader.IMaterial, babylonDrawMode: number): Material;
- /**
- * Loads properties from a glTF material into a Babylon material.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonMaterial The Babylon material
- * @returns A promise that resolves when the load is complete
- */
- loadMaterialPropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
- /**
- * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonMaterial The Babylon material
- * @returns A promise that resolves when the load is complete
- */
- loadMaterialBasePropertiesAsync(context: string, material: Loader.IMaterial, babylonMaterial: Material): Promise<void>;
- /**
- * Loads the alpha properties from a glTF material into a Babylon material.
- * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonMaterial The Babylon material
- */
- loadMaterialAlphaProperties(context: string, material: Loader.IMaterial, babylonMaterial: Material): void;
- /**
- * Loads a glTF texture info.
- * @param context The context when loading the asset
- * @param textureInfo The glTF texture info property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon texture when the load is complete
- */
- loadTextureInfoAsync(context: string, textureInfo: Loader.ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
- private _loadTextureAsync;
- private _loadSampler;
- /**
- * Loads a glTF image.
- * @param context The context when loading the asset
- * @param image The glTF image property
- * @returns A promise that resolves with the loaded data when the load is complete
- */
- loadImageAsync(context: string, image: Loader.IImage): Promise<ArrayBufferView>;
- /**
- * Loads a glTF uri.
- * @param context The context when loading the asset
- * @param uri The base64 or relative uri
- * @returns A promise that resolves with the loaded data when the load is complete
- */
- loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
- private _onProgress;
- private static _GetTextureWrapMode;
- private static _GetTextureSamplingMode;
- private static _GetTypedArray;
- private static _GetNumComponents;
- private static _ValidateUri;
- private static _GetDrawMode;
- private _compileMaterialsAsync;
- private _compileShadowGeneratorsAsync;
- private _forEachExtensions;
- private _applyExtensions;
- private _extensionsOnLoading;
- private _extensionsOnReady;
- private _extensionsLoadSceneAsync;
- private _extensionsLoadNodeAsync;
- private _extensionsLoadCameraAsync;
- private _extensionsLoadVertexDataAsync;
- private _extensionsLoadMaterialAsync;
- private _extensionsCreateMaterial;
- private _extensionsLoadMaterialPropertiesAsync;
- private _extensionsLoadTextureInfoAsync;
- private _extensionsLoadAnimationAsync;
- private _extensionsLoadUriAsync;
- /**
- * Helper method called by a loader extension to load an glTF extension.
- * @param context The context when loading the asset
- * @param property The glTF property to load the extension from
- * @param extensionName The name of the extension to load
- * @param actionAsync The action to run
- * @returns The promise returned by actionAsync or null if the extension does not exist
- */
- static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
- /**
- * Helper method called by a loader extension to load a glTF extra.
- * @param context The context when loading the asset
- * @param property The glTF property to load the extra from
- * @param extensionName The name of the extension to load
- * @param actionAsync The action to run
- * @returns The promise returned by actionAsync or null if the extra does not exist
- */
- static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
- /**
- * Increments the indentation level and logs a message.
- * @param message The message to log
- */
- logOpen(message: string): void;
- /**
- * Decrements the indentation level.
- */
- logClose(): void;
- /**
- * Logs a message
- * @param message The message to log
- */
- log(message: string): void;
- /**
- * Starts a performance counter.
- * @param counterName The name of the performance counter
- */
- startPerformanceCounter(counterName: string): void;
- /**
- * Ends a performance counter.
- * @param counterName The name of the performance counter
- */
- endPerformanceCounter(counterName: string): void;
- }
- }
- declare module BABYLON.GLTF2 {
- /**
- * Interface for a glTF loader extension.
- */
- interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
- /**
- * Called after the loader state changes to LOADING.
- */
- onLoading?(): void;
- /**
- * Called after the loader state changes to READY.
- */
- onReady?(): void;
- /**
- * Define this method to modify the default behavior when loading scenes.
- * @param context The context when loading the asset
- * @param scene The glTF scene property
- * @returns A promise that resolves when the load is complete or null if not handled
- */
- loadSceneAsync?(context: string, scene: Loader.IScene): Nullable<Promise<void>>;
- /**
- * Define this method to modify the default behavior when loading nodes.
- * @param context The context when loading the asset
- * @param node The glTF node property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
- */
- loadNodeAsync?(context: string, node: Loader.INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
- /**
- * Define this method to modify the default behavior when loading cameras.
- * @param context The context when loading the asset
- * @param camera The glTF camera property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
- */
- loadCameraAsync?(context: string, camera: Loader.ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
- /**
- * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
- * @param context The context when loading the asset
- * @param primitive The glTF mesh primitive property
- * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
- */
- _loadVertexDataAsync?(context: string, primitive: Loader.IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
- /**
- * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
- */
- _loadMaterialAsync?(context: string, material: Loader.IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
- /**
- * Define this method to modify the default behavior when creating materials.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonDrawMode The draw mode for the Babylon material
- * @returns The Babylon material or null if not handled
- */
- createMaterial?(context: string, material: Loader.IMaterial, babylonDrawMode: number): Nullable<Material>;
- /**
- * Define this method to modify the default behavior when loading material properties.
- * @param context The context when loading the asset
- * @param material The glTF material property
- * @param babylonMaterial The Babylon material
- * @returns A promise that resolves when the load is complete or null if not handled
- */
- loadMaterialPropertiesAsync?(context: string, material: Loader.IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
- /**
- * Define this method to modify the default behavior when loading texture infos.
- * @param context The context when loading the asset
- * @param textureInfo The glTF texture info property
- * @param assign A function called synchronously after parsing the glTF properties
- * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
- */
- loadTextureInfoAsync?(context: string, textureInfo: Loader.ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
- /**
- * Define this method to modify the default behavior when loading animations.
- * @param context The context when loading the asset
- * @param animation The glTF animation property
- * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
- */
- loadAnimationAsync?(context: string, animation: Loader.IAnimation): Nullable<Promise<AnimationGroup>>;
- /**
- * Define this method to modify the default behavior when loading uris.
- * @param context The context when loading the asset
- * @param uri The uri to load
- * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
- */
- _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
- }
- }
- /**
- * Defines the module for the built-in glTF 2.0 loader extensions.
- */
- declare module BABYLON.GLTF2.Loader.Extensions {
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /**
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
- */
- class MSFT_lod implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- /**
- * Maximum number of LODs to load, starting from the lowest LOD.
- */
- maxLODsToLoad: number;
- /**
- * Observable raised when all node LODs of one level are loaded.
- * The event data is the index of the loaded LOD starting from zero.
- * Dispose the loader to cancel the loading of the next level of LODs.
- */
- onNodeLODsLoadedObservable: Observable<number>;
- /**
- * Observable raised when all material LODs of one level are loaded.
- * The event data is the index of the loaded LOD starting from zero.
- * Dispose the loader to cancel the loading of the next level of LODs.
- */
- onMaterialLODsLoadedObservable: Observable<number>;
- private _loader;
- private _nodeIndexLOD;
- private _nodeSignalLODs;
- private _nodePromiseLODs;
- private _materialIndexLOD;
- private _materialSignalLODs;
- private _materialPromiseLODs;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- onReady(): void;
- /** @hidden */
- loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
- /** @hidden */
- _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
- /** @hidden */
- _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
- /**
- * Gets an array of LOD properties from lowest to highest.
- */
- private _getLODs;
- private _disposeUnusedMaterials;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /** @hidden */
- class MSFT_minecraftMesh implements IGLTFLoaderExtension {
- readonly name: string;
- enabled: boolean;
- private _loader;
- constructor(loader: GLTFLoader);
- dispose(): void;
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /** @hidden */
- class MSFT_sRGBFactors implements IGLTFLoaderExtension {
- readonly name: string;
- enabled: boolean;
- private _loader;
- constructor(loader: GLTFLoader);
- dispose(): void;
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /**
- * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
- */
- class MSFT_audio_emitter implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- private _loader;
- private _clips;
- private _emitters;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- onLoading(): void;
- /** @hidden */
- loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
- /** @hidden */
- loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
- /** @hidden */
- loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
- private _loadClipAsync;
- private _loadEmitterAsync;
- private _getEventAction;
- private _loadAnimationEventAsync;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /**
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
- */
- class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- private _loader;
- private _dracoCompression?;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /**
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
- */
- class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- private _loader;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
- private _loadSpecularGlossinessPropertiesAsync;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /**
- * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
- */
- class KHR_materials_unlit implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- private _loader;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
- private _loadUnlitPropertiesAsync;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /**
- * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
- */
- class KHR_lights implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- private _loader;
- private _lights?;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- onLoading(): void;
- /** @hidden */
- loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
- }
- }
- declare module BABYLON.GLTF2.Loader.Extensions {
- /**
- * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
- */
- class KHR_texture_transform implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- private _loader;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
- }
- }
- 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)
- */
- class EXT_lights_image_based implements IGLTFLoaderExtension {
- /** The name of this extension. */
- readonly name: string;
- /** Defines whether this extension is enabled. */
- enabled: boolean;
- private _loader;
- private _lights?;
- /** @hidden */
- constructor(loader: GLTFLoader);
- /** @hidden */
- dispose(): void;
- /** @hidden */
- onLoading(): void;
- /** @hidden */
- loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
- private _loadLightAsync;
- }
- }
|