babylonjs.loaders.module.d.ts 199 KB

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