babylonjs.loaders.module.d.ts 175 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221
  1. declare module "babylonjs-loaders/glTF/glTFFileLoader" {
  2. import { IGLTFValidationResults } from "babylonjs-gltf2interface";
  3. import { Nullable } from "babylonjs/types";
  4. import { Observable } from "babylonjs/Misc/observable";
  5. import { Camera } from "babylonjs/Cameras/camera";
  6. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  7. import { Skeleton } from "babylonjs/Bones/skeleton";
  8. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  9. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10. import { Material } from "babylonjs/Materials/material";
  11. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12. import { ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  13. import { AssetContainer } from "babylonjs/assetContainer";
  14. import { Scene, IDisposable } from "babylonjs/scene";
  15. /**
  16. * Mode that determines the coordinate system to use.
  17. */
  18. export enum GLTFLoaderCoordinateSystemMode {
  19. /**
  20. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  21. */
  22. AUTO = 0,
  23. /**
  24. * Sets the useRightHandedSystem flag on the scene.
  25. */
  26. FORCE_RIGHT_HANDED = 1
  27. }
  28. /**
  29. * Mode that determines what animations will start.
  30. */
  31. export enum GLTFLoaderAnimationStartMode {
  32. /**
  33. * No animation will start.
  34. */
  35. NONE = 0,
  36. /**
  37. * The first animation will start.
  38. */
  39. FIRST = 1,
  40. /**
  41. * All animations will start.
  42. */
  43. ALL = 2
  44. }
  45. /**
  46. * Interface that contains the data for the glTF asset.
  47. */
  48. export interface IGLTFLoaderData {
  49. /**
  50. * Object that represents the glTF JSON.
  51. */
  52. json: Object;
  53. /**
  54. * The BIN chunk of a binary glTF.
  55. */
  56. bin: Nullable<ArrayBufferView>;
  57. }
  58. /**
  59. * Interface for extending the loader.
  60. */
  61. export interface IGLTFLoaderExtension {
  62. /**
  63. * The name of this extension.
  64. */
  65. readonly name: string;
  66. /**
  67. * Defines whether this extension is enabled.
  68. */
  69. enabled: boolean;
  70. }
  71. /**
  72. * Loader state.
  73. */
  74. export enum GLTFLoaderState {
  75. /**
  76. * The asset is loading.
  77. */
  78. LOADING = 0,
  79. /**
  80. * The asset is ready for rendering.
  81. */
  82. READY = 1,
  83. /**
  84. * The asset is completely loaded.
  85. */
  86. COMPLETE = 2
  87. }
  88. /** @hidden */
  89. export interface IGLTFLoader extends IDisposable {
  90. readonly state: Nullable<GLTFLoaderState>;
  91. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  92. meshes: AbstractMesh[];
  93. particleSystems: IParticleSystem[];
  94. skeletons: Skeleton[];
  95. animationGroups: AnimationGroup[];
  96. }>;
  97. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  98. }
  99. /**
  100. * File loader for loading glTF files into a scene.
  101. */
  102. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  103. /** @hidden */
  104. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  105. /** @hidden */
  106. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  107. /**
  108. * Raised when the asset has been parsed
  109. */
  110. onParsedObservable: Observable<IGLTFLoaderData>;
  111. private _onParsedObserver;
  112. /**
  113. * Raised when the asset has been parsed
  114. */
  115. onParsed: (loaderData: IGLTFLoaderData) => void;
  116. /**
  117. * 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.
  118. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  119. * Defaults to true.
  120. * @hidden
  121. */
  122. static IncrementalLoading: boolean;
  123. /**
  124. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  125. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  126. * @hidden
  127. */
  128. static HomogeneousCoordinates: boolean;
  129. /**
  130. * The coordinate system mode. Defaults to AUTO.
  131. */
  132. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  133. /**
  134. * The animation start mode. Defaults to FIRST.
  135. */
  136. animationStartMode: GLTFLoaderAnimationStartMode;
  137. /**
  138. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  139. */
  140. compileMaterials: boolean;
  141. /**
  142. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  143. */
  144. useClipPlane: boolean;
  145. /**
  146. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  147. */
  148. compileShadowGenerators: boolean;
  149. /**
  150. * Defines if the Alpha blended materials are only applied as coverage.
  151. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  152. * If true, no extra effects are applied to transparent pixels.
  153. */
  154. transparencyAsCoverage: boolean;
  155. /**
  156. * Function called before loading a url referenced by the asset.
  157. */
  158. preprocessUrlAsync: (url: string) => Promise<string>;
  159. /**
  160. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  161. */
  162. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  163. private _onMeshLoadedObserver;
  164. /**
  165. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  166. */
  167. onMeshLoaded: (mesh: AbstractMesh) => void;
  168. /**
  169. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  170. */
  171. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  172. private _onTextureLoadedObserver;
  173. /**
  174. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  175. */
  176. onTextureLoaded: (texture: BaseTexture) => void;
  177. /**
  178. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  179. */
  180. readonly onMaterialLoadedObservable: Observable<Material>;
  181. private _onMaterialLoadedObserver;
  182. /**
  183. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  184. */
  185. onMaterialLoaded: (material: Material) => void;
  186. /**
  187. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  188. */
  189. readonly onCameraLoadedObservable: Observable<Camera>;
  190. private _onCameraLoadedObserver;
  191. /**
  192. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  193. */
  194. onCameraLoaded: (camera: Camera) => void;
  195. /**
  196. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  197. * For assets with LODs, raised when all of the LODs are complete.
  198. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  199. */
  200. readonly onCompleteObservable: Observable<void>;
  201. private _onCompleteObserver;
  202. /**
  203. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  204. * For assets with LODs, raised when all of the LODs are complete.
  205. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  206. */
  207. onComplete: () => void;
  208. /**
  209. * Observable raised when an error occurs.
  210. */
  211. readonly onErrorObservable: Observable<any>;
  212. private _onErrorObserver;
  213. /**
  214. * Callback raised when an error occurs.
  215. */
  216. onError: (reason: any) => void;
  217. /**
  218. * Observable raised after the loader is disposed.
  219. */
  220. readonly onDisposeObservable: Observable<void>;
  221. private _onDisposeObserver;
  222. /**
  223. * Callback raised after the loader is disposed.
  224. */
  225. onDispose: () => void;
  226. /**
  227. * Observable raised after a loader extension is created.
  228. * Set additional options for a loader extension in this event.
  229. */
  230. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  231. private _onExtensionLoadedObserver;
  232. /**
  233. * Callback raised after a loader extension is created.
  234. */
  235. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  236. /**
  237. * Defines if the loader logging is enabled.
  238. */
  239. loggingEnabled: boolean;
  240. /**
  241. * Defines if the loader should capture performance counters.
  242. */
  243. capturePerformanceCounters: boolean;
  244. /**
  245. * Defines if the loader should validate the asset.
  246. */
  247. validate: boolean;
  248. /**
  249. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  250. */
  251. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  252. private _onValidatedObserver;
  253. /**
  254. * Callback raised after a loader extension is created.
  255. */
  256. onValidated: (results: IGLTFValidationResults) => void;
  257. private _loader;
  258. /**
  259. * Name of the loader ("gltf")
  260. */
  261. name: string;
  262. /**
  263. * Supported file extensions of the loader (.gltf, .glb)
  264. */
  265. extensions: ISceneLoaderPluginExtensions;
  266. /**
  267. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  268. */
  269. dispose(): void;
  270. /** @hidden */
  271. _clear(): void;
  272. /**
  273. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  274. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  275. * @param scene the scene the meshes should be added to
  276. * @param data the glTF data to load
  277. * @param rootUrl root url to load from
  278. * @param onProgress event that fires when loading progress has occured
  279. * @param fileName Defines the name of the file to load
  280. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  281. */
  282. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  283. meshes: AbstractMesh[];
  284. particleSystems: IParticleSystem[];
  285. skeletons: Skeleton[];
  286. animationGroups: AnimationGroup[];
  287. }>;
  288. /**
  289. * Imports all objects from the loaded glTF data and adds them to the scene
  290. * @param scene the scene the objects should be added to
  291. * @param data the glTF data to load
  292. * @param rootUrl root url to load from
  293. * @param onProgress event that fires when loading progress has occured
  294. * @param fileName Defines the name of the file to load
  295. * @returns a promise which completes when objects have been loaded to the scene
  296. */
  297. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  298. /**
  299. * Load into an asset container.
  300. * @param scene The scene to load into
  301. * @param data The data to import
  302. * @param rootUrl The root url for scene and resources
  303. * @param onProgress The callback when the load progresses
  304. * @param fileName Defines the name of the file to load
  305. * @returns The loaded asset container
  306. */
  307. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  308. /**
  309. * If the data string can be loaded directly.
  310. * @param data string contianing the file data
  311. * @returns if the data can be loaded directly
  312. */
  313. canDirectLoad(data: string): boolean;
  314. /**
  315. * Rewrites a url by combining a root url and response url.
  316. */
  317. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  318. /**
  319. * Instantiates a glTF file loader plugin.
  320. * @returns the created plugin
  321. */
  322. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  323. /**
  324. * The loader state or null if the loader is not active.
  325. */
  326. readonly loaderState: Nullable<GLTFLoaderState>;
  327. /**
  328. * Returns a promise that resolves when the asset is completely loaded.
  329. * @returns a promise that resolves when the asset is completely loaded.
  330. */
  331. whenCompleteAsync(): Promise<void>;
  332. private _parseAsync;
  333. private _validateAsync;
  334. private _getLoader;
  335. private _unpackBinary;
  336. private _unpackBinaryV1;
  337. private _unpackBinaryV2;
  338. private static _parseVersion;
  339. private static _compareVersion;
  340. private static _decodeBufferToText;
  341. private static readonly _logSpaces;
  342. private _logIndentLevel;
  343. private _loggingEnabled;
  344. /** @hidden */
  345. _log: (message: string) => void;
  346. /** @hidden */
  347. _logOpen(message: string): void;
  348. /** @hidden */
  349. _logClose(): void;
  350. private _logEnabled;
  351. private _logDisabled;
  352. private _capturePerformanceCounters;
  353. /** @hidden */
  354. _startPerformanceCounter: (counterName: string) => void;
  355. /** @hidden */
  356. _endPerformanceCounter: (counterName: string) => void;
  357. private _startPerformanceCounterEnabled;
  358. private _startPerformanceCounterDisabled;
  359. private _endPerformanceCounterEnabled;
  360. private _endPerformanceCounterDisabled;
  361. }
  362. }
  363. declare module "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces" {
  364. import { Bone } from "babylonjs/Bones/bone";
  365. import { Skeleton } from "babylonjs/Bones/skeleton";
  366. import { Texture } from "babylonjs/Materials/Textures/texture";
  367. import { Node } from "babylonjs/node";
  368. import { Scene } from "babylonjs/scene";
  369. /**
  370. * Enums
  371. * @hidden
  372. */
  373. export enum EComponentType {
  374. BYTE = 5120,
  375. UNSIGNED_BYTE = 5121,
  376. SHORT = 5122,
  377. UNSIGNED_SHORT = 5123,
  378. FLOAT = 5126
  379. }
  380. /** @hidden */
  381. export enum EShaderType {
  382. FRAGMENT = 35632,
  383. VERTEX = 35633
  384. }
  385. /** @hidden */
  386. export enum EParameterType {
  387. BYTE = 5120,
  388. UNSIGNED_BYTE = 5121,
  389. SHORT = 5122,
  390. UNSIGNED_SHORT = 5123,
  391. INT = 5124,
  392. UNSIGNED_INT = 5125,
  393. FLOAT = 5126,
  394. FLOAT_VEC2 = 35664,
  395. FLOAT_VEC3 = 35665,
  396. FLOAT_VEC4 = 35666,
  397. INT_VEC2 = 35667,
  398. INT_VEC3 = 35668,
  399. INT_VEC4 = 35669,
  400. BOOL = 35670,
  401. BOOL_VEC2 = 35671,
  402. BOOL_VEC3 = 35672,
  403. BOOL_VEC4 = 35673,
  404. FLOAT_MAT2 = 35674,
  405. FLOAT_MAT3 = 35675,
  406. FLOAT_MAT4 = 35676,
  407. SAMPLER_2D = 35678
  408. }
  409. /** @hidden */
  410. export enum ETextureWrapMode {
  411. CLAMP_TO_EDGE = 33071,
  412. MIRRORED_REPEAT = 33648,
  413. REPEAT = 10497
  414. }
  415. /** @hidden */
  416. export enum ETextureFilterType {
  417. NEAREST = 9728,
  418. LINEAR = 9728,
  419. NEAREST_MIPMAP_NEAREST = 9984,
  420. LINEAR_MIPMAP_NEAREST = 9985,
  421. NEAREST_MIPMAP_LINEAR = 9986,
  422. LINEAR_MIPMAP_LINEAR = 9987
  423. }
  424. /** @hidden */
  425. export enum ETextureFormat {
  426. ALPHA = 6406,
  427. RGB = 6407,
  428. RGBA = 6408,
  429. LUMINANCE = 6409,
  430. LUMINANCE_ALPHA = 6410
  431. }
  432. /** @hidden */
  433. export enum ECullingType {
  434. FRONT = 1028,
  435. BACK = 1029,
  436. FRONT_AND_BACK = 1032
  437. }
  438. /** @hidden */
  439. export enum EBlendingFunction {
  440. ZERO = 0,
  441. ONE = 1,
  442. SRC_COLOR = 768,
  443. ONE_MINUS_SRC_COLOR = 769,
  444. DST_COLOR = 774,
  445. ONE_MINUS_DST_COLOR = 775,
  446. SRC_ALPHA = 770,
  447. ONE_MINUS_SRC_ALPHA = 771,
  448. DST_ALPHA = 772,
  449. ONE_MINUS_DST_ALPHA = 773,
  450. CONSTANT_COLOR = 32769,
  451. ONE_MINUS_CONSTANT_COLOR = 32770,
  452. CONSTANT_ALPHA = 32771,
  453. ONE_MINUS_CONSTANT_ALPHA = 32772,
  454. SRC_ALPHA_SATURATE = 776
  455. }
  456. /** @hidden */
  457. export interface IGLTFProperty {
  458. extensions?: {
  459. [key: string]: any;
  460. };
  461. extras?: Object;
  462. }
  463. /** @hidden */
  464. export interface IGLTFChildRootProperty extends IGLTFProperty {
  465. name?: string;
  466. }
  467. /** @hidden */
  468. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  469. bufferView: string;
  470. byteOffset: number;
  471. byteStride: number;
  472. count: number;
  473. type: string;
  474. componentType: EComponentType;
  475. max?: number[];
  476. min?: number[];
  477. name?: string;
  478. }
  479. /** @hidden */
  480. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  481. buffer: string;
  482. byteOffset: number;
  483. byteLength: number;
  484. byteStride: number;
  485. target?: number;
  486. }
  487. /** @hidden */
  488. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  489. uri: string;
  490. byteLength?: number;
  491. type?: string;
  492. }
  493. /** @hidden */
  494. export interface IGLTFShader extends IGLTFChildRootProperty {
  495. uri: string;
  496. type: EShaderType;
  497. }
  498. /** @hidden */
  499. export interface IGLTFProgram extends IGLTFChildRootProperty {
  500. attributes: string[];
  501. fragmentShader: string;
  502. vertexShader: string;
  503. }
  504. /** @hidden */
  505. export interface IGLTFTechniqueParameter {
  506. type: number;
  507. count?: number;
  508. semantic?: string;
  509. node?: string;
  510. value?: number | boolean | string | Array<any>;
  511. source?: string;
  512. babylonValue?: any;
  513. }
  514. /** @hidden */
  515. export interface IGLTFTechniqueCommonProfile {
  516. lightingModel: string;
  517. texcoordBindings: Object;
  518. parameters?: Array<any>;
  519. }
  520. /** @hidden */
  521. export interface IGLTFTechniqueStatesFunctions {
  522. blendColor?: number[];
  523. blendEquationSeparate?: number[];
  524. blendFuncSeparate?: number[];
  525. colorMask: boolean[];
  526. cullFace: number[];
  527. }
  528. /** @hidden */
  529. export interface IGLTFTechniqueStates {
  530. enable: number[];
  531. functions: IGLTFTechniqueStatesFunctions;
  532. }
  533. /** @hidden */
  534. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  535. parameters: {
  536. [key: string]: IGLTFTechniqueParameter;
  537. };
  538. program: string;
  539. attributes: {
  540. [key: string]: string;
  541. };
  542. uniforms: {
  543. [key: string]: string;
  544. };
  545. states: IGLTFTechniqueStates;
  546. }
  547. /** @hidden */
  548. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  549. technique?: string;
  550. values: string[];
  551. }
  552. /** @hidden */
  553. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  554. attributes: {
  555. [key: string]: string;
  556. };
  557. indices: string;
  558. material: string;
  559. mode?: number;
  560. }
  561. /** @hidden */
  562. export interface IGLTFMesh extends IGLTFChildRootProperty {
  563. primitives: IGLTFMeshPrimitive[];
  564. }
  565. /** @hidden */
  566. export interface IGLTFImage extends IGLTFChildRootProperty {
  567. uri: string;
  568. }
  569. /** @hidden */
  570. export interface IGLTFSampler extends IGLTFChildRootProperty {
  571. magFilter?: number;
  572. minFilter?: number;
  573. wrapS?: number;
  574. wrapT?: number;
  575. }
  576. /** @hidden */
  577. export interface IGLTFTexture extends IGLTFChildRootProperty {
  578. sampler: string;
  579. source: string;
  580. format?: ETextureFormat;
  581. internalFormat?: ETextureFormat;
  582. target?: number;
  583. type?: number;
  584. babylonTexture?: Texture;
  585. }
  586. /** @hidden */
  587. export interface IGLTFAmbienLight {
  588. color?: number[];
  589. }
  590. /** @hidden */
  591. export interface IGLTFDirectionalLight {
  592. color?: number[];
  593. }
  594. /** @hidden */
  595. export interface IGLTFPointLight {
  596. color?: number[];
  597. constantAttenuation?: number;
  598. linearAttenuation?: number;
  599. quadraticAttenuation?: number;
  600. }
  601. /** @hidden */
  602. export interface IGLTFSpotLight {
  603. color?: number[];
  604. constantAttenuation?: number;
  605. fallOfAngle?: number;
  606. fallOffExponent?: number;
  607. linearAttenuation?: number;
  608. quadraticAttenuation?: number;
  609. }
  610. /** @hidden */
  611. export interface IGLTFLight extends IGLTFChildRootProperty {
  612. type: string;
  613. }
  614. /** @hidden */
  615. export interface IGLTFCameraOrthographic {
  616. xmag: number;
  617. ymag: number;
  618. zfar: number;
  619. znear: number;
  620. }
  621. /** @hidden */
  622. export interface IGLTFCameraPerspective {
  623. aspectRatio: number;
  624. yfov: number;
  625. zfar: number;
  626. znear: number;
  627. }
  628. /** @hidden */
  629. export interface IGLTFCamera extends IGLTFChildRootProperty {
  630. type: string;
  631. }
  632. /** @hidden */
  633. export interface IGLTFAnimationChannelTarget {
  634. id: string;
  635. path: string;
  636. }
  637. /** @hidden */
  638. export interface IGLTFAnimationChannel {
  639. sampler: string;
  640. target: IGLTFAnimationChannelTarget;
  641. }
  642. /** @hidden */
  643. export interface IGLTFAnimationSampler {
  644. input: string;
  645. output: string;
  646. interpolation?: string;
  647. }
  648. /** @hidden */
  649. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  650. channels?: IGLTFAnimationChannel[];
  651. parameters?: {
  652. [key: string]: string;
  653. };
  654. samplers?: {
  655. [key: string]: IGLTFAnimationSampler;
  656. };
  657. }
  658. /** @hidden */
  659. export interface IGLTFNodeInstanceSkin {
  660. skeletons: string[];
  661. skin: string;
  662. meshes: string[];
  663. }
  664. /** @hidden */
  665. export interface IGLTFSkins extends IGLTFChildRootProperty {
  666. bindShapeMatrix: number[];
  667. inverseBindMatrices: string;
  668. jointNames: string[];
  669. babylonSkeleton?: Skeleton;
  670. }
  671. /** @hidden */
  672. export interface IGLTFNode extends IGLTFChildRootProperty {
  673. camera?: string;
  674. children: string[];
  675. skin?: string;
  676. jointName?: string;
  677. light?: string;
  678. matrix: number[];
  679. mesh?: string;
  680. meshes?: string[];
  681. rotation?: number[];
  682. scale?: number[];
  683. translation?: number[];
  684. babylonNode?: Node;
  685. }
  686. /** @hidden */
  687. export interface IGLTFScene extends IGLTFChildRootProperty {
  688. nodes: string[];
  689. }
  690. /** @hidden */
  691. export interface IGLTFRuntime {
  692. extensions: {
  693. [key: string]: any;
  694. };
  695. accessors: {
  696. [key: string]: IGLTFAccessor;
  697. };
  698. buffers: {
  699. [key: string]: IGLTFBuffer;
  700. };
  701. bufferViews: {
  702. [key: string]: IGLTFBufferView;
  703. };
  704. meshes: {
  705. [key: string]: IGLTFMesh;
  706. };
  707. lights: {
  708. [key: string]: IGLTFLight;
  709. };
  710. cameras: {
  711. [key: string]: IGLTFCamera;
  712. };
  713. nodes: {
  714. [key: string]: IGLTFNode;
  715. };
  716. images: {
  717. [key: string]: IGLTFImage;
  718. };
  719. textures: {
  720. [key: string]: IGLTFTexture;
  721. };
  722. shaders: {
  723. [key: string]: IGLTFShader;
  724. };
  725. programs: {
  726. [key: string]: IGLTFProgram;
  727. };
  728. samplers: {
  729. [key: string]: IGLTFSampler;
  730. };
  731. techniques: {
  732. [key: string]: IGLTFTechnique;
  733. };
  734. materials: {
  735. [key: string]: IGLTFMaterial;
  736. };
  737. animations: {
  738. [key: string]: IGLTFAnimation;
  739. };
  740. skins: {
  741. [key: string]: IGLTFSkins;
  742. };
  743. currentScene?: Object;
  744. scenes: {
  745. [key: string]: IGLTFScene;
  746. };
  747. extensionsUsed: string[];
  748. extensionsRequired?: string[];
  749. buffersCount: number;
  750. shaderscount: number;
  751. scene: Scene;
  752. rootUrl: string;
  753. loadedBufferCount: number;
  754. loadedBufferViews: {
  755. [name: string]: ArrayBufferView;
  756. };
  757. loadedShaderCount: number;
  758. importOnlyMeshes: boolean;
  759. importMeshesNames?: string[];
  760. dummyNodes: Node[];
  761. }
  762. /** @hidden */
  763. export interface INodeToRoot {
  764. bone: Bone;
  765. node: IGLTFNode;
  766. id: string;
  767. }
  768. /** @hidden */
  769. export interface IJointNode {
  770. node: IGLTFNode;
  771. id: string;
  772. }
  773. }
  774. declare module "babylonjs-loaders/glTF/1.0/glTFLoaderUtils" {
  775. import { IGLTFTechniqueParameter, IGLTFAccessor, ETextureFilterType, IGLTFRuntime, IGLTFBufferView, EComponentType } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  776. import { Effect } from "babylonjs/Materials/effect";
  777. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  778. import { Node } from "babylonjs/node";
  779. import { Scene } from "babylonjs/scene";
  780. /**
  781. * Utils functions for GLTF
  782. * @hidden
  783. */
  784. export class GLTFUtils {
  785. /**
  786. * Sets the given "parameter" matrix
  787. * @param scene: the Scene object
  788. * @param source: the source node where to pick the matrix
  789. * @param parameter: the GLTF technique parameter
  790. * @param uniformName: the name of the shader's uniform
  791. * @param shaderMaterial: the shader material
  792. */
  793. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  794. /**
  795. * Sets the given "parameter" matrix
  796. * @param shaderMaterial: the shader material
  797. * @param uniform: the name of the shader's uniform
  798. * @param value: the value of the uniform
  799. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  800. */
  801. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  802. /**
  803. * Returns the wrap mode of the texture
  804. * @param mode: the mode value
  805. */
  806. static GetWrapMode(mode: number): number;
  807. /**
  808. * Returns the byte stride giving an accessor
  809. * @param accessor: the GLTF accessor objet
  810. */
  811. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  812. /**
  813. * Returns the texture filter mode giving a mode value
  814. * @param mode: the filter mode value
  815. */
  816. static GetTextureFilterMode(mode: number): ETextureFilterType;
  817. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  818. /**
  819. * Returns a buffer from its accessor
  820. * @param gltfRuntime: the GLTF runtime
  821. * @param accessor: the GLTF accessor
  822. */
  823. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  824. /**
  825. * Decodes a buffer view into a string
  826. * @param view: the buffer view
  827. */
  828. static DecodeBufferToText(view: ArrayBufferView): string;
  829. /**
  830. * Returns the default material of gltf. Related to
  831. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  832. * @param scene: the Babylon.js scene
  833. */
  834. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  835. private static _DefaultMaterial;
  836. }
  837. }
  838. declare module "babylonjs-loaders/glTF/1.0/glTFLoader" {
  839. import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  840. import { Nullable } from "babylonjs/types";
  841. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  842. import { Skeleton } from "babylonjs/Bones/skeleton";
  843. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  844. import { Material } from "babylonjs/Materials/material";
  845. import { Texture } from "babylonjs/Materials/Textures/texture";
  846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  847. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  848. import { Scene } from "babylonjs/scene";
  849. import { IGLTFLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
  850. /**
  851. * Implementation of the base glTF spec
  852. * @hidden
  853. */
  854. export class GLTFLoaderBase {
  855. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  856. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  857. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  858. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  859. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  860. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  861. }
  862. /**
  863. * glTF V1 Loader
  864. * @hidden
  865. */
  866. export class GLTFLoader implements IGLTFLoader {
  867. static Extensions: {
  868. [name: string]: GLTFLoaderExtension;
  869. };
  870. static RegisterExtension(extension: GLTFLoaderExtension): void;
  871. state: Nullable<GLTFLoaderState>;
  872. dispose(): void;
  873. private _importMeshAsync;
  874. /**
  875. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  876. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  877. * @param scene the scene the meshes should be added to
  878. * @param data gltf data containing information of the meshes in a loaded file
  879. * @param rootUrl root url to load from
  880. * @param onProgress event that fires when loading progress has occured
  881. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  882. */
  883. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  884. meshes: AbstractMesh[];
  885. particleSystems: IParticleSystem[];
  886. skeletons: Skeleton[];
  887. animationGroups: AnimationGroup[];
  888. }>;
  889. private _loadAsync;
  890. /**
  891. * Imports all objects from a loaded gltf file and adds them to the scene
  892. * @param scene the scene the objects should be added to
  893. * @param data gltf data containing information of the meshes in a loaded file
  894. * @param rootUrl root url to load from
  895. * @param onProgress event that fires when loading progress has occured
  896. * @returns a promise which completes when objects have been loaded to the scene
  897. */
  898. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  899. private _loadShadersAsync;
  900. private _loadBuffersAsync;
  901. private _createNodes;
  902. }
  903. /** @hidden */
  904. export abstract class GLTFLoaderExtension {
  905. private _name;
  906. constructor(name: string);
  907. readonly name: string;
  908. /**
  909. * Defines an override for loading the runtime
  910. * Return true to stop further extensions from loading the runtime
  911. */
  912. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  913. /**
  914. * Defines an onverride for creating gltf runtime
  915. * Return true to stop further extensions from creating the runtime
  916. */
  917. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  918. /**
  919. * Defines an override for loading buffers
  920. * Return true to stop further extensions from loading this buffer
  921. */
  922. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  923. /**
  924. * Defines an override for loading texture buffers
  925. * Return true to stop further extensions from loading this texture data
  926. */
  927. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  928. /**
  929. * Defines an override for creating textures
  930. * Return true to stop further extensions from loading this texture
  931. */
  932. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  933. /**
  934. * Defines an override for loading shader strings
  935. * Return true to stop further extensions from loading this shader data
  936. */
  937. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  938. /**
  939. * Defines an override for loading materials
  940. * Return true to stop further extensions from loading this material
  941. */
  942. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  943. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  944. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  945. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  946. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  947. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  948. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  949. private static LoadTextureBufferAsync;
  950. private static CreateTextureAsync;
  951. private static ApplyExtensions;
  952. }
  953. }
  954. declare module "babylonjs-loaders/glTF/1.0/glTFBinaryExtension" {
  955. import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader";
  956. import { Scene } from "babylonjs/scene";
  957. import { IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
  958. import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  959. /** @hidden */
  960. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  961. private _bin;
  962. constructor();
  963. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  964. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  965. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  966. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  967. }
  968. }
  969. declare module "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension" {
  970. import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader";
  971. import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  972. import { Material } from "babylonjs/Materials/material";
  973. /** @hidden */
  974. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  975. constructor();
  976. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  977. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  978. private _loadTexture;
  979. }
  980. }
  981. declare module "babylonjs-loaders/glTF/1.0/index" {
  982. export * from "babylonjs-loaders/glTF/1.0/glTFBinaryExtension";
  983. export * from "babylonjs-loaders/glTF/1.0/glTFLoader";
  984. export * from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  985. export * from "babylonjs-loaders/glTF/1.0/glTFLoaderUtils";
  986. export * from "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension";
  987. }
  988. declare module "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces" {
  989. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  990. import { Bone } from "babylonjs/Bones/bone";
  991. import { Skeleton } from "babylonjs/Bones/skeleton";
  992. import { Material } from "babylonjs/Materials/material";
  993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  994. import { Buffer, VertexBuffer } from "babylonjs/Meshes/buffer";
  995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  996. import { Mesh } from "babylonjs/Meshes/mesh";
  997. import * as IGLTF2 from "babylonjs-gltf2interface";
  998. /**
  999. * Loader interface with an index field.
  1000. */
  1001. export interface IArrayItem {
  1002. /**
  1003. * The index of this item in the array.
  1004. */
  1005. index: number;
  1006. }
  1007. /**
  1008. * Loader interface with additional members.
  1009. */
  1010. export interface IAccessor extends IGLTF2.IAccessor, IArrayItem {
  1011. /** @hidden */
  1012. _data?: Promise<ArrayBufferView>;
  1013. /** @hidden */
  1014. _babylonVertexBuffer?: Promise<VertexBuffer>;
  1015. }
  1016. /**
  1017. * Loader interface with additional members.
  1018. */
  1019. export interface IAnimationChannel extends IGLTF2.IAnimationChannel, IArrayItem {
  1020. }
  1021. /** @hidden */
  1022. export interface _IAnimationSamplerData {
  1023. input: Float32Array;
  1024. interpolation: IGLTF2.AnimationSamplerInterpolation;
  1025. output: Float32Array;
  1026. }
  1027. /**
  1028. * Loader interface with additional members.
  1029. */
  1030. export interface IAnimationSampler extends IGLTF2.IAnimationSampler, IArrayItem {
  1031. /** @hidden */
  1032. _data?: Promise<_IAnimationSamplerData>;
  1033. }
  1034. /**
  1035. * Loader interface with additional members.
  1036. */
  1037. export interface IAnimation extends IGLTF2.IAnimation, IArrayItem {
  1038. channels: IAnimationChannel[];
  1039. samplers: IAnimationSampler[];
  1040. /** @hidden */
  1041. _babylonAnimationGroup?: AnimationGroup;
  1042. }
  1043. /**
  1044. * Loader interface with additional members.
  1045. */
  1046. export interface IBuffer extends IGLTF2.IBuffer, IArrayItem {
  1047. /** @hidden */
  1048. _data?: Promise<ArrayBufferView>;
  1049. }
  1050. /**
  1051. * Loader interface with additional members.
  1052. */
  1053. export interface IBufferView extends IGLTF2.IBufferView, IArrayItem {
  1054. /** @hidden */
  1055. _data?: Promise<ArrayBufferView>;
  1056. /** @hidden */
  1057. _babylonBuffer?: Promise<Buffer>;
  1058. }
  1059. /**
  1060. * Loader interface with additional members.
  1061. */
  1062. export interface ICamera extends IGLTF2.ICamera, IArrayItem {
  1063. }
  1064. /**
  1065. * Loader interface with additional members.
  1066. */
  1067. export interface IImage extends IGLTF2.IImage, IArrayItem {
  1068. /** @hidden */
  1069. _data?: Promise<ArrayBufferView>;
  1070. }
  1071. /**
  1072. * Loader interface with additional members.
  1073. */
  1074. export interface IMaterialNormalTextureInfo extends IGLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  1075. }
  1076. /**
  1077. * Loader interface with additional members.
  1078. */
  1079. export interface IMaterialOcclusionTextureInfo extends IGLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  1080. }
  1081. /**
  1082. * Loader interface with additional members.
  1083. */
  1084. export interface IMaterialPbrMetallicRoughness extends IGLTF2.IMaterialPbrMetallicRoughness {
  1085. baseColorTexture?: ITextureInfo;
  1086. metallicRoughnessTexture?: ITextureInfo;
  1087. }
  1088. /**
  1089. * Loader interface with additional members.
  1090. */
  1091. export interface IMaterial extends IGLTF2.IMaterial, IArrayItem {
  1092. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  1093. normalTexture?: IMaterialNormalTextureInfo;
  1094. occlusionTexture?: IMaterialOcclusionTextureInfo;
  1095. emissiveTexture?: ITextureInfo;
  1096. /** @hidden */
  1097. _data?: {
  1098. [babylonDrawMode: number]: {
  1099. babylonMaterial: Material;
  1100. babylonMeshes: AbstractMesh[];
  1101. promise: Promise<void>;
  1102. };
  1103. };
  1104. }
  1105. /**
  1106. * Loader interface with additional members.
  1107. */
  1108. export interface IMesh extends IGLTF2.IMesh, IArrayItem {
  1109. primitives: IMeshPrimitive[];
  1110. }
  1111. /**
  1112. * Loader interface with additional members.
  1113. */
  1114. export interface IMeshPrimitive extends IGLTF2.IMeshPrimitive, IArrayItem {
  1115. /** @hidden */
  1116. _instanceData?: {
  1117. babylonSourceMesh: Mesh;
  1118. promise: Promise<any>;
  1119. };
  1120. }
  1121. /**
  1122. * Loader interface with additional members.
  1123. */
  1124. export interface INode extends IGLTF2.INode, IArrayItem {
  1125. /**
  1126. * The parent glTF node.
  1127. */
  1128. parent?: INode;
  1129. /** @hidden */
  1130. _babylonTransformNode?: TransformNode;
  1131. /** @hidden */
  1132. _primitiveBabylonMeshes?: AbstractMesh[];
  1133. /** @hidden */
  1134. _babylonBones?: Bone[];
  1135. /** @hidden */
  1136. _numMorphTargets?: number;
  1137. }
  1138. /** @hidden */
  1139. export interface _ISamplerData {
  1140. noMipMaps: boolean;
  1141. samplingMode: number;
  1142. wrapU: number;
  1143. wrapV: number;
  1144. }
  1145. /**
  1146. * Loader interface with additional members.
  1147. */
  1148. export interface ISampler extends IGLTF2.ISampler, IArrayItem {
  1149. /** @hidden */
  1150. _data?: _ISamplerData;
  1151. }
  1152. /**
  1153. * Loader interface with additional members.
  1154. */
  1155. export interface IScene extends IGLTF2.IScene, IArrayItem {
  1156. }
  1157. /**
  1158. * Loader interface with additional members.
  1159. */
  1160. export interface ISkin extends IGLTF2.ISkin, IArrayItem {
  1161. /** @hidden */
  1162. _data?: {
  1163. babylonSkeleton: Skeleton;
  1164. promise: Promise<void>;
  1165. };
  1166. }
  1167. /**
  1168. * Loader interface with additional members.
  1169. */
  1170. export interface ITexture extends IGLTF2.ITexture, IArrayItem {
  1171. }
  1172. /**
  1173. * Loader interface with additional members.
  1174. */
  1175. export interface ITextureInfo extends IGLTF2.ITextureInfo {
  1176. }
  1177. /**
  1178. * Loader interface with additional members.
  1179. */
  1180. export interface IGLTF extends IGLTF2.IGLTF {
  1181. accessors?: IAccessor[];
  1182. animations?: IAnimation[];
  1183. buffers?: IBuffer[];
  1184. bufferViews?: IBufferView[];
  1185. cameras?: ICamera[];
  1186. images?: IImage[];
  1187. materials?: IMaterial[];
  1188. meshes?: IMesh[];
  1189. nodes?: INode[];
  1190. samplers?: ISampler[];
  1191. scenes?: IScene[];
  1192. skins?: ISkin[];
  1193. textures?: ITexture[];
  1194. }
  1195. }
  1196. declare module "babylonjs-loaders/glTF/2.0/glTFLoaderExtension" {
  1197. import { Nullable } from "babylonjs/types";
  1198. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1199. import { Material } from "babylonjs/Materials/material";
  1200. import { Camera } from "babylonjs/Cameras/camera";
  1201. import { Geometry } from "babylonjs/Meshes/geometry";
  1202. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1204. import { Mesh } from "babylonjs/Meshes/mesh";
  1205. import { IDisposable } from "babylonjs/scene";
  1206. import { IScene, INode, ICamera, IMeshPrimitive, IMaterial, ITextureInfo, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1207. import { IGLTFLoaderExtension as IGLTFBaseLoaderExtension } from "babylonjs-loaders/glTF/glTFFileLoader";
  1208. /**
  1209. * Interface for a glTF loader extension.
  1210. */
  1211. export interface IGLTFLoaderExtension extends IGLTFBaseLoaderExtension, IDisposable {
  1212. /**
  1213. * Called after the loader state changes to LOADING.
  1214. */
  1215. onLoading?(): void;
  1216. /**
  1217. * Called after the loader state changes to READY.
  1218. */
  1219. onReady?(): void;
  1220. /**
  1221. * Define this method to modify the default behavior when loading scenes.
  1222. * @param context The context when loading the asset
  1223. * @param scene The glTF scene property
  1224. * @returns A promise that resolves when the load is complete or null if not handled
  1225. */
  1226. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  1227. /**
  1228. * Define this method to modify the default behavior when loading nodes.
  1229. * @param context The context when loading the asset
  1230. * @param node The glTF node property
  1231. * @param assign A function called synchronously after parsing the glTF properties
  1232. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  1233. */
  1234. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1235. /**
  1236. * Define this method to modify the default behavior when loading cameras.
  1237. * @param context The context when loading the asset
  1238. * @param camera The glTF camera property
  1239. * @param assign A function called synchronously after parsing the glTF properties
  1240. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1241. */
  1242. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1243. /**
  1244. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1245. * @param context The context when loading the asset
  1246. * @param primitive The glTF mesh primitive property
  1247. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1248. */
  1249. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1250. /**
  1251. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1252. * @param context The context when loading the asset
  1253. * @param material The glTF material property
  1254. * @param assign A function called synchronously after parsing the glTF properties
  1255. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1256. */
  1257. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1258. /**
  1259. * Define this method to modify the default behavior when creating materials.
  1260. * @param context The context when loading the asset
  1261. * @param material The glTF material property
  1262. * @param babylonDrawMode The draw mode for the Babylon material
  1263. * @returns The Babylon material or null if not handled
  1264. */
  1265. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1266. /**
  1267. * Define this method to modify the default behavior when loading material properties.
  1268. * @param context The context when loading the asset
  1269. * @param material The glTF material property
  1270. * @param babylonMaterial The Babylon material
  1271. * @returns A promise that resolves when the load is complete or null if not handled
  1272. */
  1273. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1274. /**
  1275. * Define this method to modify the default behavior when loading texture infos.
  1276. * @param context The context when loading the asset
  1277. * @param textureInfo The glTF texture info property
  1278. * @param assign A function called synchronously after parsing the glTF properties
  1279. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1280. */
  1281. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1282. /**
  1283. * Define this method to modify the default behavior when loading animations.
  1284. * @param context The context when loading the asset
  1285. * @param animation The glTF animation property
  1286. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1287. */
  1288. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1289. /**
  1290. * Define this method to modify the default behavior when loading uris.
  1291. * @param context The context when loading the asset
  1292. * @param uri The uri to load
  1293. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1294. */
  1295. _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1296. }
  1297. }
  1298. declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
  1299. import { Nullable } from "babylonjs/types";
  1300. import { Camera } from "babylonjs/Cameras/camera";
  1301. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1302. import { Skeleton } from "babylonjs/Bones/skeleton";
  1303. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  1304. import { Material } from "babylonjs/Materials/material";
  1305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1306. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  1308. import { Mesh } from "babylonjs/Meshes/mesh";
  1309. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  1310. import { Scene } from "babylonjs/scene";
  1311. import { IProperty } from "babylonjs-gltf2interface";
  1312. import { IGLTF, INode, IScene, ICamera, IAnimation, IBufferView, IMaterial, ITextureInfo, IImage, IArrayItem as IArrItem } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1313. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1314. import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
  1315. /**
  1316. * Helper class for working with arrays when loading the glTF asset
  1317. */
  1318. export class ArrayItem {
  1319. /**
  1320. * Gets an item from the given array.
  1321. * @param context The context when loading the asset
  1322. * @param array The array to get the item from
  1323. * @param index The index to the array
  1324. * @returns The array item
  1325. */
  1326. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1327. /**
  1328. * Assign an `index` field to each item of the given array.
  1329. * @param array The array of items
  1330. */
  1331. static Assign(array?: IArrItem[]): void;
  1332. }
  1333. /**
  1334. * The glTF 2.0 loader
  1335. */
  1336. export class GLTFLoader implements IGLTFLoader {
  1337. /** The glTF object parsed from the JSON. */
  1338. gltf: IGLTF;
  1339. /** The Babylon scene when loading the asset. */
  1340. babylonScene: Scene;
  1341. /** @hidden */
  1342. _completePromises: Promise<any>[];
  1343. private _disposed;
  1344. private _parent;
  1345. private _state;
  1346. private _extensions;
  1347. private _rootUrl;
  1348. private _fileName;
  1349. private _uniqueRootUrl;
  1350. private _rootBabylonMesh;
  1351. private _defaultBabylonMaterialData;
  1352. private _progressCallback?;
  1353. private _requests;
  1354. private static readonly _DefaultSampler;
  1355. private static _ExtensionNames;
  1356. private static _ExtensionFactories;
  1357. /**
  1358. * Registers a loader extension.
  1359. * @param name The name of the loader extension.
  1360. * @param factory The factory function that creates the loader extension.
  1361. */
  1362. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1363. /**
  1364. * Unregisters a loader extension.
  1365. * @param name The name of the loader extenion.
  1366. * @returns A boolean indicating whether the extension has been unregistered
  1367. */
  1368. static UnregisterExtension(name: string): boolean;
  1369. /**
  1370. * Gets the loader state.
  1371. */
  1372. readonly state: Nullable<GLTFLoaderState>;
  1373. /** @hidden */
  1374. constructor(parent: GLTFFileLoader);
  1375. /** @hidden */
  1376. dispose(): void;
  1377. /** @hidden */
  1378. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1379. meshes: AbstractMesh[];
  1380. particleSystems: IParticleSystem[];
  1381. skeletons: Skeleton[];
  1382. animationGroups: AnimationGroup[];
  1383. }>;
  1384. /** @hidden */
  1385. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1386. private _loadAsync;
  1387. private _loadData;
  1388. private _setupData;
  1389. private _loadExtensions;
  1390. private _checkExtensions;
  1391. private _setState;
  1392. private _createRootNode;
  1393. /**
  1394. * Loads a glTF scene.
  1395. * @param context The context when loading the asset
  1396. * @param scene The glTF scene property
  1397. * @returns A promise that resolves when the load is complete
  1398. */
  1399. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  1400. private _forEachPrimitive;
  1401. private _getMeshes;
  1402. private _getSkeletons;
  1403. private _getAnimationGroups;
  1404. private _startAnimations;
  1405. /**
  1406. * Loads a glTF node.
  1407. * @param context The context when loading the asset
  1408. * @param node The glTF node property
  1409. * @param assign A function called synchronously after parsing the glTF properties
  1410. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1411. */
  1412. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  1413. private _loadMeshAsync;
  1414. private _loadMeshPrimitiveAsync;
  1415. private _loadVertexDataAsync;
  1416. private _createMorphTargets;
  1417. private _loadMorphTargetsAsync;
  1418. private _loadMorphTargetVertexDataAsync;
  1419. private static _LoadTransform;
  1420. private _loadSkinAsync;
  1421. private _loadBones;
  1422. private _loadBone;
  1423. private _loadSkinInverseBindMatricesDataAsync;
  1424. private _updateBoneMatrices;
  1425. private _getNodeMatrix;
  1426. /**
  1427. * Loads a glTF camera.
  1428. * @param context The context when loading the asset
  1429. * @param camera The glTF camera property
  1430. * @param assign A function called synchronously after parsing the glTF properties
  1431. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1432. */
  1433. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1434. private _loadAnimationsAsync;
  1435. /**
  1436. * Loads a glTF animation.
  1437. * @param context The context when loading the asset
  1438. * @param animation The glTF animation property
  1439. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1440. */
  1441. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  1442. private _loadAnimationChannelAsync;
  1443. private _loadAnimationSamplerAsync;
  1444. private _loadBufferAsync;
  1445. /**
  1446. * Loads a glTF buffer view.
  1447. * @param context The context when loading the asset
  1448. * @param bufferView The glTF buffer view property
  1449. * @returns A promise that resolves with the loaded data when the load is complete
  1450. */
  1451. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1452. private _loadIndicesAccessorAsync;
  1453. private _loadFloatAccessorAsync;
  1454. private _loadVertexBufferViewAsync;
  1455. private _loadVertexAccessorAsync;
  1456. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1457. /** @hidden */
  1458. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1459. private _createDefaultMaterial;
  1460. /**
  1461. * Creates a Babylon material from a glTF material.
  1462. * @param context The context when loading the asset
  1463. * @param material The glTF material property
  1464. * @param babylonDrawMode The draw mode for the Babylon material
  1465. * @returns The Babylon material
  1466. */
  1467. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1468. /**
  1469. * Loads properties from a glTF material into a Babylon material.
  1470. * @param context The context when loading the asset
  1471. * @param material The glTF material property
  1472. * @param babylonMaterial The Babylon material
  1473. * @returns A promise that resolves when the load is complete
  1474. */
  1475. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1476. /**
  1477. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1478. * @param context The context when loading the asset
  1479. * @param material The glTF material property
  1480. * @param babylonMaterial The Babylon material
  1481. * @returns A promise that resolves when the load is complete
  1482. */
  1483. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1484. /**
  1485. * Loads the alpha properties from a glTF material into a Babylon material.
  1486. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1487. * @param context The context when loading the asset
  1488. * @param material The glTF material property
  1489. * @param babylonMaterial The Babylon material
  1490. */
  1491. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1492. /**
  1493. * Loads a glTF texture info.
  1494. * @param context The context when loading the asset
  1495. * @param textureInfo The glTF texture info property
  1496. * @param assign A function called synchronously after parsing the glTF properties
  1497. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1498. */
  1499. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1500. private _loadTextureAsync;
  1501. private _loadSampler;
  1502. /**
  1503. * Loads a glTF image.
  1504. * @param context The context when loading the asset
  1505. * @param image The glTF image property
  1506. * @returns A promise that resolves with the loaded data when the load is complete
  1507. */
  1508. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1509. /**
  1510. * Loads a glTF uri.
  1511. * @param context The context when loading the asset
  1512. * @param uri The base64 or relative uri
  1513. * @returns A promise that resolves with the loaded data when the load is complete
  1514. */
  1515. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  1516. private _onProgress;
  1517. /**
  1518. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1519. * @param babylonObject the Babylon object with metadata
  1520. * @param pointer the JSON pointer
  1521. */
  1522. static AddPointerMetadata(babylonObject: {
  1523. metadata: any;
  1524. }, pointer: string): void;
  1525. private static _GetTextureWrapMode;
  1526. private static _GetTextureSamplingMode;
  1527. private static _GetTypedArray;
  1528. private static _GetNumComponents;
  1529. private static _ValidateUri;
  1530. private static _GetDrawMode;
  1531. private _compileMaterialsAsync;
  1532. private _compileShadowGeneratorsAsync;
  1533. private _forEachExtensions;
  1534. private _applyExtensions;
  1535. private _extensionsOnLoading;
  1536. private _extensionsOnReady;
  1537. private _extensionsLoadSceneAsync;
  1538. private _extensionsLoadNodeAsync;
  1539. private _extensionsLoadCameraAsync;
  1540. private _extensionsLoadVertexDataAsync;
  1541. private _extensionsLoadMaterialAsync;
  1542. private _extensionsCreateMaterial;
  1543. private _extensionsLoadMaterialPropertiesAsync;
  1544. private _extensionsLoadTextureInfoAsync;
  1545. private _extensionsLoadAnimationAsync;
  1546. private _extensionsLoadUriAsync;
  1547. /**
  1548. * Helper method called by a loader extension to load an glTF extension.
  1549. * @param context The context when loading the asset
  1550. * @param property The glTF property to load the extension from
  1551. * @param extensionName The name of the extension to load
  1552. * @param actionAsync The action to run
  1553. * @returns The promise returned by actionAsync or null if the extension does not exist
  1554. */
  1555. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1556. /**
  1557. * Helper method called by a loader extension to load a glTF extra.
  1558. * @param context The context when loading the asset
  1559. * @param property The glTF property to load the extra from
  1560. * @param extensionName The name of the extension to load
  1561. * @param actionAsync The action to run
  1562. * @returns The promise returned by actionAsync or null if the extra does not exist
  1563. */
  1564. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1565. /**
  1566. * Increments the indentation level and logs a message.
  1567. * @param message The message to log
  1568. */
  1569. logOpen(message: string): void;
  1570. /**
  1571. * Decrements the indentation level.
  1572. */
  1573. logClose(): void;
  1574. /**
  1575. * Logs a message
  1576. * @param message The message to log
  1577. */
  1578. log(message: string): void;
  1579. /**
  1580. * Starts a performance counter.
  1581. * @param counterName The name of the performance counter
  1582. */
  1583. startPerformanceCounter(counterName: string): void;
  1584. /**
  1585. * Ends a performance counter.
  1586. * @param counterName The name of the performance counter
  1587. */
  1588. endPerformanceCounter(counterName: string): void;
  1589. }
  1590. }
  1591. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based" {
  1592. import { Nullable } from "babylonjs/types";
  1593. import { IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1594. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1595. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1596. /**
  1597. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  1598. */
  1599. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1600. /** The name of this extension. */
  1601. readonly name: string;
  1602. /** Defines whether this extension is enabled. */
  1603. enabled: boolean;
  1604. private _loader;
  1605. private _lights?;
  1606. /** @hidden */
  1607. constructor(loader: GLTFLoader);
  1608. /** @hidden */
  1609. dispose(): void;
  1610. /** @hidden */
  1611. onLoading(): void;
  1612. /** @hidden */
  1613. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1614. private _loadLightAsync;
  1615. }
  1616. }
  1617. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression" {
  1618. import { Nullable } from "babylonjs/types";
  1619. import { Geometry } from "babylonjs/Meshes/geometry";
  1620. import { Mesh } from "babylonjs/Meshes/mesh";
  1621. import { IMeshPrimitive } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1622. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1623. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1624. /**
  1625. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1626. */
  1627. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1628. /** The name of this extension. */
  1629. readonly name: string;
  1630. /** Defines whether this extension is enabled. */
  1631. enabled: boolean;
  1632. private _loader;
  1633. private _dracoCompression?;
  1634. /** @hidden */
  1635. constructor(loader: GLTFLoader);
  1636. /** @hidden */
  1637. dispose(): void;
  1638. /** @hidden */
  1639. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1640. }
  1641. }
  1642. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual" {
  1643. import { Nullable } from "babylonjs/types";
  1644. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1645. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1646. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1647. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1648. /**
  1649. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  1650. */
  1651. export class KHR_lights implements IGLTFLoaderExtension {
  1652. /** The name of this extension. */
  1653. readonly name: string;
  1654. /** Defines whether this extension is enabled. */
  1655. enabled: boolean;
  1656. private _loader;
  1657. private _lights?;
  1658. /** @hidden */
  1659. constructor(loader: GLTFLoader);
  1660. /** @hidden */
  1661. dispose(): void;
  1662. /** @hidden */
  1663. onLoading(): void;
  1664. /** @hidden */
  1665. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1666. }
  1667. }
  1668. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness" {
  1669. import { Nullable } from "babylonjs/types";
  1670. import { Material } from "babylonjs/Materials/material";
  1671. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1672. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1673. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1674. /**
  1675. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1676. */
  1677. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1678. /** The name of this extension. */
  1679. readonly name: string;
  1680. /** Defines whether this extension is enabled. */
  1681. enabled: boolean;
  1682. private _loader;
  1683. /** @hidden */
  1684. constructor(loader: GLTFLoader);
  1685. /** @hidden */
  1686. dispose(): void;
  1687. /** @hidden */
  1688. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1689. private _loadSpecularGlossinessPropertiesAsync;
  1690. }
  1691. }
  1692. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit" {
  1693. import { Nullable } from "babylonjs/types";
  1694. import { Material } from "babylonjs/Materials/material";
  1695. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1696. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1697. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1698. /**
  1699. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1700. */
  1701. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1702. /** The name of this extension. */
  1703. readonly name: string;
  1704. /** Defines whether this extension is enabled. */
  1705. enabled: boolean;
  1706. private _loader;
  1707. /** @hidden */
  1708. constructor(loader: GLTFLoader);
  1709. /** @hidden */
  1710. dispose(): void;
  1711. /** @hidden */
  1712. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1713. private _loadUnlitPropertiesAsync;
  1714. }
  1715. }
  1716. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform" {
  1717. import { Nullable } from "babylonjs/types";
  1718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1719. import { ITextureInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1720. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1721. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1722. /**
  1723. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1724. */
  1725. export class KHR_texture_transform implements IGLTFLoaderExtension {
  1726. /** The name of this extension. */
  1727. readonly name: string;
  1728. /** Defines whether this extension is enabled. */
  1729. enabled: boolean;
  1730. private _loader;
  1731. /** @hidden */
  1732. constructor(loader: GLTFLoader);
  1733. /** @hidden */
  1734. dispose(): void;
  1735. /** @hidden */
  1736. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1737. }
  1738. }
  1739. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter" {
  1740. import { Nullable } from "babylonjs/types";
  1741. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1743. import { IScene, INode, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1744. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1745. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1746. /**
  1747. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1748. */
  1749. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1750. /** The name of this extension. */
  1751. readonly name: string;
  1752. /** Defines whether this extension is enabled. */
  1753. enabled: boolean;
  1754. private _loader;
  1755. private _clips;
  1756. private _emitters;
  1757. /** @hidden */
  1758. constructor(loader: GLTFLoader);
  1759. /** @hidden */
  1760. dispose(): void;
  1761. /** @hidden */
  1762. onLoading(): void;
  1763. /** @hidden */
  1764. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1765. /** @hidden */
  1766. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1767. /** @hidden */
  1768. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1769. private _loadClipAsync;
  1770. private _loadEmitterAsync;
  1771. private _getEventAction;
  1772. private _loadAnimationEventAsync;
  1773. }
  1774. }
  1775. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
  1776. import { Nullable } from "babylonjs/types";
  1777. import { Observable } from "babylonjs/Misc/observable";
  1778. import { Material } from "babylonjs/Materials/material";
  1779. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1780. import { Mesh } from "babylonjs/Meshes/mesh";
  1781. import { INode, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1782. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1783. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1784. /**
  1785. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1786. */
  1787. export class MSFT_lod implements IGLTFLoaderExtension {
  1788. /** The name of this extension. */
  1789. readonly name: string;
  1790. /** Defines whether this extension is enabled. */
  1791. enabled: boolean;
  1792. /**
  1793. * Maximum number of LODs to load, starting from the lowest LOD.
  1794. */
  1795. maxLODsToLoad: number;
  1796. /**
  1797. * Observable raised when all node LODs of one level are loaded.
  1798. * The event data is the index of the loaded LOD starting from zero.
  1799. * Dispose the loader to cancel the loading of the next level of LODs.
  1800. */
  1801. onNodeLODsLoadedObservable: Observable<number>;
  1802. /**
  1803. * Observable raised when all material LODs of one level are loaded.
  1804. * The event data is the index of the loaded LOD starting from zero.
  1805. * Dispose the loader to cancel the loading of the next level of LODs.
  1806. */
  1807. onMaterialLODsLoadedObservable: Observable<number>;
  1808. private _loader;
  1809. private _nodeIndexLOD;
  1810. private _nodeSignalLODs;
  1811. private _nodePromiseLODs;
  1812. private _materialIndexLOD;
  1813. private _materialSignalLODs;
  1814. private _materialPromiseLODs;
  1815. /** @hidden */
  1816. constructor(loader: GLTFLoader);
  1817. /** @hidden */
  1818. dispose(): void;
  1819. /** @hidden */
  1820. onReady(): void;
  1821. /** @hidden */
  1822. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1823. /** @hidden */
  1824. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1825. /** @hidden */
  1826. _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1827. /**
  1828. * Gets an array of LOD properties from lowest to highest.
  1829. */
  1830. private _getLODs;
  1831. private _disposeUnusedMaterials;
  1832. }
  1833. }
  1834. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh" {
  1835. import { Nullable } from "babylonjs/types";
  1836. import { Material } from "babylonjs/Materials/material";
  1837. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1838. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1839. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1840. /** @hidden */
  1841. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1842. readonly name: string;
  1843. enabled: boolean;
  1844. private _loader;
  1845. constructor(loader: GLTFLoader);
  1846. dispose(): void;
  1847. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1848. }
  1849. }
  1850. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors" {
  1851. import { Nullable } from "babylonjs/types";
  1852. import { Material } from "babylonjs/Materials/material";
  1853. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1854. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1855. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1856. /** @hidden */
  1857. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1858. readonly name: string;
  1859. enabled: boolean;
  1860. private _loader;
  1861. constructor(loader: GLTFLoader);
  1862. dispose(): void;
  1863. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1864. }
  1865. }
  1866. declare module "babylonjs-loaders/glTF/2.0/Extensions/index" {
  1867. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based";
  1868. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  1869. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual";
  1870. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  1871. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit";
  1872. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform";
  1873. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter";
  1874. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod";
  1875. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh";
  1876. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors";
  1877. }
  1878. declare module "babylonjs-loaders/glTF/2.0/index" {
  1879. export * from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1880. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1881. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1882. export * from "babylonjs-loaders/glTF/2.0/Extensions/index";
  1883. }
  1884. declare module "babylonjs-loaders/glTF/index" {
  1885. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  1886. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  1887. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  1888. export { GLTF1, GLTF2 };
  1889. }
  1890. declare module "babylonjs-loaders/OBJ/objFileLoader" {
  1891. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1892. import { Skeleton } from "babylonjs/Bones/skeleton";
  1893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  1894. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  1895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  1896. import { ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin } from "babylonjs/Loading/sceneLoader";
  1897. import { AssetContainer } from "babylonjs/assetContainer";
  1898. import { Scene } from "babylonjs/scene";
  1899. /**
  1900. * Class reading and parsing the MTL file bundled with the obj file.
  1901. */
  1902. export class MTLFileLoader {
  1903. /**
  1904. * All material loaded from the mtl will be set here
  1905. */
  1906. materials: StandardMaterial[];
  1907. /**
  1908. * This function will read the mtl file and create each material described inside
  1909. * This function could be improve by adding :
  1910. * -some component missing (Ni, Tf...)
  1911. * -including the specific options available
  1912. *
  1913. * @param scene defines the scene the material will be created in
  1914. * @param data defines the mtl data to parse
  1915. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  1916. */
  1917. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  1918. /**
  1919. * Gets the texture for the material.
  1920. *
  1921. * If the material is imported from input file,
  1922. * We sanitize the url to ensure it takes the textre from aside the material.
  1923. *
  1924. * @param rootUrl The root url to load from
  1925. * @param value The value stored in the mtl
  1926. * @return The Texture
  1927. */
  1928. private static _getTexture;
  1929. }
  1930. /**
  1931. * Options for loading OBJ/MTL files
  1932. */
  1933. type MeshLoadOptions = {
  1934. /**
  1935. * Defines if UVs are optimized by default during load.
  1936. */
  1937. OptimizeWithUV: boolean;
  1938. /**
  1939. * Invert model on y-axis (does a model scaling inversion)
  1940. */
  1941. InvertY: boolean;
  1942. /**
  1943. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  1944. */
  1945. ImportVertexColors: boolean;
  1946. /**
  1947. * Compute the normals for the model, even if normals are present in the file.
  1948. */
  1949. ComputeNormals: boolean;
  1950. /**
  1951. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  1952. */
  1953. SkipMaterials: boolean;
  1954. /**
  1955. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  1956. */
  1957. MaterialLoadingFailsSilently: boolean;
  1958. };
  1959. /**
  1960. * OBJ file type loader.
  1961. * This is a babylon scene loader plugin.
  1962. */
  1963. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  1964. /**
  1965. * Defines if UVs are optimized by default during load.
  1966. */
  1967. static OPTIMIZE_WITH_UV: boolean;
  1968. /**
  1969. * Invert model on y-axis (does a model scaling inversion)
  1970. */
  1971. static INVERT_Y: boolean;
  1972. /**
  1973. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  1974. */
  1975. static IMPORT_VERTEX_COLORS: boolean;
  1976. /**
  1977. * Compute the normals for the model, even if normals are present in the file.
  1978. */
  1979. static COMPUTE_NORMALS: boolean;
  1980. /**
  1981. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  1982. */
  1983. static SKIP_MATERIALS: boolean;
  1984. /**
  1985. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  1986. *
  1987. * Defaults to true for backwards compatibility.
  1988. */
  1989. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  1990. /**
  1991. * Defines the name of the plugin.
  1992. */
  1993. name: string;
  1994. /**
  1995. * Defines the extension the plugin is able to load.
  1996. */
  1997. extensions: string;
  1998. /** @hidden */
  1999. obj: RegExp;
  2000. /** @hidden */
  2001. group: RegExp;
  2002. /** @hidden */
  2003. mtllib: RegExp;
  2004. /** @hidden */
  2005. usemtl: RegExp;
  2006. /** @hidden */
  2007. smooth: RegExp;
  2008. /** @hidden */
  2009. vertexPattern: RegExp;
  2010. /** @hidden */
  2011. normalPattern: RegExp;
  2012. /** @hidden */
  2013. uvPattern: RegExp;
  2014. /** @hidden */
  2015. facePattern1: RegExp;
  2016. /** @hidden */
  2017. facePattern2: RegExp;
  2018. /** @hidden */
  2019. facePattern3: RegExp;
  2020. /** @hidden */
  2021. facePattern4: RegExp;
  2022. /** @hidden */
  2023. facePattern5: RegExp;
  2024. private _meshLoadOptions;
  2025. /**
  2026. * Creates loader for .OBJ files
  2027. *
  2028. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2029. */
  2030. constructor(meshLoadOptions?: MeshLoadOptions);
  2031. private static readonly currentMeshLoadOptions;
  2032. /**
  2033. * Calls synchronously the MTL file attached to this obj.
  2034. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2035. * Without this function materials are not displayed in the first frame (but displayed after).
  2036. * In consequence it is impossible to get material information in your HTML file
  2037. *
  2038. * @param url The URL of the MTL file
  2039. * @param rootUrl
  2040. * @param onSuccess Callback function to be called when the MTL file is loaded
  2041. * @private
  2042. */
  2043. private _loadMTL;
  2044. /**
  2045. * Instantiates a OBJ file loader plugin.
  2046. * @returns the created plugin
  2047. */
  2048. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2049. /**
  2050. * If the data string can be loaded directly.
  2051. *
  2052. * @param data string containing the file data
  2053. * @returns if the data can be loaded directly
  2054. */
  2055. canDirectLoad(data: string): boolean;
  2056. /**
  2057. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2058. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2059. * @param scene the scene the meshes should be added to
  2060. * @param data the OBJ data to load
  2061. * @param rootUrl root url to load from
  2062. * @param onProgress event that fires when loading progress has occured
  2063. * @param fileName Defines the name of the file to load
  2064. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2065. */
  2066. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2067. meshes: AbstractMesh[];
  2068. particleSystems: IParticleSystem[];
  2069. skeletons: Skeleton[];
  2070. animationGroups: AnimationGroup[];
  2071. }>;
  2072. /**
  2073. * Imports all objects from the loaded OBJ data and adds them to the scene
  2074. * @param scene the scene the objects should be added to
  2075. * @param data the OBJ data to load
  2076. * @param rootUrl root url to load from
  2077. * @param onProgress event that fires when loading progress has occured
  2078. * @param fileName Defines the name of the file to load
  2079. * @returns a promise which completes when objects have been loaded to the scene
  2080. */
  2081. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2082. /**
  2083. * Load into an asset container.
  2084. * @param scene The scene to load into
  2085. * @param data The data to import
  2086. * @param rootUrl The root url for scene and resources
  2087. * @param onProgress The callback when the load progresses
  2088. * @param fileName Defines the name of the file to load
  2089. * @returns The loaded asset container
  2090. */
  2091. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2092. /**
  2093. * Read the OBJ file and create an Array of meshes.
  2094. * Each mesh contains all information given by the OBJ and the MTL file.
  2095. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2096. *
  2097. * @param meshesNames
  2098. * @param scene Scene The scene where are displayed the data
  2099. * @param data String The content of the obj file
  2100. * @param rootUrl String The path to the folder
  2101. * @returns Array<AbstractMesh>
  2102. * @private
  2103. */
  2104. private _parseSolid;
  2105. }
  2106. }
  2107. declare module "babylonjs-loaders/OBJ/index" {
  2108. export * from "babylonjs-loaders/OBJ/objFileLoader";
  2109. }
  2110. declare module "babylonjs-loaders/STL/stlFileLoader" {
  2111. import { Nullable } from "babylonjs/types";
  2112. import { Skeleton } from "babylonjs/Bones/skeleton";
  2113. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2115. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  2116. import { AssetContainer } from "babylonjs/assetContainer";
  2117. import { Scene } from "babylonjs/scene";
  2118. /**
  2119. * STL file type loader.
  2120. * This is a babylon scene loader plugin.
  2121. */
  2122. export class STLFileLoader implements ISceneLoaderPlugin {
  2123. /** @hidden */
  2124. solidPattern: RegExp;
  2125. /** @hidden */
  2126. facetsPattern: RegExp;
  2127. /** @hidden */
  2128. normalPattern: RegExp;
  2129. /** @hidden */
  2130. vertexPattern: RegExp;
  2131. /**
  2132. * Defines the name of the plugin.
  2133. */
  2134. name: string;
  2135. /**
  2136. * Defines the extensions the stl loader is able to load.
  2137. * force data to come in as an ArrayBuffer
  2138. * we'll convert to string if it looks like it's an ASCII .stl
  2139. */
  2140. extensions: ISceneLoaderPluginExtensions;
  2141. /**
  2142. * Import meshes into a scene.
  2143. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2144. * @param scene The scene to import into
  2145. * @param data The data to import
  2146. * @param rootUrl The root url for scene and resources
  2147. * @param meshes The meshes array to import into
  2148. * @param particleSystems The particle systems array to import into
  2149. * @param skeletons The skeletons array to import into
  2150. * @param onError The callback when import fails
  2151. * @returns True if successful or false otherwise
  2152. */
  2153. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2154. /**
  2155. * Load into a scene.
  2156. * @param scene The scene to load into
  2157. * @param data The data to import
  2158. * @param rootUrl The root url for scene and resources
  2159. * @param onError The callback when import fails
  2160. * @returns true if successful or false otherwise
  2161. */
  2162. load(scene: Scene, data: any, rootUrl: string): boolean;
  2163. /**
  2164. * Load into an asset container.
  2165. * @param scene The scene to load into
  2166. * @param data The data to import
  2167. * @param rootUrl The root url for scene and resources
  2168. * @param onError The callback when import fails
  2169. * @returns The loaded asset container
  2170. */
  2171. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2172. private _isBinary;
  2173. private _parseBinary;
  2174. private _parseASCII;
  2175. }
  2176. }
  2177. declare module "babylonjs-loaders/STL/index" {
  2178. export * from "babylonjs-loaders/STL/stlFileLoader";
  2179. }
  2180. declare module "babylonjs-loaders/index" {
  2181. export * from "babylonjs-loaders/glTF/index";
  2182. export * from "babylonjs-loaders/OBJ/index";
  2183. export * from "babylonjs-loaders/STL/index";
  2184. }
  2185. declare module "babylonjs-loaders/legacy/legacy-glTF" {
  2186. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2187. }
  2188. declare module "babylonjs-loaders/legacy/legacy-glTF1" {
  2189. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2190. export { GLTF1 };
  2191. }
  2192. declare module "babylonjs-loaders/legacy/legacy-glTF1FileLoader" {
  2193. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2194. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2195. }
  2196. declare module "babylonjs-loaders/legacy/legacy-glTF2" {
  2197. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2198. export { GLTF2 };
  2199. }
  2200. declare module "babylonjs-loaders/legacy/legacy-glTF2FileLoader" {
  2201. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2202. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2203. }
  2204. declare module "babylonjs-loaders/legacy/legacy-glTFFileLoader" {
  2205. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2206. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2207. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2208. }
  2209. declare module "babylonjs-loaders/legacy/legacy-objFileLoader" {
  2210. export * from "babylonjs-loaders/OBJ/index";
  2211. }
  2212. declare module "babylonjs-loaders/legacy/legacy-stlFileLoader" {
  2213. export * from "babylonjs-loaders/STL/index";
  2214. }
  2215. declare module "babylonjs-loaders/legacy/legacy" {
  2216. import "babylonjs-loaders/index";
  2217. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2218. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2219. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2220. export * from "babylonjs-loaders/legacy/legacy-objFileLoader";
  2221. export * from "babylonjs-loaders/legacy/legacy-stlFileLoader";
  2222. }
  2223. declare module "babylonjs-loaders" {
  2224. export * from "babylonjs-loaders/legacy/legacy";
  2225. }
  2226. declare module BABYLON {
  2227. /**
  2228. * Mode that determines the coordinate system to use.
  2229. */
  2230. export enum GLTFLoaderCoordinateSystemMode {
  2231. /**
  2232. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2233. */
  2234. AUTO = 0,
  2235. /**
  2236. * Sets the useRightHandedSystem flag on the scene.
  2237. */
  2238. FORCE_RIGHT_HANDED = 1
  2239. }
  2240. /**
  2241. * Mode that determines what animations will start.
  2242. */
  2243. export enum GLTFLoaderAnimationStartMode {
  2244. /**
  2245. * No animation will start.
  2246. */
  2247. NONE = 0,
  2248. /**
  2249. * The first animation will start.
  2250. */
  2251. FIRST = 1,
  2252. /**
  2253. * All animations will start.
  2254. */
  2255. ALL = 2
  2256. }
  2257. /**
  2258. * Interface that contains the data for the glTF asset.
  2259. */
  2260. export interface IGLTFLoaderData {
  2261. /**
  2262. * Object that represents the glTF JSON.
  2263. */
  2264. json: Object;
  2265. /**
  2266. * The BIN chunk of a binary glTF.
  2267. */
  2268. bin: Nullable<ArrayBufferView>;
  2269. }
  2270. /**
  2271. * Interface for extending the loader.
  2272. */
  2273. export interface IGLTFLoaderExtension {
  2274. /**
  2275. * The name of this extension.
  2276. */
  2277. readonly name: string;
  2278. /**
  2279. * Defines whether this extension is enabled.
  2280. */
  2281. enabled: boolean;
  2282. }
  2283. /**
  2284. * Loader state.
  2285. */
  2286. export enum GLTFLoaderState {
  2287. /**
  2288. * The asset is loading.
  2289. */
  2290. LOADING = 0,
  2291. /**
  2292. * The asset is ready for rendering.
  2293. */
  2294. READY = 1,
  2295. /**
  2296. * The asset is completely loaded.
  2297. */
  2298. COMPLETE = 2
  2299. }
  2300. /** @hidden */
  2301. export interface IGLTFLoader extends IDisposable {
  2302. readonly state: Nullable<GLTFLoaderState>;
  2303. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  2304. meshes: AbstractMesh[];
  2305. particleSystems: IParticleSystem[];
  2306. skeletons: Skeleton[];
  2307. animationGroups: AnimationGroup[];
  2308. }>;
  2309. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  2310. }
  2311. /**
  2312. * File loader for loading glTF files into a scene.
  2313. */
  2314. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2315. /** @hidden */
  2316. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2317. /** @hidden */
  2318. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2319. /**
  2320. * Raised when the asset has been parsed
  2321. */
  2322. onParsedObservable: Observable<IGLTFLoaderData>;
  2323. private _onParsedObserver;
  2324. /**
  2325. * Raised when the asset has been parsed
  2326. */
  2327. onParsed: (loaderData: IGLTFLoaderData) => void;
  2328. /**
  2329. * 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.
  2330. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  2331. * Defaults to true.
  2332. * @hidden
  2333. */
  2334. static IncrementalLoading: boolean;
  2335. /**
  2336. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  2337. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  2338. * @hidden
  2339. */
  2340. static HomogeneousCoordinates: boolean;
  2341. /**
  2342. * The coordinate system mode. Defaults to AUTO.
  2343. */
  2344. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  2345. /**
  2346. * The animation start mode. Defaults to FIRST.
  2347. */
  2348. animationStartMode: GLTFLoaderAnimationStartMode;
  2349. /**
  2350. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  2351. */
  2352. compileMaterials: boolean;
  2353. /**
  2354. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  2355. */
  2356. useClipPlane: boolean;
  2357. /**
  2358. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  2359. */
  2360. compileShadowGenerators: boolean;
  2361. /**
  2362. * Defines if the Alpha blended materials are only applied as coverage.
  2363. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  2364. * If true, no extra effects are applied to transparent pixels.
  2365. */
  2366. transparencyAsCoverage: boolean;
  2367. /**
  2368. * Function called before loading a url referenced by the asset.
  2369. */
  2370. preprocessUrlAsync: (url: string) => Promise<string>;
  2371. /**
  2372. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2373. */
  2374. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  2375. private _onMeshLoadedObserver;
  2376. /**
  2377. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2378. */
  2379. onMeshLoaded: (mesh: AbstractMesh) => void;
  2380. /**
  2381. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  2382. */
  2383. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  2384. private _onTextureLoadedObserver;
  2385. /**
  2386. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  2387. */
  2388. onTextureLoaded: (texture: BaseTexture) => void;
  2389. /**
  2390. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  2391. */
  2392. readonly onMaterialLoadedObservable: Observable<Material>;
  2393. private _onMaterialLoadedObserver;
  2394. /**
  2395. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  2396. */
  2397. onMaterialLoaded: (material: Material) => void;
  2398. /**
  2399. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  2400. */
  2401. readonly onCameraLoadedObservable: Observable<Camera>;
  2402. private _onCameraLoadedObserver;
  2403. /**
  2404. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  2405. */
  2406. onCameraLoaded: (camera: Camera) => void;
  2407. /**
  2408. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  2409. * For assets with LODs, raised when all of the LODs are complete.
  2410. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2411. */
  2412. readonly onCompleteObservable: Observable<void>;
  2413. private _onCompleteObserver;
  2414. /**
  2415. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  2416. * For assets with LODs, raised when all of the LODs are complete.
  2417. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2418. */
  2419. onComplete: () => void;
  2420. /**
  2421. * Observable raised when an error occurs.
  2422. */
  2423. readonly onErrorObservable: Observable<any>;
  2424. private _onErrorObserver;
  2425. /**
  2426. * Callback raised when an error occurs.
  2427. */
  2428. onError: (reason: any) => void;
  2429. /**
  2430. * Observable raised after the loader is disposed.
  2431. */
  2432. readonly onDisposeObservable: Observable<void>;
  2433. private _onDisposeObserver;
  2434. /**
  2435. * Callback raised after the loader is disposed.
  2436. */
  2437. onDispose: () => void;
  2438. /**
  2439. * Observable raised after a loader extension is created.
  2440. * Set additional options for a loader extension in this event.
  2441. */
  2442. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  2443. private _onExtensionLoadedObserver;
  2444. /**
  2445. * Callback raised after a loader extension is created.
  2446. */
  2447. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  2448. /**
  2449. * Defines if the loader logging is enabled.
  2450. */
  2451. loggingEnabled: boolean;
  2452. /**
  2453. * Defines if the loader should capture performance counters.
  2454. */
  2455. capturePerformanceCounters: boolean;
  2456. /**
  2457. * Defines if the loader should validate the asset.
  2458. */
  2459. validate: boolean;
  2460. /**
  2461. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  2462. */
  2463. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  2464. private _onValidatedObserver;
  2465. /**
  2466. * Callback raised after a loader extension is created.
  2467. */
  2468. onValidated: (results: IGLTFValidationResults) => void;
  2469. private _loader;
  2470. /**
  2471. * Name of the loader ("gltf")
  2472. */
  2473. name: string;
  2474. /**
  2475. * Supported file extensions of the loader (.gltf, .glb)
  2476. */
  2477. extensions: ISceneLoaderPluginExtensions;
  2478. /**
  2479. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  2480. */
  2481. dispose(): void;
  2482. /** @hidden */
  2483. _clear(): void;
  2484. /**
  2485. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  2486. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2487. * @param scene the scene the meshes should be added to
  2488. * @param data the glTF data to load
  2489. * @param rootUrl root url to load from
  2490. * @param onProgress event that fires when loading progress has occured
  2491. * @param fileName Defines the name of the file to load
  2492. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2493. */
  2494. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2495. meshes: AbstractMesh[];
  2496. particleSystems: IParticleSystem[];
  2497. skeletons: Skeleton[];
  2498. animationGroups: AnimationGroup[];
  2499. }>;
  2500. /**
  2501. * Imports all objects from the loaded glTF data and adds them to the scene
  2502. * @param scene the scene the objects should be added to
  2503. * @param data the glTF data to load
  2504. * @param rootUrl root url to load from
  2505. * @param onProgress event that fires when loading progress has occured
  2506. * @param fileName Defines the name of the file to load
  2507. * @returns a promise which completes when objects have been loaded to the scene
  2508. */
  2509. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2510. /**
  2511. * Load into an asset container.
  2512. * @param scene The scene to load into
  2513. * @param data The data to import
  2514. * @param rootUrl The root url for scene and resources
  2515. * @param onProgress The callback when the load progresses
  2516. * @param fileName Defines the name of the file to load
  2517. * @returns The loaded asset container
  2518. */
  2519. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2520. /**
  2521. * If the data string can be loaded directly.
  2522. * @param data string contianing the file data
  2523. * @returns if the data can be loaded directly
  2524. */
  2525. canDirectLoad(data: string): boolean;
  2526. /**
  2527. * Rewrites a url by combining a root url and response url.
  2528. */
  2529. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  2530. /**
  2531. * Instantiates a glTF file loader plugin.
  2532. * @returns the created plugin
  2533. */
  2534. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  2535. /**
  2536. * The loader state or null if the loader is not active.
  2537. */
  2538. readonly loaderState: Nullable<GLTFLoaderState>;
  2539. /**
  2540. * Returns a promise that resolves when the asset is completely loaded.
  2541. * @returns a promise that resolves when the asset is completely loaded.
  2542. */
  2543. whenCompleteAsync(): Promise<void>;
  2544. private _parseAsync;
  2545. private _validateAsync;
  2546. private _getLoader;
  2547. private _unpackBinary;
  2548. private _unpackBinaryV1;
  2549. private _unpackBinaryV2;
  2550. private static _parseVersion;
  2551. private static _compareVersion;
  2552. private static _decodeBufferToText;
  2553. private static readonly _logSpaces;
  2554. private _logIndentLevel;
  2555. private _loggingEnabled;
  2556. /** @hidden */
  2557. _log: (message: string) => void;
  2558. /** @hidden */
  2559. _logOpen(message: string): void;
  2560. /** @hidden */
  2561. _logClose(): void;
  2562. private _logEnabled;
  2563. private _logDisabled;
  2564. private _capturePerformanceCounters;
  2565. /** @hidden */
  2566. _startPerformanceCounter: (counterName: string) => void;
  2567. /** @hidden */
  2568. _endPerformanceCounter: (counterName: string) => void;
  2569. private _startPerformanceCounterEnabled;
  2570. private _startPerformanceCounterDisabled;
  2571. private _endPerformanceCounterEnabled;
  2572. private _endPerformanceCounterDisabled;
  2573. }
  2574. }
  2575. declare module BABYLON.GLTF1 {
  2576. /**
  2577. * Enums
  2578. * @hidden
  2579. */
  2580. export enum EComponentType {
  2581. BYTE = 5120,
  2582. UNSIGNED_BYTE = 5121,
  2583. SHORT = 5122,
  2584. UNSIGNED_SHORT = 5123,
  2585. FLOAT = 5126
  2586. }
  2587. /** @hidden */
  2588. export enum EShaderType {
  2589. FRAGMENT = 35632,
  2590. VERTEX = 35633
  2591. }
  2592. /** @hidden */
  2593. export enum EParameterType {
  2594. BYTE = 5120,
  2595. UNSIGNED_BYTE = 5121,
  2596. SHORT = 5122,
  2597. UNSIGNED_SHORT = 5123,
  2598. INT = 5124,
  2599. UNSIGNED_INT = 5125,
  2600. FLOAT = 5126,
  2601. FLOAT_VEC2 = 35664,
  2602. FLOAT_VEC3 = 35665,
  2603. FLOAT_VEC4 = 35666,
  2604. INT_VEC2 = 35667,
  2605. INT_VEC3 = 35668,
  2606. INT_VEC4 = 35669,
  2607. BOOL = 35670,
  2608. BOOL_VEC2 = 35671,
  2609. BOOL_VEC3 = 35672,
  2610. BOOL_VEC4 = 35673,
  2611. FLOAT_MAT2 = 35674,
  2612. FLOAT_MAT3 = 35675,
  2613. FLOAT_MAT4 = 35676,
  2614. SAMPLER_2D = 35678
  2615. }
  2616. /** @hidden */
  2617. export enum ETextureWrapMode {
  2618. CLAMP_TO_EDGE = 33071,
  2619. MIRRORED_REPEAT = 33648,
  2620. REPEAT = 10497
  2621. }
  2622. /** @hidden */
  2623. export enum ETextureFilterType {
  2624. NEAREST = 9728,
  2625. LINEAR = 9728,
  2626. NEAREST_MIPMAP_NEAREST = 9984,
  2627. LINEAR_MIPMAP_NEAREST = 9985,
  2628. NEAREST_MIPMAP_LINEAR = 9986,
  2629. LINEAR_MIPMAP_LINEAR = 9987
  2630. }
  2631. /** @hidden */
  2632. export enum ETextureFormat {
  2633. ALPHA = 6406,
  2634. RGB = 6407,
  2635. RGBA = 6408,
  2636. LUMINANCE = 6409,
  2637. LUMINANCE_ALPHA = 6410
  2638. }
  2639. /** @hidden */
  2640. export enum ECullingType {
  2641. FRONT = 1028,
  2642. BACK = 1029,
  2643. FRONT_AND_BACK = 1032
  2644. }
  2645. /** @hidden */
  2646. export enum EBlendingFunction {
  2647. ZERO = 0,
  2648. ONE = 1,
  2649. SRC_COLOR = 768,
  2650. ONE_MINUS_SRC_COLOR = 769,
  2651. DST_COLOR = 774,
  2652. ONE_MINUS_DST_COLOR = 775,
  2653. SRC_ALPHA = 770,
  2654. ONE_MINUS_SRC_ALPHA = 771,
  2655. DST_ALPHA = 772,
  2656. ONE_MINUS_DST_ALPHA = 773,
  2657. CONSTANT_COLOR = 32769,
  2658. ONE_MINUS_CONSTANT_COLOR = 32770,
  2659. CONSTANT_ALPHA = 32771,
  2660. ONE_MINUS_CONSTANT_ALPHA = 32772,
  2661. SRC_ALPHA_SATURATE = 776
  2662. }
  2663. /** @hidden */
  2664. export interface IGLTFProperty {
  2665. extensions?: {
  2666. [key: string]: any;
  2667. };
  2668. extras?: Object;
  2669. }
  2670. /** @hidden */
  2671. export interface IGLTFChildRootProperty extends IGLTFProperty {
  2672. name?: string;
  2673. }
  2674. /** @hidden */
  2675. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  2676. bufferView: string;
  2677. byteOffset: number;
  2678. byteStride: number;
  2679. count: number;
  2680. type: string;
  2681. componentType: EComponentType;
  2682. max?: number[];
  2683. min?: number[];
  2684. name?: string;
  2685. }
  2686. /** @hidden */
  2687. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  2688. buffer: string;
  2689. byteOffset: number;
  2690. byteLength: number;
  2691. byteStride: number;
  2692. target?: number;
  2693. }
  2694. /** @hidden */
  2695. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  2696. uri: string;
  2697. byteLength?: number;
  2698. type?: string;
  2699. }
  2700. /** @hidden */
  2701. export interface IGLTFShader extends IGLTFChildRootProperty {
  2702. uri: string;
  2703. type: EShaderType;
  2704. }
  2705. /** @hidden */
  2706. export interface IGLTFProgram extends IGLTFChildRootProperty {
  2707. attributes: string[];
  2708. fragmentShader: string;
  2709. vertexShader: string;
  2710. }
  2711. /** @hidden */
  2712. export interface IGLTFTechniqueParameter {
  2713. type: number;
  2714. count?: number;
  2715. semantic?: string;
  2716. node?: string;
  2717. value?: number | boolean | string | Array<any>;
  2718. source?: string;
  2719. babylonValue?: any;
  2720. }
  2721. /** @hidden */
  2722. export interface IGLTFTechniqueCommonProfile {
  2723. lightingModel: string;
  2724. texcoordBindings: Object;
  2725. parameters?: Array<any>;
  2726. }
  2727. /** @hidden */
  2728. export interface IGLTFTechniqueStatesFunctions {
  2729. blendColor?: number[];
  2730. blendEquationSeparate?: number[];
  2731. blendFuncSeparate?: number[];
  2732. colorMask: boolean[];
  2733. cullFace: number[];
  2734. }
  2735. /** @hidden */
  2736. export interface IGLTFTechniqueStates {
  2737. enable: number[];
  2738. functions: IGLTFTechniqueStatesFunctions;
  2739. }
  2740. /** @hidden */
  2741. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  2742. parameters: {
  2743. [key: string]: IGLTFTechniqueParameter;
  2744. };
  2745. program: string;
  2746. attributes: {
  2747. [key: string]: string;
  2748. };
  2749. uniforms: {
  2750. [key: string]: string;
  2751. };
  2752. states: IGLTFTechniqueStates;
  2753. }
  2754. /** @hidden */
  2755. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  2756. technique?: string;
  2757. values: string[];
  2758. }
  2759. /** @hidden */
  2760. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  2761. attributes: {
  2762. [key: string]: string;
  2763. };
  2764. indices: string;
  2765. material: string;
  2766. mode?: number;
  2767. }
  2768. /** @hidden */
  2769. export interface IGLTFMesh extends IGLTFChildRootProperty {
  2770. primitives: IGLTFMeshPrimitive[];
  2771. }
  2772. /** @hidden */
  2773. export interface IGLTFImage extends IGLTFChildRootProperty {
  2774. uri: string;
  2775. }
  2776. /** @hidden */
  2777. export interface IGLTFSampler extends IGLTFChildRootProperty {
  2778. magFilter?: number;
  2779. minFilter?: number;
  2780. wrapS?: number;
  2781. wrapT?: number;
  2782. }
  2783. /** @hidden */
  2784. export interface IGLTFTexture extends IGLTFChildRootProperty {
  2785. sampler: string;
  2786. source: string;
  2787. format?: ETextureFormat;
  2788. internalFormat?: ETextureFormat;
  2789. target?: number;
  2790. type?: number;
  2791. babylonTexture?: Texture;
  2792. }
  2793. /** @hidden */
  2794. export interface IGLTFAmbienLight {
  2795. color?: number[];
  2796. }
  2797. /** @hidden */
  2798. export interface IGLTFDirectionalLight {
  2799. color?: number[];
  2800. }
  2801. /** @hidden */
  2802. export interface IGLTFPointLight {
  2803. color?: number[];
  2804. constantAttenuation?: number;
  2805. linearAttenuation?: number;
  2806. quadraticAttenuation?: number;
  2807. }
  2808. /** @hidden */
  2809. export interface IGLTFSpotLight {
  2810. color?: number[];
  2811. constantAttenuation?: number;
  2812. fallOfAngle?: number;
  2813. fallOffExponent?: number;
  2814. linearAttenuation?: number;
  2815. quadraticAttenuation?: number;
  2816. }
  2817. /** @hidden */
  2818. export interface IGLTFLight extends IGLTFChildRootProperty {
  2819. type: string;
  2820. }
  2821. /** @hidden */
  2822. export interface IGLTFCameraOrthographic {
  2823. xmag: number;
  2824. ymag: number;
  2825. zfar: number;
  2826. znear: number;
  2827. }
  2828. /** @hidden */
  2829. export interface IGLTFCameraPerspective {
  2830. aspectRatio: number;
  2831. yfov: number;
  2832. zfar: number;
  2833. znear: number;
  2834. }
  2835. /** @hidden */
  2836. export interface IGLTFCamera extends IGLTFChildRootProperty {
  2837. type: string;
  2838. }
  2839. /** @hidden */
  2840. export interface IGLTFAnimationChannelTarget {
  2841. id: string;
  2842. path: string;
  2843. }
  2844. /** @hidden */
  2845. export interface IGLTFAnimationChannel {
  2846. sampler: string;
  2847. target: IGLTFAnimationChannelTarget;
  2848. }
  2849. /** @hidden */
  2850. export interface IGLTFAnimationSampler {
  2851. input: string;
  2852. output: string;
  2853. interpolation?: string;
  2854. }
  2855. /** @hidden */
  2856. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  2857. channels?: IGLTFAnimationChannel[];
  2858. parameters?: {
  2859. [key: string]: string;
  2860. };
  2861. samplers?: {
  2862. [key: string]: IGLTFAnimationSampler;
  2863. };
  2864. }
  2865. /** @hidden */
  2866. export interface IGLTFNodeInstanceSkin {
  2867. skeletons: string[];
  2868. skin: string;
  2869. meshes: string[];
  2870. }
  2871. /** @hidden */
  2872. export interface IGLTFSkins extends IGLTFChildRootProperty {
  2873. bindShapeMatrix: number[];
  2874. inverseBindMatrices: string;
  2875. jointNames: string[];
  2876. babylonSkeleton?: Skeleton;
  2877. }
  2878. /** @hidden */
  2879. export interface IGLTFNode extends IGLTFChildRootProperty {
  2880. camera?: string;
  2881. children: string[];
  2882. skin?: string;
  2883. jointName?: string;
  2884. light?: string;
  2885. matrix: number[];
  2886. mesh?: string;
  2887. meshes?: string[];
  2888. rotation?: number[];
  2889. scale?: number[];
  2890. translation?: number[];
  2891. babylonNode?: Node;
  2892. }
  2893. /** @hidden */
  2894. export interface IGLTFScene extends IGLTFChildRootProperty {
  2895. nodes: string[];
  2896. }
  2897. /** @hidden */
  2898. export interface IGLTFRuntime {
  2899. extensions: {
  2900. [key: string]: any;
  2901. };
  2902. accessors: {
  2903. [key: string]: IGLTFAccessor;
  2904. };
  2905. buffers: {
  2906. [key: string]: IGLTFBuffer;
  2907. };
  2908. bufferViews: {
  2909. [key: string]: IGLTFBufferView;
  2910. };
  2911. meshes: {
  2912. [key: string]: IGLTFMesh;
  2913. };
  2914. lights: {
  2915. [key: string]: IGLTFLight;
  2916. };
  2917. cameras: {
  2918. [key: string]: IGLTFCamera;
  2919. };
  2920. nodes: {
  2921. [key: string]: IGLTFNode;
  2922. };
  2923. images: {
  2924. [key: string]: IGLTFImage;
  2925. };
  2926. textures: {
  2927. [key: string]: IGLTFTexture;
  2928. };
  2929. shaders: {
  2930. [key: string]: IGLTFShader;
  2931. };
  2932. programs: {
  2933. [key: string]: IGLTFProgram;
  2934. };
  2935. samplers: {
  2936. [key: string]: IGLTFSampler;
  2937. };
  2938. techniques: {
  2939. [key: string]: IGLTFTechnique;
  2940. };
  2941. materials: {
  2942. [key: string]: IGLTFMaterial;
  2943. };
  2944. animations: {
  2945. [key: string]: IGLTFAnimation;
  2946. };
  2947. skins: {
  2948. [key: string]: IGLTFSkins;
  2949. };
  2950. currentScene?: Object;
  2951. scenes: {
  2952. [key: string]: IGLTFScene;
  2953. };
  2954. extensionsUsed: string[];
  2955. extensionsRequired?: string[];
  2956. buffersCount: number;
  2957. shaderscount: number;
  2958. scene: Scene;
  2959. rootUrl: string;
  2960. loadedBufferCount: number;
  2961. loadedBufferViews: {
  2962. [name: string]: ArrayBufferView;
  2963. };
  2964. loadedShaderCount: number;
  2965. importOnlyMeshes: boolean;
  2966. importMeshesNames?: string[];
  2967. dummyNodes: Node[];
  2968. }
  2969. /** @hidden */
  2970. export interface INodeToRoot {
  2971. bone: Bone;
  2972. node: IGLTFNode;
  2973. id: string;
  2974. }
  2975. /** @hidden */
  2976. export interface IJointNode {
  2977. node: IGLTFNode;
  2978. id: string;
  2979. }
  2980. }
  2981. declare module BABYLON.GLTF1 {
  2982. /**
  2983. * Utils functions for GLTF
  2984. * @hidden
  2985. */
  2986. export class GLTFUtils {
  2987. /**
  2988. * Sets the given "parameter" matrix
  2989. * @param scene: the Scene object
  2990. * @param source: the source node where to pick the matrix
  2991. * @param parameter: the GLTF technique parameter
  2992. * @param uniformName: the name of the shader's uniform
  2993. * @param shaderMaterial: the shader material
  2994. */
  2995. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  2996. /**
  2997. * Sets the given "parameter" matrix
  2998. * @param shaderMaterial: the shader material
  2999. * @param uniform: the name of the shader's uniform
  3000. * @param value: the value of the uniform
  3001. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3002. */
  3003. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  3004. /**
  3005. * Returns the wrap mode of the texture
  3006. * @param mode: the mode value
  3007. */
  3008. static GetWrapMode(mode: number): number;
  3009. /**
  3010. * Returns the byte stride giving an accessor
  3011. * @param accessor: the GLTF accessor objet
  3012. */
  3013. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  3014. /**
  3015. * Returns the texture filter mode giving a mode value
  3016. * @param mode: the filter mode value
  3017. */
  3018. static GetTextureFilterMode(mode: number): ETextureFilterType;
  3019. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  3020. /**
  3021. * Returns a buffer from its accessor
  3022. * @param gltfRuntime: the GLTF runtime
  3023. * @param accessor: the GLTF accessor
  3024. */
  3025. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  3026. /**
  3027. * Decodes a buffer view into a string
  3028. * @param view: the buffer view
  3029. */
  3030. static DecodeBufferToText(view: ArrayBufferView): string;
  3031. /**
  3032. * Returns the default material of gltf. Related to
  3033. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3034. * @param scene: the Babylon.js scene
  3035. */
  3036. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  3037. private static _DefaultMaterial;
  3038. }
  3039. }
  3040. declare module BABYLON.GLTF1 {
  3041. /**
  3042. * Implementation of the base glTF spec
  3043. * @hidden
  3044. */
  3045. export class GLTFLoaderBase {
  3046. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  3047. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3048. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  3049. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3050. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  3051. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3052. }
  3053. /**
  3054. * glTF V1 Loader
  3055. * @hidden
  3056. */
  3057. export class GLTFLoader implements IGLTFLoader {
  3058. static Extensions: {
  3059. [name: string]: GLTFLoaderExtension;
  3060. };
  3061. static RegisterExtension(extension: GLTFLoaderExtension): void;
  3062. state: Nullable<GLTFLoaderState>;
  3063. dispose(): void;
  3064. private _importMeshAsync;
  3065. /**
  3066. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3067. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3068. * @param scene the scene the meshes should be added to
  3069. * @param data gltf data containing information of the meshes in a loaded file
  3070. * @param rootUrl root url to load from
  3071. * @param onProgress event that fires when loading progress has occured
  3072. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3073. */
  3074. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  3075. meshes: AbstractMesh[];
  3076. particleSystems: IParticleSystem[];
  3077. skeletons: Skeleton[];
  3078. animationGroups: AnimationGroup[];
  3079. }>;
  3080. private _loadAsync;
  3081. /**
  3082. * Imports all objects from a loaded gltf file and adds them to the scene
  3083. * @param scene the scene the objects should be added to
  3084. * @param data gltf data containing information of the meshes in a loaded file
  3085. * @param rootUrl root url to load from
  3086. * @param onProgress event that fires when loading progress has occured
  3087. * @returns a promise which completes when objects have been loaded to the scene
  3088. */
  3089. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  3090. private _loadShadersAsync;
  3091. private _loadBuffersAsync;
  3092. private _createNodes;
  3093. }
  3094. /** @hidden */
  3095. export abstract class GLTFLoaderExtension {
  3096. private _name;
  3097. constructor(name: string);
  3098. readonly name: string;
  3099. /**
  3100. * Defines an override for loading the runtime
  3101. * Return true to stop further extensions from loading the runtime
  3102. */
  3103. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  3104. /**
  3105. * Defines an onverride for creating gltf runtime
  3106. * Return true to stop further extensions from creating the runtime
  3107. */
  3108. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  3109. /**
  3110. * Defines an override for loading buffers
  3111. * Return true to stop further extensions from loading this buffer
  3112. */
  3113. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  3114. /**
  3115. * Defines an override for loading texture buffers
  3116. * Return true to stop further extensions from loading this texture data
  3117. */
  3118. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3119. /**
  3120. * Defines an override for creating textures
  3121. * Return true to stop further extensions from loading this texture
  3122. */
  3123. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  3124. /**
  3125. * Defines an override for loading shader strings
  3126. * Return true to stop further extensions from loading this shader data
  3127. */
  3128. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3129. /**
  3130. * Defines an override for loading materials
  3131. * Return true to stop further extensions from loading this material
  3132. */
  3133. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3134. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  3135. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  3136. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3137. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3138. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  3139. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3140. private static LoadTextureBufferAsync;
  3141. private static CreateTextureAsync;
  3142. private static ApplyExtensions;
  3143. }
  3144. }
  3145. declare module BABYLON.GLTF1 {
  3146. /** @hidden */
  3147. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  3148. private _bin;
  3149. constructor();
  3150. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  3151. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3152. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3153. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3154. }
  3155. }
  3156. declare module BABYLON.GLTF1 {
  3157. /** @hidden */
  3158. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  3159. constructor();
  3160. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  3161. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3162. private _loadTexture;
  3163. }
  3164. }
  3165. declare module BABYLON.GLTF2.Loader {
  3166. /**
  3167. * Loader interface with an index field.
  3168. */
  3169. export interface IArrayItem {
  3170. /**
  3171. * The index of this item in the array.
  3172. */
  3173. index: number;
  3174. }
  3175. /**
  3176. * Loader interface with additional members.
  3177. */
  3178. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3179. /** @hidden */
  3180. _data?: Promise<ArrayBufferView>;
  3181. /** @hidden */
  3182. _babylonVertexBuffer?: Promise<VertexBuffer>;
  3183. }
  3184. /**
  3185. * Loader interface with additional members.
  3186. */
  3187. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3188. }
  3189. /** @hidden */
  3190. export interface _IAnimationSamplerData {
  3191. input: Float32Array;
  3192. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3193. output: Float32Array;
  3194. }
  3195. /**
  3196. * Loader interface with additional members.
  3197. */
  3198. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3199. /** @hidden */
  3200. _data?: Promise<_IAnimationSamplerData>;
  3201. }
  3202. /**
  3203. * Loader interface with additional members.
  3204. */
  3205. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3206. channels: IAnimationChannel[];
  3207. samplers: IAnimationSampler[];
  3208. /** @hidden */
  3209. _babylonAnimationGroup?: AnimationGroup;
  3210. }
  3211. /**
  3212. * Loader interface with additional members.
  3213. */
  3214. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3215. /** @hidden */
  3216. _data?: Promise<ArrayBufferView>;
  3217. }
  3218. /**
  3219. * Loader interface with additional members.
  3220. */
  3221. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3222. /** @hidden */
  3223. _data?: Promise<ArrayBufferView>;
  3224. /** @hidden */
  3225. _babylonBuffer?: Promise<Buffer>;
  3226. }
  3227. /**
  3228. * Loader interface with additional members.
  3229. */
  3230. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3231. }
  3232. /**
  3233. * Loader interface with additional members.
  3234. */
  3235. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3236. /** @hidden */
  3237. _data?: Promise<ArrayBufferView>;
  3238. }
  3239. /**
  3240. * Loader interface with additional members.
  3241. */
  3242. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  3243. }
  3244. /**
  3245. * Loader interface with additional members.
  3246. */
  3247. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  3248. }
  3249. /**
  3250. * Loader interface with additional members.
  3251. */
  3252. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3253. baseColorTexture?: ITextureInfo;
  3254. metallicRoughnessTexture?: ITextureInfo;
  3255. }
  3256. /**
  3257. * Loader interface with additional members.
  3258. */
  3259. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3260. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3261. normalTexture?: IMaterialNormalTextureInfo;
  3262. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3263. emissiveTexture?: ITextureInfo;
  3264. /** @hidden */
  3265. _data?: {
  3266. [babylonDrawMode: number]: {
  3267. babylonMaterial: Material;
  3268. babylonMeshes: AbstractMesh[];
  3269. promise: Promise<void>;
  3270. };
  3271. };
  3272. }
  3273. /**
  3274. * Loader interface with additional members.
  3275. */
  3276. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3277. primitives: IMeshPrimitive[];
  3278. }
  3279. /**
  3280. * Loader interface with additional members.
  3281. */
  3282. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3283. /** @hidden */
  3284. _instanceData?: {
  3285. babylonSourceMesh: Mesh;
  3286. promise: Promise<any>;
  3287. };
  3288. }
  3289. /**
  3290. * Loader interface with additional members.
  3291. */
  3292. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  3293. /**
  3294. * The parent glTF node.
  3295. */
  3296. parent?: INode;
  3297. /** @hidden */
  3298. _babylonTransformNode?: TransformNode;
  3299. /** @hidden */
  3300. _primitiveBabylonMeshes?: AbstractMesh[];
  3301. /** @hidden */
  3302. _babylonBones?: Bone[];
  3303. /** @hidden */
  3304. _numMorphTargets?: number;
  3305. }
  3306. /** @hidden */
  3307. export interface _ISamplerData {
  3308. noMipMaps: boolean;
  3309. samplingMode: number;
  3310. wrapU: number;
  3311. wrapV: number;
  3312. }
  3313. /**
  3314. * Loader interface with additional members.
  3315. */
  3316. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  3317. /** @hidden */
  3318. _data?: _ISamplerData;
  3319. }
  3320. /**
  3321. * Loader interface with additional members.
  3322. */
  3323. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  3324. }
  3325. /**
  3326. * Loader interface with additional members.
  3327. */
  3328. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  3329. /** @hidden */
  3330. _data?: {
  3331. babylonSkeleton: Skeleton;
  3332. promise: Promise<void>;
  3333. };
  3334. }
  3335. /**
  3336. * Loader interface with additional members.
  3337. */
  3338. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  3339. }
  3340. /**
  3341. * Loader interface with additional members.
  3342. */
  3343. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  3344. }
  3345. /**
  3346. * Loader interface with additional members.
  3347. */
  3348. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  3349. accessors?: IAccessor[];
  3350. animations?: IAnimation[];
  3351. buffers?: IBuffer[];
  3352. bufferViews?: IBufferView[];
  3353. cameras?: ICamera[];
  3354. images?: IImage[];
  3355. materials?: IMaterial[];
  3356. meshes?: IMesh[];
  3357. nodes?: INode[];
  3358. samplers?: ISampler[];
  3359. scenes?: IScene[];
  3360. skins?: ISkin[];
  3361. textures?: ITexture[];
  3362. }
  3363. }
  3364. declare module BABYLON.GLTF2 {
  3365. /**
  3366. * Interface for a glTF loader extension.
  3367. */
  3368. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  3369. /**
  3370. * Called after the loader state changes to LOADING.
  3371. */
  3372. onLoading?(): void;
  3373. /**
  3374. * Called after the loader state changes to READY.
  3375. */
  3376. onReady?(): void;
  3377. /**
  3378. * Define this method to modify the default behavior when loading scenes.
  3379. * @param context The context when loading the asset
  3380. * @param scene The glTF scene property
  3381. * @returns A promise that resolves when the load is complete or null if not handled
  3382. */
  3383. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  3384. /**
  3385. * Define this method to modify the default behavior when loading nodes.
  3386. * @param context The context when loading the asset
  3387. * @param node The glTF node property
  3388. * @param assign A function called synchronously after parsing the glTF properties
  3389. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  3390. */
  3391. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3392. /**
  3393. * Define this method to modify the default behavior when loading cameras.
  3394. * @param context The context when loading the asset
  3395. * @param camera The glTF camera property
  3396. * @param assign A function called synchronously after parsing the glTF properties
  3397. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  3398. */
  3399. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  3400. /**
  3401. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  3402. * @param context The context when loading the asset
  3403. * @param primitive The glTF mesh primitive property
  3404. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  3405. */
  3406. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  3407. /**
  3408. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  3409. * @param context The context when loading the asset
  3410. * @param material The glTF material property
  3411. * @param assign A function called synchronously after parsing the glTF properties
  3412. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  3413. */
  3414. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  3415. /**
  3416. * Define this method to modify the default behavior when creating materials.
  3417. * @param context The context when loading the asset
  3418. * @param material The glTF material property
  3419. * @param babylonDrawMode The draw mode for the Babylon material
  3420. * @returns The Babylon material or null if not handled
  3421. */
  3422. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  3423. /**
  3424. * Define this method to modify the default behavior when loading material properties.
  3425. * @param context The context when loading the asset
  3426. * @param material The glTF material property
  3427. * @param babylonMaterial The Babylon material
  3428. * @returns A promise that resolves when the load is complete or null if not handled
  3429. */
  3430. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3431. /**
  3432. * Define this method to modify the default behavior when loading texture infos.
  3433. * @param context The context when loading the asset
  3434. * @param textureInfo The glTF texture info property
  3435. * @param assign A function called synchronously after parsing the glTF properties
  3436. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  3437. */
  3438. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3439. /**
  3440. * Define this method to modify the default behavior when loading animations.
  3441. * @param context The context when loading the asset
  3442. * @param animation The glTF animation property
  3443. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  3444. */
  3445. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  3446. /**
  3447. * Define this method to modify the default behavior when loading uris.
  3448. * @param context The context when loading the asset
  3449. * @param uri The uri to load
  3450. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3451. */
  3452. _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  3453. }
  3454. }
  3455. declare module BABYLON.GLTF2 {
  3456. /**
  3457. * Helper class for working with arrays when loading the glTF asset
  3458. */
  3459. export class ArrayItem {
  3460. /**
  3461. * Gets an item from the given array.
  3462. * @param context The context when loading the asset
  3463. * @param array The array to get the item from
  3464. * @param index The index to the array
  3465. * @returns The array item
  3466. */
  3467. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  3468. /**
  3469. * Assign an `index` field to each item of the given array.
  3470. * @param array The array of items
  3471. */
  3472. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  3473. }
  3474. /**
  3475. * The glTF 2.0 loader
  3476. */
  3477. export class GLTFLoader implements IGLTFLoader {
  3478. /** The glTF object parsed from the JSON. */
  3479. gltf: IGLTF;
  3480. /** The Babylon scene when loading the asset. */
  3481. babylonScene: Scene;
  3482. /** @hidden */
  3483. _completePromises: Promise<any>[];
  3484. private _disposed;
  3485. private _parent;
  3486. private _state;
  3487. private _extensions;
  3488. private _rootUrl;
  3489. private _fileName;
  3490. private _uniqueRootUrl;
  3491. private _rootBabylonMesh;
  3492. private _defaultBabylonMaterialData;
  3493. private _progressCallback?;
  3494. private _requests;
  3495. private static readonly _DefaultSampler;
  3496. private static _ExtensionNames;
  3497. private static _ExtensionFactories;
  3498. /**
  3499. * Registers a loader extension.
  3500. * @param name The name of the loader extension.
  3501. * @param factory The factory function that creates the loader extension.
  3502. */
  3503. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  3504. /**
  3505. * Unregisters a loader extension.
  3506. * @param name The name of the loader extenion.
  3507. * @returns A boolean indicating whether the extension has been unregistered
  3508. */
  3509. static UnregisterExtension(name: string): boolean;
  3510. /**
  3511. * Gets the loader state.
  3512. */
  3513. readonly state: Nullable<GLTFLoaderState>;
  3514. /** @hidden */
  3515. constructor(parent: GLTFFileLoader);
  3516. /** @hidden */
  3517. dispose(): void;
  3518. /** @hidden */
  3519. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  3520. meshes: AbstractMesh[];
  3521. particleSystems: IParticleSystem[];
  3522. skeletons: Skeleton[];
  3523. animationGroups: AnimationGroup[];
  3524. }>;
  3525. /** @hidden */
  3526. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  3527. private _loadAsync;
  3528. private _loadData;
  3529. private _setupData;
  3530. private _loadExtensions;
  3531. private _checkExtensions;
  3532. private _setState;
  3533. private _createRootNode;
  3534. /**
  3535. * Loads a glTF scene.
  3536. * @param context The context when loading the asset
  3537. * @param scene The glTF scene property
  3538. * @returns A promise that resolves when the load is complete
  3539. */
  3540. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  3541. private _forEachPrimitive;
  3542. private _getMeshes;
  3543. private _getSkeletons;
  3544. private _getAnimationGroups;
  3545. private _startAnimations;
  3546. /**
  3547. * Loads a glTF node.
  3548. * @param context The context when loading the asset
  3549. * @param node The glTF node property
  3550. * @param assign A function called synchronously after parsing the glTF properties
  3551. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  3552. */
  3553. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  3554. private _loadMeshAsync;
  3555. private _loadMeshPrimitiveAsync;
  3556. private _loadVertexDataAsync;
  3557. private _createMorphTargets;
  3558. private _loadMorphTargetsAsync;
  3559. private _loadMorphTargetVertexDataAsync;
  3560. private static _LoadTransform;
  3561. private _loadSkinAsync;
  3562. private _loadBones;
  3563. private _loadBone;
  3564. private _loadSkinInverseBindMatricesDataAsync;
  3565. private _updateBoneMatrices;
  3566. private _getNodeMatrix;
  3567. /**
  3568. * Loads a glTF camera.
  3569. * @param context The context when loading the asset
  3570. * @param camera The glTF camera property
  3571. * @param assign A function called synchronously after parsing the glTF properties
  3572. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  3573. */
  3574. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  3575. private _loadAnimationsAsync;
  3576. /**
  3577. * Loads a glTF animation.
  3578. * @param context The context when loading the asset
  3579. * @param animation The glTF animation property
  3580. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  3581. */
  3582. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  3583. private _loadAnimationChannelAsync;
  3584. private _loadAnimationSamplerAsync;
  3585. private _loadBufferAsync;
  3586. /**
  3587. * Loads a glTF buffer view.
  3588. * @param context The context when loading the asset
  3589. * @param bufferView The glTF buffer view property
  3590. * @returns A promise that resolves with the loaded data when the load is complete
  3591. */
  3592. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  3593. private _loadIndicesAccessorAsync;
  3594. private _loadFloatAccessorAsync;
  3595. private _loadVertexBufferViewAsync;
  3596. private _loadVertexAccessorAsync;
  3597. private _loadMaterialMetallicRoughnessPropertiesAsync;
  3598. /** @hidden */
  3599. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  3600. private _createDefaultMaterial;
  3601. /**
  3602. * Creates a Babylon material from a glTF material.
  3603. * @param context The context when loading the asset
  3604. * @param material The glTF material property
  3605. * @param babylonDrawMode The draw mode for the Babylon material
  3606. * @returns The Babylon material
  3607. */
  3608. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  3609. /**
  3610. * Loads properties from a glTF material into a Babylon material.
  3611. * @param context The context when loading the asset
  3612. * @param material The glTF material property
  3613. * @param babylonMaterial The Babylon material
  3614. * @returns A promise that resolves when the load is complete
  3615. */
  3616. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3617. /**
  3618. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  3619. * @param context The context when loading the asset
  3620. * @param material The glTF material property
  3621. * @param babylonMaterial The Babylon material
  3622. * @returns A promise that resolves when the load is complete
  3623. */
  3624. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3625. /**
  3626. * Loads the alpha properties from a glTF material into a Babylon material.
  3627. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  3628. * @param context The context when loading the asset
  3629. * @param material The glTF material property
  3630. * @param babylonMaterial The Babylon material
  3631. */
  3632. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  3633. /**
  3634. * Loads a glTF texture info.
  3635. * @param context The context when loading the asset
  3636. * @param textureInfo The glTF texture info property
  3637. * @param assign A function called synchronously after parsing the glTF properties
  3638. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  3639. */
  3640. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  3641. private _loadTextureAsync;
  3642. private _loadSampler;
  3643. /**
  3644. * Loads a glTF image.
  3645. * @param context The context when loading the asset
  3646. * @param image The glTF image property
  3647. * @returns A promise that resolves with the loaded data when the load is complete
  3648. */
  3649. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  3650. /**
  3651. * Loads a glTF uri.
  3652. * @param context The context when loading the asset
  3653. * @param uri The base64 or relative uri
  3654. * @returns A promise that resolves with the loaded data when the load is complete
  3655. */
  3656. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  3657. private _onProgress;
  3658. /**
  3659. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  3660. * @param babylonObject the Babylon object with metadata
  3661. * @param pointer the JSON pointer
  3662. */
  3663. static AddPointerMetadata(babylonObject: {
  3664. metadata: any;
  3665. }, pointer: string): void;
  3666. private static _GetTextureWrapMode;
  3667. private static _GetTextureSamplingMode;
  3668. private static _GetTypedArray;
  3669. private static _GetNumComponents;
  3670. private static _ValidateUri;
  3671. private static _GetDrawMode;
  3672. private _compileMaterialsAsync;
  3673. private _compileShadowGeneratorsAsync;
  3674. private _forEachExtensions;
  3675. private _applyExtensions;
  3676. private _extensionsOnLoading;
  3677. private _extensionsOnReady;
  3678. private _extensionsLoadSceneAsync;
  3679. private _extensionsLoadNodeAsync;
  3680. private _extensionsLoadCameraAsync;
  3681. private _extensionsLoadVertexDataAsync;
  3682. private _extensionsLoadMaterialAsync;
  3683. private _extensionsCreateMaterial;
  3684. private _extensionsLoadMaterialPropertiesAsync;
  3685. private _extensionsLoadTextureInfoAsync;
  3686. private _extensionsLoadAnimationAsync;
  3687. private _extensionsLoadUriAsync;
  3688. /**
  3689. * Helper method called by a loader extension to load an glTF extension.
  3690. * @param context The context when loading the asset
  3691. * @param property The glTF property to load the extension from
  3692. * @param extensionName The name of the extension to load
  3693. * @param actionAsync The action to run
  3694. * @returns The promise returned by actionAsync or null if the extension does not exist
  3695. */
  3696. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  3697. /**
  3698. * Helper method called by a loader extension to load a glTF extra.
  3699. * @param context The context when loading the asset
  3700. * @param property The glTF property to load the extra from
  3701. * @param extensionName The name of the extension to load
  3702. * @param actionAsync The action to run
  3703. * @returns The promise returned by actionAsync or null if the extra does not exist
  3704. */
  3705. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  3706. /**
  3707. * Increments the indentation level and logs a message.
  3708. * @param message The message to log
  3709. */
  3710. logOpen(message: string): void;
  3711. /**
  3712. * Decrements the indentation level.
  3713. */
  3714. logClose(): void;
  3715. /**
  3716. * Logs a message
  3717. * @param message The message to log
  3718. */
  3719. log(message: string): void;
  3720. /**
  3721. * Starts a performance counter.
  3722. * @param counterName The name of the performance counter
  3723. */
  3724. startPerformanceCounter(counterName: string): void;
  3725. /**
  3726. * Ends a performance counter.
  3727. * @param counterName The name of the performance counter
  3728. */
  3729. endPerformanceCounter(counterName: string): void;
  3730. }
  3731. }
  3732. declare module BABYLON.GLTF2.Loader.Extensions {
  3733. /**
  3734. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  3735. */
  3736. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  3737. /** The name of this extension. */
  3738. readonly name: string;
  3739. /** Defines whether this extension is enabled. */
  3740. enabled: boolean;
  3741. private _loader;
  3742. private _lights?;
  3743. /** @hidden */
  3744. constructor(loader: GLTFLoader);
  3745. /** @hidden */
  3746. dispose(): void;
  3747. /** @hidden */
  3748. onLoading(): void;
  3749. /** @hidden */
  3750. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  3751. private _loadLightAsync;
  3752. }
  3753. }
  3754. declare module BABYLON.GLTF2.Loader.Extensions {
  3755. /**
  3756. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  3757. */
  3758. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  3759. /** The name of this extension. */
  3760. readonly name: string;
  3761. /** Defines whether this extension is enabled. */
  3762. enabled: boolean;
  3763. private _loader;
  3764. private _dracoCompression?;
  3765. /** @hidden */
  3766. constructor(loader: GLTFLoader);
  3767. /** @hidden */
  3768. dispose(): void;
  3769. /** @hidden */
  3770. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  3771. }
  3772. }
  3773. declare module BABYLON.GLTF2.Loader.Extensions {
  3774. /**
  3775. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  3776. */
  3777. export class KHR_lights implements IGLTFLoaderExtension {
  3778. /** The name of this extension. */
  3779. readonly name: string;
  3780. /** Defines whether this extension is enabled. */
  3781. enabled: boolean;
  3782. private _loader;
  3783. private _lights?;
  3784. /** @hidden */
  3785. constructor(loader: GLTFLoader);
  3786. /** @hidden */
  3787. dispose(): void;
  3788. /** @hidden */
  3789. onLoading(): void;
  3790. /** @hidden */
  3791. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3792. }
  3793. }
  3794. declare module BABYLON.GLTF2.Loader.Extensions {
  3795. /**
  3796. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  3797. */
  3798. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  3799. /** The name of this extension. */
  3800. readonly name: string;
  3801. /** Defines whether this extension is enabled. */
  3802. enabled: boolean;
  3803. private _loader;
  3804. /** @hidden */
  3805. constructor(loader: GLTFLoader);
  3806. /** @hidden */
  3807. dispose(): void;
  3808. /** @hidden */
  3809. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3810. private _loadSpecularGlossinessPropertiesAsync;
  3811. }
  3812. }
  3813. declare module BABYLON.GLTF2.Loader.Extensions {
  3814. /**
  3815. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  3816. */
  3817. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  3818. /** The name of this extension. */
  3819. readonly name: string;
  3820. /** Defines whether this extension is enabled. */
  3821. enabled: boolean;
  3822. private _loader;
  3823. /** @hidden */
  3824. constructor(loader: GLTFLoader);
  3825. /** @hidden */
  3826. dispose(): void;
  3827. /** @hidden */
  3828. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3829. private _loadUnlitPropertiesAsync;
  3830. }
  3831. }
  3832. declare module BABYLON.GLTF2.Loader.Extensions {
  3833. /**
  3834. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  3835. */
  3836. export class KHR_texture_transform implements IGLTFLoaderExtension {
  3837. /** The name of this extension. */
  3838. readonly name: string;
  3839. /** Defines whether this extension is enabled. */
  3840. enabled: boolean;
  3841. private _loader;
  3842. /** @hidden */
  3843. constructor(loader: GLTFLoader);
  3844. /** @hidden */
  3845. dispose(): void;
  3846. /** @hidden */
  3847. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3848. }
  3849. }
  3850. declare module BABYLON.GLTF2.Loader.Extensions {
  3851. /**
  3852. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  3853. */
  3854. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  3855. /** The name of this extension. */
  3856. readonly name: string;
  3857. /** Defines whether this extension is enabled. */
  3858. enabled: boolean;
  3859. private _loader;
  3860. private _clips;
  3861. private _emitters;
  3862. /** @hidden */
  3863. constructor(loader: GLTFLoader);
  3864. /** @hidden */
  3865. dispose(): void;
  3866. /** @hidden */
  3867. onLoading(): void;
  3868. /** @hidden */
  3869. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  3870. /** @hidden */
  3871. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3872. /** @hidden */
  3873. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  3874. private _loadClipAsync;
  3875. private _loadEmitterAsync;
  3876. private _getEventAction;
  3877. private _loadAnimationEventAsync;
  3878. }
  3879. }
  3880. declare module BABYLON.GLTF2.Loader.Extensions {
  3881. /**
  3882. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  3883. */
  3884. export class MSFT_lod implements IGLTFLoaderExtension {
  3885. /** The name of this extension. */
  3886. readonly name: string;
  3887. /** Defines whether this extension is enabled. */
  3888. enabled: boolean;
  3889. /**
  3890. * Maximum number of LODs to load, starting from the lowest LOD.
  3891. */
  3892. maxLODsToLoad: number;
  3893. /**
  3894. * Observable raised when all node LODs of one level are loaded.
  3895. * The event data is the index of the loaded LOD starting from zero.
  3896. * Dispose the loader to cancel the loading of the next level of LODs.
  3897. */
  3898. onNodeLODsLoadedObservable: Observable<number>;
  3899. /**
  3900. * Observable raised when all material LODs of one level are loaded.
  3901. * The event data is the index of the loaded LOD starting from zero.
  3902. * Dispose the loader to cancel the loading of the next level of LODs.
  3903. */
  3904. onMaterialLODsLoadedObservable: Observable<number>;
  3905. private _loader;
  3906. private _nodeIndexLOD;
  3907. private _nodeSignalLODs;
  3908. private _nodePromiseLODs;
  3909. private _materialIndexLOD;
  3910. private _materialSignalLODs;
  3911. private _materialPromiseLODs;
  3912. /** @hidden */
  3913. constructor(loader: GLTFLoader);
  3914. /** @hidden */
  3915. dispose(): void;
  3916. /** @hidden */
  3917. onReady(): void;
  3918. /** @hidden */
  3919. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3920. /** @hidden */
  3921. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  3922. /** @hidden */
  3923. _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  3924. /**
  3925. * Gets an array of LOD properties from lowest to highest.
  3926. */
  3927. private _getLODs;
  3928. private _disposeUnusedMaterials;
  3929. }
  3930. }
  3931. declare module BABYLON.GLTF2.Loader.Extensions {
  3932. /** @hidden */
  3933. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  3934. readonly name: string;
  3935. enabled: boolean;
  3936. private _loader;
  3937. constructor(loader: GLTFLoader);
  3938. dispose(): void;
  3939. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3940. }
  3941. }
  3942. declare module BABYLON.GLTF2.Loader.Extensions {
  3943. /** @hidden */
  3944. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  3945. readonly name: string;
  3946. enabled: boolean;
  3947. private _loader;
  3948. constructor(loader: GLTFLoader);
  3949. dispose(): void;
  3950. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3951. }
  3952. }
  3953. declare module BABYLON {
  3954. /**
  3955. * Class reading and parsing the MTL file bundled with the obj file.
  3956. */
  3957. export class MTLFileLoader {
  3958. /**
  3959. * All material loaded from the mtl will be set here
  3960. */
  3961. materials: StandardMaterial[];
  3962. /**
  3963. * This function will read the mtl file and create each material described inside
  3964. * This function could be improve by adding :
  3965. * -some component missing (Ni, Tf...)
  3966. * -including the specific options available
  3967. *
  3968. * @param scene defines the scene the material will be created in
  3969. * @param data defines the mtl data to parse
  3970. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  3971. */
  3972. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  3973. /**
  3974. * Gets the texture for the material.
  3975. *
  3976. * If the material is imported from input file,
  3977. * We sanitize the url to ensure it takes the textre from aside the material.
  3978. *
  3979. * @param rootUrl The root url to load from
  3980. * @param value The value stored in the mtl
  3981. * @return The Texture
  3982. */
  3983. private static _getTexture;
  3984. }
  3985. /**
  3986. * Options for loading OBJ/MTL files
  3987. */
  3988. type MeshLoadOptions = {
  3989. /**
  3990. * Defines if UVs are optimized by default during load.
  3991. */
  3992. OptimizeWithUV: boolean;
  3993. /**
  3994. * Invert model on y-axis (does a model scaling inversion)
  3995. */
  3996. InvertY: boolean;
  3997. /**
  3998. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  3999. */
  4000. ImportVertexColors: boolean;
  4001. /**
  4002. * Compute the normals for the model, even if normals are present in the file.
  4003. */
  4004. ComputeNormals: boolean;
  4005. /**
  4006. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4007. */
  4008. SkipMaterials: boolean;
  4009. /**
  4010. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4011. */
  4012. MaterialLoadingFailsSilently: boolean;
  4013. };
  4014. /**
  4015. * OBJ file type loader.
  4016. * This is a babylon scene loader plugin.
  4017. */
  4018. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  4019. /**
  4020. * Defines if UVs are optimized by default during load.
  4021. */
  4022. static OPTIMIZE_WITH_UV: boolean;
  4023. /**
  4024. * Invert model on y-axis (does a model scaling inversion)
  4025. */
  4026. static INVERT_Y: boolean;
  4027. /**
  4028. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4029. */
  4030. static IMPORT_VERTEX_COLORS: boolean;
  4031. /**
  4032. * Compute the normals for the model, even if normals are present in the file.
  4033. */
  4034. static COMPUTE_NORMALS: boolean;
  4035. /**
  4036. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4037. */
  4038. static SKIP_MATERIALS: boolean;
  4039. /**
  4040. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4041. *
  4042. * Defaults to true for backwards compatibility.
  4043. */
  4044. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  4045. /**
  4046. * Defines the name of the plugin.
  4047. */
  4048. name: string;
  4049. /**
  4050. * Defines the extension the plugin is able to load.
  4051. */
  4052. extensions: string;
  4053. /** @hidden */
  4054. obj: RegExp;
  4055. /** @hidden */
  4056. group: RegExp;
  4057. /** @hidden */
  4058. mtllib: RegExp;
  4059. /** @hidden */
  4060. usemtl: RegExp;
  4061. /** @hidden */
  4062. smooth: RegExp;
  4063. /** @hidden */
  4064. vertexPattern: RegExp;
  4065. /** @hidden */
  4066. normalPattern: RegExp;
  4067. /** @hidden */
  4068. uvPattern: RegExp;
  4069. /** @hidden */
  4070. facePattern1: RegExp;
  4071. /** @hidden */
  4072. facePattern2: RegExp;
  4073. /** @hidden */
  4074. facePattern3: RegExp;
  4075. /** @hidden */
  4076. facePattern4: RegExp;
  4077. /** @hidden */
  4078. facePattern5: RegExp;
  4079. private _meshLoadOptions;
  4080. /**
  4081. * Creates loader for .OBJ files
  4082. *
  4083. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  4084. */
  4085. constructor(meshLoadOptions?: MeshLoadOptions);
  4086. private static readonly currentMeshLoadOptions;
  4087. /**
  4088. * Calls synchronously the MTL file attached to this obj.
  4089. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  4090. * Without this function materials are not displayed in the first frame (but displayed after).
  4091. * In consequence it is impossible to get material information in your HTML file
  4092. *
  4093. * @param url The URL of the MTL file
  4094. * @param rootUrl
  4095. * @param onSuccess Callback function to be called when the MTL file is loaded
  4096. * @private
  4097. */
  4098. private _loadMTL;
  4099. /**
  4100. * Instantiates a OBJ file loader plugin.
  4101. * @returns the created plugin
  4102. */
  4103. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  4104. /**
  4105. * If the data string can be loaded directly.
  4106. *
  4107. * @param data string containing the file data
  4108. * @returns if the data can be loaded directly
  4109. */
  4110. canDirectLoad(data: string): boolean;
  4111. /**
  4112. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  4113. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  4114. * @param scene the scene the meshes should be added to
  4115. * @param data the OBJ data to load
  4116. * @param rootUrl root url to load from
  4117. * @param onProgress event that fires when loading progress has occured
  4118. * @param fileName Defines the name of the file to load
  4119. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  4120. */
  4121. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  4122. meshes: AbstractMesh[];
  4123. particleSystems: IParticleSystem[];
  4124. skeletons: Skeleton[];
  4125. animationGroups: AnimationGroup[];
  4126. }>;
  4127. /**
  4128. * Imports all objects from the loaded OBJ data and adds them to the scene
  4129. * @param scene the scene the objects should be added to
  4130. * @param data the OBJ data to load
  4131. * @param rootUrl root url to load from
  4132. * @param onProgress event that fires when loading progress has occured
  4133. * @param fileName Defines the name of the file to load
  4134. * @returns a promise which completes when objects have been loaded to the scene
  4135. */
  4136. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4137. /**
  4138. * Load into an asset container.
  4139. * @param scene The scene to load into
  4140. * @param data The data to import
  4141. * @param rootUrl The root url for scene and resources
  4142. * @param onProgress The callback when the load progresses
  4143. * @param fileName Defines the name of the file to load
  4144. * @returns The loaded asset container
  4145. */
  4146. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  4147. /**
  4148. * Read the OBJ file and create an Array of meshes.
  4149. * Each mesh contains all information given by the OBJ and the MTL file.
  4150. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  4151. *
  4152. * @param meshesNames
  4153. * @param scene Scene The scene where are displayed the data
  4154. * @param data String The content of the obj file
  4155. * @param rootUrl String The path to the folder
  4156. * @returns Array<AbstractMesh>
  4157. * @private
  4158. */
  4159. private _parseSolid;
  4160. }
  4161. }
  4162. declare module BABYLON {
  4163. /**
  4164. * STL file type loader.
  4165. * This is a babylon scene loader plugin.
  4166. */
  4167. export class STLFileLoader implements ISceneLoaderPlugin {
  4168. /** @hidden */
  4169. solidPattern: RegExp;
  4170. /** @hidden */
  4171. facetsPattern: RegExp;
  4172. /** @hidden */
  4173. normalPattern: RegExp;
  4174. /** @hidden */
  4175. vertexPattern: RegExp;
  4176. /**
  4177. * Defines the name of the plugin.
  4178. */
  4179. name: string;
  4180. /**
  4181. * Defines the extensions the stl loader is able to load.
  4182. * force data to come in as an ArrayBuffer
  4183. * we'll convert to string if it looks like it's an ASCII .stl
  4184. */
  4185. extensions: ISceneLoaderPluginExtensions;
  4186. /**
  4187. * Import meshes into a scene.
  4188. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  4189. * @param scene The scene to import into
  4190. * @param data The data to import
  4191. * @param rootUrl The root url for scene and resources
  4192. * @param meshes The meshes array to import into
  4193. * @param particleSystems The particle systems array to import into
  4194. * @param skeletons The skeletons array to import into
  4195. * @param onError The callback when import fails
  4196. * @returns True if successful or false otherwise
  4197. */
  4198. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  4199. /**
  4200. * Load into a scene.
  4201. * @param scene The scene to load into
  4202. * @param data The data to import
  4203. * @param rootUrl The root url for scene and resources
  4204. * @param onError The callback when import fails
  4205. * @returns true if successful or false otherwise
  4206. */
  4207. load(scene: Scene, data: any, rootUrl: string): boolean;
  4208. /**
  4209. * Load into an asset container.
  4210. * @param scene The scene to load into
  4211. * @param data The data to import
  4212. * @param rootUrl The root url for scene and resources
  4213. * @param onError The callback when import fails
  4214. * @returns The loaded asset container
  4215. */
  4216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  4217. private _isBinary;
  4218. private _parseBinary;
  4219. private _parseASCII;
  4220. }
  4221. }