babylonjs.loaders.d.ts 92 KB

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