babylonjs.loaders.module.d.ts 199 KB

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