babylonjs.loaders.module.d.ts 176 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247
  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. import { IProperty } from 'babylonjs-gltf2interface';
  1209. /**
  1210. * Interface for a glTF loader extension.
  1211. */
  1212. export interface IGLTFLoaderExtension extends IGLTFBaseLoaderExtension, IDisposable {
  1213. /**
  1214. * Called after the loader state changes to LOADING.
  1215. */
  1216. onLoading?(): void;
  1217. /**
  1218. * Called after the loader state changes to READY.
  1219. */
  1220. onReady?(): void;
  1221. /**
  1222. * Define this method to modify the default behavior when loading scenes.
  1223. * @param context The context when loading the asset
  1224. * @param scene The glTF scene property
  1225. * @returns A promise that resolves when the load is complete or null if not handled
  1226. */
  1227. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  1228. /**
  1229. * Define this method to modify the default behavior when loading nodes.
  1230. * @param context The context when loading the asset
  1231. * @param node The glTF node property
  1232. * @param assign A function called synchronously after parsing the glTF properties
  1233. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  1234. */
  1235. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1236. /**
  1237. * Define this method to modify the default behavior when loading cameras.
  1238. * @param context The context when loading the asset
  1239. * @param camera The glTF camera property
  1240. * @param assign A function called synchronously after parsing the glTF properties
  1241. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1242. */
  1243. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1244. /**
  1245. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1246. * @param context The context when loading the asset
  1247. * @param primitive The glTF mesh primitive property
  1248. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1249. */
  1250. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1251. /**
  1252. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1253. * @param context The context when loading the asset
  1254. * @param material The glTF material property
  1255. * @param assign A function called synchronously after parsing the glTF properties
  1256. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1257. */
  1258. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1259. /**
  1260. * Define this method to modify the default behavior when creating materials.
  1261. * @param context The context when loading the asset
  1262. * @param material The glTF material property
  1263. * @param babylonDrawMode The draw mode for the Babylon material
  1264. * @returns The Babylon material or null if not handled
  1265. */
  1266. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1267. /**
  1268. * Define this method to modify the default behavior when loading material properties.
  1269. * @param context The context when loading the asset
  1270. * @param material The glTF material property
  1271. * @param babylonMaterial The Babylon material
  1272. * @returns A promise that resolves when the load is complete or null if not handled
  1273. */
  1274. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1275. /**
  1276. * Define this method to modify the default behavior when loading texture infos.
  1277. * @param context The context when loading the asset
  1278. * @param textureInfo The glTF texture info property
  1279. * @param assign A function called synchronously after parsing the glTF properties
  1280. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1281. */
  1282. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1283. /**
  1284. * Define this method to modify the default behavior when loading animations.
  1285. * @param context The context when loading the asset
  1286. * @param animation The glTF animation property
  1287. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1288. */
  1289. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1290. /**
  1291. * Define this method to modify the default behavior when loading uris.
  1292. * @param context The context when loading the asset
  1293. * @param property The glTF property associated with the uri
  1294. * @param uri The uri to load
  1295. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1296. */
  1297. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1298. }
  1299. }
  1300. declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
  1301. import { Nullable } from "babylonjs/types";
  1302. import { Camera } from "babylonjs/Cameras/camera";
  1303. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1304. import { Skeleton } from "babylonjs/Bones/skeleton";
  1305. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  1306. import { Material } from "babylonjs/Materials/material";
  1307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1308. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  1310. import { Mesh } from "babylonjs/Meshes/mesh";
  1311. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  1312. import { Scene } from "babylonjs/scene";
  1313. import { IProperty } from "babylonjs-gltf2interface";
  1314. import { IGLTF, INode, IScene, ICamera, IAnimation, IBufferView, IMaterial, ITextureInfo, IImage, IArrayItem as IArrItem } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1315. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1316. import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
  1317. /**
  1318. * Helper class for working with arrays when loading the glTF asset
  1319. */
  1320. export class ArrayItem {
  1321. /**
  1322. * Gets an item from the given array.
  1323. * @param context The context when loading the asset
  1324. * @param array The array to get the item from
  1325. * @param index The index to the array
  1326. * @returns The array item
  1327. */
  1328. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1329. /**
  1330. * Assign an `index` field to each item of the given array.
  1331. * @param array The array of items
  1332. */
  1333. static Assign(array?: IArrItem[]): void;
  1334. }
  1335. /**
  1336. * The glTF 2.0 loader
  1337. */
  1338. export class GLTFLoader implements IGLTFLoader {
  1339. /** @hidden */
  1340. _completePromises: Promise<any>[];
  1341. private _disposed;
  1342. private _parent;
  1343. private _state;
  1344. private _extensions;
  1345. private _rootUrl;
  1346. private _fileName;
  1347. private _uniqueRootUrl;
  1348. private _gltf;
  1349. private _babylonScene;
  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. /**
  1374. * The glTF object parsed from the JSON.
  1375. */
  1376. readonly gltf: IGLTF;
  1377. /**
  1378. * The Babylon scene when loading the asset.
  1379. */
  1380. readonly babylonScene: Scene;
  1381. /**
  1382. * The root Babylon mesh when loading the asset.
  1383. */
  1384. readonly rootBabylonMesh: Mesh;
  1385. /** @hidden */
  1386. constructor(parent: GLTFFileLoader);
  1387. /** @hidden */
  1388. dispose(): void;
  1389. /** @hidden */
  1390. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1391. meshes: AbstractMesh[];
  1392. particleSystems: IParticleSystem[];
  1393. skeletons: Skeleton[];
  1394. animationGroups: AnimationGroup[];
  1395. }>;
  1396. /** @hidden */
  1397. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1398. private _loadAsync;
  1399. private _loadData;
  1400. private _setupData;
  1401. private _loadExtensions;
  1402. private _checkExtensions;
  1403. private _setState;
  1404. private _createRootNode;
  1405. /**
  1406. * Loads a glTF scene.
  1407. * @param context The context when loading the asset
  1408. * @param scene The glTF scene property
  1409. * @returns A promise that resolves when the load is complete
  1410. */
  1411. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  1412. private _forEachPrimitive;
  1413. private _getMeshes;
  1414. private _getSkeletons;
  1415. private _getAnimationGroups;
  1416. private _startAnimations;
  1417. /**
  1418. * Loads a glTF node.
  1419. * @param context The context when loading the asset
  1420. * @param node The glTF node property
  1421. * @param assign A function called synchronously after parsing the glTF properties
  1422. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1423. */
  1424. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  1425. private _loadMeshAsync;
  1426. private _loadMeshPrimitiveAsync;
  1427. private _loadVertexDataAsync;
  1428. private _createMorphTargets;
  1429. private _loadMorphTargetsAsync;
  1430. private _loadMorphTargetVertexDataAsync;
  1431. private static _LoadTransform;
  1432. private _loadSkinAsync;
  1433. private _loadBones;
  1434. private _loadBone;
  1435. private _loadSkinInverseBindMatricesDataAsync;
  1436. private _updateBoneMatrices;
  1437. private _getNodeMatrix;
  1438. /**
  1439. * Loads a glTF camera.
  1440. * @param context The context when loading the asset
  1441. * @param camera The glTF camera property
  1442. * @param assign A function called synchronously after parsing the glTF properties
  1443. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1444. */
  1445. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1446. private _loadAnimationsAsync;
  1447. /**
  1448. * Loads a glTF animation.
  1449. * @param context The context when loading the asset
  1450. * @param animation The glTF animation property
  1451. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1452. */
  1453. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  1454. private _loadAnimationChannelAsync;
  1455. private _loadAnimationSamplerAsync;
  1456. private _loadBufferAsync;
  1457. /**
  1458. * Loads a glTF buffer view.
  1459. * @param context The context when loading the asset
  1460. * @param bufferView The glTF buffer view property
  1461. * @returns A promise that resolves with the loaded data when the load is complete
  1462. */
  1463. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1464. private _loadIndicesAccessorAsync;
  1465. private _loadFloatAccessorAsync;
  1466. private _loadVertexBufferViewAsync;
  1467. private _loadVertexAccessorAsync;
  1468. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1469. /** @hidden */
  1470. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1471. private _createDefaultMaterial;
  1472. /**
  1473. * Creates a Babylon material from a glTF material.
  1474. * @param context The context when loading the asset
  1475. * @param material The glTF material property
  1476. * @param babylonDrawMode The draw mode for the Babylon material
  1477. * @returns The Babylon material
  1478. */
  1479. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1480. /**
  1481. * Loads properties from a glTF material into a Babylon material.
  1482. * @param context The context when loading the asset
  1483. * @param material The glTF material property
  1484. * @param babylonMaterial The Babylon material
  1485. * @returns A promise that resolves when the load is complete
  1486. */
  1487. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1488. /**
  1489. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1490. * @param context The context when loading the asset
  1491. * @param material The glTF material property
  1492. * @param babylonMaterial The Babylon material
  1493. * @returns A promise that resolves when the load is complete
  1494. */
  1495. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1496. /**
  1497. * Loads the alpha properties from a glTF material into a Babylon material.
  1498. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1499. * @param context The context when loading the asset
  1500. * @param material The glTF material property
  1501. * @param babylonMaterial The Babylon material
  1502. */
  1503. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1504. /**
  1505. * Loads a glTF texture info.
  1506. * @param context The context when loading the asset
  1507. * @param textureInfo The glTF texture info property
  1508. * @param assign A function called synchronously after parsing the glTF properties
  1509. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1510. */
  1511. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1512. private _loadTextureAsync;
  1513. private _loadSampler;
  1514. /**
  1515. * Loads a glTF image.
  1516. * @param context The context when loading the asset
  1517. * @param image The glTF image property
  1518. * @returns A promise that resolves with the loaded data when the load is complete
  1519. */
  1520. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1521. /**
  1522. * Loads a glTF uri.
  1523. * @param context The context when loading the asset
  1524. * @param property The glTF property associated with the uri
  1525. * @param uri The base64 or relative uri
  1526. * @returns A promise that resolves with the loaded data when the load is complete
  1527. */
  1528. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  1529. private _onProgress;
  1530. /**
  1531. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1532. * @param babylonObject the Babylon object with metadata
  1533. * @param pointer the JSON pointer
  1534. */
  1535. static AddPointerMetadata(babylonObject: {
  1536. metadata: any;
  1537. }, pointer: string): void;
  1538. private static _GetTextureWrapMode;
  1539. private static _GetTextureSamplingMode;
  1540. private static _GetTypedArray;
  1541. private static _GetNumComponents;
  1542. private static _ValidateUri;
  1543. private static _GetDrawMode;
  1544. private _compileMaterialsAsync;
  1545. private _compileShadowGeneratorsAsync;
  1546. private _forEachExtensions;
  1547. private _applyExtensions;
  1548. private _extensionsOnLoading;
  1549. private _extensionsOnReady;
  1550. private _extensionsLoadSceneAsync;
  1551. private _extensionsLoadNodeAsync;
  1552. private _extensionsLoadCameraAsync;
  1553. private _extensionsLoadVertexDataAsync;
  1554. private _extensionsLoadMaterialAsync;
  1555. private _extensionsCreateMaterial;
  1556. private _extensionsLoadMaterialPropertiesAsync;
  1557. private _extensionsLoadTextureInfoAsync;
  1558. private _extensionsLoadAnimationAsync;
  1559. private _extensionsLoadUriAsync;
  1560. /**
  1561. * Helper method called by a loader extension to load an glTF extension.
  1562. * @param context The context when loading the asset
  1563. * @param property The glTF property to load the extension from
  1564. * @param extensionName The name of the extension to load
  1565. * @param actionAsync The action to run
  1566. * @returns The promise returned by actionAsync or null if the extension does not exist
  1567. */
  1568. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1569. /**
  1570. * Helper method called by a loader extension to load a glTF extra.
  1571. * @param context The context when loading the asset
  1572. * @param property The glTF property to load the extra from
  1573. * @param extensionName The name of the extension to load
  1574. * @param actionAsync The action to run
  1575. * @returns The promise returned by actionAsync or null if the extra does not exist
  1576. */
  1577. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1578. /**
  1579. * Increments the indentation level and logs a message.
  1580. * @param message The message to log
  1581. */
  1582. logOpen(message: string): void;
  1583. /**
  1584. * Decrements the indentation level.
  1585. */
  1586. logClose(): void;
  1587. /**
  1588. * Logs a message
  1589. * @param message The message to log
  1590. */
  1591. log(message: string): void;
  1592. /**
  1593. * Starts a performance counter.
  1594. * @param counterName The name of the performance counter
  1595. */
  1596. startPerformanceCounter(counterName: string): void;
  1597. /**
  1598. * Ends a performance counter.
  1599. * @param counterName The name of the performance counter
  1600. */
  1601. endPerformanceCounter(counterName: string): void;
  1602. }
  1603. }
  1604. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based" {
  1605. import { Nullable } from "babylonjs/types";
  1606. import { IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1607. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1608. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1609. /**
  1610. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  1611. */
  1612. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1613. /** The name of this extension. */
  1614. readonly name: string;
  1615. /** Defines whether this extension is enabled. */
  1616. enabled: boolean;
  1617. private _loader;
  1618. private _lights?;
  1619. /** @hidden */
  1620. constructor(loader: GLTFLoader);
  1621. /** @hidden */
  1622. dispose(): void;
  1623. /** @hidden */
  1624. onLoading(): void;
  1625. /** @hidden */
  1626. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1627. private _loadLightAsync;
  1628. }
  1629. }
  1630. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression" {
  1631. import { Nullable } from "babylonjs/types";
  1632. import { Geometry } from "babylonjs/Meshes/geometry";
  1633. import { Mesh } from "babylonjs/Meshes/mesh";
  1634. import { IMeshPrimitive } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1635. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1636. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1637. /**
  1638. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1639. */
  1640. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1641. /** The name of this extension. */
  1642. readonly name: string;
  1643. /** Defines whether this extension is enabled. */
  1644. enabled: boolean;
  1645. private _loader;
  1646. private _dracoCompression?;
  1647. /** @hidden */
  1648. constructor(loader: GLTFLoader);
  1649. /** @hidden */
  1650. dispose(): void;
  1651. /** @hidden */
  1652. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1653. }
  1654. }
  1655. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual" {
  1656. import { Nullable } from "babylonjs/types";
  1657. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1658. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1659. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1660. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1661. /**
  1662. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  1663. */
  1664. export class KHR_lights implements IGLTFLoaderExtension {
  1665. /** The name of this extension. */
  1666. readonly name: string;
  1667. /** Defines whether this extension is enabled. */
  1668. enabled: boolean;
  1669. private _loader;
  1670. private _lights?;
  1671. /** @hidden */
  1672. constructor(loader: GLTFLoader);
  1673. /** @hidden */
  1674. dispose(): void;
  1675. /** @hidden */
  1676. onLoading(): void;
  1677. /** @hidden */
  1678. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1679. }
  1680. }
  1681. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness" {
  1682. import { Nullable } from "babylonjs/types";
  1683. import { Material } from "babylonjs/Materials/material";
  1684. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1685. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1686. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1687. /**
  1688. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1689. */
  1690. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1691. /** The name of this extension. */
  1692. readonly name: string;
  1693. /** Defines whether this extension is enabled. */
  1694. enabled: boolean;
  1695. private _loader;
  1696. /** @hidden */
  1697. constructor(loader: GLTFLoader);
  1698. /** @hidden */
  1699. dispose(): void;
  1700. /** @hidden */
  1701. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1702. private _loadSpecularGlossinessPropertiesAsync;
  1703. }
  1704. }
  1705. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit" {
  1706. import { Nullable } from "babylonjs/types";
  1707. import { Material } from "babylonjs/Materials/material";
  1708. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1709. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1710. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1711. /**
  1712. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1713. */
  1714. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1715. /** The name of this extension. */
  1716. readonly name: string;
  1717. /** Defines whether this extension is enabled. */
  1718. enabled: boolean;
  1719. private _loader;
  1720. /** @hidden */
  1721. constructor(loader: GLTFLoader);
  1722. /** @hidden */
  1723. dispose(): void;
  1724. /** @hidden */
  1725. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1726. private _loadUnlitPropertiesAsync;
  1727. }
  1728. }
  1729. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform" {
  1730. import { Nullable } from "babylonjs/types";
  1731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1732. import { ITextureInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1733. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1734. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1735. /**
  1736. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1737. */
  1738. export class KHR_texture_transform implements IGLTFLoaderExtension {
  1739. /** The name of this extension. */
  1740. readonly name: string;
  1741. /** Defines whether this extension is enabled. */
  1742. enabled: boolean;
  1743. private _loader;
  1744. /** @hidden */
  1745. constructor(loader: GLTFLoader);
  1746. /** @hidden */
  1747. dispose(): void;
  1748. /** @hidden */
  1749. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1750. }
  1751. }
  1752. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter" {
  1753. import { Nullable } from "babylonjs/types";
  1754. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1755. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1756. import { IScene, INode, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1757. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1758. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1759. /**
  1760. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1761. */
  1762. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1763. /** The name of this extension. */
  1764. readonly name: string;
  1765. /** Defines whether this extension is enabled. */
  1766. enabled: boolean;
  1767. private _loader;
  1768. private _clips;
  1769. private _emitters;
  1770. /** @hidden */
  1771. constructor(loader: GLTFLoader);
  1772. /** @hidden */
  1773. dispose(): void;
  1774. /** @hidden */
  1775. onLoading(): void;
  1776. /** @hidden */
  1777. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1778. /** @hidden */
  1779. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1780. /** @hidden */
  1781. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1782. private _loadClipAsync;
  1783. private _loadEmitterAsync;
  1784. private _getEventAction;
  1785. private _loadAnimationEventAsync;
  1786. }
  1787. }
  1788. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
  1789. import { Nullable } from "babylonjs/types";
  1790. import { Observable } from "babylonjs/Misc/observable";
  1791. import { Material } from "babylonjs/Materials/material";
  1792. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1793. import { Mesh } from "babylonjs/Meshes/mesh";
  1794. import { INode, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1795. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1796. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1797. import { IProperty } from 'babylonjs-gltf2interface';
  1798. /**
  1799. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1800. */
  1801. export class MSFT_lod implements IGLTFLoaderExtension {
  1802. /** The name of this extension. */
  1803. readonly name: string;
  1804. /** Defines whether this extension is enabled. */
  1805. enabled: boolean;
  1806. /**
  1807. * Maximum number of LODs to load, starting from the lowest LOD.
  1808. */
  1809. maxLODsToLoad: number;
  1810. /**
  1811. * Observable raised when all node LODs of one level are loaded.
  1812. * The event data is the index of the loaded LOD starting from zero.
  1813. * Dispose the loader to cancel the loading of the next level of LODs.
  1814. */
  1815. onNodeLODsLoadedObservable: Observable<number>;
  1816. /**
  1817. * Observable raised when all material LODs of one level are loaded.
  1818. * The event data is the index of the loaded LOD starting from zero.
  1819. * Dispose the loader to cancel the loading of the next level of LODs.
  1820. */
  1821. onMaterialLODsLoadedObservable: Observable<number>;
  1822. private _loader;
  1823. private _nodeIndexLOD;
  1824. private _nodeSignalLODs;
  1825. private _nodePromiseLODs;
  1826. private _materialIndexLOD;
  1827. private _materialSignalLODs;
  1828. private _materialPromiseLODs;
  1829. /** @hidden */
  1830. constructor(loader: GLTFLoader);
  1831. /** @hidden */
  1832. dispose(): void;
  1833. /** @hidden */
  1834. onReady(): void;
  1835. /** @hidden */
  1836. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1837. /** @hidden */
  1838. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1839. /** @hidden */
  1840. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1841. /**
  1842. * Gets an array of LOD properties from lowest to highest.
  1843. */
  1844. private _getLODs;
  1845. private _disposeUnusedMaterials;
  1846. }
  1847. }
  1848. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh" {
  1849. import { Nullable } from "babylonjs/types";
  1850. import { Material } from "babylonjs/Materials/material";
  1851. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1852. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1853. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1854. /** @hidden */
  1855. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1856. readonly name: string;
  1857. enabled: boolean;
  1858. private _loader;
  1859. constructor(loader: GLTFLoader);
  1860. dispose(): void;
  1861. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1862. }
  1863. }
  1864. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors" {
  1865. import { Nullable } from "babylonjs/types";
  1866. import { Material } from "babylonjs/Materials/material";
  1867. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1868. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1869. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1870. /** @hidden */
  1871. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1872. readonly name: string;
  1873. enabled: boolean;
  1874. private _loader;
  1875. constructor(loader: GLTFLoader);
  1876. dispose(): void;
  1877. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1878. }
  1879. }
  1880. declare module "babylonjs-loaders/glTF/2.0/Extensions/index" {
  1881. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based";
  1882. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  1883. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual";
  1884. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  1885. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit";
  1886. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform";
  1887. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter";
  1888. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod";
  1889. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh";
  1890. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors";
  1891. }
  1892. declare module "babylonjs-loaders/glTF/2.0/index" {
  1893. export * from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1894. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1895. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1896. export * from "babylonjs-loaders/glTF/2.0/Extensions/index";
  1897. }
  1898. declare module "babylonjs-loaders/glTF/index" {
  1899. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  1900. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  1901. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  1902. export { GLTF1, GLTF2 };
  1903. }
  1904. declare module "babylonjs-loaders/OBJ/objFileLoader" {
  1905. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1906. import { Skeleton } from "babylonjs/Bones/skeleton";
  1907. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  1908. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  1909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  1910. import { ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin } from "babylonjs/Loading/sceneLoader";
  1911. import { AssetContainer } from "babylonjs/assetContainer";
  1912. import { Scene } from "babylonjs/scene";
  1913. /**
  1914. * Class reading and parsing the MTL file bundled with the obj file.
  1915. */
  1916. export class MTLFileLoader {
  1917. /**
  1918. * All material loaded from the mtl will be set here
  1919. */
  1920. materials: StandardMaterial[];
  1921. /**
  1922. * This function will read the mtl file and create each material described inside
  1923. * This function could be improve by adding :
  1924. * -some component missing (Ni, Tf...)
  1925. * -including the specific options available
  1926. *
  1927. * @param scene defines the scene the material will be created in
  1928. * @param data defines the mtl data to parse
  1929. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  1930. */
  1931. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  1932. /**
  1933. * Gets the texture for the material.
  1934. *
  1935. * If the material is imported from input file,
  1936. * We sanitize the url to ensure it takes the textre from aside the material.
  1937. *
  1938. * @param rootUrl The root url to load from
  1939. * @param value The value stored in the mtl
  1940. * @return The Texture
  1941. */
  1942. private static _getTexture;
  1943. }
  1944. /**
  1945. * Options for loading OBJ/MTL files
  1946. */
  1947. type MeshLoadOptions = {
  1948. /**
  1949. * Defines if UVs are optimized by default during load.
  1950. */
  1951. OptimizeWithUV: boolean;
  1952. /**
  1953. * Invert model on y-axis (does a model scaling inversion)
  1954. */
  1955. InvertY: boolean;
  1956. /**
  1957. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  1958. */
  1959. ImportVertexColors: boolean;
  1960. /**
  1961. * Compute the normals for the model, even if normals are present in the file.
  1962. */
  1963. ComputeNormals: boolean;
  1964. /**
  1965. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  1966. */
  1967. SkipMaterials: boolean;
  1968. /**
  1969. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  1970. */
  1971. MaterialLoadingFailsSilently: boolean;
  1972. };
  1973. /**
  1974. * OBJ file type loader.
  1975. * This is a babylon scene loader plugin.
  1976. */
  1977. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  1978. /**
  1979. * Defines if UVs are optimized by default during load.
  1980. */
  1981. static OPTIMIZE_WITH_UV: boolean;
  1982. /**
  1983. * Invert model on y-axis (does a model scaling inversion)
  1984. */
  1985. static INVERT_Y: boolean;
  1986. /**
  1987. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  1988. */
  1989. static IMPORT_VERTEX_COLORS: boolean;
  1990. /**
  1991. * Compute the normals for the model, even if normals are present in the file.
  1992. */
  1993. static COMPUTE_NORMALS: boolean;
  1994. /**
  1995. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  1996. */
  1997. static SKIP_MATERIALS: boolean;
  1998. /**
  1999. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2000. *
  2001. * Defaults to true for backwards compatibility.
  2002. */
  2003. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2004. /**
  2005. * Defines the name of the plugin.
  2006. */
  2007. name: string;
  2008. /**
  2009. * Defines the extension the plugin is able to load.
  2010. */
  2011. extensions: string;
  2012. /** @hidden */
  2013. obj: RegExp;
  2014. /** @hidden */
  2015. group: RegExp;
  2016. /** @hidden */
  2017. mtllib: RegExp;
  2018. /** @hidden */
  2019. usemtl: RegExp;
  2020. /** @hidden */
  2021. smooth: RegExp;
  2022. /** @hidden */
  2023. vertexPattern: RegExp;
  2024. /** @hidden */
  2025. normalPattern: RegExp;
  2026. /** @hidden */
  2027. uvPattern: RegExp;
  2028. /** @hidden */
  2029. facePattern1: RegExp;
  2030. /** @hidden */
  2031. facePattern2: RegExp;
  2032. /** @hidden */
  2033. facePattern3: RegExp;
  2034. /** @hidden */
  2035. facePattern4: RegExp;
  2036. /** @hidden */
  2037. facePattern5: RegExp;
  2038. private _meshLoadOptions;
  2039. /**
  2040. * Creates loader for .OBJ files
  2041. *
  2042. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2043. */
  2044. constructor(meshLoadOptions?: MeshLoadOptions);
  2045. private static readonly currentMeshLoadOptions;
  2046. /**
  2047. * Calls synchronously the MTL file attached to this obj.
  2048. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2049. * Without this function materials are not displayed in the first frame (but displayed after).
  2050. * In consequence it is impossible to get material information in your HTML file
  2051. *
  2052. * @param url The URL of the MTL file
  2053. * @param rootUrl
  2054. * @param onSuccess Callback function to be called when the MTL file is loaded
  2055. * @private
  2056. */
  2057. private _loadMTL;
  2058. /**
  2059. * Instantiates a OBJ file loader plugin.
  2060. * @returns the created plugin
  2061. */
  2062. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2063. /**
  2064. * If the data string can be loaded directly.
  2065. *
  2066. * @param data string containing the file data
  2067. * @returns if the data can be loaded directly
  2068. */
  2069. canDirectLoad(data: string): boolean;
  2070. /**
  2071. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2072. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2073. * @param scene the scene the meshes should be added to
  2074. * @param data the OBJ data to load
  2075. * @param rootUrl root url to load from
  2076. * @param onProgress event that fires when loading progress has occured
  2077. * @param fileName Defines the name of the file to load
  2078. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2079. */
  2080. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2081. meshes: AbstractMesh[];
  2082. particleSystems: IParticleSystem[];
  2083. skeletons: Skeleton[];
  2084. animationGroups: AnimationGroup[];
  2085. }>;
  2086. /**
  2087. * Imports all objects from the loaded OBJ data and adds them to the scene
  2088. * @param scene the scene the objects should be added to
  2089. * @param data the OBJ data to load
  2090. * @param rootUrl root url to load from
  2091. * @param onProgress event that fires when loading progress has occured
  2092. * @param fileName Defines the name of the file to load
  2093. * @returns a promise which completes when objects have been loaded to the scene
  2094. */
  2095. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2096. /**
  2097. * Load into an asset container.
  2098. * @param scene The scene to load into
  2099. * @param data The data to import
  2100. * @param rootUrl The root url for scene and resources
  2101. * @param onProgress The callback when the load progresses
  2102. * @param fileName Defines the name of the file to load
  2103. * @returns The loaded asset container
  2104. */
  2105. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2106. /**
  2107. * Read the OBJ file and create an Array of meshes.
  2108. * Each mesh contains all information given by the OBJ and the MTL file.
  2109. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2110. *
  2111. * @param meshesNames
  2112. * @param scene Scene The scene where are displayed the data
  2113. * @param data String The content of the obj file
  2114. * @param rootUrl String The path to the folder
  2115. * @returns Array<AbstractMesh>
  2116. * @private
  2117. */
  2118. private _parseSolid;
  2119. }
  2120. }
  2121. declare module "babylonjs-loaders/OBJ/index" {
  2122. export * from "babylonjs-loaders/OBJ/objFileLoader";
  2123. }
  2124. declare module "babylonjs-loaders/STL/stlFileLoader" {
  2125. import { Nullable } from "babylonjs/types";
  2126. import { Skeleton } from "babylonjs/Bones/skeleton";
  2127. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2129. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  2130. import { AssetContainer } from "babylonjs/assetContainer";
  2131. import { Scene } from "babylonjs/scene";
  2132. /**
  2133. * STL file type loader.
  2134. * This is a babylon scene loader plugin.
  2135. */
  2136. export class STLFileLoader implements ISceneLoaderPlugin {
  2137. /** @hidden */
  2138. solidPattern: RegExp;
  2139. /** @hidden */
  2140. facetsPattern: RegExp;
  2141. /** @hidden */
  2142. normalPattern: RegExp;
  2143. /** @hidden */
  2144. vertexPattern: RegExp;
  2145. /**
  2146. * Defines the name of the plugin.
  2147. */
  2148. name: string;
  2149. /**
  2150. * Defines the extensions the stl loader is able to load.
  2151. * force data to come in as an ArrayBuffer
  2152. * we'll convert to string if it looks like it's an ASCII .stl
  2153. */
  2154. extensions: ISceneLoaderPluginExtensions;
  2155. /**
  2156. * Import meshes into a scene.
  2157. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2158. * @param scene The scene to import into
  2159. * @param data The data to import
  2160. * @param rootUrl The root url for scene and resources
  2161. * @param meshes The meshes array to import into
  2162. * @param particleSystems The particle systems array to import into
  2163. * @param skeletons The skeletons array to import into
  2164. * @param onError The callback when import fails
  2165. * @returns True if successful or false otherwise
  2166. */
  2167. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2168. /**
  2169. * Load into a scene.
  2170. * @param scene The scene to load into
  2171. * @param data The data to import
  2172. * @param rootUrl The root url for scene and resources
  2173. * @param onError The callback when import fails
  2174. * @returns true if successful or false otherwise
  2175. */
  2176. load(scene: Scene, data: any, rootUrl: string): boolean;
  2177. /**
  2178. * Load into an asset container.
  2179. * @param scene The scene to load into
  2180. * @param data The data to import
  2181. * @param rootUrl The root url for scene and resources
  2182. * @param onError The callback when import fails
  2183. * @returns The loaded asset container
  2184. */
  2185. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2186. private _isBinary;
  2187. private _parseBinary;
  2188. private _parseASCII;
  2189. }
  2190. }
  2191. declare module "babylonjs-loaders/STL/index" {
  2192. export * from "babylonjs-loaders/STL/stlFileLoader";
  2193. }
  2194. declare module "babylonjs-loaders/index" {
  2195. export * from "babylonjs-loaders/glTF/index";
  2196. export * from "babylonjs-loaders/OBJ/index";
  2197. export * from "babylonjs-loaders/STL/index";
  2198. }
  2199. declare module "babylonjs-loaders/legacy/legacy-glTF" {
  2200. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2201. }
  2202. declare module "babylonjs-loaders/legacy/legacy-glTF1" {
  2203. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2204. export { GLTF1 };
  2205. }
  2206. declare module "babylonjs-loaders/legacy/legacy-glTF1FileLoader" {
  2207. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2208. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2209. }
  2210. declare module "babylonjs-loaders/legacy/legacy-glTF2" {
  2211. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2212. export { GLTF2 };
  2213. }
  2214. declare module "babylonjs-loaders/legacy/legacy-glTF2FileLoader" {
  2215. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2216. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2217. }
  2218. declare module "babylonjs-loaders/legacy/legacy-glTFFileLoader" {
  2219. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2220. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2221. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2222. }
  2223. declare module "babylonjs-loaders/legacy/legacy-objFileLoader" {
  2224. export * from "babylonjs-loaders/OBJ/index";
  2225. }
  2226. declare module "babylonjs-loaders/legacy/legacy-stlFileLoader" {
  2227. export * from "babylonjs-loaders/STL/index";
  2228. }
  2229. declare module "babylonjs-loaders/legacy/legacy" {
  2230. import "babylonjs-loaders/index";
  2231. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2232. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2233. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2234. export * from "babylonjs-loaders/legacy/legacy-objFileLoader";
  2235. export * from "babylonjs-loaders/legacy/legacy-stlFileLoader";
  2236. }
  2237. declare module "babylonjs-loaders" {
  2238. export * from "babylonjs-loaders/legacy/legacy";
  2239. }
  2240. declare module BABYLON {
  2241. /**
  2242. * Mode that determines the coordinate system to use.
  2243. */
  2244. export enum GLTFLoaderCoordinateSystemMode {
  2245. /**
  2246. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2247. */
  2248. AUTO = 0,
  2249. /**
  2250. * Sets the useRightHandedSystem flag on the scene.
  2251. */
  2252. FORCE_RIGHT_HANDED = 1
  2253. }
  2254. /**
  2255. * Mode that determines what animations will start.
  2256. */
  2257. export enum GLTFLoaderAnimationStartMode {
  2258. /**
  2259. * No animation will start.
  2260. */
  2261. NONE = 0,
  2262. /**
  2263. * The first animation will start.
  2264. */
  2265. FIRST = 1,
  2266. /**
  2267. * All animations will start.
  2268. */
  2269. ALL = 2
  2270. }
  2271. /**
  2272. * Interface that contains the data for the glTF asset.
  2273. */
  2274. export interface IGLTFLoaderData {
  2275. /**
  2276. * Object that represents the glTF JSON.
  2277. */
  2278. json: Object;
  2279. /**
  2280. * The BIN chunk of a binary glTF.
  2281. */
  2282. bin: Nullable<ArrayBufferView>;
  2283. }
  2284. /**
  2285. * Interface for extending the loader.
  2286. */
  2287. export interface IGLTFLoaderExtension {
  2288. /**
  2289. * The name of this extension.
  2290. */
  2291. readonly name: string;
  2292. /**
  2293. * Defines whether this extension is enabled.
  2294. */
  2295. enabled: boolean;
  2296. }
  2297. /**
  2298. * Loader state.
  2299. */
  2300. export enum GLTFLoaderState {
  2301. /**
  2302. * The asset is loading.
  2303. */
  2304. LOADING = 0,
  2305. /**
  2306. * The asset is ready for rendering.
  2307. */
  2308. READY = 1,
  2309. /**
  2310. * The asset is completely loaded.
  2311. */
  2312. COMPLETE = 2
  2313. }
  2314. /** @hidden */
  2315. export interface IGLTFLoader extends IDisposable {
  2316. readonly state: Nullable<GLTFLoaderState>;
  2317. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  2318. meshes: AbstractMesh[];
  2319. particleSystems: IParticleSystem[];
  2320. skeletons: Skeleton[];
  2321. animationGroups: AnimationGroup[];
  2322. }>;
  2323. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  2324. }
  2325. /**
  2326. * File loader for loading glTF files into a scene.
  2327. */
  2328. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2329. /** @hidden */
  2330. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2331. /** @hidden */
  2332. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2333. /**
  2334. * Raised when the asset has been parsed
  2335. */
  2336. onParsedObservable: Observable<IGLTFLoaderData>;
  2337. private _onParsedObserver;
  2338. /**
  2339. * Raised when the asset has been parsed
  2340. */
  2341. onParsed: (loaderData: IGLTFLoaderData) => void;
  2342. /**
  2343. * 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.
  2344. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  2345. * Defaults to true.
  2346. * @hidden
  2347. */
  2348. static IncrementalLoading: boolean;
  2349. /**
  2350. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  2351. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  2352. * @hidden
  2353. */
  2354. static HomogeneousCoordinates: boolean;
  2355. /**
  2356. * The coordinate system mode. Defaults to AUTO.
  2357. */
  2358. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  2359. /**
  2360. * The animation start mode. Defaults to FIRST.
  2361. */
  2362. animationStartMode: GLTFLoaderAnimationStartMode;
  2363. /**
  2364. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  2365. */
  2366. compileMaterials: boolean;
  2367. /**
  2368. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  2369. */
  2370. useClipPlane: boolean;
  2371. /**
  2372. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  2373. */
  2374. compileShadowGenerators: boolean;
  2375. /**
  2376. * Defines if the Alpha blended materials are only applied as coverage.
  2377. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  2378. * If true, no extra effects are applied to transparent pixels.
  2379. */
  2380. transparencyAsCoverage: boolean;
  2381. /**
  2382. * Function called before loading a url referenced by the asset.
  2383. */
  2384. preprocessUrlAsync: (url: string) => Promise<string>;
  2385. /**
  2386. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2387. */
  2388. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  2389. private _onMeshLoadedObserver;
  2390. /**
  2391. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2392. */
  2393. onMeshLoaded: (mesh: AbstractMesh) => void;
  2394. /**
  2395. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  2396. */
  2397. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  2398. private _onTextureLoadedObserver;
  2399. /**
  2400. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  2401. */
  2402. onTextureLoaded: (texture: BaseTexture) => void;
  2403. /**
  2404. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  2405. */
  2406. readonly onMaterialLoadedObservable: Observable<Material>;
  2407. private _onMaterialLoadedObserver;
  2408. /**
  2409. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  2410. */
  2411. onMaterialLoaded: (material: Material) => void;
  2412. /**
  2413. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  2414. */
  2415. readonly onCameraLoadedObservable: Observable<Camera>;
  2416. private _onCameraLoadedObserver;
  2417. /**
  2418. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  2419. */
  2420. onCameraLoaded: (camera: Camera) => void;
  2421. /**
  2422. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  2423. * For assets with LODs, raised when all of the LODs are complete.
  2424. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2425. */
  2426. readonly onCompleteObservable: Observable<void>;
  2427. private _onCompleteObserver;
  2428. /**
  2429. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  2430. * For assets with LODs, raised when all of the LODs are complete.
  2431. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2432. */
  2433. onComplete: () => void;
  2434. /**
  2435. * Observable raised when an error occurs.
  2436. */
  2437. readonly onErrorObservable: Observable<any>;
  2438. private _onErrorObserver;
  2439. /**
  2440. * Callback raised when an error occurs.
  2441. */
  2442. onError: (reason: any) => void;
  2443. /**
  2444. * Observable raised after the loader is disposed.
  2445. */
  2446. readonly onDisposeObservable: Observable<void>;
  2447. private _onDisposeObserver;
  2448. /**
  2449. * Callback raised after the loader is disposed.
  2450. */
  2451. onDispose: () => void;
  2452. /**
  2453. * Observable raised after a loader extension is created.
  2454. * Set additional options for a loader extension in this event.
  2455. */
  2456. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  2457. private _onExtensionLoadedObserver;
  2458. /**
  2459. * Callback raised after a loader extension is created.
  2460. */
  2461. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  2462. /**
  2463. * Defines if the loader logging is enabled.
  2464. */
  2465. loggingEnabled: boolean;
  2466. /**
  2467. * Defines if the loader should capture performance counters.
  2468. */
  2469. capturePerformanceCounters: boolean;
  2470. /**
  2471. * Defines if the loader should validate the asset.
  2472. */
  2473. validate: boolean;
  2474. /**
  2475. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  2476. */
  2477. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  2478. private _onValidatedObserver;
  2479. /**
  2480. * Callback raised after a loader extension is created.
  2481. */
  2482. onValidated: (results: IGLTFValidationResults) => void;
  2483. private _loader;
  2484. /**
  2485. * Name of the loader ("gltf")
  2486. */
  2487. name: string;
  2488. /**
  2489. * Supported file extensions of the loader (.gltf, .glb)
  2490. */
  2491. extensions: ISceneLoaderPluginExtensions;
  2492. /**
  2493. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  2494. */
  2495. dispose(): void;
  2496. /** @hidden */
  2497. _clear(): void;
  2498. /**
  2499. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  2500. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2501. * @param scene the scene the meshes should be added to
  2502. * @param data the glTF data to load
  2503. * @param rootUrl root url to load from
  2504. * @param onProgress event that fires when loading progress has occured
  2505. * @param fileName Defines the name of the file to load
  2506. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2507. */
  2508. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2509. meshes: AbstractMesh[];
  2510. particleSystems: IParticleSystem[];
  2511. skeletons: Skeleton[];
  2512. animationGroups: AnimationGroup[];
  2513. }>;
  2514. /**
  2515. * Imports all objects from the loaded glTF data and adds them to the scene
  2516. * @param scene the scene the objects should be added to
  2517. * @param data the glTF data to load
  2518. * @param rootUrl root url to load from
  2519. * @param onProgress event that fires when loading progress has occured
  2520. * @param fileName Defines the name of the file to load
  2521. * @returns a promise which completes when objects have been loaded to the scene
  2522. */
  2523. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2524. /**
  2525. * Load into an asset container.
  2526. * @param scene The scene to load into
  2527. * @param data The data to import
  2528. * @param rootUrl The root url for scene and resources
  2529. * @param onProgress The callback when the load progresses
  2530. * @param fileName Defines the name of the file to load
  2531. * @returns The loaded asset container
  2532. */
  2533. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2534. /**
  2535. * If the data string can be loaded directly.
  2536. * @param data string contianing the file data
  2537. * @returns if the data can be loaded directly
  2538. */
  2539. canDirectLoad(data: string): boolean;
  2540. /**
  2541. * Rewrites a url by combining a root url and response url.
  2542. */
  2543. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  2544. /**
  2545. * Instantiates a glTF file loader plugin.
  2546. * @returns the created plugin
  2547. */
  2548. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  2549. /**
  2550. * The loader state or null if the loader is not active.
  2551. */
  2552. readonly loaderState: Nullable<GLTFLoaderState>;
  2553. /**
  2554. * Returns a promise that resolves when the asset is completely loaded.
  2555. * @returns a promise that resolves when the asset is completely loaded.
  2556. */
  2557. whenCompleteAsync(): Promise<void>;
  2558. private _parseAsync;
  2559. private _validateAsync;
  2560. private _getLoader;
  2561. private _unpackBinary;
  2562. private _unpackBinaryV1;
  2563. private _unpackBinaryV2;
  2564. private static _parseVersion;
  2565. private static _compareVersion;
  2566. private static _decodeBufferToText;
  2567. private static readonly _logSpaces;
  2568. private _logIndentLevel;
  2569. private _loggingEnabled;
  2570. /** @hidden */
  2571. _log: (message: string) => void;
  2572. /** @hidden */
  2573. _logOpen(message: string): void;
  2574. /** @hidden */
  2575. _logClose(): void;
  2576. private _logEnabled;
  2577. private _logDisabled;
  2578. private _capturePerformanceCounters;
  2579. /** @hidden */
  2580. _startPerformanceCounter: (counterName: string) => void;
  2581. /** @hidden */
  2582. _endPerformanceCounter: (counterName: string) => void;
  2583. private _startPerformanceCounterEnabled;
  2584. private _startPerformanceCounterDisabled;
  2585. private _endPerformanceCounterEnabled;
  2586. private _endPerformanceCounterDisabled;
  2587. }
  2588. }
  2589. declare module BABYLON.GLTF1 {
  2590. /**
  2591. * Enums
  2592. * @hidden
  2593. */
  2594. export enum EComponentType {
  2595. BYTE = 5120,
  2596. UNSIGNED_BYTE = 5121,
  2597. SHORT = 5122,
  2598. UNSIGNED_SHORT = 5123,
  2599. FLOAT = 5126
  2600. }
  2601. /** @hidden */
  2602. export enum EShaderType {
  2603. FRAGMENT = 35632,
  2604. VERTEX = 35633
  2605. }
  2606. /** @hidden */
  2607. export enum EParameterType {
  2608. BYTE = 5120,
  2609. UNSIGNED_BYTE = 5121,
  2610. SHORT = 5122,
  2611. UNSIGNED_SHORT = 5123,
  2612. INT = 5124,
  2613. UNSIGNED_INT = 5125,
  2614. FLOAT = 5126,
  2615. FLOAT_VEC2 = 35664,
  2616. FLOAT_VEC3 = 35665,
  2617. FLOAT_VEC4 = 35666,
  2618. INT_VEC2 = 35667,
  2619. INT_VEC3 = 35668,
  2620. INT_VEC4 = 35669,
  2621. BOOL = 35670,
  2622. BOOL_VEC2 = 35671,
  2623. BOOL_VEC3 = 35672,
  2624. BOOL_VEC4 = 35673,
  2625. FLOAT_MAT2 = 35674,
  2626. FLOAT_MAT3 = 35675,
  2627. FLOAT_MAT4 = 35676,
  2628. SAMPLER_2D = 35678
  2629. }
  2630. /** @hidden */
  2631. export enum ETextureWrapMode {
  2632. CLAMP_TO_EDGE = 33071,
  2633. MIRRORED_REPEAT = 33648,
  2634. REPEAT = 10497
  2635. }
  2636. /** @hidden */
  2637. export enum ETextureFilterType {
  2638. NEAREST = 9728,
  2639. LINEAR = 9728,
  2640. NEAREST_MIPMAP_NEAREST = 9984,
  2641. LINEAR_MIPMAP_NEAREST = 9985,
  2642. NEAREST_MIPMAP_LINEAR = 9986,
  2643. LINEAR_MIPMAP_LINEAR = 9987
  2644. }
  2645. /** @hidden */
  2646. export enum ETextureFormat {
  2647. ALPHA = 6406,
  2648. RGB = 6407,
  2649. RGBA = 6408,
  2650. LUMINANCE = 6409,
  2651. LUMINANCE_ALPHA = 6410
  2652. }
  2653. /** @hidden */
  2654. export enum ECullingType {
  2655. FRONT = 1028,
  2656. BACK = 1029,
  2657. FRONT_AND_BACK = 1032
  2658. }
  2659. /** @hidden */
  2660. export enum EBlendingFunction {
  2661. ZERO = 0,
  2662. ONE = 1,
  2663. SRC_COLOR = 768,
  2664. ONE_MINUS_SRC_COLOR = 769,
  2665. DST_COLOR = 774,
  2666. ONE_MINUS_DST_COLOR = 775,
  2667. SRC_ALPHA = 770,
  2668. ONE_MINUS_SRC_ALPHA = 771,
  2669. DST_ALPHA = 772,
  2670. ONE_MINUS_DST_ALPHA = 773,
  2671. CONSTANT_COLOR = 32769,
  2672. ONE_MINUS_CONSTANT_COLOR = 32770,
  2673. CONSTANT_ALPHA = 32771,
  2674. ONE_MINUS_CONSTANT_ALPHA = 32772,
  2675. SRC_ALPHA_SATURATE = 776
  2676. }
  2677. /** @hidden */
  2678. export interface IGLTFProperty {
  2679. extensions?: {
  2680. [key: string]: any;
  2681. };
  2682. extras?: Object;
  2683. }
  2684. /** @hidden */
  2685. export interface IGLTFChildRootProperty extends IGLTFProperty {
  2686. name?: string;
  2687. }
  2688. /** @hidden */
  2689. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  2690. bufferView: string;
  2691. byteOffset: number;
  2692. byteStride: number;
  2693. count: number;
  2694. type: string;
  2695. componentType: EComponentType;
  2696. max?: number[];
  2697. min?: number[];
  2698. name?: string;
  2699. }
  2700. /** @hidden */
  2701. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  2702. buffer: string;
  2703. byteOffset: number;
  2704. byteLength: number;
  2705. byteStride: number;
  2706. target?: number;
  2707. }
  2708. /** @hidden */
  2709. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  2710. uri: string;
  2711. byteLength?: number;
  2712. type?: string;
  2713. }
  2714. /** @hidden */
  2715. export interface IGLTFShader extends IGLTFChildRootProperty {
  2716. uri: string;
  2717. type: EShaderType;
  2718. }
  2719. /** @hidden */
  2720. export interface IGLTFProgram extends IGLTFChildRootProperty {
  2721. attributes: string[];
  2722. fragmentShader: string;
  2723. vertexShader: string;
  2724. }
  2725. /** @hidden */
  2726. export interface IGLTFTechniqueParameter {
  2727. type: number;
  2728. count?: number;
  2729. semantic?: string;
  2730. node?: string;
  2731. value?: number | boolean | string | Array<any>;
  2732. source?: string;
  2733. babylonValue?: any;
  2734. }
  2735. /** @hidden */
  2736. export interface IGLTFTechniqueCommonProfile {
  2737. lightingModel: string;
  2738. texcoordBindings: Object;
  2739. parameters?: Array<any>;
  2740. }
  2741. /** @hidden */
  2742. export interface IGLTFTechniqueStatesFunctions {
  2743. blendColor?: number[];
  2744. blendEquationSeparate?: number[];
  2745. blendFuncSeparate?: number[];
  2746. colorMask: boolean[];
  2747. cullFace: number[];
  2748. }
  2749. /** @hidden */
  2750. export interface IGLTFTechniqueStates {
  2751. enable: number[];
  2752. functions: IGLTFTechniqueStatesFunctions;
  2753. }
  2754. /** @hidden */
  2755. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  2756. parameters: {
  2757. [key: string]: IGLTFTechniqueParameter;
  2758. };
  2759. program: string;
  2760. attributes: {
  2761. [key: string]: string;
  2762. };
  2763. uniforms: {
  2764. [key: string]: string;
  2765. };
  2766. states: IGLTFTechniqueStates;
  2767. }
  2768. /** @hidden */
  2769. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  2770. technique?: string;
  2771. values: string[];
  2772. }
  2773. /** @hidden */
  2774. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  2775. attributes: {
  2776. [key: string]: string;
  2777. };
  2778. indices: string;
  2779. material: string;
  2780. mode?: number;
  2781. }
  2782. /** @hidden */
  2783. export interface IGLTFMesh extends IGLTFChildRootProperty {
  2784. primitives: IGLTFMeshPrimitive[];
  2785. }
  2786. /** @hidden */
  2787. export interface IGLTFImage extends IGLTFChildRootProperty {
  2788. uri: string;
  2789. }
  2790. /** @hidden */
  2791. export interface IGLTFSampler extends IGLTFChildRootProperty {
  2792. magFilter?: number;
  2793. minFilter?: number;
  2794. wrapS?: number;
  2795. wrapT?: number;
  2796. }
  2797. /** @hidden */
  2798. export interface IGLTFTexture extends IGLTFChildRootProperty {
  2799. sampler: string;
  2800. source: string;
  2801. format?: ETextureFormat;
  2802. internalFormat?: ETextureFormat;
  2803. target?: number;
  2804. type?: number;
  2805. babylonTexture?: Texture;
  2806. }
  2807. /** @hidden */
  2808. export interface IGLTFAmbienLight {
  2809. color?: number[];
  2810. }
  2811. /** @hidden */
  2812. export interface IGLTFDirectionalLight {
  2813. color?: number[];
  2814. }
  2815. /** @hidden */
  2816. export interface IGLTFPointLight {
  2817. color?: number[];
  2818. constantAttenuation?: number;
  2819. linearAttenuation?: number;
  2820. quadraticAttenuation?: number;
  2821. }
  2822. /** @hidden */
  2823. export interface IGLTFSpotLight {
  2824. color?: number[];
  2825. constantAttenuation?: number;
  2826. fallOfAngle?: number;
  2827. fallOffExponent?: number;
  2828. linearAttenuation?: number;
  2829. quadraticAttenuation?: number;
  2830. }
  2831. /** @hidden */
  2832. export interface IGLTFLight extends IGLTFChildRootProperty {
  2833. type: string;
  2834. }
  2835. /** @hidden */
  2836. export interface IGLTFCameraOrthographic {
  2837. xmag: number;
  2838. ymag: number;
  2839. zfar: number;
  2840. znear: number;
  2841. }
  2842. /** @hidden */
  2843. export interface IGLTFCameraPerspective {
  2844. aspectRatio: number;
  2845. yfov: number;
  2846. zfar: number;
  2847. znear: number;
  2848. }
  2849. /** @hidden */
  2850. export interface IGLTFCamera extends IGLTFChildRootProperty {
  2851. type: string;
  2852. }
  2853. /** @hidden */
  2854. export interface IGLTFAnimationChannelTarget {
  2855. id: string;
  2856. path: string;
  2857. }
  2858. /** @hidden */
  2859. export interface IGLTFAnimationChannel {
  2860. sampler: string;
  2861. target: IGLTFAnimationChannelTarget;
  2862. }
  2863. /** @hidden */
  2864. export interface IGLTFAnimationSampler {
  2865. input: string;
  2866. output: string;
  2867. interpolation?: string;
  2868. }
  2869. /** @hidden */
  2870. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  2871. channels?: IGLTFAnimationChannel[];
  2872. parameters?: {
  2873. [key: string]: string;
  2874. };
  2875. samplers?: {
  2876. [key: string]: IGLTFAnimationSampler;
  2877. };
  2878. }
  2879. /** @hidden */
  2880. export interface IGLTFNodeInstanceSkin {
  2881. skeletons: string[];
  2882. skin: string;
  2883. meshes: string[];
  2884. }
  2885. /** @hidden */
  2886. export interface IGLTFSkins extends IGLTFChildRootProperty {
  2887. bindShapeMatrix: number[];
  2888. inverseBindMatrices: string;
  2889. jointNames: string[];
  2890. babylonSkeleton?: Skeleton;
  2891. }
  2892. /** @hidden */
  2893. export interface IGLTFNode extends IGLTFChildRootProperty {
  2894. camera?: string;
  2895. children: string[];
  2896. skin?: string;
  2897. jointName?: string;
  2898. light?: string;
  2899. matrix: number[];
  2900. mesh?: string;
  2901. meshes?: string[];
  2902. rotation?: number[];
  2903. scale?: number[];
  2904. translation?: number[];
  2905. babylonNode?: Node;
  2906. }
  2907. /** @hidden */
  2908. export interface IGLTFScene extends IGLTFChildRootProperty {
  2909. nodes: string[];
  2910. }
  2911. /** @hidden */
  2912. export interface IGLTFRuntime {
  2913. extensions: {
  2914. [key: string]: any;
  2915. };
  2916. accessors: {
  2917. [key: string]: IGLTFAccessor;
  2918. };
  2919. buffers: {
  2920. [key: string]: IGLTFBuffer;
  2921. };
  2922. bufferViews: {
  2923. [key: string]: IGLTFBufferView;
  2924. };
  2925. meshes: {
  2926. [key: string]: IGLTFMesh;
  2927. };
  2928. lights: {
  2929. [key: string]: IGLTFLight;
  2930. };
  2931. cameras: {
  2932. [key: string]: IGLTFCamera;
  2933. };
  2934. nodes: {
  2935. [key: string]: IGLTFNode;
  2936. };
  2937. images: {
  2938. [key: string]: IGLTFImage;
  2939. };
  2940. textures: {
  2941. [key: string]: IGLTFTexture;
  2942. };
  2943. shaders: {
  2944. [key: string]: IGLTFShader;
  2945. };
  2946. programs: {
  2947. [key: string]: IGLTFProgram;
  2948. };
  2949. samplers: {
  2950. [key: string]: IGLTFSampler;
  2951. };
  2952. techniques: {
  2953. [key: string]: IGLTFTechnique;
  2954. };
  2955. materials: {
  2956. [key: string]: IGLTFMaterial;
  2957. };
  2958. animations: {
  2959. [key: string]: IGLTFAnimation;
  2960. };
  2961. skins: {
  2962. [key: string]: IGLTFSkins;
  2963. };
  2964. currentScene?: Object;
  2965. scenes: {
  2966. [key: string]: IGLTFScene;
  2967. };
  2968. extensionsUsed: string[];
  2969. extensionsRequired?: string[];
  2970. buffersCount: number;
  2971. shaderscount: number;
  2972. scene: Scene;
  2973. rootUrl: string;
  2974. loadedBufferCount: number;
  2975. loadedBufferViews: {
  2976. [name: string]: ArrayBufferView;
  2977. };
  2978. loadedShaderCount: number;
  2979. importOnlyMeshes: boolean;
  2980. importMeshesNames?: string[];
  2981. dummyNodes: Node[];
  2982. }
  2983. /** @hidden */
  2984. export interface INodeToRoot {
  2985. bone: Bone;
  2986. node: IGLTFNode;
  2987. id: string;
  2988. }
  2989. /** @hidden */
  2990. export interface IJointNode {
  2991. node: IGLTFNode;
  2992. id: string;
  2993. }
  2994. }
  2995. declare module BABYLON.GLTF1 {
  2996. /**
  2997. * Utils functions for GLTF
  2998. * @hidden
  2999. */
  3000. export class GLTFUtils {
  3001. /**
  3002. * Sets the given "parameter" matrix
  3003. * @param scene: the Scene object
  3004. * @param source: the source node where to pick the matrix
  3005. * @param parameter: the GLTF technique parameter
  3006. * @param uniformName: the name of the shader's uniform
  3007. * @param shaderMaterial: the shader material
  3008. */
  3009. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  3010. /**
  3011. * Sets the given "parameter" matrix
  3012. * @param shaderMaterial: the shader material
  3013. * @param uniform: the name of the shader's uniform
  3014. * @param value: the value of the uniform
  3015. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3016. */
  3017. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  3018. /**
  3019. * Returns the wrap mode of the texture
  3020. * @param mode: the mode value
  3021. */
  3022. static GetWrapMode(mode: number): number;
  3023. /**
  3024. * Returns the byte stride giving an accessor
  3025. * @param accessor: the GLTF accessor objet
  3026. */
  3027. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  3028. /**
  3029. * Returns the texture filter mode giving a mode value
  3030. * @param mode: the filter mode value
  3031. */
  3032. static GetTextureFilterMode(mode: number): ETextureFilterType;
  3033. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  3034. /**
  3035. * Returns a buffer from its accessor
  3036. * @param gltfRuntime: the GLTF runtime
  3037. * @param accessor: the GLTF accessor
  3038. */
  3039. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  3040. /**
  3041. * Decodes a buffer view into a string
  3042. * @param view: the buffer view
  3043. */
  3044. static DecodeBufferToText(view: ArrayBufferView): string;
  3045. /**
  3046. * Returns the default material of gltf. Related to
  3047. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3048. * @param scene: the Babylon.js scene
  3049. */
  3050. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  3051. private static _DefaultMaterial;
  3052. }
  3053. }
  3054. declare module BABYLON.GLTF1 {
  3055. /**
  3056. * Implementation of the base glTF spec
  3057. * @hidden
  3058. */
  3059. export class GLTFLoaderBase {
  3060. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  3061. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3062. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  3063. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3064. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  3065. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3066. }
  3067. /**
  3068. * glTF V1 Loader
  3069. * @hidden
  3070. */
  3071. export class GLTFLoader implements IGLTFLoader {
  3072. static Extensions: {
  3073. [name: string]: GLTFLoaderExtension;
  3074. };
  3075. static RegisterExtension(extension: GLTFLoaderExtension): void;
  3076. state: Nullable<GLTFLoaderState>;
  3077. dispose(): void;
  3078. private _importMeshAsync;
  3079. /**
  3080. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3081. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3082. * @param scene the scene the meshes should be added to
  3083. * @param data gltf data containing information of the meshes in a loaded file
  3084. * @param rootUrl root url to load from
  3085. * @param onProgress event that fires when loading progress has occured
  3086. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3087. */
  3088. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  3089. meshes: AbstractMesh[];
  3090. particleSystems: IParticleSystem[];
  3091. skeletons: Skeleton[];
  3092. animationGroups: AnimationGroup[];
  3093. }>;
  3094. private _loadAsync;
  3095. /**
  3096. * Imports all objects from a loaded gltf file and adds them to the scene
  3097. * @param scene the scene the objects should be added to
  3098. * @param data gltf data containing information of the meshes in a loaded file
  3099. * @param rootUrl root url to load from
  3100. * @param onProgress event that fires when loading progress has occured
  3101. * @returns a promise which completes when objects have been loaded to the scene
  3102. */
  3103. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  3104. private _loadShadersAsync;
  3105. private _loadBuffersAsync;
  3106. private _createNodes;
  3107. }
  3108. /** @hidden */
  3109. export abstract class GLTFLoaderExtension {
  3110. private _name;
  3111. constructor(name: string);
  3112. readonly name: string;
  3113. /**
  3114. * Defines an override for loading the runtime
  3115. * Return true to stop further extensions from loading the runtime
  3116. */
  3117. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  3118. /**
  3119. * Defines an onverride for creating gltf runtime
  3120. * Return true to stop further extensions from creating the runtime
  3121. */
  3122. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  3123. /**
  3124. * Defines an override for loading buffers
  3125. * Return true to stop further extensions from loading this buffer
  3126. */
  3127. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  3128. /**
  3129. * Defines an override for loading texture buffers
  3130. * Return true to stop further extensions from loading this texture data
  3131. */
  3132. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3133. /**
  3134. * Defines an override for creating textures
  3135. * Return true to stop further extensions from loading this texture
  3136. */
  3137. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  3138. /**
  3139. * Defines an override for loading shader strings
  3140. * Return true to stop further extensions from loading this shader data
  3141. */
  3142. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3143. /**
  3144. * Defines an override for loading materials
  3145. * Return true to stop further extensions from loading this material
  3146. */
  3147. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3148. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  3149. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  3150. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3151. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3152. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  3153. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3154. private static LoadTextureBufferAsync;
  3155. private static CreateTextureAsync;
  3156. private static ApplyExtensions;
  3157. }
  3158. }
  3159. declare module BABYLON.GLTF1 {
  3160. /** @hidden */
  3161. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  3162. private _bin;
  3163. constructor();
  3164. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  3165. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3166. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3167. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3168. }
  3169. }
  3170. declare module BABYLON.GLTF1 {
  3171. /** @hidden */
  3172. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  3173. constructor();
  3174. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  3175. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3176. private _loadTexture;
  3177. }
  3178. }
  3179. declare module BABYLON.GLTF2.Loader {
  3180. /**
  3181. * Loader interface with an index field.
  3182. */
  3183. export interface IArrayItem {
  3184. /**
  3185. * The index of this item in the array.
  3186. */
  3187. index: number;
  3188. }
  3189. /**
  3190. * Loader interface with additional members.
  3191. */
  3192. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3193. /** @hidden */
  3194. _data?: Promise<ArrayBufferView>;
  3195. /** @hidden */
  3196. _babylonVertexBuffer?: Promise<VertexBuffer>;
  3197. }
  3198. /**
  3199. * Loader interface with additional members.
  3200. */
  3201. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3202. }
  3203. /** @hidden */
  3204. export interface _IAnimationSamplerData {
  3205. input: Float32Array;
  3206. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3207. output: Float32Array;
  3208. }
  3209. /**
  3210. * Loader interface with additional members.
  3211. */
  3212. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3213. /** @hidden */
  3214. _data?: Promise<_IAnimationSamplerData>;
  3215. }
  3216. /**
  3217. * Loader interface with additional members.
  3218. */
  3219. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3220. channels: IAnimationChannel[];
  3221. samplers: IAnimationSampler[];
  3222. /** @hidden */
  3223. _babylonAnimationGroup?: AnimationGroup;
  3224. }
  3225. /**
  3226. * Loader interface with additional members.
  3227. */
  3228. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3229. /** @hidden */
  3230. _data?: Promise<ArrayBufferView>;
  3231. }
  3232. /**
  3233. * Loader interface with additional members.
  3234. */
  3235. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3236. /** @hidden */
  3237. _data?: Promise<ArrayBufferView>;
  3238. /** @hidden */
  3239. _babylonBuffer?: Promise<Buffer>;
  3240. }
  3241. /**
  3242. * Loader interface with additional members.
  3243. */
  3244. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3245. }
  3246. /**
  3247. * Loader interface with additional members.
  3248. */
  3249. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3250. /** @hidden */
  3251. _data?: Promise<ArrayBufferView>;
  3252. }
  3253. /**
  3254. * Loader interface with additional members.
  3255. */
  3256. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  3257. }
  3258. /**
  3259. * Loader interface with additional members.
  3260. */
  3261. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  3262. }
  3263. /**
  3264. * Loader interface with additional members.
  3265. */
  3266. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3267. baseColorTexture?: ITextureInfo;
  3268. metallicRoughnessTexture?: ITextureInfo;
  3269. }
  3270. /**
  3271. * Loader interface with additional members.
  3272. */
  3273. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3274. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3275. normalTexture?: IMaterialNormalTextureInfo;
  3276. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3277. emissiveTexture?: ITextureInfo;
  3278. /** @hidden */
  3279. _data?: {
  3280. [babylonDrawMode: number]: {
  3281. babylonMaterial: Material;
  3282. babylonMeshes: AbstractMesh[];
  3283. promise: Promise<void>;
  3284. };
  3285. };
  3286. }
  3287. /**
  3288. * Loader interface with additional members.
  3289. */
  3290. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3291. primitives: IMeshPrimitive[];
  3292. }
  3293. /**
  3294. * Loader interface with additional members.
  3295. */
  3296. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3297. /** @hidden */
  3298. _instanceData?: {
  3299. babylonSourceMesh: Mesh;
  3300. promise: Promise<any>;
  3301. };
  3302. }
  3303. /**
  3304. * Loader interface with additional members.
  3305. */
  3306. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  3307. /**
  3308. * The parent glTF node.
  3309. */
  3310. parent?: INode;
  3311. /** @hidden */
  3312. _babylonTransformNode?: TransformNode;
  3313. /** @hidden */
  3314. _primitiveBabylonMeshes?: AbstractMesh[];
  3315. /** @hidden */
  3316. _babylonBones?: Bone[];
  3317. /** @hidden */
  3318. _numMorphTargets?: number;
  3319. }
  3320. /** @hidden */
  3321. export interface _ISamplerData {
  3322. noMipMaps: boolean;
  3323. samplingMode: number;
  3324. wrapU: number;
  3325. wrapV: number;
  3326. }
  3327. /**
  3328. * Loader interface with additional members.
  3329. */
  3330. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  3331. /** @hidden */
  3332. _data?: _ISamplerData;
  3333. }
  3334. /**
  3335. * Loader interface with additional members.
  3336. */
  3337. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  3338. }
  3339. /**
  3340. * Loader interface with additional members.
  3341. */
  3342. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  3343. /** @hidden */
  3344. _data?: {
  3345. babylonSkeleton: Skeleton;
  3346. promise: Promise<void>;
  3347. };
  3348. }
  3349. /**
  3350. * Loader interface with additional members.
  3351. */
  3352. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  3353. }
  3354. /**
  3355. * Loader interface with additional members.
  3356. */
  3357. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  3358. }
  3359. /**
  3360. * Loader interface with additional members.
  3361. */
  3362. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  3363. accessors?: IAccessor[];
  3364. animations?: IAnimation[];
  3365. buffers?: IBuffer[];
  3366. bufferViews?: IBufferView[];
  3367. cameras?: ICamera[];
  3368. images?: IImage[];
  3369. materials?: IMaterial[];
  3370. meshes?: IMesh[];
  3371. nodes?: INode[];
  3372. samplers?: ISampler[];
  3373. scenes?: IScene[];
  3374. skins?: ISkin[];
  3375. textures?: ITexture[];
  3376. }
  3377. }
  3378. declare module BABYLON.GLTF2 {
  3379. /**
  3380. * Interface for a glTF loader extension.
  3381. */
  3382. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  3383. /**
  3384. * Called after the loader state changes to LOADING.
  3385. */
  3386. onLoading?(): void;
  3387. /**
  3388. * Called after the loader state changes to READY.
  3389. */
  3390. onReady?(): void;
  3391. /**
  3392. * Define this method to modify the default behavior when loading scenes.
  3393. * @param context The context when loading the asset
  3394. * @param scene The glTF scene property
  3395. * @returns A promise that resolves when the load is complete or null if not handled
  3396. */
  3397. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  3398. /**
  3399. * Define this method to modify the default behavior when loading nodes.
  3400. * @param context The context when loading the asset
  3401. * @param node The glTF node property
  3402. * @param assign A function called synchronously after parsing the glTF properties
  3403. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  3404. */
  3405. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3406. /**
  3407. * Define this method to modify the default behavior when loading cameras.
  3408. * @param context The context when loading the asset
  3409. * @param camera The glTF camera property
  3410. * @param assign A function called synchronously after parsing the glTF properties
  3411. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  3412. */
  3413. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  3414. /**
  3415. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  3416. * @param context The context when loading the asset
  3417. * @param primitive The glTF mesh primitive property
  3418. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  3419. */
  3420. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  3421. /**
  3422. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  3423. * @param context The context when loading the asset
  3424. * @param material The glTF material property
  3425. * @param assign A function called synchronously after parsing the glTF properties
  3426. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  3427. */
  3428. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  3429. /**
  3430. * Define this method to modify the default behavior when creating materials.
  3431. * @param context The context when loading the asset
  3432. * @param material The glTF material property
  3433. * @param babylonDrawMode The draw mode for the Babylon material
  3434. * @returns The Babylon material or null if not handled
  3435. */
  3436. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  3437. /**
  3438. * Define this method to modify the default behavior when loading material properties.
  3439. * @param context The context when loading the asset
  3440. * @param material The glTF material property
  3441. * @param babylonMaterial The Babylon material
  3442. * @returns A promise that resolves when the load is complete or null if not handled
  3443. */
  3444. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3445. /**
  3446. * Define this method to modify the default behavior when loading texture infos.
  3447. * @param context The context when loading the asset
  3448. * @param textureInfo The glTF texture info property
  3449. * @param assign A function called synchronously after parsing the glTF properties
  3450. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  3451. */
  3452. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3453. /**
  3454. * Define this method to modify the default behavior when loading animations.
  3455. * @param context The context when loading the asset
  3456. * @param animation The glTF animation property
  3457. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  3458. */
  3459. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  3460. /**
  3461. * Define this method to modify the default behavior when loading uris.
  3462. * @param context The context when loading the asset
  3463. * @param property The glTF property associated with the uri
  3464. * @param uri The uri to load
  3465. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3466. */
  3467. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  3468. }
  3469. }
  3470. declare module BABYLON.GLTF2 {
  3471. /**
  3472. * Helper class for working with arrays when loading the glTF asset
  3473. */
  3474. export class ArrayItem {
  3475. /**
  3476. * Gets an item from the given array.
  3477. * @param context The context when loading the asset
  3478. * @param array The array to get the item from
  3479. * @param index The index to the array
  3480. * @returns The array item
  3481. */
  3482. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  3483. /**
  3484. * Assign an `index` field to each item of the given array.
  3485. * @param array The array of items
  3486. */
  3487. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  3488. }
  3489. /**
  3490. * The glTF 2.0 loader
  3491. */
  3492. export class GLTFLoader implements IGLTFLoader {
  3493. /** @hidden */
  3494. _completePromises: Promise<any>[];
  3495. private _disposed;
  3496. private _parent;
  3497. private _state;
  3498. private _extensions;
  3499. private _rootUrl;
  3500. private _fileName;
  3501. private _uniqueRootUrl;
  3502. private _gltf;
  3503. private _babylonScene;
  3504. private _rootBabylonMesh;
  3505. private _defaultBabylonMaterialData;
  3506. private _progressCallback?;
  3507. private _requests;
  3508. private static readonly _DefaultSampler;
  3509. private static _ExtensionNames;
  3510. private static _ExtensionFactories;
  3511. /**
  3512. * Registers a loader extension.
  3513. * @param name The name of the loader extension.
  3514. * @param factory The factory function that creates the loader extension.
  3515. */
  3516. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  3517. /**
  3518. * Unregisters a loader extension.
  3519. * @param name The name of the loader extenion.
  3520. * @returns A boolean indicating whether the extension has been unregistered
  3521. */
  3522. static UnregisterExtension(name: string): boolean;
  3523. /**
  3524. * Gets the loader state.
  3525. */
  3526. readonly state: Nullable<GLTFLoaderState>;
  3527. /**
  3528. * The glTF object parsed from the JSON.
  3529. */
  3530. readonly gltf: IGLTF;
  3531. /**
  3532. * The Babylon scene when loading the asset.
  3533. */
  3534. readonly babylonScene: Scene;
  3535. /**
  3536. * The root Babylon mesh when loading the asset.
  3537. */
  3538. readonly rootBabylonMesh: Mesh;
  3539. /** @hidden */
  3540. constructor(parent: GLTFFileLoader);
  3541. /** @hidden */
  3542. dispose(): void;
  3543. /** @hidden */
  3544. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  3545. meshes: AbstractMesh[];
  3546. particleSystems: IParticleSystem[];
  3547. skeletons: Skeleton[];
  3548. animationGroups: AnimationGroup[];
  3549. }>;
  3550. /** @hidden */
  3551. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  3552. private _loadAsync;
  3553. private _loadData;
  3554. private _setupData;
  3555. private _loadExtensions;
  3556. private _checkExtensions;
  3557. private _setState;
  3558. private _createRootNode;
  3559. /**
  3560. * Loads a glTF scene.
  3561. * @param context The context when loading the asset
  3562. * @param scene The glTF scene property
  3563. * @returns A promise that resolves when the load is complete
  3564. */
  3565. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  3566. private _forEachPrimitive;
  3567. private _getMeshes;
  3568. private _getSkeletons;
  3569. private _getAnimationGroups;
  3570. private _startAnimations;
  3571. /**
  3572. * Loads a glTF node.
  3573. * @param context The context when loading the asset
  3574. * @param node The glTF node property
  3575. * @param assign A function called synchronously after parsing the glTF properties
  3576. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  3577. */
  3578. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  3579. private _loadMeshAsync;
  3580. private _loadMeshPrimitiveAsync;
  3581. private _loadVertexDataAsync;
  3582. private _createMorphTargets;
  3583. private _loadMorphTargetsAsync;
  3584. private _loadMorphTargetVertexDataAsync;
  3585. private static _LoadTransform;
  3586. private _loadSkinAsync;
  3587. private _loadBones;
  3588. private _loadBone;
  3589. private _loadSkinInverseBindMatricesDataAsync;
  3590. private _updateBoneMatrices;
  3591. private _getNodeMatrix;
  3592. /**
  3593. * Loads a glTF camera.
  3594. * @param context The context when loading the asset
  3595. * @param camera The glTF camera property
  3596. * @param assign A function called synchronously after parsing the glTF properties
  3597. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  3598. */
  3599. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  3600. private _loadAnimationsAsync;
  3601. /**
  3602. * Loads a glTF animation.
  3603. * @param context The context when loading the asset
  3604. * @param animation The glTF animation property
  3605. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  3606. */
  3607. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  3608. private _loadAnimationChannelAsync;
  3609. private _loadAnimationSamplerAsync;
  3610. private _loadBufferAsync;
  3611. /**
  3612. * Loads a glTF buffer view.
  3613. * @param context The context when loading the asset
  3614. * @param bufferView The glTF buffer view property
  3615. * @returns A promise that resolves with the loaded data when the load is complete
  3616. */
  3617. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  3618. private _loadIndicesAccessorAsync;
  3619. private _loadFloatAccessorAsync;
  3620. private _loadVertexBufferViewAsync;
  3621. private _loadVertexAccessorAsync;
  3622. private _loadMaterialMetallicRoughnessPropertiesAsync;
  3623. /** @hidden */
  3624. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  3625. private _createDefaultMaterial;
  3626. /**
  3627. * Creates a Babylon material from a glTF material.
  3628. * @param context The context when loading the asset
  3629. * @param material The glTF material property
  3630. * @param babylonDrawMode The draw mode for the Babylon material
  3631. * @returns The Babylon material
  3632. */
  3633. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  3634. /**
  3635. * Loads properties from a glTF material into a Babylon material.
  3636. * @param context The context when loading the asset
  3637. * @param material The glTF material property
  3638. * @param babylonMaterial The Babylon material
  3639. * @returns A promise that resolves when the load is complete
  3640. */
  3641. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3642. /**
  3643. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  3644. * @param context The context when loading the asset
  3645. * @param material The glTF material property
  3646. * @param babylonMaterial The Babylon material
  3647. * @returns A promise that resolves when the load is complete
  3648. */
  3649. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3650. /**
  3651. * Loads the alpha properties from a glTF material into a Babylon material.
  3652. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  3653. * @param context The context when loading the asset
  3654. * @param material The glTF material property
  3655. * @param babylonMaterial The Babylon material
  3656. */
  3657. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  3658. /**
  3659. * Loads a glTF texture info.
  3660. * @param context The context when loading the asset
  3661. * @param textureInfo The glTF texture info property
  3662. * @param assign A function called synchronously after parsing the glTF properties
  3663. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  3664. */
  3665. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  3666. private _loadTextureAsync;
  3667. private _loadSampler;
  3668. /**
  3669. * Loads a glTF image.
  3670. * @param context The context when loading the asset
  3671. * @param image The glTF image property
  3672. * @returns A promise that resolves with the loaded data when the load is complete
  3673. */
  3674. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  3675. /**
  3676. * Loads a glTF uri.
  3677. * @param context The context when loading the asset
  3678. * @param property The glTF property associated with the uri
  3679. * @param uri The base64 or relative uri
  3680. * @returns A promise that resolves with the loaded data when the load is complete
  3681. */
  3682. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  3683. private _onProgress;
  3684. /**
  3685. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  3686. * @param babylonObject the Babylon object with metadata
  3687. * @param pointer the JSON pointer
  3688. */
  3689. static AddPointerMetadata(babylonObject: {
  3690. metadata: any;
  3691. }, pointer: string): void;
  3692. private static _GetTextureWrapMode;
  3693. private static _GetTextureSamplingMode;
  3694. private static _GetTypedArray;
  3695. private static _GetNumComponents;
  3696. private static _ValidateUri;
  3697. private static _GetDrawMode;
  3698. private _compileMaterialsAsync;
  3699. private _compileShadowGeneratorsAsync;
  3700. private _forEachExtensions;
  3701. private _applyExtensions;
  3702. private _extensionsOnLoading;
  3703. private _extensionsOnReady;
  3704. private _extensionsLoadSceneAsync;
  3705. private _extensionsLoadNodeAsync;
  3706. private _extensionsLoadCameraAsync;
  3707. private _extensionsLoadVertexDataAsync;
  3708. private _extensionsLoadMaterialAsync;
  3709. private _extensionsCreateMaterial;
  3710. private _extensionsLoadMaterialPropertiesAsync;
  3711. private _extensionsLoadTextureInfoAsync;
  3712. private _extensionsLoadAnimationAsync;
  3713. private _extensionsLoadUriAsync;
  3714. /**
  3715. * Helper method called by a loader extension to load an glTF extension.
  3716. * @param context The context when loading the asset
  3717. * @param property The glTF property to load the extension from
  3718. * @param extensionName The name of the extension to load
  3719. * @param actionAsync The action to run
  3720. * @returns The promise returned by actionAsync or null if the extension does not exist
  3721. */
  3722. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  3723. /**
  3724. * Helper method called by a loader extension to load a glTF extra.
  3725. * @param context The context when loading the asset
  3726. * @param property The glTF property to load the extra from
  3727. * @param extensionName The name of the extension to load
  3728. * @param actionAsync The action to run
  3729. * @returns The promise returned by actionAsync or null if the extra does not exist
  3730. */
  3731. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  3732. /**
  3733. * Increments the indentation level and logs a message.
  3734. * @param message The message to log
  3735. */
  3736. logOpen(message: string): void;
  3737. /**
  3738. * Decrements the indentation level.
  3739. */
  3740. logClose(): void;
  3741. /**
  3742. * Logs a message
  3743. * @param message The message to log
  3744. */
  3745. log(message: string): void;
  3746. /**
  3747. * Starts a performance counter.
  3748. * @param counterName The name of the performance counter
  3749. */
  3750. startPerformanceCounter(counterName: string): void;
  3751. /**
  3752. * Ends a performance counter.
  3753. * @param counterName The name of the performance counter
  3754. */
  3755. endPerformanceCounter(counterName: string): void;
  3756. }
  3757. }
  3758. declare module BABYLON.GLTF2.Loader.Extensions {
  3759. /**
  3760. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  3761. */
  3762. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  3763. /** The name of this extension. */
  3764. readonly name: string;
  3765. /** Defines whether this extension is enabled. */
  3766. enabled: boolean;
  3767. private _loader;
  3768. private _lights?;
  3769. /** @hidden */
  3770. constructor(loader: GLTFLoader);
  3771. /** @hidden */
  3772. dispose(): void;
  3773. /** @hidden */
  3774. onLoading(): void;
  3775. /** @hidden */
  3776. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  3777. private _loadLightAsync;
  3778. }
  3779. }
  3780. declare module BABYLON.GLTF2.Loader.Extensions {
  3781. /**
  3782. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  3783. */
  3784. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  3785. /** The name of this extension. */
  3786. readonly name: string;
  3787. /** Defines whether this extension is enabled. */
  3788. enabled: boolean;
  3789. private _loader;
  3790. private _dracoCompression?;
  3791. /** @hidden */
  3792. constructor(loader: GLTFLoader);
  3793. /** @hidden */
  3794. dispose(): void;
  3795. /** @hidden */
  3796. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  3797. }
  3798. }
  3799. declare module BABYLON.GLTF2.Loader.Extensions {
  3800. /**
  3801. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  3802. */
  3803. export class KHR_lights implements IGLTFLoaderExtension {
  3804. /** The name of this extension. */
  3805. readonly name: string;
  3806. /** Defines whether this extension is enabled. */
  3807. enabled: boolean;
  3808. private _loader;
  3809. private _lights?;
  3810. /** @hidden */
  3811. constructor(loader: GLTFLoader);
  3812. /** @hidden */
  3813. dispose(): void;
  3814. /** @hidden */
  3815. onLoading(): void;
  3816. /** @hidden */
  3817. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3818. }
  3819. }
  3820. declare module BABYLON.GLTF2.Loader.Extensions {
  3821. /**
  3822. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  3823. */
  3824. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  3825. /** The name of this extension. */
  3826. readonly name: string;
  3827. /** Defines whether this extension is enabled. */
  3828. enabled: boolean;
  3829. private _loader;
  3830. /** @hidden */
  3831. constructor(loader: GLTFLoader);
  3832. /** @hidden */
  3833. dispose(): void;
  3834. /** @hidden */
  3835. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3836. private _loadSpecularGlossinessPropertiesAsync;
  3837. }
  3838. }
  3839. declare module BABYLON.GLTF2.Loader.Extensions {
  3840. /**
  3841. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  3842. */
  3843. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  3844. /** The name of this extension. */
  3845. readonly name: string;
  3846. /** Defines whether this extension is enabled. */
  3847. enabled: boolean;
  3848. private _loader;
  3849. /** @hidden */
  3850. constructor(loader: GLTFLoader);
  3851. /** @hidden */
  3852. dispose(): void;
  3853. /** @hidden */
  3854. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3855. private _loadUnlitPropertiesAsync;
  3856. }
  3857. }
  3858. declare module BABYLON.GLTF2.Loader.Extensions {
  3859. /**
  3860. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  3861. */
  3862. export class KHR_texture_transform implements IGLTFLoaderExtension {
  3863. /** The name of this extension. */
  3864. readonly name: string;
  3865. /** Defines whether this extension is enabled. */
  3866. enabled: boolean;
  3867. private _loader;
  3868. /** @hidden */
  3869. constructor(loader: GLTFLoader);
  3870. /** @hidden */
  3871. dispose(): void;
  3872. /** @hidden */
  3873. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3874. }
  3875. }
  3876. declare module BABYLON.GLTF2.Loader.Extensions {
  3877. /**
  3878. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  3879. */
  3880. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  3881. /** The name of this extension. */
  3882. readonly name: string;
  3883. /** Defines whether this extension is enabled. */
  3884. enabled: boolean;
  3885. private _loader;
  3886. private _clips;
  3887. private _emitters;
  3888. /** @hidden */
  3889. constructor(loader: GLTFLoader);
  3890. /** @hidden */
  3891. dispose(): void;
  3892. /** @hidden */
  3893. onLoading(): void;
  3894. /** @hidden */
  3895. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  3896. /** @hidden */
  3897. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3898. /** @hidden */
  3899. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  3900. private _loadClipAsync;
  3901. private _loadEmitterAsync;
  3902. private _getEventAction;
  3903. private _loadAnimationEventAsync;
  3904. }
  3905. }
  3906. declare module BABYLON.GLTF2.Loader.Extensions {
  3907. /**
  3908. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  3909. */
  3910. export class MSFT_lod implements IGLTFLoaderExtension {
  3911. /** The name of this extension. */
  3912. readonly name: string;
  3913. /** Defines whether this extension is enabled. */
  3914. enabled: boolean;
  3915. /**
  3916. * Maximum number of LODs to load, starting from the lowest LOD.
  3917. */
  3918. maxLODsToLoad: number;
  3919. /**
  3920. * Observable raised when all node LODs of one level are loaded.
  3921. * The event data is the index of the loaded LOD starting from zero.
  3922. * Dispose the loader to cancel the loading of the next level of LODs.
  3923. */
  3924. onNodeLODsLoadedObservable: Observable<number>;
  3925. /**
  3926. * Observable raised when all material LODs of one level are loaded.
  3927. * The event data is the index of the loaded LOD starting from zero.
  3928. * Dispose the loader to cancel the loading of the next level of LODs.
  3929. */
  3930. onMaterialLODsLoadedObservable: Observable<number>;
  3931. private _loader;
  3932. private _nodeIndexLOD;
  3933. private _nodeSignalLODs;
  3934. private _nodePromiseLODs;
  3935. private _materialIndexLOD;
  3936. private _materialSignalLODs;
  3937. private _materialPromiseLODs;
  3938. /** @hidden */
  3939. constructor(loader: GLTFLoader);
  3940. /** @hidden */
  3941. dispose(): void;
  3942. /** @hidden */
  3943. onReady(): void;
  3944. /** @hidden */
  3945. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3946. /** @hidden */
  3947. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  3948. /** @hidden */
  3949. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  3950. /**
  3951. * Gets an array of LOD properties from lowest to highest.
  3952. */
  3953. private _getLODs;
  3954. private _disposeUnusedMaterials;
  3955. }
  3956. }
  3957. declare module BABYLON.GLTF2.Loader.Extensions {
  3958. /** @hidden */
  3959. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  3960. readonly name: string;
  3961. enabled: boolean;
  3962. private _loader;
  3963. constructor(loader: GLTFLoader);
  3964. dispose(): void;
  3965. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3966. }
  3967. }
  3968. declare module BABYLON.GLTF2.Loader.Extensions {
  3969. /** @hidden */
  3970. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  3971. readonly name: string;
  3972. enabled: boolean;
  3973. private _loader;
  3974. constructor(loader: GLTFLoader);
  3975. dispose(): void;
  3976. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3977. }
  3978. }
  3979. declare module BABYLON {
  3980. /**
  3981. * Class reading and parsing the MTL file bundled with the obj file.
  3982. */
  3983. export class MTLFileLoader {
  3984. /**
  3985. * All material loaded from the mtl will be set here
  3986. */
  3987. materials: StandardMaterial[];
  3988. /**
  3989. * This function will read the mtl file and create each material described inside
  3990. * This function could be improve by adding :
  3991. * -some component missing (Ni, Tf...)
  3992. * -including the specific options available
  3993. *
  3994. * @param scene defines the scene the material will be created in
  3995. * @param data defines the mtl data to parse
  3996. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  3997. */
  3998. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  3999. /**
  4000. * Gets the texture for the material.
  4001. *
  4002. * If the material is imported from input file,
  4003. * We sanitize the url to ensure it takes the textre from aside the material.
  4004. *
  4005. * @param rootUrl The root url to load from
  4006. * @param value The value stored in the mtl
  4007. * @return The Texture
  4008. */
  4009. private static _getTexture;
  4010. }
  4011. /**
  4012. * Options for loading OBJ/MTL files
  4013. */
  4014. type MeshLoadOptions = {
  4015. /**
  4016. * Defines if UVs are optimized by default during load.
  4017. */
  4018. OptimizeWithUV: boolean;
  4019. /**
  4020. * Invert model on y-axis (does a model scaling inversion)
  4021. */
  4022. InvertY: boolean;
  4023. /**
  4024. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4025. */
  4026. ImportVertexColors: boolean;
  4027. /**
  4028. * Compute the normals for the model, even if normals are present in the file.
  4029. */
  4030. ComputeNormals: boolean;
  4031. /**
  4032. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4033. */
  4034. SkipMaterials: boolean;
  4035. /**
  4036. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4037. */
  4038. MaterialLoadingFailsSilently: boolean;
  4039. };
  4040. /**
  4041. * OBJ file type loader.
  4042. * This is a babylon scene loader plugin.
  4043. */
  4044. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  4045. /**
  4046. * Defines if UVs are optimized by default during load.
  4047. */
  4048. static OPTIMIZE_WITH_UV: boolean;
  4049. /**
  4050. * Invert model on y-axis (does a model scaling inversion)
  4051. */
  4052. static INVERT_Y: boolean;
  4053. /**
  4054. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4055. */
  4056. static IMPORT_VERTEX_COLORS: boolean;
  4057. /**
  4058. * Compute the normals for the model, even if normals are present in the file.
  4059. */
  4060. static COMPUTE_NORMALS: boolean;
  4061. /**
  4062. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4063. */
  4064. static SKIP_MATERIALS: boolean;
  4065. /**
  4066. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4067. *
  4068. * Defaults to true for backwards compatibility.
  4069. */
  4070. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  4071. /**
  4072. * Defines the name of the plugin.
  4073. */
  4074. name: string;
  4075. /**
  4076. * Defines the extension the plugin is able to load.
  4077. */
  4078. extensions: string;
  4079. /** @hidden */
  4080. obj: RegExp;
  4081. /** @hidden */
  4082. group: RegExp;
  4083. /** @hidden */
  4084. mtllib: RegExp;
  4085. /** @hidden */
  4086. usemtl: RegExp;
  4087. /** @hidden */
  4088. smooth: RegExp;
  4089. /** @hidden */
  4090. vertexPattern: RegExp;
  4091. /** @hidden */
  4092. normalPattern: RegExp;
  4093. /** @hidden */
  4094. uvPattern: RegExp;
  4095. /** @hidden */
  4096. facePattern1: RegExp;
  4097. /** @hidden */
  4098. facePattern2: RegExp;
  4099. /** @hidden */
  4100. facePattern3: RegExp;
  4101. /** @hidden */
  4102. facePattern4: RegExp;
  4103. /** @hidden */
  4104. facePattern5: RegExp;
  4105. private _meshLoadOptions;
  4106. /**
  4107. * Creates loader for .OBJ files
  4108. *
  4109. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  4110. */
  4111. constructor(meshLoadOptions?: MeshLoadOptions);
  4112. private static readonly currentMeshLoadOptions;
  4113. /**
  4114. * Calls synchronously the MTL file attached to this obj.
  4115. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  4116. * Without this function materials are not displayed in the first frame (but displayed after).
  4117. * In consequence it is impossible to get material information in your HTML file
  4118. *
  4119. * @param url The URL of the MTL file
  4120. * @param rootUrl
  4121. * @param onSuccess Callback function to be called when the MTL file is loaded
  4122. * @private
  4123. */
  4124. private _loadMTL;
  4125. /**
  4126. * Instantiates a OBJ file loader plugin.
  4127. * @returns the created plugin
  4128. */
  4129. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  4130. /**
  4131. * If the data string can be loaded directly.
  4132. *
  4133. * @param data string containing the file data
  4134. * @returns if the data can be loaded directly
  4135. */
  4136. canDirectLoad(data: string): boolean;
  4137. /**
  4138. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  4139. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  4140. * @param scene the scene the meshes should be added to
  4141. * @param data the OBJ data to load
  4142. * @param rootUrl root url to load from
  4143. * @param onProgress event that fires when loading progress has occured
  4144. * @param fileName Defines the name of the file to load
  4145. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  4146. */
  4147. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  4148. meshes: AbstractMesh[];
  4149. particleSystems: IParticleSystem[];
  4150. skeletons: Skeleton[];
  4151. animationGroups: AnimationGroup[];
  4152. }>;
  4153. /**
  4154. * Imports all objects from the loaded OBJ data and adds them to the scene
  4155. * @param scene the scene the objects should be added to
  4156. * @param data the OBJ data to load
  4157. * @param rootUrl root url to load from
  4158. * @param onProgress event that fires when loading progress has occured
  4159. * @param fileName Defines the name of the file to load
  4160. * @returns a promise which completes when objects have been loaded to the scene
  4161. */
  4162. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4163. /**
  4164. * Load into an asset container.
  4165. * @param scene The scene to load into
  4166. * @param data The data to import
  4167. * @param rootUrl The root url for scene and resources
  4168. * @param onProgress The callback when the load progresses
  4169. * @param fileName Defines the name of the file to load
  4170. * @returns The loaded asset container
  4171. */
  4172. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  4173. /**
  4174. * Read the OBJ file and create an Array of meshes.
  4175. * Each mesh contains all information given by the OBJ and the MTL file.
  4176. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  4177. *
  4178. * @param meshesNames
  4179. * @param scene Scene The scene where are displayed the data
  4180. * @param data String The content of the obj file
  4181. * @param rootUrl String The path to the folder
  4182. * @returns Array<AbstractMesh>
  4183. * @private
  4184. */
  4185. private _parseSolid;
  4186. }
  4187. }
  4188. declare module BABYLON {
  4189. /**
  4190. * STL file type loader.
  4191. * This is a babylon scene loader plugin.
  4192. */
  4193. export class STLFileLoader implements ISceneLoaderPlugin {
  4194. /** @hidden */
  4195. solidPattern: RegExp;
  4196. /** @hidden */
  4197. facetsPattern: RegExp;
  4198. /** @hidden */
  4199. normalPattern: RegExp;
  4200. /** @hidden */
  4201. vertexPattern: RegExp;
  4202. /**
  4203. * Defines the name of the plugin.
  4204. */
  4205. name: string;
  4206. /**
  4207. * Defines the extensions the stl loader is able to load.
  4208. * force data to come in as an ArrayBuffer
  4209. * we'll convert to string if it looks like it's an ASCII .stl
  4210. */
  4211. extensions: ISceneLoaderPluginExtensions;
  4212. /**
  4213. * Import meshes into a scene.
  4214. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  4215. * @param scene The scene to import into
  4216. * @param data The data to import
  4217. * @param rootUrl The root url for scene and resources
  4218. * @param meshes The meshes array to import into
  4219. * @param particleSystems The particle systems array to import into
  4220. * @param skeletons The skeletons array to import into
  4221. * @param onError The callback when import fails
  4222. * @returns True if successful or false otherwise
  4223. */
  4224. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  4225. /**
  4226. * Load into a scene.
  4227. * @param scene The scene to load into
  4228. * @param data The data to import
  4229. * @param rootUrl The root url for scene and resources
  4230. * @param onError The callback when import fails
  4231. * @returns true if successful or false otherwise
  4232. */
  4233. load(scene: Scene, data: any, rootUrl: string): boolean;
  4234. /**
  4235. * Load into an asset container.
  4236. * @param scene The scene to load into
  4237. * @param data The data to import
  4238. * @param rootUrl The root url for scene and resources
  4239. * @param onError The callback when import fails
  4240. * @returns The loaded asset container
  4241. */
  4242. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  4243. private _isBinary;
  4244. private _parseBinary;
  4245. private _parseASCII;
  4246. }
  4247. }