babylonjs.loaders.module.d.ts 177 KB

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