babylonjs.loaders.d.ts 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252
  1. declare module BABYLON {
  2. /**
  3. * Mode that determines the coordinate system to use.
  4. */
  5. export enum GLTFLoaderCoordinateSystemMode {
  6. /**
  7. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  8. */
  9. AUTO = 0,
  10. /**
  11. * Sets the useRightHandedSystem flag on the scene.
  12. */
  13. FORCE_RIGHT_HANDED = 1
  14. }
  15. /**
  16. * Mode that determines what animations will start.
  17. */
  18. export enum GLTFLoaderAnimationStartMode {
  19. /**
  20. * No animation will start.
  21. */
  22. NONE = 0,
  23. /**
  24. * The first animation will start.
  25. */
  26. FIRST = 1,
  27. /**
  28. * All animations will start.
  29. */
  30. ALL = 2
  31. }
  32. /**
  33. * Interface that contains the data for the glTF asset.
  34. */
  35. export interface IGLTFLoaderData {
  36. /**
  37. * The object that represents the glTF JSON.
  38. */
  39. json: Object;
  40. /**
  41. * The BIN chunk of a binary glTF.
  42. */
  43. bin: Nullable<IDataBuffer>;
  44. }
  45. /**
  46. * Interface for extending the loader.
  47. */
  48. export interface IGLTFLoaderExtension {
  49. /**
  50. * The name of this extension.
  51. */
  52. readonly name: string;
  53. /**
  54. * Defines whether this extension is enabled.
  55. */
  56. enabled: boolean;
  57. /**
  58. * Defines the order of this extension.
  59. * The loader sorts the extensions using these values when loading.
  60. */
  61. order?: number;
  62. }
  63. /**
  64. * Loader state.
  65. */
  66. export enum GLTFLoaderState {
  67. /**
  68. * The asset is loading.
  69. */
  70. LOADING = 0,
  71. /**
  72. * The asset is ready for rendering.
  73. */
  74. READY = 1,
  75. /**
  76. * The asset is completely loaded.
  77. */
  78. COMPLETE = 2
  79. }
  80. /** @hidden */
  81. export interface IGLTFLoader extends IDisposable {
  82. readonly state: Nullable<GLTFLoaderState>;
  83. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  84. meshes: AbstractMesh[];
  85. particleSystems: IParticleSystem[];
  86. skeletons: Skeleton[];
  87. animationGroups: AnimationGroup[];
  88. }>;
  89. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  90. }
  91. /**
  92. * File loader for loading glTF files into a scene.
  93. */
  94. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  95. /** @hidden */
  96. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  97. /** @hidden */
  98. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  99. /**
  100. * Raised when the asset has been parsed
  101. */
  102. onParsedObservable: Observable<IGLTFLoaderData>;
  103. private _onParsedObserver;
  104. /**
  105. * Raised when the asset has been parsed
  106. */
  107. onParsed: (loaderData: IGLTFLoaderData) => void;
  108. /**
  109. * 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.
  110. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  111. * Defaults to true.
  112. * @hidden
  113. */
  114. static IncrementalLoading: boolean;
  115. /**
  116. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  117. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  118. * @hidden
  119. */
  120. static HomogeneousCoordinates: boolean;
  121. /**
  122. * The coordinate system mode. Defaults to AUTO.
  123. */
  124. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  125. /**
  126. * The animation start mode. Defaults to FIRST.
  127. */
  128. animationStartMode: GLTFLoaderAnimationStartMode;
  129. /**
  130. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  131. */
  132. compileMaterials: boolean;
  133. /**
  134. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  135. */
  136. useClipPlane: boolean;
  137. /**
  138. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  139. */
  140. compileShadowGenerators: boolean;
  141. /**
  142. * Defines if the Alpha blended materials are only applied as coverage.
  143. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  144. * If true, no extra effects are applied to transparent pixels.
  145. */
  146. transparencyAsCoverage: boolean;
  147. /**
  148. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  149. * Enabling will disable offline support and glTF validator.
  150. * Defaults to false.
  151. */
  152. useRangeRequests: boolean;
  153. /**
  154. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  155. */
  156. createInstances: boolean;
  157. /**
  158. * Function called before loading a url referenced by the asset.
  159. */
  160. preprocessUrlAsync: (url: string) => Promise<string>;
  161. /**
  162. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  163. */
  164. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  165. private _onMeshLoadedObserver;
  166. /**
  167. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  168. */
  169. onMeshLoaded: (mesh: AbstractMesh) => void;
  170. /**
  171. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  172. */
  173. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  174. private _onTextureLoadedObserver;
  175. /**
  176. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  177. */
  178. onTextureLoaded: (texture: BaseTexture) => void;
  179. /**
  180. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  181. */
  182. readonly onMaterialLoadedObservable: Observable<Material>;
  183. private _onMaterialLoadedObserver;
  184. /**
  185. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  186. */
  187. onMaterialLoaded: (material: Material) => void;
  188. /**
  189. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  190. */
  191. readonly onCameraLoadedObservable: Observable<Camera>;
  192. private _onCameraLoadedObserver;
  193. /**
  194. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  195. */
  196. onCameraLoaded: (camera: Camera) => void;
  197. /**
  198. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  199. * For assets with LODs, raised when all of the LODs are complete.
  200. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  201. */
  202. readonly onCompleteObservable: Observable<void>;
  203. private _onCompleteObserver;
  204. /**
  205. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  206. * For assets with LODs, raised when all of the LODs are complete.
  207. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  208. */
  209. onComplete: () => void;
  210. /**
  211. * Observable raised when an error occurs.
  212. */
  213. readonly onErrorObservable: Observable<any>;
  214. private _onErrorObserver;
  215. /**
  216. * Callback raised when an error occurs.
  217. */
  218. onError: (reason: any) => void;
  219. /**
  220. * Observable raised after the loader is disposed.
  221. */
  222. readonly onDisposeObservable: Observable<void>;
  223. private _onDisposeObserver;
  224. /**
  225. * Callback raised after the loader is disposed.
  226. */
  227. onDispose: () => void;
  228. /**
  229. * Observable raised after a loader extension is created.
  230. * Set additional options for a loader extension in this event.
  231. */
  232. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  233. private _onExtensionLoadedObserver;
  234. /**
  235. * Callback raised after a loader extension is created.
  236. */
  237. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  238. /**
  239. * Defines if the loader logging is enabled.
  240. */
  241. loggingEnabled: boolean;
  242. /**
  243. * Defines if the loader should capture performance counters.
  244. */
  245. capturePerformanceCounters: boolean;
  246. /**
  247. * Defines if the loader should validate the asset.
  248. */
  249. validate: boolean;
  250. /**
  251. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  252. */
  253. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  254. private _onValidatedObserver;
  255. /**
  256. * Callback raised after a loader extension is created.
  257. */
  258. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  259. private _loader;
  260. /**
  261. * Name of the loader ("gltf")
  262. */
  263. name: string;
  264. /** @hidden */
  265. extensions: ISceneLoaderPluginExtensions;
  266. /**
  267. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  268. */
  269. dispose(): void;
  270. /** @hidden */
  271. _clear(): void;
  272. /** @hidden */
  273. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  274. /** @hidden */
  275. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  276. /** @hidden */
  277. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  278. meshes: AbstractMesh[];
  279. particleSystems: IParticleSystem[];
  280. skeletons: Skeleton[];
  281. animationGroups: AnimationGroup[];
  282. }>;
  283. /** @hidden */
  284. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  285. /** @hidden */
  286. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  287. /** @hidden */
  288. canDirectLoad(data: string): boolean;
  289. /** @hidden */
  290. directLoad(scene: Scene, data: string): any;
  291. /**
  292. * The callback that allows custom handling of the root url based on the response url.
  293. * @param rootUrl the original root url
  294. * @param responseURL the response url if available
  295. * @returns the new root url
  296. */
  297. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  298. /** @hidden */
  299. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  300. /**
  301. * The loader state or null if the loader is not active.
  302. */
  303. readonly loaderState: Nullable<GLTFLoaderState>;
  304. /**
  305. * Returns a promise that resolves when the asset is completely loaded.
  306. * @returns a promise that resolves when the asset is completely loaded.
  307. */
  308. whenCompleteAsync(): Promise<void>;
  309. private _validateAsync;
  310. private _getLoader;
  311. private _parseJson;
  312. private _unpackBinaryAsync;
  313. private _unpackBinaryV1Async;
  314. private _unpackBinaryV2Async;
  315. private static _parseVersion;
  316. private static _compareVersion;
  317. private static readonly _logSpaces;
  318. private _logIndentLevel;
  319. private _loggingEnabled;
  320. /** @hidden */
  321. _log: (message: string) => void;
  322. /** @hidden */
  323. _logOpen(message: string): void;
  324. /** @hidden */
  325. _logClose(): void;
  326. private _logEnabled;
  327. private _logDisabled;
  328. private _capturePerformanceCounters;
  329. /** @hidden */
  330. _startPerformanceCounter: (counterName: string) => void;
  331. /** @hidden */
  332. _endPerformanceCounter: (counterName: string) => void;
  333. private _startPerformanceCounterEnabled;
  334. private _startPerformanceCounterDisabled;
  335. private _endPerformanceCounterEnabled;
  336. private _endPerformanceCounterDisabled;
  337. }
  338. }
  339. declare module BABYLON.GLTF1 {
  340. /**
  341. * Enums
  342. * @hidden
  343. */
  344. export enum EComponentType {
  345. BYTE = 5120,
  346. UNSIGNED_BYTE = 5121,
  347. SHORT = 5122,
  348. UNSIGNED_SHORT = 5123,
  349. FLOAT = 5126
  350. }
  351. /** @hidden */
  352. export enum EShaderType {
  353. FRAGMENT = 35632,
  354. VERTEX = 35633
  355. }
  356. /** @hidden */
  357. export enum EParameterType {
  358. BYTE = 5120,
  359. UNSIGNED_BYTE = 5121,
  360. SHORT = 5122,
  361. UNSIGNED_SHORT = 5123,
  362. INT = 5124,
  363. UNSIGNED_INT = 5125,
  364. FLOAT = 5126,
  365. FLOAT_VEC2 = 35664,
  366. FLOAT_VEC3 = 35665,
  367. FLOAT_VEC4 = 35666,
  368. INT_VEC2 = 35667,
  369. INT_VEC3 = 35668,
  370. INT_VEC4 = 35669,
  371. BOOL = 35670,
  372. BOOL_VEC2 = 35671,
  373. BOOL_VEC3 = 35672,
  374. BOOL_VEC4 = 35673,
  375. FLOAT_MAT2 = 35674,
  376. FLOAT_MAT3 = 35675,
  377. FLOAT_MAT4 = 35676,
  378. SAMPLER_2D = 35678
  379. }
  380. /** @hidden */
  381. export enum ETextureWrapMode {
  382. CLAMP_TO_EDGE = 33071,
  383. MIRRORED_REPEAT = 33648,
  384. REPEAT = 10497
  385. }
  386. /** @hidden */
  387. export enum ETextureFilterType {
  388. NEAREST = 9728,
  389. LINEAR = 9728,
  390. NEAREST_MIPMAP_NEAREST = 9984,
  391. LINEAR_MIPMAP_NEAREST = 9985,
  392. NEAREST_MIPMAP_LINEAR = 9986,
  393. LINEAR_MIPMAP_LINEAR = 9987
  394. }
  395. /** @hidden */
  396. export enum ETextureFormat {
  397. ALPHA = 6406,
  398. RGB = 6407,
  399. RGBA = 6408,
  400. LUMINANCE = 6409,
  401. LUMINANCE_ALPHA = 6410
  402. }
  403. /** @hidden */
  404. export enum ECullingType {
  405. FRONT = 1028,
  406. BACK = 1029,
  407. FRONT_AND_BACK = 1032
  408. }
  409. /** @hidden */
  410. export enum EBlendingFunction {
  411. ZERO = 0,
  412. ONE = 1,
  413. SRC_COLOR = 768,
  414. ONE_MINUS_SRC_COLOR = 769,
  415. DST_COLOR = 774,
  416. ONE_MINUS_DST_COLOR = 775,
  417. SRC_ALPHA = 770,
  418. ONE_MINUS_SRC_ALPHA = 771,
  419. DST_ALPHA = 772,
  420. ONE_MINUS_DST_ALPHA = 773,
  421. CONSTANT_COLOR = 32769,
  422. ONE_MINUS_CONSTANT_COLOR = 32770,
  423. CONSTANT_ALPHA = 32771,
  424. ONE_MINUS_CONSTANT_ALPHA = 32772,
  425. SRC_ALPHA_SATURATE = 776
  426. }
  427. /** @hidden */
  428. export interface IGLTFProperty {
  429. extensions?: {
  430. [key: string]: any;
  431. };
  432. extras?: Object;
  433. }
  434. /** @hidden */
  435. export interface IGLTFChildRootProperty extends IGLTFProperty {
  436. name?: string;
  437. }
  438. /** @hidden */
  439. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  440. bufferView: string;
  441. byteOffset: number;
  442. byteStride: number;
  443. count: number;
  444. type: string;
  445. componentType: EComponentType;
  446. max?: number[];
  447. min?: number[];
  448. name?: string;
  449. }
  450. /** @hidden */
  451. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  452. buffer: string;
  453. byteOffset: number;
  454. byteLength: number;
  455. byteStride: number;
  456. target?: number;
  457. }
  458. /** @hidden */
  459. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  460. uri: string;
  461. byteLength?: number;
  462. type?: string;
  463. }
  464. /** @hidden */
  465. export interface IGLTFShader extends IGLTFChildRootProperty {
  466. uri: string;
  467. type: EShaderType;
  468. }
  469. /** @hidden */
  470. export interface IGLTFProgram extends IGLTFChildRootProperty {
  471. attributes: string[];
  472. fragmentShader: string;
  473. vertexShader: string;
  474. }
  475. /** @hidden */
  476. export interface IGLTFTechniqueParameter {
  477. type: number;
  478. count?: number;
  479. semantic?: string;
  480. node?: string;
  481. value?: number | boolean | string | Array<any>;
  482. source?: string;
  483. babylonValue?: any;
  484. }
  485. /** @hidden */
  486. export interface IGLTFTechniqueCommonProfile {
  487. lightingModel: string;
  488. texcoordBindings: Object;
  489. parameters?: Array<any>;
  490. }
  491. /** @hidden */
  492. export interface IGLTFTechniqueStatesFunctions {
  493. blendColor?: number[];
  494. blendEquationSeparate?: number[];
  495. blendFuncSeparate?: number[];
  496. colorMask: boolean[];
  497. cullFace: number[];
  498. }
  499. /** @hidden */
  500. export interface IGLTFTechniqueStates {
  501. enable: number[];
  502. functions: IGLTFTechniqueStatesFunctions;
  503. }
  504. /** @hidden */
  505. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  506. parameters: {
  507. [key: string]: IGLTFTechniqueParameter;
  508. };
  509. program: string;
  510. attributes: {
  511. [key: string]: string;
  512. };
  513. uniforms: {
  514. [key: string]: string;
  515. };
  516. states: IGLTFTechniqueStates;
  517. }
  518. /** @hidden */
  519. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  520. technique?: string;
  521. values: string[];
  522. }
  523. /** @hidden */
  524. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  525. attributes: {
  526. [key: string]: string;
  527. };
  528. indices: string;
  529. material: string;
  530. mode?: number;
  531. }
  532. /** @hidden */
  533. export interface IGLTFMesh extends IGLTFChildRootProperty {
  534. primitives: IGLTFMeshPrimitive[];
  535. }
  536. /** @hidden */
  537. export interface IGLTFImage extends IGLTFChildRootProperty {
  538. uri: string;
  539. }
  540. /** @hidden */
  541. export interface IGLTFSampler extends IGLTFChildRootProperty {
  542. magFilter?: number;
  543. minFilter?: number;
  544. wrapS?: number;
  545. wrapT?: number;
  546. }
  547. /** @hidden */
  548. export interface IGLTFTexture extends IGLTFChildRootProperty {
  549. sampler: string;
  550. source: string;
  551. format?: ETextureFormat;
  552. internalFormat?: ETextureFormat;
  553. target?: number;
  554. type?: number;
  555. babylonTexture?: Texture;
  556. }
  557. /** @hidden */
  558. export interface IGLTFAmbienLight {
  559. color?: number[];
  560. }
  561. /** @hidden */
  562. export interface IGLTFDirectionalLight {
  563. color?: number[];
  564. }
  565. /** @hidden */
  566. export interface IGLTFPointLight {
  567. color?: number[];
  568. constantAttenuation?: number;
  569. linearAttenuation?: number;
  570. quadraticAttenuation?: number;
  571. }
  572. /** @hidden */
  573. export interface IGLTFSpotLight {
  574. color?: number[];
  575. constantAttenuation?: number;
  576. fallOfAngle?: number;
  577. fallOffExponent?: number;
  578. linearAttenuation?: number;
  579. quadraticAttenuation?: number;
  580. }
  581. /** @hidden */
  582. export interface IGLTFLight extends IGLTFChildRootProperty {
  583. type: string;
  584. }
  585. /** @hidden */
  586. export interface IGLTFCameraOrthographic {
  587. xmag: number;
  588. ymag: number;
  589. zfar: number;
  590. znear: number;
  591. }
  592. /** @hidden */
  593. export interface IGLTFCameraPerspective {
  594. aspectRatio: number;
  595. yfov: number;
  596. zfar: number;
  597. znear: number;
  598. }
  599. /** @hidden */
  600. export interface IGLTFCamera extends IGLTFChildRootProperty {
  601. type: string;
  602. }
  603. /** @hidden */
  604. export interface IGLTFAnimationChannelTarget {
  605. id: string;
  606. path: string;
  607. }
  608. /** @hidden */
  609. export interface IGLTFAnimationChannel {
  610. sampler: string;
  611. target: IGLTFAnimationChannelTarget;
  612. }
  613. /** @hidden */
  614. export interface IGLTFAnimationSampler {
  615. input: string;
  616. output: string;
  617. interpolation?: string;
  618. }
  619. /** @hidden */
  620. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  621. channels?: IGLTFAnimationChannel[];
  622. parameters?: {
  623. [key: string]: string;
  624. };
  625. samplers?: {
  626. [key: string]: IGLTFAnimationSampler;
  627. };
  628. }
  629. /** @hidden */
  630. export interface IGLTFNodeInstanceSkin {
  631. skeletons: string[];
  632. skin: string;
  633. meshes: string[];
  634. }
  635. /** @hidden */
  636. export interface IGLTFSkins extends IGLTFChildRootProperty {
  637. bindShapeMatrix: number[];
  638. inverseBindMatrices: string;
  639. jointNames: string[];
  640. babylonSkeleton?: Skeleton;
  641. }
  642. /** @hidden */
  643. export interface IGLTFNode extends IGLTFChildRootProperty {
  644. camera?: string;
  645. children: string[];
  646. skin?: string;
  647. jointName?: string;
  648. light?: string;
  649. matrix: number[];
  650. mesh?: string;
  651. meshes?: string[];
  652. rotation?: number[];
  653. scale?: number[];
  654. translation?: number[];
  655. babylonNode?: Node;
  656. }
  657. /** @hidden */
  658. export interface IGLTFScene extends IGLTFChildRootProperty {
  659. nodes: string[];
  660. }
  661. /** @hidden */
  662. export interface IGLTFRuntime {
  663. extensions: {
  664. [key: string]: any;
  665. };
  666. accessors: {
  667. [key: string]: IGLTFAccessor;
  668. };
  669. buffers: {
  670. [key: string]: IGLTFBuffer;
  671. };
  672. bufferViews: {
  673. [key: string]: IGLTFBufferView;
  674. };
  675. meshes: {
  676. [key: string]: IGLTFMesh;
  677. };
  678. lights: {
  679. [key: string]: IGLTFLight;
  680. };
  681. cameras: {
  682. [key: string]: IGLTFCamera;
  683. };
  684. nodes: {
  685. [key: string]: IGLTFNode;
  686. };
  687. images: {
  688. [key: string]: IGLTFImage;
  689. };
  690. textures: {
  691. [key: string]: IGLTFTexture;
  692. };
  693. shaders: {
  694. [key: string]: IGLTFShader;
  695. };
  696. programs: {
  697. [key: string]: IGLTFProgram;
  698. };
  699. samplers: {
  700. [key: string]: IGLTFSampler;
  701. };
  702. techniques: {
  703. [key: string]: IGLTFTechnique;
  704. };
  705. materials: {
  706. [key: string]: IGLTFMaterial;
  707. };
  708. animations: {
  709. [key: string]: IGLTFAnimation;
  710. };
  711. skins: {
  712. [key: string]: IGLTFSkins;
  713. };
  714. currentScene?: Object;
  715. scenes: {
  716. [key: string]: IGLTFScene;
  717. };
  718. extensionsUsed: string[];
  719. extensionsRequired?: string[];
  720. buffersCount: number;
  721. shaderscount: number;
  722. scene: Scene;
  723. rootUrl: string;
  724. loadedBufferCount: number;
  725. loadedBufferViews: {
  726. [name: string]: ArrayBufferView;
  727. };
  728. loadedShaderCount: number;
  729. importOnlyMeshes: boolean;
  730. importMeshesNames?: string[];
  731. dummyNodes: Node[];
  732. }
  733. /** @hidden */
  734. export interface INodeToRoot {
  735. bone: Bone;
  736. node: IGLTFNode;
  737. id: string;
  738. }
  739. /** @hidden */
  740. export interface IJointNode {
  741. node: IGLTFNode;
  742. id: string;
  743. }
  744. }
  745. declare module BABYLON.GLTF1 {
  746. /**
  747. * Utils functions for GLTF
  748. * @hidden
  749. */
  750. export class GLTFUtils {
  751. /**
  752. * Sets the given "parameter" matrix
  753. * @param scene: the Scene object
  754. * @param source: the source node where to pick the matrix
  755. * @param parameter: the GLTF technique parameter
  756. * @param uniformName: the name of the shader's uniform
  757. * @param shaderMaterial: the shader material
  758. */
  759. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  760. /**
  761. * Sets the given "parameter" matrix
  762. * @param shaderMaterial: the shader material
  763. * @param uniform: the name of the shader's uniform
  764. * @param value: the value of the uniform
  765. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  766. */
  767. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  768. /**
  769. * Returns the wrap mode of the texture
  770. * @param mode: the mode value
  771. */
  772. static GetWrapMode(mode: number): number;
  773. /**
  774. * Returns the byte stride giving an accessor
  775. * @param accessor: the GLTF accessor objet
  776. */
  777. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  778. /**
  779. * Returns the texture filter mode giving a mode value
  780. * @param mode: the filter mode value
  781. */
  782. static GetTextureFilterMode(mode: number): ETextureFilterType;
  783. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  784. /**
  785. * Returns a buffer from its accessor
  786. * @param gltfRuntime: the GLTF runtime
  787. * @param accessor: the GLTF accessor
  788. */
  789. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  790. /**
  791. * Decodes a buffer view into a string
  792. * @param view: the buffer view
  793. */
  794. static DecodeBufferToText(view: ArrayBufferView): string;
  795. /**
  796. * Returns the default material of gltf. Related to
  797. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  798. * @param scene: the Babylon.js scene
  799. */
  800. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  801. private static _DefaultMaterial;
  802. }
  803. }
  804. declare module BABYLON.GLTF1 {
  805. /**
  806. * Implementation of the base glTF spec
  807. * @hidden
  808. */
  809. export class GLTFLoaderBase {
  810. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  811. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  812. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  813. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  814. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  815. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  816. }
  817. /**
  818. * glTF V1 Loader
  819. * @hidden
  820. */
  821. export class GLTFLoader implements IGLTFLoader {
  822. static Extensions: {
  823. [name: string]: GLTFLoaderExtension;
  824. };
  825. static RegisterExtension(extension: GLTFLoaderExtension): void;
  826. state: Nullable<GLTFLoaderState>;
  827. dispose(): void;
  828. private _importMeshAsync;
  829. /**
  830. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  831. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  832. * @param scene the scene the meshes should be added to
  833. * @param data gltf data containing information of the meshes in a loaded file
  834. * @param rootUrl root url to load from
  835. * @param onProgress event that fires when loading progress has occured
  836. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  837. */
  838. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  839. meshes: AbstractMesh[];
  840. particleSystems: IParticleSystem[];
  841. skeletons: Skeleton[];
  842. animationGroups: AnimationGroup[];
  843. }>;
  844. private _loadAsync;
  845. /**
  846. * Imports all objects from a loaded gltf file and adds them to the scene
  847. * @param scene the scene the objects should be added to
  848. * @param data gltf data containing information of the meshes in a loaded file
  849. * @param rootUrl root url to load from
  850. * @param onProgress event that fires when loading progress has occured
  851. * @returns a promise which completes when objects have been loaded to the scene
  852. */
  853. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  854. private _loadShadersAsync;
  855. private _loadBuffersAsync;
  856. private _createNodes;
  857. }
  858. /** @hidden */
  859. export abstract class GLTFLoaderExtension {
  860. private _name;
  861. constructor(name: string);
  862. readonly name: string;
  863. /**
  864. * Defines an override for loading the runtime
  865. * Return true to stop further extensions from loading the runtime
  866. */
  867. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  868. /**
  869. * Defines an onverride for creating gltf runtime
  870. * Return true to stop further extensions from creating the runtime
  871. */
  872. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  873. /**
  874. * Defines an override for loading buffers
  875. * Return true to stop further extensions from loading this buffer
  876. */
  877. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  878. /**
  879. * Defines an override for loading texture buffers
  880. * Return true to stop further extensions from loading this texture data
  881. */
  882. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  883. /**
  884. * Defines an override for creating textures
  885. * Return true to stop further extensions from loading this texture
  886. */
  887. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  888. /**
  889. * Defines an override for loading shader strings
  890. * Return true to stop further extensions from loading this shader data
  891. */
  892. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  893. /**
  894. * Defines an override for loading materials
  895. * Return true to stop further extensions from loading this material
  896. */
  897. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  898. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  899. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  900. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  901. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  902. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  903. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  904. private static LoadTextureBufferAsync;
  905. private static CreateTextureAsync;
  906. private static ApplyExtensions;
  907. }
  908. }
  909. declare module BABYLON.GLTF1 {
  910. /** @hidden */
  911. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  912. private _bin;
  913. constructor();
  914. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  915. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  916. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  917. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  918. }
  919. }
  920. declare module BABYLON.GLTF1 {
  921. /** @hidden */
  922. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  923. constructor();
  924. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  925. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  926. private _loadTexture;
  927. }
  928. }
  929. declare module BABYLON.GLTF2.Loader {
  930. /**
  931. * Loader interface with an index field.
  932. */
  933. export interface IArrayItem {
  934. /**
  935. * The index of this item in the array.
  936. */
  937. index: number;
  938. }
  939. /**
  940. * Loader interface with additional members.
  941. */
  942. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  943. /** @hidden */
  944. _data?: Promise<ArrayBufferView>;
  945. /** @hidden */
  946. _babylonVertexBuffer?: Promise<VertexBuffer>;
  947. }
  948. /**
  949. * Loader interface with additional members.
  950. */
  951. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  952. }
  953. /** @hidden */
  954. export interface _IAnimationSamplerData {
  955. input: Float32Array;
  956. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  957. output: Float32Array;
  958. }
  959. /**
  960. * Loader interface with additional members.
  961. */
  962. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  963. /** @hidden */
  964. _data?: Promise<_IAnimationSamplerData>;
  965. }
  966. /**
  967. * Loader interface with additional members.
  968. */
  969. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  970. channels: IAnimationChannel[];
  971. samplers: IAnimationSampler[];
  972. /** @hidden */
  973. _babylonAnimationGroup?: AnimationGroup;
  974. }
  975. /**
  976. * Loader interface with additional members.
  977. */
  978. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  979. /** @hidden */
  980. _data?: Promise<ArrayBufferView>;
  981. }
  982. /**
  983. * Loader interface with additional members.
  984. */
  985. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  986. /** @hidden */
  987. _data?: Promise<ArrayBufferView>;
  988. /** @hidden */
  989. _babylonBuffer?: Promise<Buffer>;
  990. }
  991. /**
  992. * Loader interface with additional members.
  993. */
  994. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  995. }
  996. /**
  997. * Loader interface with additional members.
  998. */
  999. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  1000. /** @hidden */
  1001. _data?: Promise<ArrayBufferView>;
  1002. }
  1003. /**
  1004. * Loader interface with additional members.
  1005. */
  1006. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  1007. }
  1008. /**
  1009. * Loader interface with additional members.
  1010. */
  1011. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  1012. }
  1013. /**
  1014. * Loader interface with additional members.
  1015. */
  1016. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  1017. baseColorTexture?: ITextureInfo;
  1018. metallicRoughnessTexture?: ITextureInfo;
  1019. }
  1020. /**
  1021. * Loader interface with additional members.
  1022. */
  1023. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  1024. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  1025. normalTexture?: IMaterialNormalTextureInfo;
  1026. occlusionTexture?: IMaterialOcclusionTextureInfo;
  1027. emissiveTexture?: ITextureInfo;
  1028. /** @hidden */
  1029. _data?: {
  1030. [babylonDrawMode: number]: {
  1031. babylonMaterial: Material;
  1032. babylonMeshes: AbstractMesh[];
  1033. promise: Promise<void>;
  1034. };
  1035. };
  1036. }
  1037. /**
  1038. * Loader interface with additional members.
  1039. */
  1040. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  1041. primitives: IMeshPrimitive[];
  1042. }
  1043. /**
  1044. * Loader interface with additional members.
  1045. */
  1046. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  1047. /** @hidden */
  1048. _instanceData?: {
  1049. babylonSourceMesh: Mesh;
  1050. promise: Promise<any>;
  1051. };
  1052. }
  1053. /**
  1054. * Loader interface with additional members.
  1055. */
  1056. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  1057. /**
  1058. * The parent glTF node.
  1059. */
  1060. parent?: INode;
  1061. /** @hidden */
  1062. _babylonTransformNode?: TransformNode;
  1063. /** @hidden */
  1064. _primitiveBabylonMeshes?: AbstractMesh[];
  1065. /** @hidden */
  1066. _babylonBones?: Bone[];
  1067. /** @hidden */
  1068. _numMorphTargets?: number;
  1069. }
  1070. /** @hidden */
  1071. export interface _ISamplerData {
  1072. noMipMaps: boolean;
  1073. samplingMode: number;
  1074. wrapU: number;
  1075. wrapV: number;
  1076. }
  1077. /**
  1078. * Loader interface with additional members.
  1079. */
  1080. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  1081. /** @hidden */
  1082. _data?: _ISamplerData;
  1083. }
  1084. /**
  1085. * Loader interface with additional members.
  1086. */
  1087. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  1088. }
  1089. /**
  1090. * Loader interface with additional members.
  1091. */
  1092. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  1093. /** @hidden */
  1094. _data?: {
  1095. babylonSkeleton: Skeleton;
  1096. promise: Promise<void>;
  1097. };
  1098. }
  1099. /**
  1100. * Loader interface with additional members.
  1101. */
  1102. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  1103. }
  1104. /**
  1105. * Loader interface with additional members.
  1106. */
  1107. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  1108. }
  1109. /**
  1110. * Loader interface with additional members.
  1111. */
  1112. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  1113. accessors?: IAccessor[];
  1114. animations?: IAnimation[];
  1115. buffers?: IBuffer[];
  1116. bufferViews?: IBufferView[];
  1117. cameras?: ICamera[];
  1118. images?: IImage[];
  1119. materials?: IMaterial[];
  1120. meshes?: IMesh[];
  1121. nodes?: INode[];
  1122. samplers?: ISampler[];
  1123. scenes?: IScene[];
  1124. skins?: ISkin[];
  1125. textures?: ITexture[];
  1126. }
  1127. }
  1128. declare module BABYLON.GLTF2 {
  1129. /**
  1130. * Interface for a glTF loader extension.
  1131. */
  1132. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  1133. /**
  1134. * Called after the loader state changes to LOADING.
  1135. */
  1136. onLoading?(): void;
  1137. /**
  1138. * Called after the loader state changes to READY.
  1139. */
  1140. onReady?(): void;
  1141. /**
  1142. * Define this method to modify the default behavior when loading scenes.
  1143. * @param context The context when loading the asset
  1144. * @param scene The glTF scene property
  1145. * @returns A promise that resolves when the load is complete or null if not handled
  1146. */
  1147. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  1148. /**
  1149. * Define this method to modify the default behavior when loading nodes.
  1150. * @param context The context when loading the asset
  1151. * @param node The glTF node property
  1152. * @param assign A function called synchronously after parsing the glTF properties
  1153. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  1154. */
  1155. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1156. /**
  1157. * Define this method to modify the default behavior when loading cameras.
  1158. * @param context The context when loading the asset
  1159. * @param camera The glTF camera property
  1160. * @param assign A function called synchronously after parsing the glTF properties
  1161. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1162. */
  1163. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1164. /**
  1165. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1166. * @param context The context when loading the asset
  1167. * @param primitive The glTF mesh primitive property
  1168. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1169. */
  1170. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1171. /**
  1172. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  1173. * @param context The context when loading the asset
  1174. * @param name The mesh name when loading the asset
  1175. * @param node The glTF node when loading the asset
  1176. * @param mesh The glTF mesh when loading the asset
  1177. * @param primitive The glTF mesh primitive property
  1178. * @param assign A function called synchronously after parsing the glTF properties
  1179. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  1180. */
  1181. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  1182. /**
  1183. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1184. * @param context The context when loading the asset
  1185. * @param material The glTF material property
  1186. * @param assign A function called synchronously after parsing the glTF properties
  1187. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1188. */
  1189. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1190. /**
  1191. * Define this method to modify the default behavior when creating materials.
  1192. * @param context The context when loading the asset
  1193. * @param material The glTF material property
  1194. * @param babylonDrawMode The draw mode for the Babylon material
  1195. * @returns The Babylon material or null if not handled
  1196. */
  1197. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1198. /**
  1199. * Define this method to modify the default behavior when loading material properties.
  1200. * @param context The context when loading the asset
  1201. * @param material The glTF material property
  1202. * @param babylonMaterial The Babylon material
  1203. * @returns A promise that resolves when the load is complete or null if not handled
  1204. */
  1205. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1206. /**
  1207. * Define this method to modify the default behavior when loading texture infos.
  1208. * @param context The context when loading the asset
  1209. * @param textureInfo The glTF texture info property
  1210. * @param assign A function called synchronously after parsing the glTF properties
  1211. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1212. */
  1213. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1214. /**
  1215. * Define this method to modify the default behavior when loading animations.
  1216. * @param context The context when loading the asset
  1217. * @param animation The glTF animation property
  1218. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1219. */
  1220. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1221. /**
  1222. * @hidden Define this method to modify the default behavior when loading skins.
  1223. * @param context The context when loading the asset
  1224. * @param node The glTF node property
  1225. * @param skin The glTF skin property
  1226. * @returns A promise that resolves when the load is complete or null if not handled
  1227. */
  1228. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  1229. /**
  1230. * @hidden Define this method to modify the default behavior when loading uris.
  1231. * @param context The context when loading the asset
  1232. * @param property The glTF property associated with the uri
  1233. * @param uri The uri to load
  1234. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1235. */
  1236. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1237. /**
  1238. * Define this method to modify the default behavior when loading buffer views.
  1239. * @param context The context when loading the asset
  1240. * @param bufferView The glTF buffer view property
  1241. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1242. */
  1243. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  1244. /**
  1245. * Define this method to modify the default behavior when loading buffers.
  1246. * @param context The context when loading the asset
  1247. * @param buffer The glTF buffer property
  1248. * @param byteOffset The byte offset to load
  1249. * @param byteLength The byte length to load
  1250. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1251. */
  1252. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  1253. }
  1254. }
  1255. declare module BABYLON.GLTF2 {
  1256. /**
  1257. * Helper class for working with arrays when loading the glTF asset
  1258. */
  1259. export class ArrayItem {
  1260. /**
  1261. * Gets an item from the given array.
  1262. * @param context The context when loading the asset
  1263. * @param array The array to get the item from
  1264. * @param index The index to the array
  1265. * @returns The array item
  1266. */
  1267. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1268. /**
  1269. * Assign an `index` field to each item of the given array.
  1270. * @param array The array of items
  1271. */
  1272. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  1273. }
  1274. /**
  1275. * The glTF 2.0 loader
  1276. */
  1277. export class GLTFLoader implements IGLTFLoader {
  1278. /** @hidden */
  1279. _completePromises: Promise<any>[];
  1280. private _disposed;
  1281. private _parent;
  1282. private _state;
  1283. private _extensions;
  1284. private _rootUrl;
  1285. private _fileName;
  1286. private _uniqueRootUrl;
  1287. private _gltf;
  1288. private _bin;
  1289. private _babylonScene;
  1290. private _rootBabylonMesh;
  1291. private _defaultBabylonMaterialData;
  1292. private _progressCallback?;
  1293. private _requests;
  1294. private static readonly _DefaultSampler;
  1295. private static _RegisteredExtensions;
  1296. /**
  1297. * Registers a loader extension.
  1298. * @param name The name of the loader extension.
  1299. * @param factory The factory function that creates the loader extension.
  1300. */
  1301. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1302. /**
  1303. * Unregisters a loader extension.
  1304. * @param name The name of the loader extension.
  1305. * @returns A boolean indicating whether the extension has been unregistered
  1306. */
  1307. static UnregisterExtension(name: string): boolean;
  1308. /**
  1309. * Gets the loader state.
  1310. */
  1311. readonly state: Nullable<GLTFLoaderState>;
  1312. /**
  1313. * The object that represents the glTF JSON.
  1314. */
  1315. readonly gltf: IGLTF;
  1316. /**
  1317. * The BIN chunk of a binary glTF.
  1318. */
  1319. readonly bin: Nullable<IDataBuffer>;
  1320. /**
  1321. * The parent file loader.
  1322. */
  1323. readonly parent: GLTFFileLoader;
  1324. /**
  1325. * The Babylon scene when loading the asset.
  1326. */
  1327. readonly babylonScene: Scene;
  1328. /**
  1329. * The root Babylon mesh when loading the asset.
  1330. */
  1331. readonly rootBabylonMesh: Mesh;
  1332. /** @hidden */
  1333. constructor(parent: GLTFFileLoader);
  1334. /** @hidden */
  1335. dispose(): void;
  1336. /** @hidden */
  1337. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1338. meshes: AbstractMesh[];
  1339. particleSystems: IParticleSystem[];
  1340. skeletons: Skeleton[];
  1341. animationGroups: AnimationGroup[];
  1342. }>;
  1343. /** @hidden */
  1344. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1345. private _loadAsync;
  1346. private _loadData;
  1347. private _setupData;
  1348. private _loadExtensions;
  1349. private _checkExtensions;
  1350. private _setState;
  1351. private _createRootNode;
  1352. /**
  1353. * Loads a glTF scene.
  1354. * @param context The context when loading the asset
  1355. * @param scene The glTF scene property
  1356. * @returns A promise that resolves when the load is complete
  1357. */
  1358. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  1359. private _forEachPrimitive;
  1360. private _getMeshes;
  1361. private _getSkeletons;
  1362. private _getAnimationGroups;
  1363. private _startAnimations;
  1364. /**
  1365. * Loads a glTF node.
  1366. * @param context The context when loading the asset
  1367. * @param node The glTF node property
  1368. * @param assign A function called synchronously after parsing the glTF properties
  1369. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1370. */
  1371. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  1372. private _loadMeshAsync;
  1373. /**
  1374. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  1375. * @param context The context when loading the asset
  1376. * @param name The mesh name when loading the asset
  1377. * @param node The glTF node when loading the asset
  1378. * @param mesh The glTF mesh when loading the asset
  1379. * @param primitive The glTF mesh primitive property
  1380. * @param assign A function called synchronously after parsing the glTF properties
  1381. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  1382. */
  1383. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  1384. private _loadVertexDataAsync;
  1385. private _createMorphTargets;
  1386. private _loadMorphTargetsAsync;
  1387. private _loadMorphTargetVertexDataAsync;
  1388. private static _LoadTransform;
  1389. private _loadSkinAsync;
  1390. private _loadBones;
  1391. private _loadBone;
  1392. private _loadSkinInverseBindMatricesDataAsync;
  1393. private _updateBoneMatrices;
  1394. private _getNodeMatrix;
  1395. /**
  1396. * Loads a glTF camera.
  1397. * @param context The context when loading the asset
  1398. * @param camera The glTF camera property
  1399. * @param assign A function called synchronously after parsing the glTF properties
  1400. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1401. */
  1402. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1403. private _loadAnimationsAsync;
  1404. /**
  1405. * Loads a glTF animation.
  1406. * @param context The context when loading the asset
  1407. * @param animation The glTF animation property
  1408. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1409. */
  1410. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  1411. /**
  1412. * @hidden Loads a glTF animation channel.
  1413. * @param context The context when loading the asset
  1414. * @param animationContext The context of the animation when loading the asset
  1415. * @param animation The glTF animation property
  1416. * @param channel The glTF animation channel property
  1417. * @param babylonAnimationGroup The babylon animation group property
  1418. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  1419. * @returns A void promise when the channel load is complete
  1420. */
  1421. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  1422. private _loadAnimationSamplerAsync;
  1423. private _loadBufferAsync;
  1424. /**
  1425. * Loads a glTF buffer view.
  1426. * @param context The context when loading the asset
  1427. * @param bufferView The glTF buffer view property
  1428. * @returns A promise that resolves with the loaded data when the load is complete
  1429. */
  1430. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1431. private _loadAccessorAsync;
  1432. private _loadFloatAccessorAsync;
  1433. private _loadIndicesAccessorAsync;
  1434. private _loadVertexBufferViewAsync;
  1435. private _loadVertexAccessorAsync;
  1436. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1437. /** @hidden */
  1438. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1439. private _createDefaultMaterial;
  1440. /**
  1441. * Creates a Babylon material from a glTF material.
  1442. * @param context The context when loading the asset
  1443. * @param material The glTF material property
  1444. * @param babylonDrawMode The draw mode for the Babylon material
  1445. * @returns The Babylon material
  1446. */
  1447. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1448. /**
  1449. * Loads properties from a glTF material into a Babylon material.
  1450. * @param context The context when loading the asset
  1451. * @param material The glTF material property
  1452. * @param babylonMaterial The Babylon material
  1453. * @returns A promise that resolves when the load is complete
  1454. */
  1455. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1456. /**
  1457. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1458. * @param context The context when loading the asset
  1459. * @param material The glTF material property
  1460. * @param babylonMaterial The Babylon material
  1461. * @returns A promise that resolves when the load is complete
  1462. */
  1463. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1464. /**
  1465. * Loads the alpha properties from a glTF material into a Babylon material.
  1466. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1467. * @param context The context when loading the asset
  1468. * @param material The glTF material property
  1469. * @param babylonMaterial The Babylon material
  1470. */
  1471. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1472. /**
  1473. * Loads a glTF texture info.
  1474. * @param context The context when loading the asset
  1475. * @param textureInfo The glTF texture info property
  1476. * @param assign A function called synchronously after parsing the glTF properties
  1477. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1478. */
  1479. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1480. private _loadTextureAsync;
  1481. private _loadSampler;
  1482. /**
  1483. * Loads a glTF image.
  1484. * @param context The context when loading the asset
  1485. * @param image The glTF image property
  1486. * @returns A promise that resolves with the loaded data when the load is complete
  1487. */
  1488. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1489. /**
  1490. * Loads a glTF uri.
  1491. * @param context The context when loading the asset
  1492. * @param property The glTF property associated with the uri
  1493. * @param uri The base64 or relative uri
  1494. * @returns A promise that resolves with the loaded data when the load is complete
  1495. */
  1496. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  1497. private _onProgress;
  1498. /**
  1499. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1500. * @param babylonObject the Babylon object with metadata
  1501. * @param pointer the JSON pointer
  1502. */
  1503. static AddPointerMetadata(babylonObject: {
  1504. metadata: any;
  1505. }, pointer: string): void;
  1506. private static _GetTextureWrapMode;
  1507. private static _GetTextureSamplingMode;
  1508. private static _GetTypedArrayConstructor;
  1509. private static _GetTypedArray;
  1510. private static _GetNumComponents;
  1511. private static _ValidateUri;
  1512. private static _GetDrawMode;
  1513. private _compileMaterialsAsync;
  1514. private _compileShadowGeneratorsAsync;
  1515. private _forEachExtensions;
  1516. private _applyExtensions;
  1517. private _extensionsOnLoading;
  1518. private _extensionsOnReady;
  1519. private _extensionsLoadSceneAsync;
  1520. private _extensionsLoadNodeAsync;
  1521. private _extensionsLoadCameraAsync;
  1522. private _extensionsLoadVertexDataAsync;
  1523. private _extensionsLoadMeshPrimitiveAsync;
  1524. private _extensionsLoadMaterialAsync;
  1525. private _extensionsCreateMaterial;
  1526. private _extensionsLoadMaterialPropertiesAsync;
  1527. private _extensionsLoadTextureInfoAsync;
  1528. private _extensionsLoadAnimationAsync;
  1529. private _extensionsLoadSkinAsync;
  1530. private _extensionsLoadUriAsync;
  1531. private _extensionsLoadBufferViewAsync;
  1532. private _extensionsLoadBufferAsync;
  1533. /**
  1534. * Helper method called by a loader extension to load an glTF extension.
  1535. * @param context The context when loading the asset
  1536. * @param property The glTF property to load the extension from
  1537. * @param extensionName The name of the extension to load
  1538. * @param actionAsync The action to run
  1539. * @returns The promise returned by actionAsync or null if the extension does not exist
  1540. */
  1541. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1542. /**
  1543. * Helper method called by a loader extension to load a glTF extra.
  1544. * @param context The context when loading the asset
  1545. * @param property The glTF property to load the extra from
  1546. * @param extensionName The name of the extension to load
  1547. * @param actionAsync The action to run
  1548. * @returns The promise returned by actionAsync or null if the extra does not exist
  1549. */
  1550. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1551. /**
  1552. * Checks for presence of an extension.
  1553. * @param name The name of the extension to check
  1554. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  1555. */
  1556. isExtensionUsed(name: string): boolean;
  1557. /**
  1558. * Increments the indentation level and logs a message.
  1559. * @param message The message to log
  1560. */
  1561. logOpen(message: string): void;
  1562. /**
  1563. * Decrements the indentation level.
  1564. */
  1565. logClose(): void;
  1566. /**
  1567. * Logs a message
  1568. * @param message The message to log
  1569. */
  1570. log(message: string): void;
  1571. /**
  1572. * Starts a performance counter.
  1573. * @param counterName The name of the performance counter
  1574. */
  1575. startPerformanceCounter(counterName: string): void;
  1576. /**
  1577. * Ends a performance counter.
  1578. * @param counterName The name of the performance counter
  1579. */
  1580. endPerformanceCounter(counterName: string): void;
  1581. }
  1582. }
  1583. declare module BABYLON.GLTF2.Loader.Extensions {
  1584. /**
  1585. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  1586. */
  1587. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1588. /**
  1589. * The name of this extension.
  1590. */
  1591. readonly name: string;
  1592. /**
  1593. * Defines whether this extension is enabled.
  1594. */
  1595. enabled: boolean;
  1596. private _loader;
  1597. private _lights?;
  1598. /** @hidden */
  1599. constructor(loader: GLTFLoader);
  1600. /** @hidden */
  1601. dispose(): void;
  1602. /** @hidden */
  1603. onLoading(): void;
  1604. /** @hidden */
  1605. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1606. private _loadLightAsync;
  1607. }
  1608. }
  1609. declare module BABYLON.GLTF2.Loader.Extensions {
  1610. /**
  1611. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1612. */
  1613. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1614. /**
  1615. * The name of this extension.
  1616. */
  1617. readonly name: string;
  1618. /**
  1619. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  1620. */
  1621. dracoCompression?: DracoCompression;
  1622. /**
  1623. * Defines whether this extension is enabled.
  1624. */
  1625. enabled: boolean;
  1626. private _loader;
  1627. /** @hidden */
  1628. constructor(loader: GLTFLoader);
  1629. /** @hidden */
  1630. dispose(): void;
  1631. /** @hidden */
  1632. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1633. }
  1634. }
  1635. declare module BABYLON.GLTF2.Loader.Extensions {
  1636. /**
  1637. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  1638. */
  1639. export class KHR_lights implements IGLTFLoaderExtension {
  1640. /**
  1641. * The name of this extension.
  1642. */
  1643. readonly name: string;
  1644. /**
  1645. * Defines whether this extension is enabled.
  1646. */
  1647. enabled: boolean;
  1648. private _loader;
  1649. private _lights?;
  1650. /** @hidden */
  1651. constructor(loader: GLTFLoader);
  1652. /** @hidden */
  1653. dispose(): void;
  1654. /** @hidden */
  1655. onLoading(): void;
  1656. /** @hidden */
  1657. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1658. }
  1659. }
  1660. declare module BABYLON.GLTF2.Loader.Extensions {
  1661. /**
  1662. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1663. */
  1664. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1665. /**
  1666. * The name of this extension.
  1667. */
  1668. readonly name: string;
  1669. /**
  1670. * Defines whether this extension is enabled.
  1671. */
  1672. enabled: boolean;
  1673. /**
  1674. * Defines a number that determines the order the extensions are applied.
  1675. */
  1676. order: number;
  1677. private _loader;
  1678. /** @hidden */
  1679. constructor(loader: GLTFLoader);
  1680. /** @hidden */
  1681. dispose(): void;
  1682. /** @hidden */
  1683. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1684. private _loadSpecularGlossinessPropertiesAsync;
  1685. }
  1686. }
  1687. declare module BABYLON.GLTF2.Loader.Extensions {
  1688. /**
  1689. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1690. */
  1691. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1692. /**
  1693. * The name of this extension.
  1694. */
  1695. readonly name: string;
  1696. /**
  1697. * Defines whether this extension is enabled.
  1698. */
  1699. enabled: boolean;
  1700. /**
  1701. * Defines a number that determines the order the extensions are applied.
  1702. */
  1703. order: number;
  1704. private _loader;
  1705. /** @hidden */
  1706. constructor(loader: GLTFLoader);
  1707. /** @hidden */
  1708. dispose(): void;
  1709. /** @hidden */
  1710. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1711. private _loadUnlitPropertiesAsync;
  1712. }
  1713. }
  1714. declare module BABYLON.GLTF2.Loader.Extensions {
  1715. /**
  1716. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1717. * [Playground Sample](https://www.babylonjs-playground.com/#7F7PN6)
  1718. * !!! Experimental Extension Subject to Changes !!!
  1719. */
  1720. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  1721. /**
  1722. * The name of this extension.
  1723. */
  1724. readonly name: string;
  1725. /**
  1726. * Defines whether this extension is enabled.
  1727. */
  1728. enabled: boolean;
  1729. /**
  1730. * Defines a number that determines the order the extensions are applied.
  1731. */
  1732. order: number;
  1733. private _loader;
  1734. /** @hidden */
  1735. constructor(loader: GLTFLoader);
  1736. /** @hidden */
  1737. dispose(): void;
  1738. /** @hidden */
  1739. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1740. private _loadClearCoatPropertiesAsync;
  1741. }
  1742. }
  1743. declare module BABYLON.GLTF2.Loader.Extensions {
  1744. /**
  1745. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  1746. * !!! Experimental Extension Subject to Changes !!!
  1747. */
  1748. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  1749. /**
  1750. * The name of this extension.
  1751. */
  1752. readonly name: string;
  1753. /**
  1754. * Defines whether this extension is enabled.
  1755. */
  1756. enabled: boolean;
  1757. /**
  1758. * Defines a number that determines the order the extensions are applied.
  1759. */
  1760. order: number;
  1761. private _loader;
  1762. /** @hidden */
  1763. constructor(loader: GLTFLoader);
  1764. /** @hidden */
  1765. dispose(): void;
  1766. /** @hidden */
  1767. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1768. private _loadSheenPropertiesAsync;
  1769. }
  1770. }
  1771. declare module BABYLON.GLTF2.Loader.Extensions {
  1772. /**
  1773. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1774. * !!! Experimental Extension Subject to Changes !!!
  1775. */
  1776. export class KHR_materials_specular implements IGLTFLoaderExtension {
  1777. /**
  1778. * The name of this extension.
  1779. */
  1780. readonly name: string;
  1781. /**
  1782. * Defines whether this extension is enabled.
  1783. */
  1784. enabled: boolean;
  1785. /**
  1786. * Defines a number that determines the order the extensions are applied.
  1787. */
  1788. order: number;
  1789. private _loader;
  1790. /** @hidden */
  1791. constructor(loader: GLTFLoader);
  1792. /** @hidden */
  1793. dispose(): void;
  1794. /** @hidden */
  1795. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1796. private _loadSpecularPropertiesAsync;
  1797. }
  1798. }
  1799. declare module BABYLON.GLTF2.Loader.Extensions {
  1800. /**
  1801. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1802. */
  1803. export class KHR_texture_transform implements IGLTFLoaderExtension {
  1804. /**
  1805. * The name of this extension.
  1806. */
  1807. readonly name: string;
  1808. /**
  1809. * Defines whether this extension is enabled.
  1810. */
  1811. enabled: boolean;
  1812. private _loader;
  1813. /** @hidden */
  1814. constructor(loader: GLTFLoader);
  1815. /** @hidden */
  1816. dispose(): void;
  1817. /** @hidden */
  1818. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1819. }
  1820. }
  1821. declare module BABYLON.GLTF2.Loader.Extensions {
  1822. /**
  1823. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1824. */
  1825. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1826. /**
  1827. * The name of this extension.
  1828. */
  1829. readonly name: string;
  1830. /**
  1831. * Defines whether this extension is enabled.
  1832. */
  1833. enabled: boolean;
  1834. private _loader;
  1835. private _clips;
  1836. private _emitters;
  1837. /** @hidden */
  1838. constructor(loader: GLTFLoader);
  1839. /** @hidden */
  1840. dispose(): void;
  1841. /** @hidden */
  1842. onLoading(): void;
  1843. /** @hidden */
  1844. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1845. /** @hidden */
  1846. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1847. /** @hidden */
  1848. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1849. private _loadClipAsync;
  1850. private _loadEmitterAsync;
  1851. private _getEventAction;
  1852. private _loadAnimationEventAsync;
  1853. }
  1854. }
  1855. declare module BABYLON.GLTF2.Loader.Extensions {
  1856. /**
  1857. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1858. */
  1859. export class MSFT_lod implements IGLTFLoaderExtension {
  1860. /**
  1861. * The name of this extension.
  1862. */
  1863. readonly name: string;
  1864. /**
  1865. * Defines whether this extension is enabled.
  1866. */
  1867. enabled: boolean;
  1868. /**
  1869. * Defines a number that determines the order the extensions are applied.
  1870. */
  1871. order: number;
  1872. /**
  1873. * Maximum number of LODs to load, starting from the lowest LOD.
  1874. */
  1875. maxLODsToLoad: number;
  1876. /**
  1877. * Observable raised when all node LODs of one level are loaded.
  1878. * The event data is the index of the loaded LOD starting from zero.
  1879. * Dispose the loader to cancel the loading of the next level of LODs.
  1880. */
  1881. onNodeLODsLoadedObservable: Observable<number>;
  1882. /**
  1883. * Observable raised when all material LODs of one level are loaded.
  1884. * The event data is the index of the loaded LOD starting from zero.
  1885. * Dispose the loader to cancel the loading of the next level of LODs.
  1886. */
  1887. onMaterialLODsLoadedObservable: Observable<number>;
  1888. private _loader;
  1889. private _nodeIndexLOD;
  1890. private _nodeSignalLODs;
  1891. private _nodePromiseLODs;
  1892. private _materialIndexLOD;
  1893. private _materialSignalLODs;
  1894. private _materialPromiseLODs;
  1895. private _indexLOD;
  1896. private _bufferLODs;
  1897. /** @hidden */
  1898. constructor(loader: GLTFLoader);
  1899. /** @hidden */
  1900. dispose(): void;
  1901. /** @hidden */
  1902. onReady(): void;
  1903. /** @hidden */
  1904. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1905. /** @hidden */
  1906. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1907. /** @hidden */
  1908. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1909. /** @hidden */
  1910. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  1911. private _loadBufferLOD;
  1912. /**
  1913. * Gets an array of LOD properties from lowest to highest.
  1914. */
  1915. private _getLODs;
  1916. private _disposeUnusedMaterials;
  1917. }
  1918. }
  1919. declare module BABYLON.GLTF2.Loader.Extensions {
  1920. /** @hidden */
  1921. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1922. readonly name: string;
  1923. enabled: boolean;
  1924. private _loader;
  1925. constructor(loader: GLTFLoader);
  1926. dispose(): void;
  1927. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1928. }
  1929. }
  1930. declare module BABYLON.GLTF2.Loader.Extensions {
  1931. /** @hidden */
  1932. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1933. readonly name: string;
  1934. enabled: boolean;
  1935. private _loader;
  1936. constructor(loader: GLTFLoader);
  1937. dispose(): void;
  1938. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1939. }
  1940. }
  1941. declare module BABYLON.GLTF2.Loader.Extensions {
  1942. /**
  1943. * Store glTF extras (if present) in BJS objects' metadata
  1944. */
  1945. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  1946. /**
  1947. * The name of this extension.
  1948. */
  1949. readonly name: string;
  1950. /**
  1951. * Defines whether this extension is enabled.
  1952. */
  1953. enabled: boolean;
  1954. private _loader;
  1955. private _assignExtras;
  1956. /** @hidden */
  1957. constructor(loader: GLTFLoader);
  1958. /** @hidden */
  1959. dispose(): void;
  1960. /** @hidden */
  1961. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1962. /** @hidden */
  1963. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1964. /** @hidden */
  1965. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1966. }
  1967. }
  1968. declare module BABYLON {
  1969. /**
  1970. * Class reading and parsing the MTL file bundled with the obj file.
  1971. */
  1972. export class MTLFileLoader {
  1973. /**
  1974. * All material loaded from the mtl will be set here
  1975. */
  1976. materials: StandardMaterial[];
  1977. /**
  1978. * This function will read the mtl file and create each material described inside
  1979. * This function could be improve by adding :
  1980. * -some component missing (Ni, Tf...)
  1981. * -including the specific options available
  1982. *
  1983. * @param scene defines the scene the material will be created in
  1984. * @param data defines the mtl data to parse
  1985. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  1986. */
  1987. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  1988. /**
  1989. * Gets the texture for the material.
  1990. *
  1991. * If the material is imported from input file,
  1992. * We sanitize the url to ensure it takes the textre from aside the material.
  1993. *
  1994. * @param rootUrl The root url to load from
  1995. * @param value The value stored in the mtl
  1996. * @return The Texture
  1997. */
  1998. private static _getTexture;
  1999. }
  2000. /**
  2001. * Options for loading OBJ/MTL files
  2002. */
  2003. type MeshLoadOptions = {
  2004. /**
  2005. * Defines if UVs are optimized by default during load.
  2006. */
  2007. OptimizeWithUV: boolean;
  2008. /**
  2009. * Defines custom scaling of UV coordinates of loaded meshes.
  2010. */
  2011. UVScaling: Vector2;
  2012. /**
  2013. * Invert model on y-axis (does a model scaling inversion)
  2014. */
  2015. InvertY: boolean;
  2016. /**
  2017. * Invert Y-Axis of referenced textures on load
  2018. */
  2019. InvertTextureY: boolean;
  2020. /**
  2021. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2022. */
  2023. ImportVertexColors: boolean;
  2024. /**
  2025. * Compute the normals for the model, even if normals are present in the file.
  2026. */
  2027. ComputeNormals: boolean;
  2028. /**
  2029. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2030. */
  2031. SkipMaterials: boolean;
  2032. /**
  2033. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2034. */
  2035. MaterialLoadingFailsSilently: boolean;
  2036. };
  2037. /**
  2038. * OBJ file type loader.
  2039. * This is a babylon scene loader plugin.
  2040. */
  2041. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2042. /**
  2043. * Defines if UVs are optimized by default during load.
  2044. */
  2045. static OPTIMIZE_WITH_UV: boolean;
  2046. /**
  2047. * Invert model on y-axis (does a model scaling inversion)
  2048. */
  2049. static INVERT_Y: boolean;
  2050. /**
  2051. * Invert Y-Axis of referenced textures on load
  2052. */
  2053. static INVERT_TEXTURE_Y: boolean;
  2054. /**
  2055. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2056. */
  2057. static IMPORT_VERTEX_COLORS: boolean;
  2058. /**
  2059. * Compute the normals for the model, even if normals are present in the file.
  2060. */
  2061. static COMPUTE_NORMALS: boolean;
  2062. /**
  2063. * Defines custom scaling of UV coordinates of loaded meshes.
  2064. */
  2065. static UV_SCALING: Vector2;
  2066. /**
  2067. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2068. */
  2069. static SKIP_MATERIALS: boolean;
  2070. /**
  2071. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2072. *
  2073. * Defaults to true for backwards compatibility.
  2074. */
  2075. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2076. /**
  2077. * Defines the name of the plugin.
  2078. */
  2079. name: string;
  2080. /**
  2081. * Defines the extension the plugin is able to load.
  2082. */
  2083. extensions: string;
  2084. /** @hidden */
  2085. obj: RegExp;
  2086. /** @hidden */
  2087. group: RegExp;
  2088. /** @hidden */
  2089. mtllib: RegExp;
  2090. /** @hidden */
  2091. usemtl: RegExp;
  2092. /** @hidden */
  2093. smooth: RegExp;
  2094. /** @hidden */
  2095. vertexPattern: RegExp;
  2096. /** @hidden */
  2097. normalPattern: RegExp;
  2098. /** @hidden */
  2099. uvPattern: RegExp;
  2100. /** @hidden */
  2101. facePattern1: RegExp;
  2102. /** @hidden */
  2103. facePattern2: RegExp;
  2104. /** @hidden */
  2105. facePattern3: RegExp;
  2106. /** @hidden */
  2107. facePattern4: RegExp;
  2108. /** @hidden */
  2109. facePattern5: RegExp;
  2110. private _meshLoadOptions;
  2111. /**
  2112. * Creates loader for .OBJ files
  2113. *
  2114. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2115. */
  2116. constructor(meshLoadOptions?: MeshLoadOptions);
  2117. private static readonly currentMeshLoadOptions;
  2118. /**
  2119. * Calls synchronously the MTL file attached to this obj.
  2120. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2121. * Without this function materials are not displayed in the first frame (but displayed after).
  2122. * In consequence it is impossible to get material information in your HTML file
  2123. *
  2124. * @param url The URL of the MTL file
  2125. * @param rootUrl
  2126. * @param onSuccess Callback function to be called when the MTL file is loaded
  2127. * @private
  2128. */
  2129. private _loadMTL;
  2130. /**
  2131. * Instantiates a OBJ file loader plugin.
  2132. * @returns the created plugin
  2133. */
  2134. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2135. /**
  2136. * If the data string can be loaded directly.
  2137. *
  2138. * @param data string containing the file data
  2139. * @returns if the data can be loaded directly
  2140. */
  2141. canDirectLoad(data: string): boolean;
  2142. /**
  2143. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2144. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2145. * @param scene the scene the meshes should be added to
  2146. * @param data the OBJ data to load
  2147. * @param rootUrl root url to load from
  2148. * @param onProgress event that fires when loading progress has occured
  2149. * @param fileName Defines the name of the file to load
  2150. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2151. */
  2152. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2153. meshes: AbstractMesh[];
  2154. particleSystems: IParticleSystem[];
  2155. skeletons: Skeleton[];
  2156. animationGroups: AnimationGroup[];
  2157. }>;
  2158. /**
  2159. * Imports all objects from the loaded OBJ data and adds them to the scene
  2160. * @param scene the scene the objects should be added to
  2161. * @param data the OBJ data to load
  2162. * @param rootUrl root url to load from
  2163. * @param onProgress event that fires when loading progress has occured
  2164. * @param fileName Defines the name of the file to load
  2165. * @returns a promise which completes when objects have been loaded to the scene
  2166. */
  2167. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2168. /**
  2169. * Load into an asset container.
  2170. * @param scene The scene to load into
  2171. * @param data The data to import
  2172. * @param rootUrl The root url for scene and resources
  2173. * @param onProgress The callback when the load progresses
  2174. * @param fileName Defines the name of the file to load
  2175. * @returns The loaded asset container
  2176. */
  2177. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2178. /**
  2179. * Read the OBJ file and create an Array of meshes.
  2180. * Each mesh contains all information given by the OBJ and the MTL file.
  2181. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2182. *
  2183. * @param meshesNames
  2184. * @param scene Scene The scene where are displayed the data
  2185. * @param data String The content of the obj file
  2186. * @param rootUrl String The path to the folder
  2187. * @returns Array<AbstractMesh>
  2188. * @private
  2189. */
  2190. private _parseSolid;
  2191. }
  2192. }
  2193. declare module BABYLON {
  2194. /**
  2195. * STL file type loader.
  2196. * This is a babylon scene loader plugin.
  2197. */
  2198. export class STLFileLoader implements ISceneLoaderPlugin {
  2199. /** @hidden */
  2200. solidPattern: RegExp;
  2201. /** @hidden */
  2202. facetsPattern: RegExp;
  2203. /** @hidden */
  2204. normalPattern: RegExp;
  2205. /** @hidden */
  2206. vertexPattern: RegExp;
  2207. /**
  2208. * Defines the name of the plugin.
  2209. */
  2210. name: string;
  2211. /**
  2212. * Defines the extensions the stl loader is able to load.
  2213. * force data to come in as an ArrayBuffer
  2214. * we'll convert to string if it looks like it's an ASCII .stl
  2215. */
  2216. extensions: ISceneLoaderPluginExtensions;
  2217. /**
  2218. * Import meshes into a scene.
  2219. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2220. * @param scene The scene to import into
  2221. * @param data The data to import
  2222. * @param rootUrl The root url for scene and resources
  2223. * @param meshes The meshes array to import into
  2224. * @param particleSystems The particle systems array to import into
  2225. * @param skeletons The skeletons array to import into
  2226. * @param onError The callback when import fails
  2227. * @returns True if successful or false otherwise
  2228. */
  2229. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2230. /**
  2231. * Load into a scene.
  2232. * @param scene The scene to load into
  2233. * @param data The data to import
  2234. * @param rootUrl The root url for scene and resources
  2235. * @param onError The callback when import fails
  2236. * @returns true if successful or false otherwise
  2237. */
  2238. load(scene: Scene, data: any, rootUrl: string): boolean;
  2239. /**
  2240. * Load into an asset container.
  2241. * @param scene The scene to load into
  2242. * @param data The data to import
  2243. * @param rootUrl The root url for scene and resources
  2244. * @param onError The callback when import fails
  2245. * @returns The loaded asset container
  2246. */
  2247. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2248. private _isBinary;
  2249. private _parseBinary;
  2250. private _parseASCII;
  2251. }
  2252. }