babylonjs.loaders.d.ts 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619
  1. /*BabylonJS Loaders*/
  2. // Dependencies for this module:
  3. // ../../../../Tools/Gulp/babylonjs
  4. // ../../../../Tools/Gulp/babylonjs-gltf2interface
  5. declare module BABYLON {
  6. /**
  7. * Mode that determines the coordinate system to use.
  8. */
  9. export enum GLTFLoaderCoordinateSystemMode {
  10. /**
  11. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  12. */
  13. AUTO = 0,
  14. /**
  15. * Sets the useRightHandedSystem flag on the scene.
  16. */
  17. FORCE_RIGHT_HANDED = 1
  18. }
  19. /**
  20. * Mode that determines what animations will start.
  21. */
  22. export enum GLTFLoaderAnimationStartMode {
  23. /**
  24. * No animation will start.
  25. */
  26. NONE = 0,
  27. /**
  28. * The first animation will start.
  29. */
  30. FIRST = 1,
  31. /**
  32. * All animations will start.
  33. */
  34. ALL = 2
  35. }
  36. /**
  37. * Interface that contains the data for the glTF asset.
  38. */
  39. export interface IGLTFLoaderData {
  40. /**
  41. * Object that represents the glTF JSON.
  42. */
  43. json: Object;
  44. /**
  45. * The BIN chunk of a binary glTF.
  46. */
  47. bin: BABYLON.Nullable<ArrayBufferView>;
  48. }
  49. /**
  50. * Interface for extending the loader.
  51. */
  52. export interface IGLTFLoaderExtension {
  53. /**
  54. * The name of this extension.
  55. */
  56. readonly name: string;
  57. /**
  58. * Defines whether this extension is enabled.
  59. */
  60. enabled: boolean;
  61. }
  62. /**
  63. * Loader state.
  64. */
  65. export enum GLTFLoaderState {
  66. /**
  67. * The asset is loading.
  68. */
  69. LOADING = 0,
  70. /**
  71. * The asset is ready for rendering.
  72. */
  73. READY = 1,
  74. /**
  75. * The asset is completely loaded.
  76. */
  77. COMPLETE = 2
  78. }
  79. /** @hidden */
  80. export interface IGLTFLoader extends BABYLON.IDisposable {
  81. readonly state: BABYLON.Nullable<GLTFLoaderState>;
  82. importMeshAsync: (meshesNames: any, scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  83. meshes: BABYLON.AbstractMesh[];
  84. particleSystems: BABYLON.IParticleSystem[];
  85. skeletons: BABYLON.Skeleton[];
  86. animationGroups: BABYLON.AnimationGroup[];
  87. }>;
  88. loadAsync: (scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  89. }
  90. /**
  91. * File loader for loading glTF files into a scene.
  92. */
  93. export class GLTFFileLoader implements BABYLON.IDisposable, BABYLON.ISceneLoaderPluginAsync, BABYLON.ISceneLoaderPluginFactory {
  94. /** @hidden */
  95. static _CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
  96. /** @hidden */
  97. static _CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
  98. /**
  99. * Raised when the asset has been parsed
  100. */
  101. onParsedObservable: BABYLON.Observable<IGLTFLoaderData>;
  102. /**
  103. * Raised when the asset has been parsed
  104. */
  105. onParsed: (loaderData: IGLTFLoaderData) => void;
  106. /**
  107. * 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.
  108. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  109. * Defaults to true.
  110. * @hidden
  111. */
  112. static IncrementalLoading: boolean;
  113. /**
  114. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  115. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  116. * @hidden
  117. */
  118. static HomogeneousCoordinates: boolean;
  119. /**
  120. * The coordinate system mode. Defaults to AUTO.
  121. */
  122. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  123. /**
  124. * The animation start mode. Defaults to FIRST.
  125. */
  126. animationStartMode: GLTFLoaderAnimationStartMode;
  127. /**
  128. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  129. */
  130. compileMaterials: boolean;
  131. /**
  132. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  133. */
  134. useClipPlane: boolean;
  135. /**
  136. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  137. */
  138. compileShadowGenerators: boolean;
  139. /**
  140. * Defines if the Alpha blended materials are only applied as coverage.
  141. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  142. * If true, no extra effects are applied to transparent pixels.
  143. */
  144. transparencyAsCoverage: boolean;
  145. /**
  146. * Function called before loading a url referenced by the asset.
  147. */
  148. preprocessUrlAsync: (url: string) => Promise<string>;
  149. /**
  150. * BABYLON.Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  151. */
  152. readonly onMeshLoadedObservable: BABYLON.Observable<BABYLON.AbstractMesh>;
  153. /**
  154. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  155. */
  156. onMeshLoaded: (mesh: BABYLON.AbstractMesh) => void;
  157. /**
  158. * BABYLON.Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  159. */
  160. readonly onTextureLoadedObservable: BABYLON.Observable<BABYLON.BaseTexture>;
  161. /**
  162. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  163. */
  164. onTextureLoaded: (texture: BABYLON.BaseTexture) => void;
  165. /**
  166. * BABYLON.Observable raised when the loader creates a material after parsing the glTF properties of the material.
  167. */
  168. readonly onMaterialLoadedObservable: BABYLON.Observable<BABYLON.Material>;
  169. /**
  170. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  171. */
  172. onMaterialLoaded: (material: BABYLON.Material) => void;
  173. /**
  174. * BABYLON.Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  175. */
  176. readonly onCameraLoadedObservable: BABYLON.Observable<BABYLON.Camera>;
  177. /**
  178. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  179. */
  180. onCameraLoaded: (camera: BABYLON.Camera) => void;
  181. /**
  182. * BABYLON.Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  183. * For assets with LODs, raised when all of the LODs are complete.
  184. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  185. */
  186. readonly onCompleteObservable: BABYLON.Observable<void>;
  187. /**
  188. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  189. * For assets with LODs, raised when all of the LODs are complete.
  190. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  191. */
  192. onComplete: () => void;
  193. /**
  194. * BABYLON.Observable raised when an error occurs.
  195. */
  196. readonly onErrorObservable: BABYLON.Observable<any>;
  197. /**
  198. * Callback raised when an error occurs.
  199. */
  200. onError: (reason: any) => void;
  201. /**
  202. * BABYLON.Observable raised after the loader is disposed.
  203. */
  204. readonly onDisposeObservable: BABYLON.Observable<void>;
  205. /**
  206. * Callback raised after the loader is disposed.
  207. */
  208. onDispose: () => void;
  209. /**
  210. * BABYLON.Observable raised after a loader extension is created.
  211. * Set additional options for a loader extension in this event.
  212. */
  213. readonly onExtensionLoadedObservable: BABYLON.Observable<IGLTFLoaderExtension>;
  214. /**
  215. * Callback raised after a loader extension is created.
  216. */
  217. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  218. /**
  219. * Defines if the loader logging is enabled.
  220. */
  221. loggingEnabled: boolean;
  222. /**
  223. * Defines if the loader should capture performance counters.
  224. */
  225. capturePerformanceCounters: boolean;
  226. /**
  227. * Defines if the loader should validate the asset.
  228. */
  229. validate: boolean;
  230. /**
  231. * BABYLON.Observable raised after validation when validate is set to true. The event data is the result of the validation.
  232. */
  233. readonly onValidatedObservable: BABYLON.Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  234. /**
  235. * Callback raised after a loader extension is created.
  236. */
  237. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  238. /**
  239. * Name of the loader ("gltf")
  240. */
  241. name: string;
  242. /**
  243. * Supported file extensions of the loader (.gltf, .glb)
  244. */
  245. extensions: BABYLON.ISceneLoaderPluginExtensions;
  246. /**
  247. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  248. */
  249. dispose(): void;
  250. /** @hidden */
  251. _clear(): void;
  252. /**
  253. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  254. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  255. * @param scene the scene the meshes should be added to
  256. * @param data the glTF data to load
  257. * @param rootUrl root url to load from
  258. * @param onProgress event that fires when loading progress has occured
  259. * @param fileName Defines the name of the file to load
  260. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  261. */
  262. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: any, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  263. meshes: BABYLON.AbstractMesh[];
  264. particleSystems: BABYLON.IParticleSystem[];
  265. skeletons: BABYLON.Skeleton[];
  266. animationGroups: BABYLON.AnimationGroup[];
  267. }>;
  268. /**
  269. * Imports all objects from the loaded glTF data and adds them to the scene
  270. * @param scene the scene the objects should be added to
  271. * @param data the glTF data to load
  272. * @param rootUrl root url to load from
  273. * @param onProgress event that fires when loading progress has occured
  274. * @param fileName Defines the name of the file to load
  275. * @returns a promise which completes when objects have been loaded to the scene
  276. */
  277. loadAsync(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  278. /**
  279. * Load into an asset container.
  280. * @param scene The scene to load into
  281. * @param data The data to import
  282. * @param rootUrl The root url for scene and resources
  283. * @param onProgress The callback when the load progresses
  284. * @param fileName Defines the name of the file to load
  285. * @returns The loaded asset container
  286. */
  287. loadAssetContainerAsync(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<BABYLON.AssetContainer>;
  288. /**
  289. * If the data string can be loaded directly.
  290. * @param data string contianing the file data
  291. * @returns if the data can be loaded directly
  292. */
  293. canDirectLoad(data: string): boolean;
  294. /**
  295. * Rewrites a url by combining a root url and response url.
  296. */
  297. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  298. /**
  299. * Instantiates a glTF file loader plugin.
  300. * @returns the created plugin
  301. */
  302. createPlugin(): BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync;
  303. /**
  304. * The loader state or null if the loader is not active.
  305. */
  306. readonly loaderState: BABYLON.Nullable<GLTFLoaderState>;
  307. /**
  308. * Returns a promise that resolves when the asset is completely loaded.
  309. * @returns a promise that resolves when the asset is completely loaded.
  310. */
  311. whenCompleteAsync(): Promise<void>;
  312. /** @hidden */
  313. _log: (message: string) => void;
  314. /** @hidden */
  315. _logOpen(message: string): void;
  316. /** @hidden */
  317. _logClose(): void;
  318. /** @hidden */
  319. _startPerformanceCounter: (counterName: string) => void;
  320. /** @hidden */
  321. _endPerformanceCounter: (counterName: string) => void;
  322. }
  323. }
  324. declare module BABYLON {
  325. /**
  326. * Class reading and parsing the MTL file bundled with the obj file.
  327. */
  328. export class MTLFileLoader {
  329. materials: BABYLON.StandardMaterial[];
  330. /**
  331. * This function will read the mtl file and create each material described inside
  332. * This function could be improve by adding :
  333. * -some component missing (Ni, Tf...)
  334. * -including the specific options available
  335. *
  336. * @param scene
  337. * @param data
  338. * @param rootUrl
  339. */
  340. parseMTL(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string): void;
  341. }
  342. export class OBJFileLoader implements BABYLON.ISceneLoaderPluginAsync {
  343. static OPTIMIZE_WITH_UV: boolean;
  344. static INVERT_Y: boolean;
  345. name: string;
  346. extensions: string;
  347. obj: RegExp;
  348. group: RegExp;
  349. mtllib: RegExp;
  350. usemtl: RegExp;
  351. smooth: RegExp;
  352. vertexPattern: RegExp;
  353. normalPattern: RegExp;
  354. uvPattern: RegExp;
  355. facePattern1: RegExp;
  356. facePattern2: RegExp;
  357. facePattern3: RegExp;
  358. facePattern4: RegExp;
  359. facePattern5: RegExp;
  360. /**
  361. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  362. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  363. * @param scene the scene the meshes should be added to
  364. * @param data the glTF data to load
  365. * @param rootUrl root url to load from
  366. * @param onProgress event that fires when loading progress has occured
  367. * @param fileName Defines the name of the file to load
  368. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  369. */
  370. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: any, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  371. meshes: BABYLON.AbstractMesh[];
  372. particleSystems: BABYLON.IParticleSystem[];
  373. skeletons: BABYLON.Skeleton[];
  374. animationGroups: BABYLON.AnimationGroup[];
  375. }>;
  376. /**
  377. * Imports all objects from the loaded glTF data and adds them to the scene
  378. * @param scene the scene the objects should be added to
  379. * @param data the glTF data to load
  380. * @param rootUrl root url to load from
  381. * @param onProgress event that fires when loading progress has occured
  382. * @param fileName Defines the name of the file to load
  383. * @returns a promise which completes when objects have been loaded to the scene
  384. */
  385. loadAsync(scene: BABYLON.Scene, data: string, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  386. /**
  387. * Load into an asset container.
  388. * @param scene The scene to load into
  389. * @param data The data to import
  390. * @param rootUrl The root url for scene and resources
  391. * @param onProgress The callback when the load progresses
  392. * @param fileName Defines the name of the file to load
  393. * @returns The loaded asset container
  394. */
  395. loadAssetContainerAsync(scene: BABYLON.Scene, data: string, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<BABYLON.AssetContainer>;
  396. }
  397. }
  398. declare module BABYLON {
  399. export class STLFileLoader implements BABYLON.ISceneLoaderPlugin {
  400. solidPattern: RegExp;
  401. facetsPattern: RegExp;
  402. normalPattern: RegExp;
  403. vertexPattern: RegExp;
  404. name: string;
  405. extensions: BABYLON.ISceneLoaderPluginExtensions;
  406. importMesh(meshesNames: any, scene: BABYLON.Scene, data: any, rootUrl: string, meshes: BABYLON.Nullable<BABYLON.AbstractMesh[]>, particleSystems: BABYLON.Nullable<BABYLON.IParticleSystem[]>, skeletons: BABYLON.Nullable<BABYLON.Skeleton[]>): boolean;
  407. load(scene: BABYLON.Scene, data: any, rootUrl: string): boolean;
  408. loadAssetContainer(scene: BABYLON.Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): BABYLON.AssetContainer;
  409. }
  410. }
  411. declare module BABYLON {
  412. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  413. constructor();
  414. loadRuntimeAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  415. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  416. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  417. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  418. }
  419. }
  420. declare module BABYLON {
  421. /**
  422. * Implementation of the base glTF spec
  423. */
  424. export class GLTFLoaderBase {
  425. static CreateRuntime(parsedData: any, scene: BABYLON.Scene, rootUrl: string): IGLTFRuntime;
  426. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  427. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: BABYLON.Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  428. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: BABYLON.Nullable<ArrayBufferView>, onSuccess: (texture: BABYLON.Texture) => void, onError: (message: string) => void): void;
  429. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  430. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): void;
  431. }
  432. /**
  433. * glTF V1 Loader
  434. */
  435. export class GLTFLoaderV1 implements IGLTFLoader {
  436. static Extensions: {
  437. [name: string]: GLTFLoaderExtension;
  438. };
  439. static RegisterExtension(extension: GLTFLoaderExtension): void;
  440. state: BABYLON.Nullable<GLTFLoaderState>;
  441. dispose(): void;
  442. /**
  443. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  444. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  445. * @param scene the scene the meshes should be added to
  446. * @param data gltf data containing information of the meshes in a loaded file
  447. * @param rootUrl root url to load from
  448. * @param onProgress event that fires when loading progress has occured
  449. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  450. */
  451. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void): Promise<{
  452. meshes: BABYLON.AbstractMesh[];
  453. particleSystems: BABYLON.IParticleSystem[];
  454. skeletons: BABYLON.Skeleton[];
  455. animationGroups: BABYLON.AnimationGroup[];
  456. }>;
  457. /**
  458. * Imports all objects from a loaded gltf file and adds them to the scene
  459. * @param scene the scene the objects should be added to
  460. * @param data gltf data containing information of the meshes in a loaded file
  461. * @param rootUrl root url to load from
  462. * @param onProgress event that fires when loading progress has occured
  463. * @returns a promise which completes when objects have been loaded to the scene
  464. */
  465. loadAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void): Promise<void>;
  466. }
  467. }
  468. declare module BABYLON {
  469. export abstract class GLTFLoaderExtension {
  470. constructor(name: string);
  471. readonly name: string;
  472. /**
  473. * Defines an override for loading the runtime
  474. * Return true to stop further extensions from loading the runtime
  475. */
  476. loadRuntimeAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  477. /**
  478. * Defines an onverride for creating gltf runtime
  479. * Return true to stop further extensions from creating the runtime
  480. */
  481. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  482. /**
  483. * Defines an override for loading buffers
  484. * Return true to stop further extensions from loading this buffer
  485. */
  486. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  487. /**
  488. * Defines an override for loading texture buffers
  489. * Return true to stop further extensions from loading this texture data
  490. */
  491. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  492. /**
  493. * Defines an override for creating textures
  494. * Return true to stop further extensions from loading this texture
  495. */
  496. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: BABYLON.Texture) => void, onError: (message: string) => void): boolean;
  497. /**
  498. * Defines an override for loading shader strings
  499. * Return true to stop further extensions from loading this shader data
  500. */
  501. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  502. /**
  503. * Defines an override for loading materials
  504. * Return true to stop further extensions from loading this material
  505. */
  506. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): boolean;
  507. static LoadRuntimeAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  508. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  509. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  510. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: BABYLON.Texture) => void, onError: (message: string) => void): void;
  511. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  512. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): void;
  513. }
  514. }
  515. declare module BABYLON {
  516. /**
  517. * Enums
  518. */
  519. export enum EComponentType {
  520. BYTE = 5120,
  521. UNSIGNED_BYTE = 5121,
  522. SHORT = 5122,
  523. UNSIGNED_SHORT = 5123,
  524. FLOAT = 5126
  525. }
  526. export enum EShaderType {
  527. FRAGMENT = 35632,
  528. VERTEX = 35633
  529. }
  530. export enum EParameterType {
  531. BYTE = 5120,
  532. UNSIGNED_BYTE = 5121,
  533. SHORT = 5122,
  534. UNSIGNED_SHORT = 5123,
  535. INT = 5124,
  536. UNSIGNED_INT = 5125,
  537. FLOAT = 5126,
  538. FLOAT_VEC2 = 35664,
  539. FLOAT_VEC3 = 35665,
  540. FLOAT_VEC4 = 35666,
  541. INT_VEC2 = 35667,
  542. INT_VEC3 = 35668,
  543. INT_VEC4 = 35669,
  544. BOOL = 35670,
  545. BOOL_VEC2 = 35671,
  546. BOOL_VEC3 = 35672,
  547. BOOL_VEC4 = 35673,
  548. FLOAT_MAT2 = 35674,
  549. FLOAT_MAT3 = 35675,
  550. FLOAT_MAT4 = 35676,
  551. SAMPLER_2D = 35678
  552. }
  553. export enum ETextureWrapMode {
  554. CLAMP_TO_EDGE = 33071,
  555. MIRRORED_REPEAT = 33648,
  556. REPEAT = 10497
  557. }
  558. export enum ETextureFilterType {
  559. NEAREST = 9728,
  560. LINEAR = 9728,
  561. NEAREST_MIPMAP_NEAREST = 9984,
  562. LINEAR_MIPMAP_NEAREST = 9985,
  563. NEAREST_MIPMAP_LINEAR = 9986,
  564. LINEAR_MIPMAP_LINEAR = 9987
  565. }
  566. export enum ETextureFormat {
  567. ALPHA = 6406,
  568. RGB = 6407,
  569. RGBA = 6408,
  570. LUMINANCE = 6409,
  571. LUMINANCE_ALPHA = 6410
  572. }
  573. export enum ECullingType {
  574. FRONT = 1028,
  575. BACK = 1029,
  576. FRONT_AND_BACK = 1032
  577. }
  578. export enum EBlendingFunction {
  579. ZERO = 0,
  580. ONE = 1,
  581. SRC_COLOR = 768,
  582. ONE_MINUS_SRC_COLOR = 769,
  583. DST_COLOR = 774,
  584. ONE_MINUS_DST_COLOR = 775,
  585. SRC_ALPHA = 770,
  586. ONE_MINUS_SRC_ALPHA = 771,
  587. DST_ALPHA = 772,
  588. ONE_MINUS_DST_ALPHA = 773,
  589. CONSTANT_COLOR = 32769,
  590. ONE_MINUS_CONSTANT_COLOR = 32770,
  591. CONSTANT_ALPHA = 32771,
  592. ONE_MINUS_CONSTANT_ALPHA = 32772,
  593. SRC_ALPHA_SATURATE = 776
  594. }
  595. /**
  596. * Interfaces
  597. */
  598. export interface IGLTFProperty {
  599. extensions?: {
  600. [key: string]: any;
  601. };
  602. extras?: Object;
  603. }
  604. export interface IGLTFChildRootProperty extends IGLTFProperty {
  605. name?: string;
  606. }
  607. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  608. bufferView: string;
  609. byteOffset: number;
  610. byteStride: number;
  611. count: number;
  612. type: string;
  613. componentType: EComponentType;
  614. max?: number[];
  615. min?: number[];
  616. name?: string;
  617. }
  618. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  619. buffer: string;
  620. byteOffset: number;
  621. byteLength: number;
  622. byteStride: number;
  623. target?: number;
  624. }
  625. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  626. uri: string;
  627. byteLength?: number;
  628. type?: string;
  629. }
  630. export interface IGLTFShader extends IGLTFChildRootProperty {
  631. uri: string;
  632. type: EShaderType;
  633. }
  634. export interface IGLTFProgram extends IGLTFChildRootProperty {
  635. attributes: string[];
  636. fragmentShader: string;
  637. vertexShader: string;
  638. }
  639. export interface IGLTFTechniqueParameter {
  640. type: number;
  641. count?: number;
  642. semantic?: string;
  643. node?: string;
  644. value?: number | boolean | string | Array<any>;
  645. source?: string;
  646. babylonValue?: any;
  647. }
  648. export interface IGLTFTechniqueCommonProfile {
  649. lightingModel: string;
  650. texcoordBindings: Object;
  651. parameters?: Array<any>;
  652. }
  653. export interface IGLTFTechniqueStatesFunctions {
  654. blendColor?: number[];
  655. blendEquationSeparate?: number[];
  656. blendFuncSeparate?: number[];
  657. colorMask: boolean[];
  658. cullFace: number[];
  659. }
  660. export interface IGLTFTechniqueStates {
  661. enable: number[];
  662. functions: IGLTFTechniqueStatesFunctions;
  663. }
  664. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  665. parameters: {
  666. [key: string]: IGLTFTechniqueParameter;
  667. };
  668. program: string;
  669. attributes: {
  670. [key: string]: string;
  671. };
  672. uniforms: {
  673. [key: string]: string;
  674. };
  675. states: IGLTFTechniqueStates;
  676. }
  677. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  678. technique?: string;
  679. values: string[];
  680. }
  681. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  682. attributes: {
  683. [key: string]: string;
  684. };
  685. indices: string;
  686. material: string;
  687. mode?: number;
  688. }
  689. export interface IGLTFMesh extends IGLTFChildRootProperty {
  690. primitives: IGLTFMeshPrimitive[];
  691. }
  692. export interface IGLTFImage extends IGLTFChildRootProperty {
  693. uri: string;
  694. }
  695. export interface IGLTFSampler extends IGLTFChildRootProperty {
  696. magFilter?: number;
  697. minFilter?: number;
  698. wrapS?: number;
  699. wrapT?: number;
  700. }
  701. export interface IGLTFTexture extends IGLTFChildRootProperty {
  702. sampler: string;
  703. source: string;
  704. format?: ETextureFormat;
  705. internalFormat?: ETextureFormat;
  706. target?: number;
  707. type?: number;
  708. babylonTexture?: BABYLON.Texture;
  709. }
  710. export interface IGLTFAmbienLight {
  711. color?: number[];
  712. }
  713. export interface IGLTFDirectionalLight {
  714. color?: number[];
  715. }
  716. export interface IGLTFPointLight {
  717. color?: number[];
  718. constantAttenuation?: number;
  719. linearAttenuation?: number;
  720. quadraticAttenuation?: number;
  721. }
  722. export interface IGLTFSpotLight {
  723. color?: number[];
  724. constantAttenuation?: number;
  725. fallOfAngle?: number;
  726. fallOffExponent?: number;
  727. linearAttenuation?: number;
  728. quadraticAttenuation?: number;
  729. }
  730. export interface IGLTFLight extends IGLTFChildRootProperty {
  731. type: string;
  732. }
  733. export interface IGLTFCameraOrthographic {
  734. xmag: number;
  735. ymag: number;
  736. zfar: number;
  737. znear: number;
  738. }
  739. export interface IGLTFCameraPerspective {
  740. aspectRatio: number;
  741. yfov: number;
  742. zfar: number;
  743. znear: number;
  744. }
  745. export interface IGLTFCamera extends IGLTFChildRootProperty {
  746. type: string;
  747. }
  748. export interface IGLTFAnimationChannelTarget {
  749. id: string;
  750. path: string;
  751. }
  752. export interface IGLTFAnimationChannel {
  753. sampler: string;
  754. target: IGLTFAnimationChannelTarget;
  755. }
  756. export interface IGLTFAnimationSampler {
  757. input: string;
  758. output: string;
  759. interpolation?: string;
  760. }
  761. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  762. channels?: IGLTFAnimationChannel[];
  763. parameters?: {
  764. [key: string]: string;
  765. };
  766. samplers?: {
  767. [key: string]: IGLTFAnimationSampler;
  768. };
  769. }
  770. export interface IGLTFNodeInstanceSkin {
  771. skeletons: string[];
  772. skin: string;
  773. meshes: string[];
  774. }
  775. export interface IGLTFSkins extends IGLTFChildRootProperty {
  776. bindShapeMatrix: number[];
  777. inverseBindMatrices: string;
  778. jointNames: string[];
  779. babylonSkeleton?: BABYLON.Skeleton;
  780. }
  781. export interface IGLTFNode extends IGLTFChildRootProperty {
  782. camera?: string;
  783. children: string[];
  784. skin?: string;
  785. jointName?: string;
  786. light?: string;
  787. matrix: number[];
  788. mesh?: string;
  789. meshes?: string[];
  790. rotation?: number[];
  791. scale?: number[];
  792. translation?: number[];
  793. babylonNode?: BABYLON.Node;
  794. }
  795. export interface IGLTFScene extends IGLTFChildRootProperty {
  796. nodes: string[];
  797. }
  798. /**
  799. * Runtime
  800. */
  801. export interface IGLTFRuntime {
  802. extensions: {
  803. [key: string]: any;
  804. };
  805. accessors: {
  806. [key: string]: IGLTFAccessor;
  807. };
  808. buffers: {
  809. [key: string]: IGLTFBuffer;
  810. };
  811. bufferViews: {
  812. [key: string]: IGLTFBufferView;
  813. };
  814. meshes: {
  815. [key: string]: IGLTFMesh;
  816. };
  817. lights: {
  818. [key: string]: IGLTFLight;
  819. };
  820. cameras: {
  821. [key: string]: IGLTFCamera;
  822. };
  823. nodes: {
  824. [key: string]: IGLTFNode;
  825. };
  826. images: {
  827. [key: string]: IGLTFImage;
  828. };
  829. textures: {
  830. [key: string]: IGLTFTexture;
  831. };
  832. shaders: {
  833. [key: string]: IGLTFShader;
  834. };
  835. programs: {
  836. [key: string]: IGLTFProgram;
  837. };
  838. samplers: {
  839. [key: string]: IGLTFSampler;
  840. };
  841. techniques: {
  842. [key: string]: IGLTFTechnique;
  843. };
  844. materials: {
  845. [key: string]: IGLTFMaterial;
  846. };
  847. animations: {
  848. [key: string]: IGLTFAnimation;
  849. };
  850. skins: {
  851. [key: string]: IGLTFSkins;
  852. };
  853. currentScene?: Object;
  854. scenes: {
  855. [key: string]: IGLTFScene;
  856. };
  857. extensionsUsed: string[];
  858. extensionsRequired?: string[];
  859. buffersCount: number;
  860. shaderscount: number;
  861. scene: BABYLON.Scene;
  862. rootUrl: string;
  863. loadedBufferCount: number;
  864. loadedBufferViews: {
  865. [name: string]: ArrayBufferView;
  866. };
  867. loadedShaderCount: number;
  868. importOnlyMeshes: boolean;
  869. importMeshesNames?: string[];
  870. dummyNodes: BABYLON.Node[];
  871. }
  872. /**
  873. * Bones
  874. */
  875. export interface INodeToRoot {
  876. bone: BABYLON.Bone;
  877. node: IGLTFNode;
  878. id: string;
  879. }
  880. export interface IJointNode {
  881. node: IGLTFNode;
  882. id: string;
  883. }
  884. }
  885. declare module BABYLON {
  886. /**
  887. * Utils functions for GLTF
  888. */
  889. export class GLTFUtils {
  890. /**
  891. * Sets the given "parameter" matrix
  892. * @param scene: the BABYLON.Scene object
  893. * @param source: the source node where to pick the matrix
  894. * @param parameter: the GLTF technique parameter
  895. * @param uniformName: the name of the shader's uniform
  896. * @param shaderMaterial: the shader material
  897. */
  898. static SetMatrix(scene: BABYLON.Scene, source: BABYLON.Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: BABYLON.ShaderMaterial | BABYLON.Effect): void;
  899. /**
  900. * Sets the given "parameter" matrix
  901. * @param shaderMaterial: the shader material
  902. * @param uniform: the name of the shader's uniform
  903. * @param value: the value of the uniform
  904. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  905. */
  906. static SetUniform(shaderMaterial: BABYLON.ShaderMaterial | BABYLON.Effect, uniform: string, value: any, type: number): boolean;
  907. /**
  908. * Returns the wrap mode of the texture
  909. * @param mode: the mode value
  910. */
  911. static GetWrapMode(mode: number): number;
  912. /**
  913. * Returns the byte stride giving an accessor
  914. * @param accessor: the GLTF accessor objet
  915. */
  916. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  917. /**
  918. * Returns the texture filter mode giving a mode value
  919. * @param mode: the filter mode value
  920. */
  921. static GetTextureFilterMode(mode: number): ETextureFilterType;
  922. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  923. /**
  924. * Returns a buffer from its accessor
  925. * @param gltfRuntime: the GLTF runtime
  926. * @param accessor: the GLTF accessor
  927. */
  928. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  929. /**
  930. * Decodes a buffer view into a string
  931. * @param view: the buffer view
  932. */
  933. static DecodeBufferToText(view: ArrayBufferView): string;
  934. /**
  935. * Returns the default material of gltf. Related to
  936. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  937. * @param scene: the Babylon.js scene
  938. */
  939. static GetDefaultMaterial(scene: BABYLON.Scene): BABYLON.ShaderMaterial;
  940. }
  941. }
  942. declare module BABYLON {
  943. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  944. constructor();
  945. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  946. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): boolean;
  947. }
  948. }
  949. declare module BABYLON {
  950. /**
  951. * Helper class for working with arrays when loading the glTF asset
  952. */
  953. export class ArrayItem {
  954. /**
  955. * Gets an item from the given array.
  956. * @param context The context when loading the asset
  957. * @param array The array to get the item from
  958. * @param index The index to the array
  959. * @returns The array item
  960. */
  961. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  962. /**
  963. * Assign an `index` field to each item of the given array.
  964. * @param array The array of items
  965. */
  966. static Assign(array?: IArrayItemV2[]): void;
  967. }
  968. /**
  969. * The glTF 2.0 loader
  970. */
  971. export class GLTFLoaderV2 implements IGLTFLoader {
  972. /** The glTF object parsed from the JSON. */
  973. gltf: IGLTFV2;
  974. /** The Babylon scene when loading the asset. */
  975. babylonScene: BABYLON.Scene;
  976. /** @hidden */
  977. _completePromises: Promise<any>[];
  978. /**
  979. * Registers a loader extension.
  980. * @param name The name of the loader extension.
  981. * @param factory The factory function that creates the loader extension.
  982. */
  983. static RegisterExtension(name: string, factory: (loader: GLTFLoaderV2) => IGLTFLoaderExtensionV2): void;
  984. /**
  985. * Unregisters a loader extension.
  986. * @param name The name of the loader extenion.
  987. * @returns A boolean indicating whether the extension has been unregistered
  988. */
  989. static UnregisterExtension(name: string): boolean;
  990. /**
  991. * Gets the loader state.
  992. */
  993. readonly state: BABYLON.Nullable<GLTFLoaderState>;
  994. /** @hidden */
  995. constructor(parent: GLTFFileLoader);
  996. /** @hidden */
  997. dispose(): void;
  998. /** @hidden */
  999. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1000. meshes: BABYLON.AbstractMesh[];
  1001. particleSystems: BABYLON.IParticleSystem[];
  1002. skeletons: BABYLON.Skeleton[];
  1003. animationGroups: BABYLON.AnimationGroup[];
  1004. }>;
  1005. /** @hidden */
  1006. loadAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1007. /**
  1008. * Loads a glTF scene.
  1009. * @param context The context when loading the asset
  1010. * @param scene The glTF scene property
  1011. * @returns A promise that resolves when the load is complete
  1012. */
  1013. loadSceneAsync(context: string, scene: ISceneV2): Promise<void>;
  1014. /**
  1015. * Loads a glTF node.
  1016. * @param context The context when loading the asset
  1017. * @param node The glTF node property
  1018. * @param assign A function called synchronously after parsing the glTF properties
  1019. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1020. */
  1021. loadNodeAsync(context: string, node: INodeV2, assign?: (babylonMesh: BABYLON.Mesh) => void): Promise<BABYLON.Mesh>;
  1022. /**
  1023. * Loads a glTF camera.
  1024. * @param context The context when loading the asset
  1025. * @param camera The glTF camera property
  1026. * @param assign A function called synchronously after parsing the glTF properties
  1027. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1028. */
  1029. loadCameraAsync(context: string, camera: ICameraV2, assign?: (babylonCamera: BABYLON.Camera) => void): Promise<BABYLON.Camera>;
  1030. /**
  1031. * Loads a glTF animation.
  1032. * @param context The context when loading the asset
  1033. * @param animation The glTF animation property
  1034. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1035. */
  1036. loadAnimationAsync(context: string, animation: IAnimationV2): Promise<BABYLON.AnimationGroup>;
  1037. /**
  1038. * Loads a glTF buffer view.
  1039. * @param context The context when loading the asset
  1040. * @param bufferView The glTF buffer view property
  1041. * @returns A promise that resolves with the loaded data when the load is complete
  1042. */
  1043. loadBufferViewAsync(context: string, bufferView: IBufferViewV2): Promise<ArrayBufferView>;
  1044. /** @hidden */
  1045. _loadMaterialAsync(context: string, material: IMaterialV2, babylonMesh: BABYLON.Mesh, babylonDrawMode: number, assign?: (babylonMaterial: BABYLON.Material) => void): Promise<BABYLON.Material>;
  1046. /**
  1047. * Creates a Babylon material from a glTF material.
  1048. * @param context The context when loading the asset
  1049. * @param material The glTF material property
  1050. * @param babylonDrawMode The draw mode for the Babylon material
  1051. * @returns The Babylon material
  1052. */
  1053. createMaterial(context: string, material: IMaterialV2, babylonDrawMode: number): BABYLON.Material;
  1054. /**
  1055. * Loads properties from a glTF material into a Babylon material.
  1056. * @param context The context when loading the asset
  1057. * @param material The glTF material property
  1058. * @param babylonMaterial The Babylon material
  1059. * @returns A promise that resolves when the load is complete
  1060. */
  1061. loadMaterialPropertiesAsync(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): Promise<void>;
  1062. /**
  1063. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1064. * @param context The context when loading the asset
  1065. * @param material The glTF material property
  1066. * @param babylonMaterial The Babylon material
  1067. * @returns A promise that resolves when the load is complete
  1068. */
  1069. loadMaterialBasePropertiesAsync(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): Promise<void>;
  1070. /**
  1071. * Loads the alpha properties from a glTF material into a Babylon material.
  1072. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1073. * @param context The context when loading the asset
  1074. * @param material The glTF material property
  1075. * @param babylonMaterial The Babylon material
  1076. */
  1077. loadMaterialAlphaProperties(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): void;
  1078. /**
  1079. * Loads a glTF texture info.
  1080. * @param context The context when loading the asset
  1081. * @param textureInfo The glTF texture info property
  1082. * @param assign A function called synchronously after parsing the glTF properties
  1083. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1084. */
  1085. loadTextureInfoAsync(context: string, textureInfo: ITextureInfoV2, assign?: (babylonTexture: BABYLON.BaseTexture) => void): Promise<BABYLON.BaseTexture>;
  1086. /**
  1087. * Loads a glTF image.
  1088. * @param context The context when loading the asset
  1089. * @param image The glTF image property
  1090. * @returns A promise that resolves with the loaded data when the load is complete
  1091. */
  1092. loadImageAsync(context: string, image: IImageV2): Promise<ArrayBufferView>;
  1093. /**
  1094. * Loads a glTF uri.
  1095. * @param context The context when loading the asset
  1096. * @param uri The base64 or relative uri
  1097. * @returns A promise that resolves with the loaded data when the load is complete
  1098. */
  1099. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  1100. /**
  1101. * Helper method called by a loader extension to load an glTF extension.
  1102. * @param context The context when loading the asset
  1103. * @param property The glTF property to load the extension from
  1104. * @param extensionName The name of the extension to load
  1105. * @param actionAsync The action to run
  1106. * @returns The promise returned by actionAsync or null if the extension does not exist
  1107. */
  1108. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: BABYLON.GLTF2.IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => BABYLON.Nullable<Promise<TResult>>): BABYLON.Nullable<Promise<TResult>>;
  1109. /**
  1110. * Helper method called by a loader extension to load a glTF extra.
  1111. * @param context The context when loading the asset
  1112. * @param property The glTF property to load the extra from
  1113. * @param extensionName The name of the extension to load
  1114. * @param actionAsync The action to run
  1115. * @returns The promise returned by actionAsync or null if the extra does not exist
  1116. */
  1117. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: BABYLON.GLTF2.IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => BABYLON.Nullable<Promise<TResult>>): BABYLON.Nullable<Promise<TResult>>;
  1118. /**
  1119. * Increments the indentation level and logs a message.
  1120. * @param message The message to log
  1121. */
  1122. logOpen(message: string): void;
  1123. /**
  1124. * Decrements the indentation level.
  1125. */
  1126. logClose(): void;
  1127. /**
  1128. * Logs a message
  1129. * @param message The message to log
  1130. */
  1131. log(message: string): void;
  1132. /**
  1133. * Starts a performance counter.
  1134. * @param counterName The name of the performance counter
  1135. */
  1136. startPerformanceCounter(counterName: string): void;
  1137. /**
  1138. * Ends a performance counter.
  1139. * @param counterName The name of the performance counter
  1140. */
  1141. endPerformanceCounter(counterName: string): void;
  1142. }
  1143. }
  1144. declare module BABYLON {
  1145. /** @hidden */
  1146. export var __IGLTFLoaderExtensionV2: number;
  1147. /**
  1148. * Interface for a glTF loader extension.
  1149. */
  1150. export interface IGLTFLoaderExtensionV2 extends IGLTFLoaderExtension, BABYLON.IDisposable {
  1151. /**
  1152. * Called after the loader state changes to LOADING.
  1153. */
  1154. onLoading?(): void;
  1155. /**
  1156. * Called after the loader state changes to READY.
  1157. */
  1158. onReady?(): void;
  1159. /**
  1160. * Define this method to modify the default behavior when loading scenes.
  1161. * @param context The context when loading the asset
  1162. * @param scene The glTF scene property
  1163. * @returns A promise that resolves when the load is complete or null if not handled
  1164. */
  1165. loadSceneAsync?(context: string, scene: ISceneV2): BABYLON.Nullable<Promise<void>>;
  1166. /**
  1167. * Define this method to modify the default behavior when loading nodes.
  1168. * @param context The context when loading the asset
  1169. * @param node The glTF node property
  1170. * @param assign A function called synchronously after parsing the glTF properties
  1171. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
  1172. */
  1173. loadNodeAsync?(context: string, node: INodeV2, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  1174. /**
  1175. * Define this method to modify the default behavior when loading cameras.
  1176. * @param context The context when loading the asset
  1177. * @param camera The glTF camera property
  1178. * @param assign A function called synchronously after parsing the glTF properties
  1179. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1180. */
  1181. loadCameraAsync?(context: string, camera: ICameraV2, assign: (babylonCamera: BABYLON.Camera) => void): BABYLON.Nullable<Promise<BABYLON.Camera>>;
  1182. /**
  1183. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1184. * @param context The context when loading the asset
  1185. * @param primitive The glTF mesh primitive property
  1186. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1187. */
  1188. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitiveV2, babylonMesh: BABYLON.Mesh): BABYLON.Nullable<Promise<BABYLON.Geometry>>;
  1189. /**
  1190. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1191. * @param context The context when loading the asset
  1192. * @param material The glTF material property
  1193. * @param assign A function called synchronously after parsing the glTF properties
  1194. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1195. */
  1196. _loadMaterialAsync?(context: string, material: IMaterialV2, babylonMesh: BABYLON.Mesh, babylonDrawMode: number, assign: (babylonMaterial: BABYLON.Material) => void): BABYLON.Nullable<Promise<BABYLON.Material>>;
  1197. /**
  1198. * Define this method to modify the default behavior when creating materials.
  1199. * @param context The context when loading the asset
  1200. * @param material The glTF material property
  1201. * @param babylonDrawMode The draw mode for the Babylon material
  1202. * @returns The Babylon material or null if not handled
  1203. */
  1204. createMaterial?(context: string, material: IMaterialV2, babylonDrawMode: number): BABYLON.Nullable<BABYLON.Material>;
  1205. /**
  1206. * Define this method to modify the default behavior when loading material properties.
  1207. * @param context The context when loading the asset
  1208. * @param material The glTF material property
  1209. * @param babylonMaterial The Babylon material
  1210. * @returns A promise that resolves when the load is complete or null if not handled
  1211. */
  1212. loadMaterialPropertiesAsync?(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  1213. /**
  1214. * Define this method to modify the default behavior when loading texture infos.
  1215. * @param context The context when loading the asset
  1216. * @param textureInfo The glTF texture info property
  1217. * @param assign A function called synchronously after parsing the glTF properties
  1218. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1219. */
  1220. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfoV2, assign: (babylonTexture: BABYLON.BaseTexture) => void): BABYLON.Nullable<Promise<BABYLON.BaseTexture>>;
  1221. /**
  1222. * Define this method to modify the default behavior when loading animations.
  1223. * @param context The context when loading the asset
  1224. * @param animation The glTF animation property
  1225. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1226. */
  1227. loadAnimationAsync?(context: string, animation: IAnimationV2): BABYLON.Nullable<Promise<BABYLON.AnimationGroup>>;
  1228. /**
  1229. * Define this method to modify the default behavior when loading uris.
  1230. * @param context The context when loading the asset
  1231. * @param uri The uri to load
  1232. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1233. */
  1234. _loadUriAsync?(context: string, uri: string): BABYLON.Nullable<Promise<ArrayBufferView>>;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export var __IGLTFLoaderInterfacesV2: number;
  1240. /**
  1241. * Loader interface with an index field.
  1242. */
  1243. export interface IArrayItemV2 {
  1244. /**
  1245. * The index of this item in the array.
  1246. */
  1247. index: number;
  1248. }
  1249. /**
  1250. * Loader interface with additional members.
  1251. */
  1252. export interface IAccessorV2 extends BABYLON.GLTF2.IAccessor, IArrayItemV2 {
  1253. /** @hidden */
  1254. _data?: Promise<ArrayBufferView>;
  1255. /** @hidden */
  1256. _babylonVertexBuffer?: Promise<BABYLON.VertexBuffer>;
  1257. }
  1258. /**
  1259. * Loader interface with additional members.
  1260. */
  1261. export interface IAnimationChannelV2 extends BABYLON.GLTF2.IAnimationChannel, IArrayItemV2 {
  1262. }
  1263. /** @hidden */
  1264. export interface _IAnimationSamplerDataV2 {
  1265. input: Float32Array;
  1266. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  1267. output: Float32Array;
  1268. }
  1269. /**
  1270. * Loader interface with additional members.
  1271. */
  1272. export interface IAnimationSamplerV2 extends BABYLON.GLTF2.IAnimationSampler, IArrayItemV2 {
  1273. /** @hidden */
  1274. _data?: Promise<_IAnimationSamplerDataV2>;
  1275. }
  1276. /**
  1277. * Loader interface with additional members.
  1278. */
  1279. export interface IAnimationV2 extends BABYLON.GLTF2.IAnimation, IArrayItemV2 {
  1280. channels: IAnimationChannelV2[];
  1281. samplers: IAnimationSamplerV2[];
  1282. /** @hidden */
  1283. _babylonAnimationGroup?: BABYLON.AnimationGroup;
  1284. }
  1285. /**
  1286. * Loader interface with additional members.
  1287. */
  1288. export interface IBufferV2 extends BABYLON.GLTF2.IBuffer, IArrayItemV2 {
  1289. /** @hidden */
  1290. _data?: Promise<ArrayBufferView>;
  1291. }
  1292. /**
  1293. * Loader interface with additional members.
  1294. */
  1295. export interface IBufferViewV2 extends BABYLON.GLTF2.IBufferView, IArrayItemV2 {
  1296. /** @hidden */
  1297. _data?: Promise<ArrayBufferView>;
  1298. /** @hidden */
  1299. _babylonBuffer?: Promise<BABYLON.Buffer>;
  1300. }
  1301. /**
  1302. * Loader interface with additional members.
  1303. */
  1304. export interface ICameraV2 extends BABYLON.GLTF2.ICamera, IArrayItemV2 {
  1305. }
  1306. /**
  1307. * Loader interface with additional members.
  1308. */
  1309. export interface IImageV2 extends BABYLON.GLTF2.IImage, IArrayItemV2 {
  1310. /** @hidden */
  1311. _data?: Promise<ArrayBufferView>;
  1312. }
  1313. /**
  1314. * Loader interface with additional members.
  1315. */
  1316. export interface IMaterialNormalTextureInfoV2 extends BABYLON.GLTF2.IMaterialNormalTextureInfo, BABYLON.GLTF2.ITextureInfo {
  1317. }
  1318. /**
  1319. * Loader interface with additional members.
  1320. */
  1321. export interface IMaterialOcclusionTextureInfoV2 extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, BABYLON.GLTF2.ITextureInfo {
  1322. }
  1323. /**
  1324. * Loader interface with additional members.
  1325. */
  1326. export interface IMaterialPbrMetallicRoughnessV2 extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  1327. baseColorTexture?: ITextureInfoV2;
  1328. metallicRoughnessTexture?: ITextureInfoV2;
  1329. }
  1330. /**
  1331. * Loader interface with additional members.
  1332. */
  1333. export interface IMaterialV2 extends BABYLON.GLTF2.IMaterial, IArrayItemV2 {
  1334. pbrMetallicRoughness?: IMaterialPbrMetallicRoughnessV2;
  1335. normalTexture?: IMaterialNormalTextureInfoV2;
  1336. occlusionTexture?: IMaterialOcclusionTextureInfoV2;
  1337. emissiveTexture?: ITextureInfoV2;
  1338. /** @hidden */
  1339. _babylonData?: {
  1340. [drawMode: number]: {
  1341. material: BABYLON.Material;
  1342. meshes: BABYLON.AbstractMesh[];
  1343. promise: Promise<void>;
  1344. };
  1345. };
  1346. }
  1347. /**
  1348. * Loader interface with additional members.
  1349. */
  1350. export interface IMeshV2 extends BABYLON.GLTF2.IMesh, IArrayItemV2 {
  1351. primitives: IMeshPrimitiveV2[];
  1352. }
  1353. /**
  1354. * Loader interface with additional members.
  1355. */
  1356. export interface IMeshPrimitiveV2 extends BABYLON.GLTF2.IMeshPrimitive, IArrayItemV2 {
  1357. }
  1358. /**
  1359. * Loader interface with additional members.
  1360. */
  1361. export interface INodeV2 extends BABYLON.GLTF2.INode, IArrayItemV2 {
  1362. /**
  1363. * The parent glTF node.
  1364. */
  1365. parent?: INodeV2;
  1366. /** @hidden */
  1367. _babylonMesh?: BABYLON.Mesh;
  1368. /** @hidden */
  1369. _primitiveBabylonMeshes?: BABYLON.Mesh[];
  1370. /** @hidden */
  1371. _babylonBones?: BABYLON.Bone[];
  1372. /** @hidden */
  1373. _numMorphTargets?: number;
  1374. }
  1375. /** @hidden */
  1376. export interface _ISamplerDataV2 {
  1377. noMipMaps: boolean;
  1378. samplingMode: number;
  1379. wrapU: number;
  1380. wrapV: number;
  1381. }
  1382. /**
  1383. * Loader interface with additional members.
  1384. */
  1385. export interface ISamplerV2 extends BABYLON.GLTF2.ISampler, IArrayItemV2 {
  1386. /** @hidden */
  1387. _data?: _ISamplerDataV2;
  1388. }
  1389. /**
  1390. * Loader interface with additional members.
  1391. */
  1392. export interface ISceneV2 extends BABYLON.GLTF2.IScene, IArrayItemV2 {
  1393. }
  1394. /**
  1395. * Loader interface with additional members.
  1396. */
  1397. export interface ISkinV2 extends BABYLON.GLTF2.ISkin, IArrayItemV2 {
  1398. /** @hidden */
  1399. _babylonSkeleton?: BABYLON.Skeleton;
  1400. /** @hidden */
  1401. _promise?: Promise<void>;
  1402. }
  1403. /**
  1404. * Loader interface with additional members.
  1405. */
  1406. export interface ITextureV2 extends BABYLON.GLTF2.ITexture, IArrayItemV2 {
  1407. }
  1408. /**
  1409. * Loader interface with additional members.
  1410. */
  1411. export interface ITextureInfoV2 extends BABYLON.GLTF2.ITextureInfo {
  1412. }
  1413. /**
  1414. * Loader interface with additional members.
  1415. */
  1416. export interface IGLTFV2 extends BABYLON.GLTF2.IGLTF {
  1417. accessors?: IAccessorV2[];
  1418. animations?: IAnimationV2[];
  1419. buffers?: IBufferV2[];
  1420. bufferViews?: IBufferViewV2[];
  1421. cameras?: ICameraV2[];
  1422. images?: IImageV2[];
  1423. materials?: IMaterialV2[];
  1424. meshes?: IMeshV2[];
  1425. nodes?: INodeV2[];
  1426. samplers?: ISamplerV2[];
  1427. scenes?: ISceneV2[];
  1428. skins?: ISkinV2[];
  1429. textures?: ITextureV2[];
  1430. }
  1431. }
  1432. declare module BABYLON {
  1433. /**
  1434. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  1435. */
  1436. export class EXT_lights_image_based implements IGLTFLoaderExtensionV2 {
  1437. /** The name of this extension. */
  1438. readonly name: string;
  1439. /** Defines whether this extension is enabled. */
  1440. enabled: boolean;
  1441. /** @hidden */
  1442. constructor(loader: GLTFLoaderV2);
  1443. /** @hidden */
  1444. dispose(): void;
  1445. /** @hidden */
  1446. onLoading(): void;
  1447. /** @hidden */
  1448. loadSceneAsync(context: string, scene: ISceneV2): BABYLON.Nullable<Promise<void>>;
  1449. }
  1450. }
  1451. declare module BABYLON {
  1452. /**
  1453. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1454. */
  1455. export class KHR_draco_mesh_compression implements IGLTFLoaderExtensionV2 {
  1456. /** The name of this extension. */
  1457. readonly name: string;
  1458. /** Defines whether this extension is enabled. */
  1459. enabled: boolean;
  1460. /** @hidden */
  1461. constructor(loader: GLTFLoaderV2);
  1462. /** @hidden */
  1463. dispose(): void;
  1464. /** @hidden */
  1465. _loadVertexDataAsync(context: string, primitive: IMeshPrimitiveV2, babylonMesh: BABYLON.Mesh): BABYLON.Nullable<Promise<BABYLON.Geometry>>;
  1466. }
  1467. }
  1468. declare module BABYLON {
  1469. /**
  1470. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  1471. */
  1472. export class KHR_lights implements IGLTFLoaderExtensionV2 {
  1473. /** The name of this extension. */
  1474. readonly name: string;
  1475. /** Defines whether this extension is enabled. */
  1476. enabled: boolean;
  1477. /** @hidden */
  1478. constructor(loader: GLTFLoaderV2);
  1479. /** @hidden */
  1480. dispose(): void;
  1481. /** @hidden */
  1482. onLoading(): void;
  1483. /** @hidden */
  1484. loadNodeAsync(context: string, node: INodeV2, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  1485. }
  1486. }
  1487. declare module BABYLON {
  1488. /**
  1489. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1490. */
  1491. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtensionV2 {
  1492. /** The name of this extension. */
  1493. readonly name: string;
  1494. /** Defines whether this extension is enabled. */
  1495. enabled: boolean;
  1496. /** @hidden */
  1497. constructor(loader: GLTFLoaderV2);
  1498. /** @hidden */
  1499. dispose(): void;
  1500. /** @hidden */
  1501. loadMaterialPropertiesAsync(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  1502. }
  1503. }
  1504. declare module BABYLON {
  1505. /**
  1506. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1507. */
  1508. export class KHR_materials_unlit implements IGLTFLoaderExtensionV2 {
  1509. /** The name of this extension. */
  1510. readonly name: string;
  1511. /** Defines whether this extension is enabled. */
  1512. enabled: boolean;
  1513. /** @hidden */
  1514. constructor(loader: GLTFLoaderV2);
  1515. /** @hidden */
  1516. dispose(): void;
  1517. /** @hidden */
  1518. loadMaterialPropertiesAsync(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  1519. }
  1520. }
  1521. declare module BABYLON {
  1522. /**
  1523. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1524. */
  1525. export class KHR_texture_transform implements IGLTFLoaderExtensionV2 {
  1526. /** The name of this extension. */
  1527. readonly name: string;
  1528. /** Defines whether this extension is enabled. */
  1529. enabled: boolean;
  1530. /** @hidden */
  1531. constructor(loader: GLTFLoaderV2);
  1532. /** @hidden */
  1533. dispose(): void;
  1534. /** @hidden */
  1535. loadTextureInfoAsync(context: string, textureInfo: ITextureInfoV2, assign: (babylonTexture: BABYLON.BaseTexture) => void): BABYLON.Nullable<Promise<BABYLON.BaseTexture>>;
  1536. }
  1537. }
  1538. declare module BABYLON {
  1539. /**
  1540. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1541. */
  1542. export class MSFT_audio_emitter implements IGLTFLoaderExtensionV2 {
  1543. /** The name of this extension. */
  1544. readonly name: string;
  1545. /** Defines whether this extension is enabled. */
  1546. enabled: boolean;
  1547. /** @hidden */
  1548. constructor(loader: GLTFLoaderV2);
  1549. /** @hidden */
  1550. dispose(): void;
  1551. /** @hidden */
  1552. onLoading(): void;
  1553. /** @hidden */
  1554. loadSceneAsync(context: string, scene: ISceneV2): BABYLON.Nullable<Promise<void>>;
  1555. /** @hidden */
  1556. loadNodeAsync(context: string, node: INodeV2, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  1557. /** @hidden */
  1558. loadAnimationAsync(context: string, animation: IAnimationV2): BABYLON.Nullable<Promise<BABYLON.AnimationGroup>>;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1564. */
  1565. export class MSFT_lod implements IGLTFLoaderExtensionV2 {
  1566. /** The name of this extension. */
  1567. readonly name: string;
  1568. /** Defines whether this extension is enabled. */
  1569. enabled: boolean;
  1570. /**
  1571. * Maximum number of LODs to load, starting from the lowest LOD.
  1572. */
  1573. maxLODsToLoad: number;
  1574. /**
  1575. * BABYLON.Observable raised when all node LODs of one level are loaded.
  1576. * The event data is the index of the loaded LOD starting from zero.
  1577. * Dispose the loader to cancel the loading of the next level of LODs.
  1578. */
  1579. onNodeLODsLoadedObservable: BABYLON.Observable<number>;
  1580. /**
  1581. * BABYLON.Observable raised when all material LODs of one level are loaded.
  1582. * The event data is the index of the loaded LOD starting from zero.
  1583. * Dispose the loader to cancel the loading of the next level of LODs.
  1584. */
  1585. onMaterialLODsLoadedObservable: BABYLON.Observable<number>;
  1586. /** @hidden */
  1587. constructor(loader: GLTFLoaderV2);
  1588. /** @hidden */
  1589. dispose(): void;
  1590. /** @hidden */
  1591. onReady(): void;
  1592. /** @hidden */
  1593. loadNodeAsync(context: string, node: INodeV2, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  1594. /** @hidden */
  1595. _loadMaterialAsync(context: string, material: IMaterialV2, babylonMesh: BABYLON.Mesh, babylonDrawMode: number, assign: (babylonMaterial: BABYLON.Material) => void): BABYLON.Nullable<Promise<BABYLON.Material>>;
  1596. /** @hidden */
  1597. _loadUriAsync(context: string, uri: string): BABYLON.Nullable<Promise<ArrayBufferView>>;
  1598. }
  1599. }
  1600. declare module BABYLON {
  1601. /** @hidden */
  1602. export class MSFT_minecraftMesh implements IGLTFLoaderExtensionV2 {
  1603. readonly name: string;
  1604. enabled: boolean;
  1605. constructor(loader: GLTFLoaderV2);
  1606. dispose(): void;
  1607. loadMaterialPropertiesAsync(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  1608. }
  1609. }
  1610. declare module BABYLON {
  1611. /** @hidden */
  1612. export class MSFT_sRGBFactors implements IGLTFLoaderExtensionV2 {
  1613. readonly name: string;
  1614. enabled: boolean;
  1615. constructor(loader: GLTFLoaderV2);
  1616. dispose(): void;
  1617. loadMaterialPropertiesAsync(context: string, material: IMaterialV2, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  1618. }
  1619. }