babylonWebGPU.d.txt 3.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  160. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Checks if the navigator object exists
  282. * @returns true if the navigator object exists
  283. */
  284. static IsNavigatorAvailable(): boolean;
  285. /**
  286. * Extracts text content from a DOM element hierarchy
  287. * @param element defines the root element
  288. * @returns a string
  289. */
  290. static GetDOMTextContent(element: HTMLElement): string;
  291. }
  292. }
  293. declare module BABYLON {
  294. /**
  295. * Logger used througouht the application to allow configuration of
  296. * the log level required for the messages.
  297. */
  298. export class Logger {
  299. /**
  300. * No log
  301. */
  302. static readonly NoneLogLevel: number;
  303. /**
  304. * Only message logs
  305. */
  306. static readonly MessageLogLevel: number;
  307. /**
  308. * Only warning logs
  309. */
  310. static readonly WarningLogLevel: number;
  311. /**
  312. * Only error logs
  313. */
  314. static readonly ErrorLogLevel: number;
  315. /**
  316. * All logs
  317. */
  318. static readonly AllLogLevel: number;
  319. private static _LogCache;
  320. /**
  321. * Gets a value indicating the number of loading errors
  322. * @ignorenaming
  323. */
  324. static errorsCount: number;
  325. /**
  326. * Callback called when a new log is added
  327. */
  328. static OnNewCacheEntry: (entry: string) => void;
  329. private static _AddLogEntry;
  330. private static _FormatMessage;
  331. private static _LogDisabled;
  332. private static _LogEnabled;
  333. private static _WarnDisabled;
  334. private static _WarnEnabled;
  335. private static _ErrorDisabled;
  336. private static _ErrorEnabled;
  337. /**
  338. * Log a message to the console
  339. */
  340. static Log: (message: string) => void;
  341. /**
  342. * Write a warning message to the console
  343. */
  344. static Warn: (message: string) => void;
  345. /**
  346. * Write an error message to the console
  347. */
  348. static Error: (message: string) => void;
  349. /**
  350. * Gets current log cache (list of logs)
  351. */
  352. static readonly LogCache: string;
  353. /**
  354. * Clears the log cache
  355. */
  356. static ClearLogCache(): void;
  357. /**
  358. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  359. */
  360. static LogLevels: number;
  361. }
  362. }
  363. declare module BABYLON {
  364. /** @hidden */
  365. export class _TypeStore {
  366. /** @hidden */
  367. static RegisteredTypes: {
  368. [key: string]: Object;
  369. };
  370. /** @hidden */
  371. static GetClass(fqdn: string): any;
  372. }
  373. }
  374. declare module BABYLON {
  375. /**
  376. * Class containing a set of static utilities functions for deep copy.
  377. */
  378. export class DeepCopier {
  379. /**
  380. * Tries to copy an object by duplicating every property
  381. * @param source defines the source object
  382. * @param destination defines the target object
  383. * @param doNotCopyList defines a list of properties to avoid
  384. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  385. */
  386. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  387. }
  388. }
  389. declare module BABYLON {
  390. /**
  391. * Class containing a set of static utilities functions for precision date
  392. */
  393. export class PrecisionDate {
  394. /**
  395. * Gets either window.performance.now() if supported or Date.now() else
  396. */
  397. static readonly Now: number;
  398. }
  399. }
  400. declare module BABYLON {
  401. /** @hidden */
  402. export class _DevTools {
  403. static WarnImport(name: string): string;
  404. }
  405. }
  406. declare module BABYLON {
  407. /**
  408. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  409. */
  410. export class WebRequest {
  411. private _xhr;
  412. /**
  413. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  414. * i.e. when loading files, where the server/service expects an Authorization header
  415. */
  416. static CustomRequestHeaders: {
  417. [key: string]: string;
  418. };
  419. /**
  420. * Add callback functions in this array to update all the requests before they get sent to the network
  421. */
  422. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  423. private _injectCustomRequestHeaders;
  424. /**
  425. * Gets or sets a function to be called when loading progress changes
  426. */
  427. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  428. /**
  429. * Returns client's state
  430. */
  431. readonly readyState: number;
  432. /**
  433. * Returns client's status
  434. */
  435. readonly status: number;
  436. /**
  437. * Returns client's status as a text
  438. */
  439. readonly statusText: string;
  440. /**
  441. * Returns client's response
  442. */
  443. readonly response: any;
  444. /**
  445. * Returns client's response url
  446. */
  447. readonly responseURL: string;
  448. /**
  449. * Returns client's response as text
  450. */
  451. readonly responseText: string;
  452. /**
  453. * Gets or sets the expected response type
  454. */
  455. responseType: XMLHttpRequestResponseType;
  456. /** @hidden */
  457. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  458. /** @hidden */
  459. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  460. /**
  461. * Cancels any network activity
  462. */
  463. abort(): void;
  464. /**
  465. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  466. * @param body defines an optional request body
  467. */
  468. send(body?: Document | BodyInit | null): void;
  469. /**
  470. * Sets the request method, request URL
  471. * @param method defines the method to use (GET, POST, etc..)
  472. * @param url defines the url to connect with
  473. */
  474. open(method: string, url: string): void;
  475. }
  476. }
  477. declare module BABYLON {
  478. /**
  479. * File request interface
  480. */
  481. export interface IFileRequest {
  482. /**
  483. * Raised when the request is complete (success or error).
  484. */
  485. onCompleteObservable: Observable<IFileRequest>;
  486. /**
  487. * Aborts the request for a file.
  488. */
  489. abort: () => void;
  490. }
  491. }
  492. declare module BABYLON {
  493. /**
  494. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  495. */
  496. export class PerformanceMonitor {
  497. private _enabled;
  498. private _rollingFrameTime;
  499. private _lastFrameTimeMs;
  500. /**
  501. * constructor
  502. * @param frameSampleSize The number of samples required to saturate the sliding window
  503. */
  504. constructor(frameSampleSize?: number);
  505. /**
  506. * Samples current frame
  507. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  508. */
  509. sampleFrame(timeMs?: number): void;
  510. /**
  511. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  512. */
  513. readonly averageFrameTime: number;
  514. /**
  515. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  516. */
  517. readonly averageFrameTimeVariance: number;
  518. /**
  519. * Returns the frame time of the most recent frame
  520. */
  521. readonly instantaneousFrameTime: number;
  522. /**
  523. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  524. */
  525. readonly averageFPS: number;
  526. /**
  527. * Returns the average framerate in frames per second using the most recent frame time
  528. */
  529. readonly instantaneousFPS: number;
  530. /**
  531. * Returns true if enough samples have been taken to completely fill the sliding window
  532. */
  533. readonly isSaturated: boolean;
  534. /**
  535. * Enables contributions to the sliding window sample set
  536. */
  537. enable(): void;
  538. /**
  539. * Disables contributions to the sliding window sample set
  540. * Samples will not be interpolated over the disabled period
  541. */
  542. disable(): void;
  543. /**
  544. * Returns true if sampling is enabled
  545. */
  546. readonly isEnabled: boolean;
  547. /**
  548. * Resets performance monitor
  549. */
  550. reset(): void;
  551. }
  552. /**
  553. * RollingAverage
  554. *
  555. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  556. */
  557. export class RollingAverage {
  558. /**
  559. * Current average
  560. */
  561. average: number;
  562. /**
  563. * Current variance
  564. */
  565. variance: number;
  566. protected _samples: Array<number>;
  567. protected _sampleCount: number;
  568. protected _pos: number;
  569. protected _m2: number;
  570. /**
  571. * constructor
  572. * @param length The number of samples required to saturate the sliding window
  573. */
  574. constructor(length: number);
  575. /**
  576. * Adds a sample to the sample set
  577. * @param v The sample value
  578. */
  579. add(v: number): void;
  580. /**
  581. * Returns previously added values or null if outside of history or outside the sliding window domain
  582. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  583. * @return Value previously recorded with add() or null if outside of range
  584. */
  585. history(i: number): number;
  586. /**
  587. * Returns true if enough samples have been taken to completely fill the sliding window
  588. * @return true if sample-set saturated
  589. */
  590. isSaturated(): boolean;
  591. /**
  592. * Resets the rolling average (equivalent to 0 samples taken so far)
  593. */
  594. reset(): void;
  595. /**
  596. * Wraps a value around the sample range boundaries
  597. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  598. * @return Wrapped position in sample range
  599. */
  600. protected _wrapPosition(i: number): number;
  601. }
  602. }
  603. declare module BABYLON {
  604. /**
  605. * This class implement a typical dictionary using a string as key and the generic type T as value.
  606. * The underlying implementation relies on an associative array to ensure the best performances.
  607. * The value can be anything including 'null' but except 'undefined'
  608. */
  609. export class StringDictionary<T> {
  610. /**
  611. * This will clear this dictionary and copy the content from the 'source' one.
  612. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  613. * @param source the dictionary to take the content from and copy to this dictionary
  614. */
  615. copyFrom(source: StringDictionary<T>): void;
  616. /**
  617. * Get a value based from its key
  618. * @param key the given key to get the matching value from
  619. * @return the value if found, otherwise undefined is returned
  620. */
  621. get(key: string): T | undefined;
  622. /**
  623. * Get a value from its key or add it if it doesn't exist.
  624. * This method will ensure you that a given key/data will be present in the dictionary.
  625. * @param key the given key to get the matching value from
  626. * @param factory the factory that will create the value if the key is not present in the dictionary.
  627. * The factory will only be invoked if there's no data for the given key.
  628. * @return the value corresponding to the key.
  629. */
  630. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  631. /**
  632. * Get a value from its key if present in the dictionary otherwise add it
  633. * @param key the key to get the value from
  634. * @param val if there's no such key/value pair in the dictionary add it with this value
  635. * @return the value corresponding to the key
  636. */
  637. getOrAdd(key: string, val: T): T;
  638. /**
  639. * Check if there's a given key in the dictionary
  640. * @param key the key to check for
  641. * @return true if the key is present, false otherwise
  642. */
  643. contains(key: string): boolean;
  644. /**
  645. * Add a new key and its corresponding value
  646. * @param key the key to add
  647. * @param value the value corresponding to the key
  648. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  649. */
  650. add(key: string, value: T): boolean;
  651. /**
  652. * Update a specific value associated to a key
  653. * @param key defines the key to use
  654. * @param value defines the value to store
  655. * @returns true if the value was updated (or false if the key was not found)
  656. */
  657. set(key: string, value: T): boolean;
  658. /**
  659. * Get the element of the given key and remove it from the dictionary
  660. * @param key defines the key to search
  661. * @returns the value associated with the key or null if not found
  662. */
  663. getAndRemove(key: string): Nullable<T>;
  664. /**
  665. * Remove a key/value from the dictionary.
  666. * @param key the key to remove
  667. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  668. */
  669. remove(key: string): boolean;
  670. /**
  671. * Clear the whole content of the dictionary
  672. */
  673. clear(): void;
  674. /**
  675. * Gets the current count
  676. */
  677. readonly count: number;
  678. /**
  679. * Execute a callback on each key/val of the dictionary.
  680. * Note that you can remove any element in this dictionary in the callback implementation
  681. * @param callback the callback to execute on a given key/value pair
  682. */
  683. forEach(callback: (key: string, val: T) => void): void;
  684. /**
  685. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  686. * If the callback returns null or undefined the method will iterate to the next key/value pair
  687. * Note that you can remove any element in this dictionary in the callback implementation
  688. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  689. * @returns the first item
  690. */
  691. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  692. private _count;
  693. private _data;
  694. }
  695. }
  696. declare module BABYLON {
  697. /**
  698. * Class used to store gfx data (like WebGLBuffer)
  699. */
  700. export class DataBuffer {
  701. /**
  702. * Gets or sets the number of objects referencing this buffer
  703. */
  704. references: number;
  705. /** Gets or sets the size of the underlying buffer */
  706. capacity: number;
  707. /**
  708. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  709. */
  710. is32Bits: boolean;
  711. /**
  712. * Gets the underlying buffer
  713. */
  714. readonly underlyingResource: any;
  715. }
  716. }
  717. declare module BABYLON {
  718. /**
  719. * Class used to store data that will be store in GPU memory
  720. */
  721. export class Buffer {
  722. private _engine;
  723. private _buffer;
  724. /** @hidden */ private _data: Nullable<DataArray>;
  725. private _updatable;
  726. private _instanced;
  727. /**
  728. * Gets the byte stride.
  729. */
  730. readonly byteStride: number;
  731. /**
  732. * Constructor
  733. * @param engine the engine
  734. * @param data the data to use for this buffer
  735. * @param updatable whether the data is updatable
  736. * @param stride the stride (optional)
  737. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  738. * @param instanced whether the buffer is instanced (optional)
  739. * @param useBytes set to true if the stride in in bytes (optional)
  740. */
  741. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  742. /**
  743. * Create a new VertexBuffer based on the current buffer
  744. * @param kind defines the vertex buffer kind (position, normal, etc.)
  745. * @param offset defines offset in the buffer (0 by default)
  746. * @param size defines the size in floats of attributes (position is 3 for instance)
  747. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  748. * @param instanced defines if the vertex buffer contains indexed data
  749. * @param useBytes defines if the offset and stride are in bytes
  750. * @returns the new vertex buffer
  751. */
  752. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  753. /**
  754. * Gets a boolean indicating if the Buffer is updatable?
  755. * @returns true if the buffer is updatable
  756. */
  757. isUpdatable(): boolean;
  758. /**
  759. * Gets current buffer's data
  760. * @returns a DataArray or null
  761. */
  762. getData(): Nullable<DataArray>;
  763. /**
  764. * Gets underlying native buffer
  765. * @returns underlying native buffer
  766. */
  767. getBuffer(): Nullable<DataBuffer>;
  768. /**
  769. * Gets the stride in float32 units (i.e. byte stride / 4).
  770. * May not be an integer if the byte stride is not divisible by 4.
  771. * DEPRECATED. Use byteStride instead.
  772. * @returns the stride in float32 units
  773. */
  774. getStrideSize(): number;
  775. /**
  776. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  777. * @param data defines the data to store
  778. */
  779. create(data?: Nullable<DataArray>): void;
  780. /** @hidden */ private _rebuild(): void;
  781. /**
  782. * Update current buffer data
  783. * @param data defines the data to store
  784. */
  785. update(data: DataArray): void;
  786. /**
  787. * Updates the data directly.
  788. * @param data the new data
  789. * @param offset the new offset
  790. * @param vertexCount the vertex count (optional)
  791. * @param useBytes set to true if the offset is in bytes
  792. */
  793. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  794. /**
  795. * Release all resources
  796. */
  797. dispose(): void;
  798. }
  799. /**
  800. * Specialized buffer used to store vertex data
  801. */
  802. export class VertexBuffer {
  803. /** @hidden */ private _buffer: Buffer;
  804. private _kind;
  805. private _size;
  806. private _ownsBuffer;
  807. private _instanced;
  808. private _instanceDivisor;
  809. /**
  810. * The byte type.
  811. */
  812. static readonly BYTE: number;
  813. /**
  814. * The unsigned byte type.
  815. */
  816. static readonly UNSIGNED_BYTE: number;
  817. /**
  818. * The short type.
  819. */
  820. static readonly SHORT: number;
  821. /**
  822. * The unsigned short type.
  823. */
  824. static readonly UNSIGNED_SHORT: number;
  825. /**
  826. * The integer type.
  827. */
  828. static readonly INT: number;
  829. /**
  830. * The unsigned integer type.
  831. */
  832. static readonly UNSIGNED_INT: number;
  833. /**
  834. * The float type.
  835. */
  836. static readonly FLOAT: number;
  837. /**
  838. * Gets or sets the instance divisor when in instanced mode
  839. */
  840. instanceDivisor: number;
  841. /**
  842. * Gets the byte stride.
  843. */
  844. readonly byteStride: number;
  845. /**
  846. * Gets the byte offset.
  847. */
  848. readonly byteOffset: number;
  849. /**
  850. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  851. */
  852. readonly normalized: boolean;
  853. /**
  854. * Gets the data type of each component in the array.
  855. */
  856. readonly type: number;
  857. /**
  858. * Constructor
  859. * @param engine the engine
  860. * @param data the data to use for this vertex buffer
  861. * @param kind the vertex buffer kind
  862. * @param updatable whether the data is updatable
  863. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  864. * @param stride the stride (optional)
  865. * @param instanced whether the buffer is instanced (optional)
  866. * @param offset the offset of the data (optional)
  867. * @param size the number of components (optional)
  868. * @param type the type of the component (optional)
  869. * @param normalized whether the data contains normalized data (optional)
  870. * @param useBytes set to true if stride and offset are in bytes (optional)
  871. */
  872. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  873. /** @hidden */ private _rebuild(): void;
  874. /**
  875. * Returns the kind of the VertexBuffer (string)
  876. * @returns a string
  877. */
  878. getKind(): string;
  879. /**
  880. * Gets a boolean indicating if the VertexBuffer is updatable?
  881. * @returns true if the buffer is updatable
  882. */
  883. isUpdatable(): boolean;
  884. /**
  885. * Gets current buffer's data
  886. * @returns a DataArray or null
  887. */
  888. getData(): Nullable<DataArray>;
  889. /**
  890. * Gets underlying native buffer
  891. * @returns underlying native buffer
  892. */
  893. getBuffer(): Nullable<DataBuffer>;
  894. /**
  895. * Gets the stride in float32 units (i.e. byte stride / 4).
  896. * May not be an integer if the byte stride is not divisible by 4.
  897. * DEPRECATED. Use byteStride instead.
  898. * @returns the stride in float32 units
  899. */
  900. getStrideSize(): number;
  901. /**
  902. * Returns the offset as a multiple of the type byte length.
  903. * DEPRECATED. Use byteOffset instead.
  904. * @returns the offset in bytes
  905. */
  906. getOffset(): number;
  907. /**
  908. * Returns the number of components per vertex attribute (integer)
  909. * @returns the size in float
  910. */
  911. getSize(): number;
  912. /**
  913. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  914. * @returns true if this buffer is instanced
  915. */
  916. getIsInstanced(): boolean;
  917. /**
  918. * Returns the instancing divisor, zero for non-instanced (integer).
  919. * @returns a number
  920. */
  921. getInstanceDivisor(): number;
  922. /**
  923. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  924. * @param data defines the data to store
  925. */
  926. create(data?: DataArray): void;
  927. /**
  928. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  929. * This function will create a new buffer if the current one is not updatable
  930. * @param data defines the data to store
  931. */
  932. update(data: DataArray): void;
  933. /**
  934. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  935. * Returns the directly updated WebGLBuffer.
  936. * @param data the new data
  937. * @param offset the new offset
  938. * @param useBytes set to true if the offset is in bytes
  939. */
  940. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  941. /**
  942. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  943. */
  944. dispose(): void;
  945. /**
  946. * Enumerates each value of this vertex buffer as numbers.
  947. * @param count the number of values to enumerate
  948. * @param callback the callback function called for each value
  949. */
  950. forEach(count: number, callback: (value: number, index: number) => void): void;
  951. /**
  952. * Positions
  953. */
  954. static readonly PositionKind: string;
  955. /**
  956. * Normals
  957. */
  958. static readonly NormalKind: string;
  959. /**
  960. * Tangents
  961. */
  962. static readonly TangentKind: string;
  963. /**
  964. * Texture coordinates
  965. */
  966. static readonly UVKind: string;
  967. /**
  968. * Texture coordinates 2
  969. */
  970. static readonly UV2Kind: string;
  971. /**
  972. * Texture coordinates 3
  973. */
  974. static readonly UV3Kind: string;
  975. /**
  976. * Texture coordinates 4
  977. */
  978. static readonly UV4Kind: string;
  979. /**
  980. * Texture coordinates 5
  981. */
  982. static readonly UV5Kind: string;
  983. /**
  984. * Texture coordinates 6
  985. */
  986. static readonly UV6Kind: string;
  987. /**
  988. * Colors
  989. */
  990. static readonly ColorKind: string;
  991. /**
  992. * Matrix indices (for bones)
  993. */
  994. static readonly MatricesIndicesKind: string;
  995. /**
  996. * Matrix weights (for bones)
  997. */
  998. static readonly MatricesWeightsKind: string;
  999. /**
  1000. * Additional matrix indices (for bones)
  1001. */
  1002. static readonly MatricesIndicesExtraKind: string;
  1003. /**
  1004. * Additional matrix weights (for bones)
  1005. */
  1006. static readonly MatricesWeightsExtraKind: string;
  1007. /**
  1008. * Deduces the stride given a kind.
  1009. * @param kind The kind string to deduce
  1010. * @returns The deduced stride
  1011. */
  1012. static DeduceStride(kind: string): number;
  1013. /**
  1014. * Gets the byte length of the given type.
  1015. * @param type the type
  1016. * @returns the number of bytes
  1017. */
  1018. static GetTypeByteLength(type: number): number;
  1019. /**
  1020. * Enumerates each value of the given parameters as numbers.
  1021. * @param data the data to enumerate
  1022. * @param byteOffset the byte offset of the data
  1023. * @param byteStride the byte stride of the data
  1024. * @param componentCount the number of components per element
  1025. * @param componentType the type of the component
  1026. * @param count the number of values to enumerate
  1027. * @param normalized whether the data is normalized
  1028. * @param callback the callback function called for each value
  1029. */
  1030. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1031. private static _GetFloatValue;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * Scalar computation library
  1037. */
  1038. export class Scalar {
  1039. /**
  1040. * Two pi constants convenient for computation.
  1041. */
  1042. static TwoPi: number;
  1043. /**
  1044. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1045. * @param a number
  1046. * @param b number
  1047. * @param epsilon (default = 1.401298E-45)
  1048. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1049. */
  1050. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1051. /**
  1052. * Returns a string : the upper case translation of the number i to hexadecimal.
  1053. * @param i number
  1054. * @returns the upper case translation of the number i to hexadecimal.
  1055. */
  1056. static ToHex(i: number): string;
  1057. /**
  1058. * Returns -1 if value is negative and +1 is value is positive.
  1059. * @param value the value
  1060. * @returns the value itself if it's equal to zero.
  1061. */
  1062. static Sign(value: number): number;
  1063. /**
  1064. * Returns the value itself if it's between min and max.
  1065. * Returns min if the value is lower than min.
  1066. * Returns max if the value is greater than max.
  1067. * @param value the value to clmap
  1068. * @param min the min value to clamp to (default: 0)
  1069. * @param max the max value to clamp to (default: 1)
  1070. * @returns the clamped value
  1071. */
  1072. static Clamp(value: number, min?: number, max?: number): number;
  1073. /**
  1074. * the log2 of value.
  1075. * @param value the value to compute log2 of
  1076. * @returns the log2 of value.
  1077. */
  1078. static Log2(value: number): number;
  1079. /**
  1080. * Loops the value, so that it is never larger than length and never smaller than 0.
  1081. *
  1082. * This is similar to the modulo operator but it works with floating point numbers.
  1083. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1084. * With t = 5 and length = 2.5, the result would be 0.0.
  1085. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1086. * @param value the value
  1087. * @param length the length
  1088. * @returns the looped value
  1089. */
  1090. static Repeat(value: number, length: number): number;
  1091. /**
  1092. * Normalize the value between 0.0 and 1.0 using min and max values
  1093. * @param value value to normalize
  1094. * @param min max to normalize between
  1095. * @param max min to normalize between
  1096. * @returns the normalized value
  1097. */
  1098. static Normalize(value: number, min: number, max: number): number;
  1099. /**
  1100. * Denormalize the value from 0.0 and 1.0 using min and max values
  1101. * @param normalized value to denormalize
  1102. * @param min max to denormalize between
  1103. * @param max min to denormalize between
  1104. * @returns the denormalized value
  1105. */
  1106. static Denormalize(normalized: number, min: number, max: number): number;
  1107. /**
  1108. * Calculates the shortest difference between two given angles given in degrees.
  1109. * @param current current angle in degrees
  1110. * @param target target angle in degrees
  1111. * @returns the delta
  1112. */
  1113. static DeltaAngle(current: number, target: number): number;
  1114. /**
  1115. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1116. * @param tx value
  1117. * @param length length
  1118. * @returns The returned value will move back and forth between 0 and length
  1119. */
  1120. static PingPong(tx: number, length: number): number;
  1121. /**
  1122. * Interpolates between min and max with smoothing at the limits.
  1123. *
  1124. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1125. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1126. * @param from from
  1127. * @param to to
  1128. * @param tx value
  1129. * @returns the smooth stepped value
  1130. */
  1131. static SmoothStep(from: number, to: number, tx: number): number;
  1132. /**
  1133. * Moves a value current towards target.
  1134. *
  1135. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1136. * Negative values of maxDelta pushes the value away from target.
  1137. * @param current current value
  1138. * @param target target value
  1139. * @param maxDelta max distance to move
  1140. * @returns resulting value
  1141. */
  1142. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1143. /**
  1144. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1145. *
  1146. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1147. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1148. * @param current current value
  1149. * @param target target value
  1150. * @param maxDelta max distance to move
  1151. * @returns resulting angle
  1152. */
  1153. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1154. /**
  1155. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1156. * @param start start value
  1157. * @param end target value
  1158. * @param amount amount to lerp between
  1159. * @returns the lerped value
  1160. */
  1161. static Lerp(start: number, end: number, amount: number): number;
  1162. /**
  1163. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1164. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1165. * @param start start value
  1166. * @param end target value
  1167. * @param amount amount to lerp between
  1168. * @returns the lerped value
  1169. */
  1170. static LerpAngle(start: number, end: number, amount: number): number;
  1171. /**
  1172. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1173. * @param a start value
  1174. * @param b target value
  1175. * @param value value between a and b
  1176. * @returns the inverseLerp value
  1177. */
  1178. static InverseLerp(a: number, b: number, value: number): number;
  1179. /**
  1180. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1181. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1182. * @param value1 spline value
  1183. * @param tangent1 spline value
  1184. * @param value2 spline value
  1185. * @param tangent2 spline value
  1186. * @param amount input value
  1187. * @returns hermite result
  1188. */
  1189. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1190. /**
  1191. * Returns a random float number between and min and max values
  1192. * @param min min value of random
  1193. * @param max max value of random
  1194. * @returns random value
  1195. */
  1196. static RandomRange(min: number, max: number): number;
  1197. /**
  1198. * This function returns percentage of a number in a given range.
  1199. *
  1200. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1201. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1202. * @param number to convert to percentage
  1203. * @param min min range
  1204. * @param max max range
  1205. * @returns the percentage
  1206. */
  1207. static RangeToPercent(number: number, min: number, max: number): number;
  1208. /**
  1209. * This function returns number that corresponds to the percentage in a given range.
  1210. *
  1211. * PercentToRange(0.34,0,100) will return 34.
  1212. * @param percent to convert to number
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the number
  1216. */
  1217. static PercentToRange(percent: number, min: number, max: number): number;
  1218. /**
  1219. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1220. * @param angle The angle to normalize in radian.
  1221. * @return The converted angle.
  1222. */
  1223. static NormalizeRadians(angle: number): number;
  1224. }
  1225. }
  1226. declare module BABYLON {
  1227. /**
  1228. * Constant used to convert a value to gamma space
  1229. * @ignorenaming
  1230. */
  1231. export const ToGammaSpace: number;
  1232. /**
  1233. * Constant used to convert a value to linear space
  1234. * @ignorenaming
  1235. */
  1236. export const ToLinearSpace = 2.2;
  1237. /**
  1238. * Constant used to define the minimal number value in Babylon.js
  1239. * @ignorenaming
  1240. */
  1241. let Epsilon: number;
  1242. }
  1243. declare module BABYLON {
  1244. /**
  1245. * Class used to represent a viewport on screen
  1246. */
  1247. export class Viewport {
  1248. /** viewport left coordinate */
  1249. x: number;
  1250. /** viewport top coordinate */
  1251. y: number;
  1252. /**viewport width */
  1253. width: number;
  1254. /** viewport height */
  1255. height: number;
  1256. /**
  1257. * Creates a Viewport object located at (x, y) and sized (width, height)
  1258. * @param x defines viewport left coordinate
  1259. * @param y defines viewport top coordinate
  1260. * @param width defines the viewport width
  1261. * @param height defines the viewport height
  1262. */
  1263. constructor(
  1264. /** viewport left coordinate */
  1265. x: number,
  1266. /** viewport top coordinate */
  1267. y: number,
  1268. /**viewport width */
  1269. width: number,
  1270. /** viewport height */
  1271. height: number);
  1272. /**
  1273. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1274. * @param renderWidth defines the rendering width
  1275. * @param renderHeight defines the rendering height
  1276. * @returns a new Viewport
  1277. */
  1278. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1279. /**
  1280. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1281. * @param renderWidth defines the rendering width
  1282. * @param renderHeight defines the rendering height
  1283. * @param ref defines the target viewport
  1284. * @returns the current viewport
  1285. */
  1286. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1287. /**
  1288. * Returns a new Viewport copied from the current one
  1289. * @returns a new Viewport
  1290. */
  1291. clone(): Viewport;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class containing a set of static utilities functions for arrays.
  1297. */
  1298. export class ArrayTools {
  1299. /**
  1300. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1301. * @param size the number of element to construct and put in the array
  1302. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1303. * @returns a new array filled with new objects
  1304. */
  1305. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * @hidden
  1311. */
  1312. export interface IColor4Like {
  1313. r: float;
  1314. g: float;
  1315. b: float;
  1316. a: float;
  1317. }
  1318. /**
  1319. * @hidden
  1320. */
  1321. export interface IColor3Like {
  1322. r: float;
  1323. g: float;
  1324. b: float;
  1325. }
  1326. /**
  1327. * @hidden
  1328. */
  1329. export interface IVector4Like {
  1330. x: float;
  1331. y: float;
  1332. z: float;
  1333. w: float;
  1334. }
  1335. /**
  1336. * @hidden
  1337. */
  1338. export interface IVector3Like {
  1339. x: float;
  1340. y: float;
  1341. z: float;
  1342. }
  1343. /**
  1344. * @hidden
  1345. */
  1346. export interface IVector2Like {
  1347. x: float;
  1348. y: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IMatrixLike {
  1354. toArray(): DeepImmutable<Float32Array>;
  1355. updateFlag: int;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IViewportLike {
  1361. x: float;
  1362. y: float;
  1363. width: float;
  1364. height: float;
  1365. }
  1366. /**
  1367. * @hidden
  1368. */
  1369. export interface IPlaneLike {
  1370. normal: IVector3Like;
  1371. d: float;
  1372. normalize(): void;
  1373. }
  1374. }
  1375. declare module BABYLON {
  1376. /**
  1377. * Class representing a vector containing 2 coordinates
  1378. */
  1379. export class Vector2 {
  1380. /** defines the first coordinate */
  1381. x: number;
  1382. /** defines the second coordinate */
  1383. y: number;
  1384. /**
  1385. * Creates a new Vector2 from the given x and y coordinates
  1386. * @param x defines the first coordinate
  1387. * @param y defines the second coordinate
  1388. */
  1389. constructor(
  1390. /** defines the first coordinate */
  1391. x?: number,
  1392. /** defines the second coordinate */
  1393. y?: number);
  1394. /**
  1395. * Gets a string with the Vector2 coordinates
  1396. * @returns a string with the Vector2 coordinates
  1397. */
  1398. toString(): string;
  1399. /**
  1400. * Gets class name
  1401. * @returns the string "Vector2"
  1402. */
  1403. getClassName(): string;
  1404. /**
  1405. * Gets current vector hash code
  1406. * @returns the Vector2 hash code as a number
  1407. */
  1408. getHashCode(): number;
  1409. /**
  1410. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1411. * @param array defines the source array
  1412. * @param index defines the offset in source array
  1413. * @returns the current Vector2
  1414. */
  1415. toArray(array: FloatArray, index?: number): Vector2;
  1416. /**
  1417. * Copy the current vector to an array
  1418. * @returns a new array with 2 elements: the Vector2 coordinates.
  1419. */
  1420. asArray(): number[];
  1421. /**
  1422. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1423. * @param source defines the source Vector2
  1424. * @returns the current updated Vector2
  1425. */
  1426. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1427. /**
  1428. * Sets the Vector2 coordinates with the given floats
  1429. * @param x defines the first coordinate
  1430. * @param y defines the second coordinate
  1431. * @returns the current updated Vector2
  1432. */
  1433. copyFromFloats(x: number, y: number): Vector2;
  1434. /**
  1435. * Sets the Vector2 coordinates with the given floats
  1436. * @param x defines the first coordinate
  1437. * @param y defines the second coordinate
  1438. * @returns the current updated Vector2
  1439. */
  1440. set(x: number, y: number): Vector2;
  1441. /**
  1442. * Add another vector with the current one
  1443. * @param otherVector defines the other vector
  1444. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1445. */
  1446. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1447. /**
  1448. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1449. * @param otherVector defines the other vector
  1450. * @param result defines the target vector
  1451. * @returns the unmodified current Vector2
  1452. */
  1453. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1454. /**
  1455. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1456. * @param otherVector defines the other vector
  1457. * @returns the current updated Vector2
  1458. */
  1459. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1460. /**
  1461. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1462. * @param otherVector defines the other vector
  1463. * @returns a new Vector2
  1464. */
  1465. addVector3(otherVector: Vector3): Vector2;
  1466. /**
  1467. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1468. * @param otherVector defines the other vector
  1469. * @returns a new Vector2
  1470. */
  1471. subtract(otherVector: Vector2): Vector2;
  1472. /**
  1473. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1474. * @param otherVector defines the other vector
  1475. * @param result defines the target vector
  1476. * @returns the unmodified current Vector2
  1477. */
  1478. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1479. /**
  1480. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1481. * @param otherVector defines the other vector
  1482. * @returns the current updated Vector2
  1483. */
  1484. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1485. /**
  1486. * Multiplies in place the current Vector2 coordinates by the given ones
  1487. * @param otherVector defines the other vector
  1488. * @returns the current updated Vector2
  1489. */
  1490. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1491. /**
  1492. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1493. * @param otherVector defines the other vector
  1494. * @returns a new Vector2
  1495. */
  1496. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1497. /**
  1498. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1499. * @param otherVector defines the other vector
  1500. * @param result defines the target vector
  1501. * @returns the unmodified current Vector2
  1502. */
  1503. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1504. /**
  1505. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1506. * @param x defines the first coordinate
  1507. * @param y defines the second coordinate
  1508. * @returns a new Vector2
  1509. */
  1510. multiplyByFloats(x: number, y: number): Vector2;
  1511. /**
  1512. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1513. * @param otherVector defines the other vector
  1514. * @returns a new Vector2
  1515. */
  1516. divide(otherVector: Vector2): Vector2;
  1517. /**
  1518. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1519. * @param otherVector defines the other vector
  1520. * @param result defines the target vector
  1521. * @returns the unmodified current Vector2
  1522. */
  1523. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1524. /**
  1525. * Divides the current Vector2 coordinates by the given ones
  1526. * @param otherVector defines the other vector
  1527. * @returns the current updated Vector2
  1528. */
  1529. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1530. /**
  1531. * Gets a new Vector2 with current Vector2 negated coordinates
  1532. * @returns a new Vector2
  1533. */
  1534. negate(): Vector2;
  1535. /**
  1536. * Multiply the Vector2 coordinates by scale
  1537. * @param scale defines the scaling factor
  1538. * @returns the current updated Vector2
  1539. */
  1540. scaleInPlace(scale: number): Vector2;
  1541. /**
  1542. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1543. * @param scale defines the scaling factor
  1544. * @returns a new Vector2
  1545. */
  1546. scale(scale: number): Vector2;
  1547. /**
  1548. * Scale the current Vector2 values by a factor to a given Vector2
  1549. * @param scale defines the scale factor
  1550. * @param result defines the Vector2 object where to store the result
  1551. * @returns the unmodified current Vector2
  1552. */
  1553. scaleToRef(scale: number, result: Vector2): Vector2;
  1554. /**
  1555. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1556. * @param scale defines the scale factor
  1557. * @param result defines the Vector2 object where to store the result
  1558. * @returns the unmodified current Vector2
  1559. */
  1560. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1561. /**
  1562. * Gets a boolean if two vectors are equals
  1563. * @param otherVector defines the other vector
  1564. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1565. */
  1566. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1567. /**
  1568. * Gets a boolean if two vectors are equals (using an epsilon value)
  1569. * @param otherVector defines the other vector
  1570. * @param epsilon defines the minimal distance to consider equality
  1571. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1572. */
  1573. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. floor(): Vector2;
  1579. /**
  1580. * Gets a new Vector2 from current Vector2 floored values
  1581. * @returns a new Vector2
  1582. */
  1583. fract(): Vector2;
  1584. /**
  1585. * Gets the length of the vector
  1586. * @returns the vector length (float)
  1587. */
  1588. length(): number;
  1589. /**
  1590. * Gets the vector squared length
  1591. * @returns the vector squared length (float)
  1592. */
  1593. lengthSquared(): number;
  1594. /**
  1595. * Normalize the vector
  1596. * @returns the current updated Vector2
  1597. */
  1598. normalize(): Vector2;
  1599. /**
  1600. * Gets a new Vector2 copied from the Vector2
  1601. * @returns a new Vector2
  1602. */
  1603. clone(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(0, 0)
  1606. * @returns a new Vector2
  1607. */
  1608. static Zero(): Vector2;
  1609. /**
  1610. * Gets a new Vector2(1, 1)
  1611. * @returns a new Vector2
  1612. */
  1613. static One(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 set from the given index element of the given array
  1616. * @param array defines the data source
  1617. * @param offset defines the offset in the data source
  1618. * @returns a new Vector2
  1619. */
  1620. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1621. /**
  1622. * Sets "result" from the given index element of the given array
  1623. * @param array defines the data source
  1624. * @param offset defines the offset in the data source
  1625. * @param result defines the target vector
  1626. */
  1627. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1628. /**
  1629. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1630. * @param value1 defines 1st point of control
  1631. * @param value2 defines 2nd point of control
  1632. * @param value3 defines 3rd point of control
  1633. * @param value4 defines 4th point of control
  1634. * @param amount defines the interpolation factor
  1635. * @returns a new Vector2
  1636. */
  1637. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1638. /**
  1639. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1640. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1641. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1642. * @param value defines the value to clamp
  1643. * @param min defines the lower limit
  1644. * @param max defines the upper limit
  1645. * @returns a new Vector2
  1646. */
  1647. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1648. /**
  1649. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1650. * @param value1 defines the 1st control point
  1651. * @param tangent1 defines the outgoing tangent
  1652. * @param value2 defines the 2nd control point
  1653. * @param tangent2 defines the incoming tangent
  1654. * @param amount defines the interpolation factor
  1655. * @returns a new Vector2
  1656. */
  1657. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1660. * @param start defines the start vector
  1661. * @param end defines the end vector
  1662. * @param amount defines the interpolation factor
  1663. * @returns a new Vector2
  1664. */
  1665. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1666. /**
  1667. * Gets the dot product of the vector "left" and the vector "right"
  1668. * @param left defines first vector
  1669. * @param right defines second vector
  1670. * @returns the dot product (float)
  1671. */
  1672. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1673. /**
  1674. * Returns a new Vector2 equal to the normalized given vector
  1675. * @param vector defines the vector to normalize
  1676. * @returns a new Vector2
  1677. */
  1678. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1679. /**
  1680. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1681. * @param left defines 1st vector
  1682. * @param right defines 2nd vector
  1683. * @returns a new Vector2
  1684. */
  1685. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1686. /**
  1687. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1688. * @param left defines 1st vector
  1689. * @param right defines 2nd vector
  1690. * @returns a new Vector2
  1691. */
  1692. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1693. /**
  1694. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1695. * @param vector defines the vector to transform
  1696. * @param transformation defines the matrix to apply
  1697. * @returns a new Vector2
  1698. */
  1699. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1700. /**
  1701. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1702. * @param vector defines the vector to transform
  1703. * @param transformation defines the matrix to apply
  1704. * @param result defines the target vector
  1705. */
  1706. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1707. /**
  1708. * Determines if a given vector is included in a triangle
  1709. * @param p defines the vector to test
  1710. * @param p0 defines 1st triangle point
  1711. * @param p1 defines 2nd triangle point
  1712. * @param p2 defines 3rd triangle point
  1713. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1714. */
  1715. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1716. /**
  1717. * Gets the distance between the vectors "value1" and "value2"
  1718. * @param value1 defines first vector
  1719. * @param value2 defines second vector
  1720. * @returns the distance between vectors
  1721. */
  1722. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1723. /**
  1724. * Returns the squared distance between the vectors "value1" and "value2"
  1725. * @param value1 defines first vector
  1726. * @param value2 defines second vector
  1727. * @returns the squared distance between vectors
  1728. */
  1729. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1730. /**
  1731. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1732. * @param value1 defines first vector
  1733. * @param value2 defines second vector
  1734. * @returns a new Vector2
  1735. */
  1736. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1737. /**
  1738. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1739. * @param p defines the middle point
  1740. * @param segA defines one point of the segment
  1741. * @param segB defines the other point of the segment
  1742. * @returns the shortest distance
  1743. */
  1744. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1745. }
  1746. /**
  1747. * Classed used to store (x,y,z) vector representation
  1748. * A Vector3 is the main object used in 3D geometry
  1749. * It can represent etiher the coordinates of a point the space, either a direction
  1750. * Reminder: js uses a left handed forward facing system
  1751. */
  1752. export class Vector3 {
  1753. /**
  1754. * Defines the first coordinates (on X axis)
  1755. */
  1756. x: number;
  1757. /**
  1758. * Defines the second coordinates (on Y axis)
  1759. */
  1760. y: number;
  1761. /**
  1762. * Defines the third coordinates (on Z axis)
  1763. */
  1764. z: number;
  1765. private static _UpReadOnly;
  1766. private static _ZeroReadOnly;
  1767. /**
  1768. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1769. * @param x defines the first coordinates (on X axis)
  1770. * @param y defines the second coordinates (on Y axis)
  1771. * @param z defines the third coordinates (on Z axis)
  1772. */
  1773. constructor(
  1774. /**
  1775. * Defines the first coordinates (on X axis)
  1776. */
  1777. x?: number,
  1778. /**
  1779. * Defines the second coordinates (on Y axis)
  1780. */
  1781. y?: number,
  1782. /**
  1783. * Defines the third coordinates (on Z axis)
  1784. */
  1785. z?: number);
  1786. /**
  1787. * Creates a string representation of the Vector3
  1788. * @returns a string with the Vector3 coordinates.
  1789. */
  1790. toString(): string;
  1791. /**
  1792. * Gets the class name
  1793. * @returns the string "Vector3"
  1794. */
  1795. getClassName(): string;
  1796. /**
  1797. * Creates the Vector3 hash code
  1798. * @returns a number which tends to be unique between Vector3 instances
  1799. */
  1800. getHashCode(): number;
  1801. /**
  1802. * Creates an array containing three elements : the coordinates of the Vector3
  1803. * @returns a new array of numbers
  1804. */
  1805. asArray(): number[];
  1806. /**
  1807. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1808. * @param array defines the destination array
  1809. * @param index defines the offset in the destination array
  1810. * @returns the current Vector3
  1811. */
  1812. toArray(array: FloatArray, index?: number): Vector3;
  1813. /**
  1814. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1815. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1816. */
  1817. toQuaternion(): Quaternion;
  1818. /**
  1819. * Adds the given vector to the current Vector3
  1820. * @param otherVector defines the second operand
  1821. * @returns the current updated Vector3
  1822. */
  1823. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1824. /**
  1825. * Adds the given coordinates to the current Vector3
  1826. * @param x defines the x coordinate of the operand
  1827. * @param y defines the y coordinate of the operand
  1828. * @param z defines the z coordinate of the operand
  1829. * @returns the current updated Vector3
  1830. */
  1831. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1832. /**
  1833. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1834. * @param otherVector defines the second operand
  1835. * @returns the resulting Vector3
  1836. */
  1837. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1838. /**
  1839. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1840. * @param otherVector defines the second operand
  1841. * @param result defines the Vector3 object where to store the result
  1842. * @returns the current Vector3
  1843. */
  1844. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1845. /**
  1846. * Subtract the given vector from the current Vector3
  1847. * @param otherVector defines the second operand
  1848. * @returns the current updated Vector3
  1849. */
  1850. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1851. /**
  1852. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1853. * @param otherVector defines the second operand
  1854. * @returns the resulting Vector3
  1855. */
  1856. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1859. * @param otherVector defines the second operand
  1860. * @param result defines the Vector3 object where to store the result
  1861. * @returns the current Vector3
  1862. */
  1863. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1864. /**
  1865. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1866. * @param x defines the x coordinate of the operand
  1867. * @param y defines the y coordinate of the operand
  1868. * @param z defines the z coordinate of the operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1872. /**
  1873. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1874. * @param x defines the x coordinate of the operand
  1875. * @param y defines the y coordinate of the operand
  1876. * @param z defines the z coordinate of the operand
  1877. * @param result defines the Vector3 object where to store the result
  1878. * @returns the current Vector3
  1879. */
  1880. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1881. /**
  1882. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1883. * @returns a new Vector3
  1884. */
  1885. negate(): Vector3;
  1886. /**
  1887. * Multiplies the Vector3 coordinates by the float "scale"
  1888. * @param scale defines the multiplier factor
  1889. * @returns the current updated Vector3
  1890. */
  1891. scaleInPlace(scale: number): Vector3;
  1892. /**
  1893. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1894. * @param scale defines the multiplier factor
  1895. * @returns a new Vector3
  1896. */
  1897. scale(scale: number): Vector3;
  1898. /**
  1899. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1900. * @param scale defines the multiplier factor
  1901. * @param result defines the Vector3 object where to store the result
  1902. * @returns the current Vector3
  1903. */
  1904. scaleToRef(scale: number, result: Vector3): Vector3;
  1905. /**
  1906. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1907. * @param scale defines the scale factor
  1908. * @param result defines the Vector3 object where to store the result
  1909. * @returns the unmodified current Vector3
  1910. */
  1911. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1912. /**
  1913. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1914. * @param otherVector defines the second operand
  1915. * @returns true if both vectors are equals
  1916. */
  1917. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1918. /**
  1919. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1920. * @param otherVector defines the second operand
  1921. * @param epsilon defines the minimal distance to define values as equals
  1922. * @returns true if both vectors are distant less than epsilon
  1923. */
  1924. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1925. /**
  1926. * Returns true if the current Vector3 coordinates equals the given floats
  1927. * @param x defines the x coordinate of the operand
  1928. * @param y defines the y coordinate of the operand
  1929. * @param z defines the z coordinate of the operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equalsToFloats(x: number, y: number, z: number): boolean;
  1933. /**
  1934. * Multiplies the current Vector3 coordinates by the given ones
  1935. * @param otherVector defines the second operand
  1936. * @returns the current updated Vector3
  1937. */
  1938. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1939. /**
  1940. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1941. * @param otherVector defines the second operand
  1942. * @returns the new Vector3
  1943. */
  1944. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1947. * @param otherVector defines the second operand
  1948. * @param result defines the Vector3 object where to store the result
  1949. * @returns the current Vector3
  1950. */
  1951. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1952. /**
  1953. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1954. * @param x defines the x coordinate of the operand
  1955. * @param y defines the y coordinate of the operand
  1956. * @param z defines the z coordinate of the operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1960. /**
  1961. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1962. * @param otherVector defines the second operand
  1963. * @returns the new Vector3
  1964. */
  1965. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1966. /**
  1967. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1968. * @param otherVector defines the second operand
  1969. * @param result defines the Vector3 object where to store the result
  1970. * @returns the current Vector3
  1971. */
  1972. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1973. /**
  1974. * Divides the current Vector3 coordinates by the given ones.
  1975. * @param otherVector defines the second operand
  1976. * @returns the current updated Vector3
  1977. */
  1978. divideInPlace(otherVector: Vector3): Vector3;
  1979. /**
  1980. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1981. * @param other defines the second operand
  1982. * @returns the current updated Vector3
  1983. */
  1984. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1985. /**
  1986. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1987. * @param other defines the second operand
  1988. * @returns the current updated Vector3
  1989. */
  1990. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1991. /**
  1992. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1993. * @param x defines the x coordinate of the operand
  1994. * @param y defines the y coordinate of the operand
  1995. * @param z defines the z coordinate of the operand
  1996. * @returns the current updated Vector3
  1997. */
  1998. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1999. /**
  2000. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2001. * @param x defines the x coordinate of the operand
  2002. * @param y defines the y coordinate of the operand
  2003. * @param z defines the z coordinate of the operand
  2004. * @returns the current updated Vector3
  2005. */
  2006. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2007. /**
  2008. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2009. * Check if is non uniform within a certain amount of decimal places to account for this
  2010. * @param epsilon the amount the values can differ
  2011. * @returns if the the vector is non uniform to a certain number of decimal places
  2012. */
  2013. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2014. /**
  2015. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2016. */
  2017. readonly isNonUniform: boolean;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. floor(): Vector3;
  2023. /**
  2024. * Gets a new Vector3 from current Vector3 floored values
  2025. * @returns a new Vector3
  2026. */
  2027. fract(): Vector3;
  2028. /**
  2029. * Gets the length of the Vector3
  2030. * @returns the length of the Vector3
  2031. */
  2032. length(): number;
  2033. /**
  2034. * Gets the squared length of the Vector3
  2035. * @returns squared length of the Vector3
  2036. */
  2037. lengthSquared(): number;
  2038. /**
  2039. * Normalize the current Vector3.
  2040. * Please note that this is an in place operation.
  2041. * @returns the current updated Vector3
  2042. */
  2043. normalize(): Vector3;
  2044. /**
  2045. * Reorders the x y z properties of the vector in place
  2046. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2047. * @returns the current updated vector
  2048. */
  2049. reorderInPlace(order: string): this;
  2050. /**
  2051. * Rotates the vector around 0,0,0 by a quaternion
  2052. * @param quaternion the rotation quaternion
  2053. * @param result vector to store the result
  2054. * @returns the resulting vector
  2055. */
  2056. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2057. /**
  2058. * Rotates a vector around a given point
  2059. * @param quaternion the rotation quaternion
  2060. * @param point the point to rotate around
  2061. * @param result vector to store the result
  2062. * @returns the resulting vector
  2063. */
  2064. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2065. /**
  2066. * Normalize the current Vector3 with the given input length.
  2067. * Please note that this is an in place operation.
  2068. * @param len the length of the vector
  2069. * @returns the current updated Vector3
  2070. */
  2071. normalizeFromLength(len: number): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to a new vector
  2074. * @returns the new Vector3
  2075. */
  2076. normalizeToNew(): Vector3;
  2077. /**
  2078. * Normalize the current Vector3 to the reference
  2079. * @param reference define the Vector3 to update
  2080. * @returns the updated Vector3
  2081. */
  2082. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2083. /**
  2084. * Creates a new Vector3 copied from the current Vector3
  2085. * @returns the new Vector3
  2086. */
  2087. clone(): Vector3;
  2088. /**
  2089. * Copies the given vector coordinates to the current Vector3 ones
  2090. * @param source defines the source Vector3
  2091. * @returns the current updated Vector3
  2092. */
  2093. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2094. /**
  2095. * Copies the given floats to the current Vector3 coordinates
  2096. * @param x defines the x coordinate of the operand
  2097. * @param y defines the y coordinate of the operand
  2098. * @param z defines the z coordinate of the operand
  2099. * @returns the current updated Vector3
  2100. */
  2101. copyFromFloats(x: number, y: number, z: number): Vector3;
  2102. /**
  2103. * Copies the given floats to the current Vector3 coordinates
  2104. * @param x defines the x coordinate of the operand
  2105. * @param y defines the y coordinate of the operand
  2106. * @param z defines the z coordinate of the operand
  2107. * @returns the current updated Vector3
  2108. */
  2109. set(x: number, y: number, z: number): Vector3;
  2110. /**
  2111. * Copies the given float to the current Vector3 coordinates
  2112. * @param v defines the x, y and z coordinates of the operand
  2113. * @returns the current updated Vector3
  2114. */
  2115. setAll(v: number): Vector3;
  2116. /**
  2117. * Get the clip factor between two vectors
  2118. * @param vector0 defines the first operand
  2119. * @param vector1 defines the second operand
  2120. * @param axis defines the axis to use
  2121. * @param size defines the size along the axis
  2122. * @returns the clip factor
  2123. */
  2124. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2125. /**
  2126. * Get angle between two vectors
  2127. * @param vector0 angle between vector0 and vector1
  2128. * @param vector1 angle between vector0 and vector1
  2129. * @param normal direction of the normal
  2130. * @return the angle between vector0 and vector1
  2131. */
  2132. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2133. /**
  2134. * Returns a new Vector3 set from the index "offset" of the given array
  2135. * @param array defines the source array
  2136. * @param offset defines the offset in the source array
  2137. * @returns the new Vector3
  2138. */
  2139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2140. /**
  2141. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2142. * This function is deprecated. Use FromArray instead
  2143. * @param array defines the source array
  2144. * @param offset defines the offset in the source array
  2145. * @returns the new Vector3
  2146. */
  2147. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2148. /**
  2149. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2150. * @param array defines the source array
  2151. * @param offset defines the offset in the source array
  2152. * @param result defines the Vector3 where to store the result
  2153. */
  2154. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2155. /**
  2156. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2157. * This function is deprecated. Use FromArrayToRef instead.
  2158. * @param array defines the source array
  2159. * @param offset defines the offset in the source array
  2160. * @param result defines the Vector3 where to store the result
  2161. */
  2162. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2163. /**
  2164. * Sets the given vector "result" with the given floats.
  2165. * @param x defines the x coordinate of the source
  2166. * @param y defines the y coordinate of the source
  2167. * @param z defines the z coordinate of the source
  2168. * @param result defines the Vector3 where to store the result
  2169. */
  2170. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2171. /**
  2172. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2173. * @returns a new empty Vector3
  2174. */
  2175. static Zero(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2178. * @returns a new unit Vector3
  2179. */
  2180. static One(): Vector3;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2183. * @returns a new up Vector3
  2184. */
  2185. static Up(): Vector3;
  2186. /**
  2187. * Gets a up Vector3 that must not be updated
  2188. */
  2189. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2190. /**
  2191. * Gets a zero Vector3 that must not be updated
  2192. */
  2193. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2196. * @returns a new down Vector3
  2197. */
  2198. static Down(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Forward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2206. * @returns a new forward Vector3
  2207. */
  2208. static Backward(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2211. * @returns a new right Vector3
  2212. */
  2213. static Right(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2216. * @returns a new left Vector3
  2217. */
  2218. static Left(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2221. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2222. * @param vector defines the Vector3 to transform
  2223. * @param transformation defines the transformation matrix
  2224. * @returns the transformed Vector3
  2225. */
  2226. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2227. /**
  2228. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2230. * @param vector defines the Vector3 to transform
  2231. * @param transformation defines the transformation matrix
  2232. * @param result defines the Vector3 where to store the result
  2233. */
  2234. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2235. /**
  2236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2237. * This method computes tranformed coordinates only, not transformed direction vectors
  2238. * @param x define the x coordinate of the source vector
  2239. * @param y define the y coordinate of the source vector
  2240. * @param z define the z coordinate of the source vector
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2247. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2248. * @param vector defines the Vector3 to transform
  2249. * @param transformation defines the transformation matrix
  2250. * @returns the new Vector3
  2251. */
  2252. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2253. /**
  2254. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2256. * @param vector defines the Vector3 to transform
  2257. * @param transformation defines the transformation matrix
  2258. * @param result defines the Vector3 where to store the result
  2259. */
  2260. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2261. /**
  2262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2264. * @param x define the x coordinate of the source vector
  2265. * @param y define the y coordinate of the source vector
  2266. * @param z define the z coordinate of the source vector
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2273. * @param value1 defines the first control point
  2274. * @param value2 defines the second control point
  2275. * @param value3 defines the third control point
  2276. * @param value4 defines the fourth control point
  2277. * @param amount defines the amount on the spline to use
  2278. * @returns the new Vector3
  2279. */
  2280. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2281. /**
  2282. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2283. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2284. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2285. * @param value defines the current value
  2286. * @param min defines the lower range value
  2287. * @param max defines the upper range value
  2288. * @returns the new Vector3
  2289. */
  2290. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2291. /**
  2292. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @param result defines the Vector3 where to store the result
  2299. */
  2300. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2301. /**
  2302. * Checks if a given vector is inside a specific range
  2303. * @param v defines the vector to test
  2304. * @param min defines the minimum range
  2305. * @param max defines the maximum range
  2306. */
  2307. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2308. /**
  2309. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2310. * @param value1 defines the first control point
  2311. * @param tangent1 defines the first tangent vector
  2312. * @param value2 defines the second control point
  2313. * @param tangent2 defines the second tangent vector
  2314. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2315. * @returns the new Vector3
  2316. */
  2317. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2320. * @param start defines the start value
  2321. * @param end defines the end value
  2322. * @param amount max defines amount between both (between 0 and 1)
  2323. * @returns the new Vector3
  2324. */
  2325. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2326. /**
  2327. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2328. * @param start defines the start value
  2329. * @param end defines the end value
  2330. * @param amount max defines amount between both (between 0 and 1)
  2331. * @param result defines the Vector3 where to store the result
  2332. */
  2333. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2334. /**
  2335. * Returns the dot product (float) between the vectors "left" and "right"
  2336. * @param left defines the left operand
  2337. * @param right defines the right operand
  2338. * @returns the dot product
  2339. */
  2340. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2341. /**
  2342. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2343. * The cross product is then orthogonal to both "left" and "right"
  2344. * @param left defines the left operand
  2345. * @param right defines the right operand
  2346. * @returns the cross product
  2347. */
  2348. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2349. /**
  2350. * Sets the given vector "result" with the cross product of "left" and "right"
  2351. * The cross product is then orthogonal to both "left" and "right"
  2352. * @param left defines the left operand
  2353. * @param right defines the right operand
  2354. * @param result defines the Vector3 where to store the result
  2355. */
  2356. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2357. /**
  2358. * Returns a new Vector3 as the normalization of the given vector
  2359. * @param vector defines the Vector3 to normalize
  2360. * @returns the new Vector3
  2361. */
  2362. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2363. /**
  2364. * Sets the given vector "result" with the normalization of the given first vector
  2365. * @param vector defines the Vector3 to normalize
  2366. * @param result defines the Vector3 where to store the result
  2367. */
  2368. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2369. /**
  2370. * Project a Vector3 onto screen space
  2371. * @param vector defines the Vector3 to project
  2372. * @param world defines the world matrix to use
  2373. * @param transform defines the transform (view x projection) matrix to use
  2374. * @param viewport defines the screen viewport to use
  2375. * @returns the new Vector3
  2376. */
  2377. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2378. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2379. /**
  2380. * Unproject from screen space to object space
  2381. * @param source defines the screen space Vector3 to use
  2382. * @param viewportWidth defines the current width of the viewport
  2383. * @param viewportHeight defines the current height of the viewport
  2384. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2385. * @param transform defines the transform (view x projection) matrix to use
  2386. * @returns the new Vector3
  2387. */
  2388. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2389. /**
  2390. * Unproject from screen space to object space
  2391. * @param source defines the screen space Vector3 to use
  2392. * @param viewportWidth defines the current width of the viewport
  2393. * @param viewportHeight defines the current height of the viewport
  2394. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2395. * @param view defines the view matrix to use
  2396. * @param projection defines the projection matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @param result defines the Vector3 where to store the result
  2409. */
  2410. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param sourceX defines the screen space x coordinate to use
  2414. * @param sourceY defines the screen space y coordinate to use
  2415. * @param sourceZ defines the screen space z coordinate to use
  2416. * @param viewportWidth defines the current width of the viewport
  2417. * @param viewportHeight defines the current height of the viewport
  2418. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2419. * @param view defines the view matrix to use
  2420. * @param projection defines the projection matrix to use
  2421. * @param result defines the Vector3 where to store the result
  2422. */
  2423. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2424. /**
  2425. * Gets the minimal coordinate values between two Vector3
  2426. * @param left defines the first operand
  2427. * @param right defines the second operand
  2428. * @returns the new Vector3
  2429. */
  2430. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Gets the maximal coordinate values between two Vector3
  2433. * @param left defines the first operand
  2434. * @param right defines the second operand
  2435. * @returns the new Vector3
  2436. */
  2437. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2438. /**
  2439. * Returns the distance between the vectors "value1" and "value2"
  2440. * @param value1 defines the first operand
  2441. * @param value2 defines the second operand
  2442. * @returns the distance
  2443. */
  2444. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2445. /**
  2446. * Returns the squared distance between the vectors "value1" and "value2"
  2447. * @param value1 defines the first operand
  2448. * @param value2 defines the second operand
  2449. * @returns the squared distance
  2450. */
  2451. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2452. /**
  2453. * Returns a new Vector3 located at the center between "value1" and "value2"
  2454. * @param value1 defines the first operand
  2455. * @param value2 defines the second operand
  2456. * @returns the new Vector3
  2457. */
  2458. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2459. /**
  2460. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2461. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2462. * to something in order to rotate it from its local system to the given target system
  2463. * Note: axis1, axis2 and axis3 are normalized during this operation
  2464. * @param axis1 defines the first axis
  2465. * @param axis2 defines the second axis
  2466. * @param axis3 defines the third axis
  2467. * @returns a new Vector3
  2468. */
  2469. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2472. * @param axis1 defines the first axis
  2473. * @param axis2 defines the second axis
  2474. * @param axis3 defines the third axis
  2475. * @param ref defines the Vector3 where to store the result
  2476. */
  2477. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2478. }
  2479. /**
  2480. * Vector4 class created for EulerAngle class conversion to Quaternion
  2481. */
  2482. export class Vector4 {
  2483. /** x value of the vector */
  2484. x: number;
  2485. /** y value of the vector */
  2486. y: number;
  2487. /** z value of the vector */
  2488. z: number;
  2489. /** w value of the vector */
  2490. w: number;
  2491. /**
  2492. * Creates a Vector4 object from the given floats.
  2493. * @param x x value of the vector
  2494. * @param y y value of the vector
  2495. * @param z z value of the vector
  2496. * @param w w value of the vector
  2497. */
  2498. constructor(
  2499. /** x value of the vector */
  2500. x: number,
  2501. /** y value of the vector */
  2502. y: number,
  2503. /** z value of the vector */
  2504. z: number,
  2505. /** w value of the vector */
  2506. w: number);
  2507. /**
  2508. * Returns the string with the Vector4 coordinates.
  2509. * @returns a string containing all the vector values
  2510. */
  2511. toString(): string;
  2512. /**
  2513. * Returns the string "Vector4".
  2514. * @returns "Vector4"
  2515. */
  2516. getClassName(): string;
  2517. /**
  2518. * Returns the Vector4 hash code.
  2519. * @returns a unique hash code
  2520. */
  2521. getHashCode(): number;
  2522. /**
  2523. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2524. * @returns the resulting array
  2525. */
  2526. asArray(): number[];
  2527. /**
  2528. * Populates the given array from the given index with the Vector4 coordinates.
  2529. * @param array array to populate
  2530. * @param index index of the array to start at (default: 0)
  2531. * @returns the Vector4.
  2532. */
  2533. toArray(array: FloatArray, index?: number): Vector4;
  2534. /**
  2535. * Adds the given vector to the current Vector4.
  2536. * @param otherVector the vector to add
  2537. * @returns the updated Vector4.
  2538. */
  2539. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2540. /**
  2541. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2542. * @param otherVector the vector to add
  2543. * @returns the resulting vector
  2544. */
  2545. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2546. /**
  2547. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2548. * @param otherVector the vector to add
  2549. * @param result the vector to store the result
  2550. * @returns the current Vector4.
  2551. */
  2552. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2553. /**
  2554. * Subtract in place the given vector from the current Vector4.
  2555. * @param otherVector the vector to subtract
  2556. * @returns the updated Vector4.
  2557. */
  2558. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2559. /**
  2560. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2561. * @param otherVector the vector to add
  2562. * @returns the new vector with the result
  2563. */
  2564. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2567. * @param otherVector the vector to subtract
  2568. * @param result the vector to store the result
  2569. * @returns the current Vector4.
  2570. */
  2571. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2572. /**
  2573. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2574. */
  2575. /**
  2576. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2577. * @param x value to subtract
  2578. * @param y value to subtract
  2579. * @param z value to subtract
  2580. * @param w value to subtract
  2581. * @returns new vector containing the result
  2582. */
  2583. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2584. /**
  2585. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2586. * @param x value to subtract
  2587. * @param y value to subtract
  2588. * @param z value to subtract
  2589. * @param w value to subtract
  2590. * @param result the vector to store the result in
  2591. * @returns the current Vector4.
  2592. */
  2593. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2594. /**
  2595. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2596. * @returns a new vector with the negated values
  2597. */
  2598. negate(): Vector4;
  2599. /**
  2600. * Multiplies the current Vector4 coordinates by scale (float).
  2601. * @param scale the number to scale with
  2602. * @returns the updated Vector4.
  2603. */
  2604. scaleInPlace(scale: number): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2607. * @param scale the number to scale with
  2608. * @returns a new vector with the result
  2609. */
  2610. scale(scale: number): Vector4;
  2611. /**
  2612. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2613. * @param scale the number to scale with
  2614. * @param result a vector to store the result in
  2615. * @returns the current Vector4.
  2616. */
  2617. scaleToRef(scale: number, result: Vector4): Vector4;
  2618. /**
  2619. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2620. * @param scale defines the scale factor
  2621. * @param result defines the Vector4 object where to store the result
  2622. * @returns the unmodified current Vector4
  2623. */
  2624. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2625. /**
  2626. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2627. * @param otherVector the vector to compare against
  2628. * @returns true if they are equal
  2629. */
  2630. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2631. /**
  2632. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2633. * @param otherVector vector to compare against
  2634. * @param epsilon (Default: very small number)
  2635. * @returns true if they are equal
  2636. */
  2637. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2638. /**
  2639. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2640. * @param x x value to compare against
  2641. * @param y y value to compare against
  2642. * @param z z value to compare against
  2643. * @param w w value to compare against
  2644. * @returns true if equal
  2645. */
  2646. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2647. /**
  2648. * Multiplies in place the current Vector4 by the given one.
  2649. * @param otherVector vector to multiple with
  2650. * @returns the updated Vector4.
  2651. */
  2652. multiplyInPlace(otherVector: Vector4): Vector4;
  2653. /**
  2654. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2655. * @param otherVector vector to multiple with
  2656. * @returns resulting new vector
  2657. */
  2658. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2659. /**
  2660. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2661. * @param otherVector vector to multiple with
  2662. * @param result vector to store the result
  2663. * @returns the current Vector4.
  2664. */
  2665. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2666. /**
  2667. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2668. * @param x x value multiply with
  2669. * @param y y value multiply with
  2670. * @param z z value multiply with
  2671. * @param w w value multiply with
  2672. * @returns resulting new vector
  2673. */
  2674. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2675. /**
  2676. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2677. * @param otherVector vector to devide with
  2678. * @returns resulting new vector
  2679. */
  2680. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2681. /**
  2682. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2683. * @param otherVector vector to devide with
  2684. * @param result vector to store the result
  2685. * @returns the current Vector4.
  2686. */
  2687. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones.
  2690. * @param otherVector vector to devide with
  2691. * @returns the updated Vector3.
  2692. */
  2693. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2694. /**
  2695. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2696. * @param other defines the second operand
  2697. * @returns the current updated Vector4
  2698. */
  2699. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2700. /**
  2701. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2702. * @param other defines the second operand
  2703. * @returns the current updated Vector4
  2704. */
  2705. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2706. /**
  2707. * Gets a new Vector4 from current Vector4 floored values
  2708. * @returns a new Vector4
  2709. */
  2710. floor(): Vector4;
  2711. /**
  2712. * Gets a new Vector4 from current Vector3 floored values
  2713. * @returns a new Vector4
  2714. */
  2715. fract(): Vector4;
  2716. /**
  2717. * Returns the Vector4 length (float).
  2718. * @returns the length
  2719. */
  2720. length(): number;
  2721. /**
  2722. * Returns the Vector4 squared length (float).
  2723. * @returns the length squared
  2724. */
  2725. lengthSquared(): number;
  2726. /**
  2727. * Normalizes in place the Vector4.
  2728. * @returns the updated Vector4.
  2729. */
  2730. normalize(): Vector4;
  2731. /**
  2732. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2733. * @returns this converted to a new vector3
  2734. */
  2735. toVector3(): Vector3;
  2736. /**
  2737. * Returns a new Vector4 copied from the current one.
  2738. * @returns the new cloned vector
  2739. */
  2740. clone(): Vector4;
  2741. /**
  2742. * Updates the current Vector4 with the given one coordinates.
  2743. * @param source the source vector to copy from
  2744. * @returns the updated Vector4.
  2745. */
  2746. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2747. /**
  2748. * Updates the current Vector4 coordinates with the given floats.
  2749. * @param x float to copy from
  2750. * @param y float to copy from
  2751. * @param z float to copy from
  2752. * @param w float to copy from
  2753. * @returns the updated Vector4.
  2754. */
  2755. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2756. /**
  2757. * Updates the current Vector4 coordinates with the given floats.
  2758. * @param x float to set from
  2759. * @param y float to set from
  2760. * @param z float to set from
  2761. * @param w float to set from
  2762. * @returns the updated Vector4.
  2763. */
  2764. set(x: number, y: number, z: number, w: number): Vector4;
  2765. /**
  2766. * Copies the given float to the current Vector3 coordinates
  2767. * @param v defines the x, y, z and w coordinates of the operand
  2768. * @returns the current updated Vector3
  2769. */
  2770. setAll(v: number): Vector4;
  2771. /**
  2772. * Returns a new Vector4 set from the starting index of the given array.
  2773. * @param array the array to pull values from
  2774. * @param offset the offset into the array to start at
  2775. * @returns the new vector
  2776. */
  2777. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2778. /**
  2779. * Updates the given vector "result" from the starting index of the given array.
  2780. * @param array the array to pull values from
  2781. * @param offset the offset into the array to start at
  2782. * @param result the vector to store the result in
  2783. */
  2784. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2785. /**
  2786. * Updates the given vector "result" from the starting index of the given Float32Array.
  2787. * @param array the array to pull values from
  2788. * @param offset the offset into the array to start at
  2789. * @param result the vector to store the result in
  2790. */
  2791. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2792. /**
  2793. * Updates the given vector "result" coordinates from the given floats.
  2794. * @param x float to set from
  2795. * @param y float to set from
  2796. * @param z float to set from
  2797. * @param w float to set from
  2798. * @param result the vector to the floats in
  2799. */
  2800. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2801. /**
  2802. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2803. * @returns the new vector
  2804. */
  2805. static Zero(): Vector4;
  2806. /**
  2807. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2808. * @returns the new vector
  2809. */
  2810. static One(): Vector4;
  2811. /**
  2812. * Returns a new normalized Vector4 from the given one.
  2813. * @param vector the vector to normalize
  2814. * @returns the vector
  2815. */
  2816. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2817. /**
  2818. * Updates the given vector "result" from the normalization of the given one.
  2819. * @param vector the vector to normalize
  2820. * @param result the vector to store the result in
  2821. */
  2822. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2823. /**
  2824. * Returns a vector with the minimum values from the left and right vectors
  2825. * @param left left vector to minimize
  2826. * @param right right vector to minimize
  2827. * @returns a new vector with the minimum of the left and right vector values
  2828. */
  2829. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2830. /**
  2831. * Returns a vector with the maximum values from the left and right vectors
  2832. * @param left left vector to maximize
  2833. * @param right right vector to maximize
  2834. * @returns a new vector with the maximum of the left and right vector values
  2835. */
  2836. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2837. /**
  2838. * Returns the distance (float) between the vectors "value1" and "value2".
  2839. * @param value1 value to calulate the distance between
  2840. * @param value2 value to calulate the distance between
  2841. * @return the distance between the two vectors
  2842. */
  2843. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2844. /**
  2845. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2846. * @param value1 value to calulate the distance between
  2847. * @param value2 value to calulate the distance between
  2848. * @return the distance between the two vectors squared
  2849. */
  2850. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2851. /**
  2852. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2853. * @param value1 value to calulate the center between
  2854. * @param value2 value to calulate the center between
  2855. * @return the center between the two vectors
  2856. */
  2857. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2858. /**
  2859. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2860. * This methods computes transformed normalized direction vectors only.
  2861. * @param vector the vector to transform
  2862. * @param transformation the transformation matrix to apply
  2863. * @returns the new vector
  2864. */
  2865. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2866. /**
  2867. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2868. * This methods computes transformed normalized direction vectors only.
  2869. * @param vector the vector to transform
  2870. * @param transformation the transformation matrix to apply
  2871. * @param result the vector to store the result in
  2872. */
  2873. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2874. /**
  2875. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2876. * This methods computes transformed normalized direction vectors only.
  2877. * @param x value to transform
  2878. * @param y value to transform
  2879. * @param z value to transform
  2880. * @param w value to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the results in
  2883. */
  2884. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Creates a new Vector4 from a Vector3
  2887. * @param source defines the source data
  2888. * @param w defines the 4th component (default is 0)
  2889. * @returns a new Vector4
  2890. */
  2891. static FromVector3(source: Vector3, w?: number): Vector4;
  2892. }
  2893. /**
  2894. * Class used to store quaternion data
  2895. * @see https://en.wikipedia.org/wiki/Quaternion
  2896. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2897. */
  2898. export class Quaternion {
  2899. /** defines the first component (0 by default) */
  2900. x: number;
  2901. /** defines the second component (0 by default) */
  2902. y: number;
  2903. /** defines the third component (0 by default) */
  2904. z: number;
  2905. /** defines the fourth component (1.0 by default) */
  2906. w: number;
  2907. /**
  2908. * Creates a new Quaternion from the given floats
  2909. * @param x defines the first component (0 by default)
  2910. * @param y defines the second component (0 by default)
  2911. * @param z defines the third component (0 by default)
  2912. * @param w defines the fourth component (1.0 by default)
  2913. */
  2914. constructor(
  2915. /** defines the first component (0 by default) */
  2916. x?: number,
  2917. /** defines the second component (0 by default) */
  2918. y?: number,
  2919. /** defines the third component (0 by default) */
  2920. z?: number,
  2921. /** defines the fourth component (1.0 by default) */
  2922. w?: number);
  2923. /**
  2924. * Gets a string representation for the current quaternion
  2925. * @returns a string with the Quaternion coordinates
  2926. */
  2927. toString(): string;
  2928. /**
  2929. * Gets the class name of the quaternion
  2930. * @returns the string "Quaternion"
  2931. */
  2932. getClassName(): string;
  2933. /**
  2934. * Gets a hash code for this quaternion
  2935. * @returns the quaternion hash code
  2936. */
  2937. getHashCode(): number;
  2938. /**
  2939. * Copy the quaternion to an array
  2940. * @returns a new array populated with 4 elements from the quaternion coordinates
  2941. */
  2942. asArray(): number[];
  2943. /**
  2944. * Check if two quaternions are equals
  2945. * @param otherQuaternion defines the second operand
  2946. * @return true if the current quaternion and the given one coordinates are strictly equals
  2947. */
  2948. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2949. /**
  2950. * Clone the current quaternion
  2951. * @returns a new quaternion copied from the current one
  2952. */
  2953. clone(): Quaternion;
  2954. /**
  2955. * Copy a quaternion to the current one
  2956. * @param other defines the other quaternion
  2957. * @returns the updated current quaternion
  2958. */
  2959. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2960. /**
  2961. * Updates the current quaternion with the given float coordinates
  2962. * @param x defines the x coordinate
  2963. * @param y defines the y coordinate
  2964. * @param z defines the z coordinate
  2965. * @param w defines the w coordinate
  2966. * @returns the updated current quaternion
  2967. */
  2968. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2969. /**
  2970. * Updates the current quaternion from the given float coordinates
  2971. * @param x defines the x coordinate
  2972. * @param y defines the y coordinate
  2973. * @param z defines the z coordinate
  2974. * @param w defines the w coordinate
  2975. * @returns the updated current quaternion
  2976. */
  2977. set(x: number, y: number, z: number, w: number): Quaternion;
  2978. /**
  2979. * Adds two quaternions
  2980. * @param other defines the second operand
  2981. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2982. */
  2983. add(other: DeepImmutable<Quaternion>): Quaternion;
  2984. /**
  2985. * Add a quaternion to the current one
  2986. * @param other defines the quaternion to add
  2987. * @returns the current quaternion
  2988. */
  2989. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2990. /**
  2991. * Subtract two quaternions
  2992. * @param other defines the second operand
  2993. * @returns a new quaternion as the subtraction result of the given one from the current one
  2994. */
  2995. subtract(other: Quaternion): Quaternion;
  2996. /**
  2997. * Multiplies the current quaternion by a scale factor
  2998. * @param value defines the scale factor
  2999. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3000. */
  3001. scale(value: number): Quaternion;
  3002. /**
  3003. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3004. * @param scale defines the scale factor
  3005. * @param result defines the Quaternion object where to store the result
  3006. * @returns the unmodified current quaternion
  3007. */
  3008. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3009. /**
  3010. * Multiplies in place the current quaternion by a scale factor
  3011. * @param value defines the scale factor
  3012. * @returns the current modified quaternion
  3013. */
  3014. scaleInPlace(value: number): Quaternion;
  3015. /**
  3016. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3017. * @param scale defines the scale factor
  3018. * @param result defines the Quaternion object where to store the result
  3019. * @returns the unmodified current quaternion
  3020. */
  3021. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3022. /**
  3023. * Multiplies two quaternions
  3024. * @param q1 defines the second operand
  3025. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3026. */
  3027. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3028. /**
  3029. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3030. * @param q1 defines the second operand
  3031. * @param result defines the target quaternion
  3032. * @returns the current quaternion
  3033. */
  3034. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3035. /**
  3036. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3037. * @param q1 defines the second operand
  3038. * @returns the currentupdated quaternion
  3039. */
  3040. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3041. /**
  3042. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3043. * @param ref defines the target quaternion
  3044. * @returns the current quaternion
  3045. */
  3046. conjugateToRef(ref: Quaternion): Quaternion;
  3047. /**
  3048. * Conjugates in place (1-q) the current quaternion
  3049. * @returns the current updated quaternion
  3050. */
  3051. conjugateInPlace(): Quaternion;
  3052. /**
  3053. * Conjugates in place (1-q) the current quaternion
  3054. * @returns a new quaternion
  3055. */
  3056. conjugate(): Quaternion;
  3057. /**
  3058. * Gets length of current quaternion
  3059. * @returns the quaternion length (float)
  3060. */
  3061. length(): number;
  3062. /**
  3063. * Normalize in place the current quaternion
  3064. * @returns the current updated quaternion
  3065. */
  3066. normalize(): Quaternion;
  3067. /**
  3068. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3069. * @param order is a reserved parameter and is ignore for now
  3070. * @returns a new Vector3 containing the Euler angles
  3071. */
  3072. toEulerAngles(order?: string): Vector3;
  3073. /**
  3074. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3075. * @param result defines the vector which will be filled with the Euler angles
  3076. * @param order is a reserved parameter and is ignore for now
  3077. * @returns the current unchanged quaternion
  3078. */
  3079. toEulerAnglesToRef(result: Vector3): Quaternion;
  3080. /**
  3081. * Updates the given rotation matrix with the current quaternion values
  3082. * @param result defines the target matrix
  3083. * @returns the current unchanged quaternion
  3084. */
  3085. toRotationMatrix(result: Matrix): Quaternion;
  3086. /**
  3087. * Updates the current quaternion from the given rotation matrix values
  3088. * @param matrix defines the source matrix
  3089. * @returns the current updated quaternion
  3090. */
  3091. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3092. /**
  3093. * Creates a new quaternion from a rotation matrix
  3094. * @param matrix defines the source matrix
  3095. * @returns a new quaternion created from the given rotation matrix values
  3096. */
  3097. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3098. /**
  3099. * Updates the given quaternion with the given rotation matrix values
  3100. * @param matrix defines the source matrix
  3101. * @param result defines the target quaternion
  3102. */
  3103. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3104. /**
  3105. * Returns the dot product (float) between the quaternions "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @returns the dot product
  3109. */
  3110. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3111. /**
  3112. * Checks if the two quaternions are close to each other
  3113. * @param quat0 defines the first quaternion to check
  3114. * @param quat1 defines the second quaternion to check
  3115. * @returns true if the two quaternions are close to each other
  3116. */
  3117. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3118. /**
  3119. * Creates an empty quaternion
  3120. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3121. */
  3122. static Zero(): Quaternion;
  3123. /**
  3124. * Inverse a given quaternion
  3125. * @param q defines the source quaternion
  3126. * @returns a new quaternion as the inverted current quaternion
  3127. */
  3128. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3129. /**
  3130. * Inverse a given quaternion
  3131. * @param q defines the source quaternion
  3132. * @param result the quaternion the result will be stored in
  3133. * @returns the result quaternion
  3134. */
  3135. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3136. /**
  3137. * Creates an identity quaternion
  3138. * @returns the identity quaternion
  3139. */
  3140. static Identity(): Quaternion;
  3141. /**
  3142. * Gets a boolean indicating if the given quaternion is identity
  3143. * @param quaternion defines the quaternion to check
  3144. * @returns true if the quaternion is identity
  3145. */
  3146. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3147. /**
  3148. * Creates a quaternion from a rotation around an axis
  3149. * @param axis defines the axis to use
  3150. * @param angle defines the angle to use
  3151. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3152. */
  3153. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3154. /**
  3155. * Creates a rotation around an axis and stores it into the given quaternion
  3156. * @param axis defines the axis to use
  3157. * @param angle defines the angle to use
  3158. * @param result defines the target quaternion
  3159. * @returns the target quaternion
  3160. */
  3161. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3162. /**
  3163. * Creates a new quaternion from data stored into an array
  3164. * @param array defines the data source
  3165. * @param offset defines the offset in the source array where the data starts
  3166. * @returns a new quaternion
  3167. */
  3168. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3169. /**
  3170. * Create a quaternion from Euler rotation angles
  3171. * @param x Pitch
  3172. * @param y Yaw
  3173. * @param z Roll
  3174. * @returns the new Quaternion
  3175. */
  3176. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3177. /**
  3178. * Updates a quaternion from Euler rotation angles
  3179. * @param x Pitch
  3180. * @param y Yaw
  3181. * @param z Roll
  3182. * @param result the quaternion to store the result
  3183. * @returns the updated quaternion
  3184. */
  3185. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3186. /**
  3187. * Create a quaternion from Euler rotation vector
  3188. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3189. * @returns the new Quaternion
  3190. */
  3191. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3192. /**
  3193. * Updates a quaternion from Euler rotation vector
  3194. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3195. * @param result the quaternion to store the result
  3196. * @returns the updated quaternion
  3197. */
  3198. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3199. /**
  3200. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3201. * @param yaw defines the rotation around Y axis
  3202. * @param pitch defines the rotation around X axis
  3203. * @param roll defines the rotation around Z axis
  3204. * @returns the new quaternion
  3205. */
  3206. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3207. /**
  3208. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3209. * @param yaw defines the rotation around Y axis
  3210. * @param pitch defines the rotation around X axis
  3211. * @param roll defines the rotation around Z axis
  3212. * @param result defines the target quaternion
  3213. */
  3214. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3215. /**
  3216. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3217. * @param alpha defines the rotation around first axis
  3218. * @param beta defines the rotation around second axis
  3219. * @param gamma defines the rotation around third axis
  3220. * @returns the new quaternion
  3221. */
  3222. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3223. /**
  3224. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3225. * @param alpha defines the rotation around first axis
  3226. * @param beta defines the rotation around second axis
  3227. * @param gamma defines the rotation around third axis
  3228. * @param result defines the target quaternion
  3229. */
  3230. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3231. /**
  3232. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3233. * @param axis1 defines the first axis
  3234. * @param axis2 defines the second axis
  3235. * @param axis3 defines the third axis
  3236. * @returns the new quaternion
  3237. */
  3238. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3239. /**
  3240. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3241. * @param axis1 defines the first axis
  3242. * @param axis2 defines the second axis
  3243. * @param axis3 defines the third axis
  3244. * @param ref defines the target quaternion
  3245. */
  3246. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3247. /**
  3248. * Interpolates between two quaternions
  3249. * @param left defines first quaternion
  3250. * @param right defines second quaternion
  3251. * @param amount defines the gradient to use
  3252. * @returns the new interpolated quaternion
  3253. */
  3254. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3255. /**
  3256. * Interpolates between two quaternions and stores it into a target quaternion
  3257. * @param left defines first quaternion
  3258. * @param right defines second quaternion
  3259. * @param amount defines the gradient to use
  3260. * @param result defines the target quaternion
  3261. */
  3262. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3263. /**
  3264. * Interpolate between two quaternions using Hermite interpolation
  3265. * @param value1 defines first quaternion
  3266. * @param tangent1 defines the incoming tangent
  3267. * @param value2 defines second quaternion
  3268. * @param tangent2 defines the outgoing tangent
  3269. * @param amount defines the target quaternion
  3270. * @returns the new interpolated quaternion
  3271. */
  3272. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3273. }
  3274. /**
  3275. * Class used to store matrix data (4x4)
  3276. */
  3277. export class Matrix {
  3278. private static _updateFlagSeed;
  3279. private static _identityReadOnly;
  3280. private _isIdentity;
  3281. private _isIdentityDirty;
  3282. private _isIdentity3x2;
  3283. private _isIdentity3x2Dirty;
  3284. /**
  3285. * Gets the update flag of the matrix which is an unique number for the matrix.
  3286. * It will be incremented every time the matrix data change.
  3287. * You can use it to speed the comparison between two versions of the same matrix.
  3288. */
  3289. updateFlag: number;
  3290. private readonly _m;
  3291. /**
  3292. * Gets the internal data of the matrix
  3293. */
  3294. readonly m: DeepImmutable<Float32Array>;
  3295. /** @hidden */ private _markAsUpdated(): void;
  3296. /** @hidden */
  3297. private _updateIdentityStatus;
  3298. /**
  3299. * Creates an empty matrix (filled with zeros)
  3300. */
  3301. constructor();
  3302. /**
  3303. * Check if the current matrix is identity
  3304. * @returns true is the matrix is the identity matrix
  3305. */
  3306. isIdentity(): boolean;
  3307. /**
  3308. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3309. * @returns true is the matrix is the identity matrix
  3310. */
  3311. isIdentityAs3x2(): boolean;
  3312. /**
  3313. * Gets the determinant of the matrix
  3314. * @returns the matrix determinant
  3315. */
  3316. determinant(): number;
  3317. /**
  3318. * Returns the matrix as a Float32Array
  3319. * @returns the matrix underlying array
  3320. */
  3321. toArray(): DeepImmutable<Float32Array>;
  3322. /**
  3323. * Returns the matrix as a Float32Array
  3324. * @returns the matrix underlying array.
  3325. */
  3326. asArray(): DeepImmutable<Float32Array>;
  3327. /**
  3328. * Inverts the current matrix in place
  3329. * @returns the current inverted matrix
  3330. */
  3331. invert(): Matrix;
  3332. /**
  3333. * Sets all the matrix elements to zero
  3334. * @returns the current matrix
  3335. */
  3336. reset(): Matrix;
  3337. /**
  3338. * Adds the current matrix with a second one
  3339. * @param other defines the matrix to add
  3340. * @returns a new matrix as the addition of the current matrix and the given one
  3341. */
  3342. add(other: DeepImmutable<Matrix>): Matrix;
  3343. /**
  3344. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3345. * @param other defines the matrix to add
  3346. * @param result defines the target matrix
  3347. * @returns the current matrix
  3348. */
  3349. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3350. /**
  3351. * Adds in place the given matrix to the current matrix
  3352. * @param other defines the second operand
  3353. * @returns the current updated matrix
  3354. */
  3355. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3356. /**
  3357. * Sets the given matrix to the current inverted Matrix
  3358. * @param other defines the target matrix
  3359. * @returns the unmodified current matrix
  3360. */
  3361. invertToRef(other: Matrix): Matrix;
  3362. /**
  3363. * add a value at the specified position in the current Matrix
  3364. * @param index the index of the value within the matrix. between 0 and 15.
  3365. * @param value the value to be added
  3366. * @returns the current updated matrix
  3367. */
  3368. addAtIndex(index: number, value: number): Matrix;
  3369. /**
  3370. * mutiply the specified position in the current Matrix by a value
  3371. * @param index the index of the value within the matrix. between 0 and 15.
  3372. * @param value the value to be added
  3373. * @returns the current updated matrix
  3374. */
  3375. multiplyAtIndex(index: number, value: number): Matrix;
  3376. /**
  3377. * Inserts the translation vector (using 3 floats) in the current matrix
  3378. * @param x defines the 1st component of the translation
  3379. * @param y defines the 2nd component of the translation
  3380. * @param z defines the 3rd component of the translation
  3381. * @returns the current updated matrix
  3382. */
  3383. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3384. /**
  3385. * Adds the translation vector (using 3 floats) in the current matrix
  3386. * @param x defines the 1st component of the translation
  3387. * @param y defines the 2nd component of the translation
  3388. * @param z defines the 3rd component of the translation
  3389. * @returns the current updated matrix
  3390. */
  3391. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3392. /**
  3393. * Inserts the translation vector in the current matrix
  3394. * @param vector3 defines the translation to insert
  3395. * @returns the current updated matrix
  3396. */
  3397. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3398. /**
  3399. * Gets the translation value of the current matrix
  3400. * @returns a new Vector3 as the extracted translation from the matrix
  3401. */
  3402. getTranslation(): Vector3;
  3403. /**
  3404. * Fill a Vector3 with the extracted translation from the matrix
  3405. * @param result defines the Vector3 where to store the translation
  3406. * @returns the current matrix
  3407. */
  3408. getTranslationToRef(result: Vector3): Matrix;
  3409. /**
  3410. * Remove rotation and scaling part from the matrix
  3411. * @returns the updated matrix
  3412. */
  3413. removeRotationAndScaling(): Matrix;
  3414. /**
  3415. * Multiply two matrices
  3416. * @param other defines the second operand
  3417. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3418. */
  3419. multiply(other: DeepImmutable<Matrix>): Matrix;
  3420. /**
  3421. * Copy the current matrix from the given one
  3422. * @param other defines the source matrix
  3423. * @returns the current updated matrix
  3424. */
  3425. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3426. /**
  3427. * Populates the given array from the starting index with the current matrix values
  3428. * @param array defines the target array
  3429. * @param offset defines the offset in the target array where to start storing values
  3430. * @returns the current matrix
  3431. */
  3432. copyToArray(array: Float32Array, offset?: number): Matrix;
  3433. /**
  3434. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3435. * @param other defines the second operand
  3436. * @param result defines the matrix where to store the multiplication
  3437. * @returns the current matrix
  3438. */
  3439. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3440. /**
  3441. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3442. * @param other defines the second operand
  3443. * @param result defines the array where to store the multiplication
  3444. * @param offset defines the offset in the target array where to start storing values
  3445. * @returns the current matrix
  3446. */
  3447. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3448. /**
  3449. * Check equality between this matrix and a second one
  3450. * @param value defines the second matrix to compare
  3451. * @returns true is the current matrix and the given one values are strictly equal
  3452. */
  3453. equals(value: DeepImmutable<Matrix>): boolean;
  3454. /**
  3455. * Clone the current matrix
  3456. * @returns a new matrix from the current matrix
  3457. */
  3458. clone(): Matrix;
  3459. /**
  3460. * Returns the name of the current matrix class
  3461. * @returns the string "Matrix"
  3462. */
  3463. getClassName(): string;
  3464. /**
  3465. * Gets the hash code of the current matrix
  3466. * @returns the hash code
  3467. */
  3468. getHashCode(): number;
  3469. /**
  3470. * Decomposes the current Matrix into a translation, rotation and scaling components
  3471. * @param scale defines the scale vector3 given as a reference to update
  3472. * @param rotation defines the rotation quaternion given as a reference to update
  3473. * @param translation defines the translation vector3 given as a reference to update
  3474. * @returns true if operation was successful
  3475. */
  3476. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3477. /**
  3478. * Gets specific row of the matrix
  3479. * @param index defines the number of the row to get
  3480. * @returns the index-th row of the current matrix as a new Vector4
  3481. */
  3482. getRow(index: number): Nullable<Vector4>;
  3483. /**
  3484. * Sets the index-th row of the current matrix to the vector4 values
  3485. * @param index defines the number of the row to set
  3486. * @param row defines the target vector4
  3487. * @returns the updated current matrix
  3488. */
  3489. setRow(index: number, row: Vector4): Matrix;
  3490. /**
  3491. * Compute the transpose of the matrix
  3492. * @returns the new transposed matrix
  3493. */
  3494. transpose(): Matrix;
  3495. /**
  3496. * Compute the transpose of the matrix and store it in a given matrix
  3497. * @param result defines the target matrix
  3498. * @returns the current matrix
  3499. */
  3500. transposeToRef(result: Matrix): Matrix;
  3501. /**
  3502. * Sets the index-th row of the current matrix with the given 4 x float values
  3503. * @param index defines the row index
  3504. * @param x defines the x component to set
  3505. * @param y defines the y component to set
  3506. * @param z defines the z component to set
  3507. * @param w defines the w component to set
  3508. * @returns the updated current matrix
  3509. */
  3510. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3511. /**
  3512. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3513. * @param scale defines the scale factor
  3514. * @returns a new matrix
  3515. */
  3516. scale(scale: number): Matrix;
  3517. /**
  3518. * Scale the current matrix values by a factor to a given result matrix
  3519. * @param scale defines the scale factor
  3520. * @param result defines the matrix to store the result
  3521. * @returns the current matrix
  3522. */
  3523. scaleToRef(scale: number, result: Matrix): Matrix;
  3524. /**
  3525. * Scale the current matrix values by a factor and add the result to a given matrix
  3526. * @param scale defines the scale factor
  3527. * @param result defines the Matrix to store the result
  3528. * @returns the current matrix
  3529. */
  3530. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3531. /**
  3532. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3533. * @param ref matrix to store the result
  3534. */
  3535. toNormalMatrix(ref: Matrix): void;
  3536. /**
  3537. * Gets only rotation part of the current matrix
  3538. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3539. */
  3540. getRotationMatrix(): Matrix;
  3541. /**
  3542. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3543. * @param result defines the target matrix to store data to
  3544. * @returns the current matrix
  3545. */
  3546. getRotationMatrixToRef(result: Matrix): Matrix;
  3547. /**
  3548. * Toggles model matrix from being right handed to left handed in place and vice versa
  3549. */
  3550. toggleModelMatrixHandInPlace(): void;
  3551. /**
  3552. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3553. */
  3554. toggleProjectionMatrixHandInPlace(): void;
  3555. /**
  3556. * Creates a matrix from an array
  3557. * @param array defines the source array
  3558. * @param offset defines an offset in the source array
  3559. * @returns a new Matrix set from the starting index of the given array
  3560. */
  3561. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3562. /**
  3563. * Copy the content of an array into a given matrix
  3564. * @param array defines the source array
  3565. * @param offset defines an offset in the source array
  3566. * @param result defines the target matrix
  3567. */
  3568. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3569. /**
  3570. * Stores an array into a matrix after having multiplied each component by a given factor
  3571. * @param array defines the source array
  3572. * @param offset defines the offset in the source array
  3573. * @param scale defines the scaling factor
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3577. /**
  3578. * Gets an identity matrix that must not be updated
  3579. */
  3580. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3581. /**
  3582. * Stores a list of values (16) inside a given matrix
  3583. * @param initialM11 defines 1st value of 1st row
  3584. * @param initialM12 defines 2nd value of 1st row
  3585. * @param initialM13 defines 3rd value of 1st row
  3586. * @param initialM14 defines 4th value of 1st row
  3587. * @param initialM21 defines 1st value of 2nd row
  3588. * @param initialM22 defines 2nd value of 2nd row
  3589. * @param initialM23 defines 3rd value of 2nd row
  3590. * @param initialM24 defines 4th value of 2nd row
  3591. * @param initialM31 defines 1st value of 3rd row
  3592. * @param initialM32 defines 2nd value of 3rd row
  3593. * @param initialM33 defines 3rd value of 3rd row
  3594. * @param initialM34 defines 4th value of 3rd row
  3595. * @param initialM41 defines 1st value of 4th row
  3596. * @param initialM42 defines 2nd value of 4th row
  3597. * @param initialM43 defines 3rd value of 4th row
  3598. * @param initialM44 defines 4th value of 4th row
  3599. * @param result defines the target matrix
  3600. */
  3601. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3602. /**
  3603. * Creates new matrix from a list of values (16)
  3604. * @param initialM11 defines 1st value of 1st row
  3605. * @param initialM12 defines 2nd value of 1st row
  3606. * @param initialM13 defines 3rd value of 1st row
  3607. * @param initialM14 defines 4th value of 1st row
  3608. * @param initialM21 defines 1st value of 2nd row
  3609. * @param initialM22 defines 2nd value of 2nd row
  3610. * @param initialM23 defines 3rd value of 2nd row
  3611. * @param initialM24 defines 4th value of 2nd row
  3612. * @param initialM31 defines 1st value of 3rd row
  3613. * @param initialM32 defines 2nd value of 3rd row
  3614. * @param initialM33 defines 3rd value of 3rd row
  3615. * @param initialM34 defines 4th value of 3rd row
  3616. * @param initialM41 defines 1st value of 4th row
  3617. * @param initialM42 defines 2nd value of 4th row
  3618. * @param initialM43 defines 3rd value of 4th row
  3619. * @param initialM44 defines 4th value of 4th row
  3620. * @returns the new matrix
  3621. */
  3622. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3623. /**
  3624. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3625. * @param scale defines the scale vector3
  3626. * @param rotation defines the rotation quaternion
  3627. * @param translation defines the translation vector3
  3628. * @returns a new matrix
  3629. */
  3630. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3631. /**
  3632. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3633. * @param scale defines the scale vector3
  3634. * @param rotation defines the rotation quaternion
  3635. * @param translation defines the translation vector3
  3636. * @param result defines the target matrix
  3637. */
  3638. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3639. /**
  3640. * Creates a new identity matrix
  3641. * @returns a new identity matrix
  3642. */
  3643. static Identity(): Matrix;
  3644. /**
  3645. * Creates a new identity matrix and stores the result in a given matrix
  3646. * @param result defines the target matrix
  3647. */
  3648. static IdentityToRef(result: Matrix): void;
  3649. /**
  3650. * Creates a new zero matrix
  3651. * @returns a new zero matrix
  3652. */
  3653. static Zero(): Matrix;
  3654. /**
  3655. * Creates a new rotation matrix for "angle" radians around the X axis
  3656. * @param angle defines the angle (in radians) to use
  3657. * @return the new matrix
  3658. */
  3659. static RotationX(angle: number): Matrix;
  3660. /**
  3661. * Creates a new matrix as the invert of a given matrix
  3662. * @param source defines the source matrix
  3663. * @returns the new matrix
  3664. */
  3665. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3668. * @param angle defines the angle (in radians) to use
  3669. * @param result defines the target matrix
  3670. */
  3671. static RotationXToRef(angle: number, result: Matrix): void;
  3672. /**
  3673. * Creates a new rotation matrix for "angle" radians around the Y axis
  3674. * @param angle defines the angle (in radians) to use
  3675. * @return the new matrix
  3676. */
  3677. static RotationY(angle: number): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationYToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Z axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationZ(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationZToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the given axis
  3698. * @param axis defines the axis to use
  3699. * @param angle defines the angle (in radians) to use
  3700. * @return the new matrix
  3701. */
  3702. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3703. /**
  3704. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3705. * @param axis defines the axis to use
  3706. * @param angle defines the angle (in radians) to use
  3707. * @param result defines the target matrix
  3708. */
  3709. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3710. /**
  3711. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3712. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3713. * @param from defines the vector to align
  3714. * @param to defines the vector to align to
  3715. * @param result defines the target matrix
  3716. */
  3717. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3718. /**
  3719. * Creates a rotation matrix
  3720. * @param yaw defines the yaw angle in radians (Y axis)
  3721. * @param pitch defines the pitch angle in radians (X axis)
  3722. * @param roll defines the roll angle in radians (X axis)
  3723. * @returns the new rotation matrix
  3724. */
  3725. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3726. /**
  3727. * Creates a rotation matrix and stores it in a given matrix
  3728. * @param yaw defines the yaw angle in radians (Y axis)
  3729. * @param pitch defines the pitch angle in radians (X axis)
  3730. * @param roll defines the roll angle in radians (X axis)
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3734. /**
  3735. * Creates a scaling matrix
  3736. * @param x defines the scale factor on X axis
  3737. * @param y defines the scale factor on Y axis
  3738. * @param z defines the scale factor on Z axis
  3739. * @returns the new matrix
  3740. */
  3741. static Scaling(x: number, y: number, z: number): Matrix;
  3742. /**
  3743. * Creates a scaling matrix and stores it in a given matrix
  3744. * @param x defines the scale factor on X axis
  3745. * @param y defines the scale factor on Y axis
  3746. * @param z defines the scale factor on Z axis
  3747. * @param result defines the target matrix
  3748. */
  3749. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3750. /**
  3751. * Creates a translation matrix
  3752. * @param x defines the translation on X axis
  3753. * @param y defines the translation on Y axis
  3754. * @param z defines the translationon Z axis
  3755. * @returns the new matrix
  3756. */
  3757. static Translation(x: number, y: number, z: number): Matrix;
  3758. /**
  3759. * Creates a translation matrix and stores it in a given matrix
  3760. * @param x defines the translation on X axis
  3761. * @param y defines the translation on Y axis
  3762. * @param z defines the translationon Z axis
  3763. * @param result defines the target matrix
  3764. */
  3765. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3766. /**
  3767. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3768. * @param startValue defines the start value
  3769. * @param endValue defines the end value
  3770. * @param gradient defines the gradient factor
  3771. * @returns the new matrix
  3772. */
  3773. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3774. /**
  3775. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3776. * @param startValue defines the start value
  3777. * @param endValue defines the end value
  3778. * @param gradient defines the gradient factor
  3779. * @param result defines the Matrix object where to store data
  3780. */
  3781. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3782. /**
  3783. * Builds a new matrix whose values are computed by:
  3784. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3785. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3786. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3787. * @param startValue defines the first matrix
  3788. * @param endValue defines the second matrix
  3789. * @param gradient defines the gradient between the two matrices
  3790. * @returns the new matrix
  3791. */
  3792. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3793. /**
  3794. * Update a matrix to values which are computed by:
  3795. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3796. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3797. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3798. * @param startValue defines the first matrix
  3799. * @param endValue defines the second matrix
  3800. * @param gradient defines the gradient between the two matrices
  3801. * @param result defines the target matrix
  3802. */
  3803. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3804. /**
  3805. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3806. * This function works in left handed mode
  3807. * @param eye defines the final position of the entity
  3808. * @param target defines where the entity should look at
  3809. * @param up defines the up vector for the entity
  3810. * @returns the new matrix
  3811. */
  3812. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3813. /**
  3814. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3815. * This function works in left handed mode
  3816. * @param eye defines the final position of the entity
  3817. * @param target defines where the entity should look at
  3818. * @param up defines the up vector for the entity
  3819. * @param result defines the target matrix
  3820. */
  3821. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3822. /**
  3823. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3824. * This function works in right handed mode
  3825. * @param eye defines the final position of the entity
  3826. * @param target defines where the entity should look at
  3827. * @param up defines the up vector for the entity
  3828. * @returns the new matrix
  3829. */
  3830. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3831. /**
  3832. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3833. * This function works in right handed mode
  3834. * @param eye defines the final position of the entity
  3835. * @param target defines where the entity should look at
  3836. * @param up defines the up vector for the entity
  3837. * @param result defines the target matrix
  3838. */
  3839. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3840. /**
  3841. * Create a left-handed orthographic projection matrix
  3842. * @param width defines the viewport width
  3843. * @param height defines the viewport height
  3844. * @param znear defines the near clip plane
  3845. * @param zfar defines the far clip plane
  3846. * @returns a new matrix as a left-handed orthographic projection matrix
  3847. */
  3848. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3849. /**
  3850. * Store a left-handed orthographic projection to a given matrix
  3851. * @param width defines the viewport width
  3852. * @param height defines the viewport height
  3853. * @param znear defines the near clip plane
  3854. * @param zfar defines the far clip plane
  3855. * @param result defines the target matrix
  3856. */
  3857. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3858. /**
  3859. * Create a left-handed orthographic projection matrix
  3860. * @param left defines the viewport left coordinate
  3861. * @param right defines the viewport right coordinate
  3862. * @param bottom defines the viewport bottom coordinate
  3863. * @param top defines the viewport top coordinate
  3864. * @param znear defines the near clip plane
  3865. * @param zfar defines the far clip plane
  3866. * @returns a new matrix as a left-handed orthographic projection matrix
  3867. */
  3868. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3869. /**
  3870. * Stores a left-handed orthographic projection into a given matrix
  3871. * @param left defines the viewport left coordinate
  3872. * @param right defines the viewport right coordinate
  3873. * @param bottom defines the viewport bottom coordinate
  3874. * @param top defines the viewport top coordinate
  3875. * @param znear defines the near clip plane
  3876. * @param zfar defines the far clip plane
  3877. * @param result defines the target matrix
  3878. */
  3879. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3880. /**
  3881. * Creates a right-handed orthographic projection matrix
  3882. * @param left defines the viewport left coordinate
  3883. * @param right defines the viewport right coordinate
  3884. * @param bottom defines the viewport bottom coordinate
  3885. * @param top defines the viewport top coordinate
  3886. * @param znear defines the near clip plane
  3887. * @param zfar defines the far clip plane
  3888. * @returns a new matrix as a right-handed orthographic projection matrix
  3889. */
  3890. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3891. /**
  3892. * Stores a right-handed orthographic projection into a given matrix
  3893. * @param left defines the viewport left coordinate
  3894. * @param right defines the viewport right coordinate
  3895. * @param bottom defines the viewport bottom coordinate
  3896. * @param top defines the viewport top coordinate
  3897. * @param znear defines the near clip plane
  3898. * @param zfar defines the far clip plane
  3899. * @param result defines the target matrix
  3900. */
  3901. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3902. /**
  3903. * Creates a left-handed perspective projection matrix
  3904. * @param width defines the viewport width
  3905. * @param height defines the viewport height
  3906. * @param znear defines the near clip plane
  3907. * @param zfar defines the far clip plane
  3908. * @returns a new matrix as a left-handed perspective projection matrix
  3909. */
  3910. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3911. /**
  3912. * Creates a left-handed perspective projection matrix
  3913. * @param fov defines the horizontal field of view
  3914. * @param aspect defines the aspect ratio
  3915. * @param znear defines the near clip plane
  3916. * @param zfar defines the far clip plane
  3917. * @returns a new matrix as a left-handed perspective projection matrix
  3918. */
  3919. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3920. /**
  3921. * Stores a left-handed perspective projection into a given matrix
  3922. * @param fov defines the horizontal field of view
  3923. * @param aspect defines the aspect ratio
  3924. * @param znear defines the near clip plane
  3925. * @param zfar defines the far clip plane
  3926. * @param result defines the target matrix
  3927. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3928. */
  3929. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3930. /**
  3931. * Creates a right-handed perspective projection matrix
  3932. * @param fov defines the horizontal field of view
  3933. * @param aspect defines the aspect ratio
  3934. * @param znear defines the near clip plane
  3935. * @param zfar defines the far clip plane
  3936. * @returns a new matrix as a right-handed perspective projection matrix
  3937. */
  3938. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3939. /**
  3940. * Stores a right-handed perspective projection into a given matrix
  3941. * @param fov defines the horizontal field of view
  3942. * @param aspect defines the aspect ratio
  3943. * @param znear defines the near clip plane
  3944. * @param zfar defines the far clip plane
  3945. * @param result defines the target matrix
  3946. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3947. */
  3948. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3949. /**
  3950. * Stores a perspective projection for WebVR info a given matrix
  3951. * @param fov defines the field of view
  3952. * @param znear defines the near clip plane
  3953. * @param zfar defines the far clip plane
  3954. * @param result defines the target matrix
  3955. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3956. */
  3957. static PerspectiveFovWebVRToRef(fov: {
  3958. upDegrees: number;
  3959. downDegrees: number;
  3960. leftDegrees: number;
  3961. rightDegrees: number;
  3962. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3963. /**
  3964. * Computes a complete transformation matrix
  3965. * @param viewport defines the viewport to use
  3966. * @param world defines the world matrix
  3967. * @param view defines the view matrix
  3968. * @param projection defines the projection matrix
  3969. * @param zmin defines the near clip plane
  3970. * @param zmax defines the far clip plane
  3971. * @returns the transformation matrix
  3972. */
  3973. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3974. /**
  3975. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3976. * @param matrix defines the matrix to use
  3977. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3978. */
  3979. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3980. /**
  3981. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3982. * @param matrix defines the matrix to use
  3983. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3984. */
  3985. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3986. /**
  3987. * Compute the transpose of a given matrix
  3988. * @param matrix defines the matrix to transpose
  3989. * @returns the new matrix
  3990. */
  3991. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3992. /**
  3993. * Compute the transpose of a matrix and store it in a target matrix
  3994. * @param matrix defines the matrix to transpose
  3995. * @param result defines the target matrix
  3996. */
  3997. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3998. /**
  3999. * Computes a reflection matrix from a plane
  4000. * @param plane defines the reflection plane
  4001. * @returns a new matrix
  4002. */
  4003. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4004. /**
  4005. * Computes a reflection matrix from a plane
  4006. * @param plane defines the reflection plane
  4007. * @param result defines the target matrix
  4008. */
  4009. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4010. /**
  4011. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4012. * @param xaxis defines the value of the 1st axis
  4013. * @param yaxis defines the value of the 2nd axis
  4014. * @param zaxis defines the value of the 3rd axis
  4015. * @param result defines the target matrix
  4016. */
  4017. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4018. /**
  4019. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4020. * @param quat defines the quaternion to use
  4021. * @param result defines the target matrix
  4022. */
  4023. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4024. }
  4025. /**
  4026. * @hidden
  4027. */
  4028. export class TmpVectors {
  4029. static Vector2: Vector2[];
  4030. static Vector3: Vector3[];
  4031. static Vector4: Vector4[];
  4032. static Quaternion: Quaternion[];
  4033. static Matrix: Matrix[];
  4034. }
  4035. }
  4036. declare module BABYLON {
  4037. /** Defines the cross module used constants to avoid circular dependncies */
  4038. export class Constants {
  4039. /** Defines that alpha blending is disabled */
  4040. static readonly ALPHA_DISABLE: number;
  4041. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4042. static readonly ALPHA_ADD: number;
  4043. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4044. static readonly ALPHA_COMBINE: number;
  4045. /** Defines that alpha blending to DEST - SRC * DEST */
  4046. static readonly ALPHA_SUBTRACT: number;
  4047. /** Defines that alpha blending to SRC * DEST */
  4048. static readonly ALPHA_MULTIPLY: number;
  4049. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4050. static readonly ALPHA_MAXIMIZED: number;
  4051. /** Defines that alpha blending to SRC + DEST */
  4052. static readonly ALPHA_ONEONE: number;
  4053. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4054. static readonly ALPHA_PREMULTIPLIED: number;
  4055. /**
  4056. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4057. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4058. */
  4059. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4060. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4061. static readonly ALPHA_INTERPOLATE: number;
  4062. /**
  4063. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4064. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4065. */
  4066. static readonly ALPHA_SCREENMODE: number;
  4067. /** Defines that the ressource is not delayed*/
  4068. static readonly DELAYLOADSTATE_NONE: number;
  4069. /** Defines that the ressource was successfully delay loaded */
  4070. static readonly DELAYLOADSTATE_LOADED: number;
  4071. /** Defines that the ressource is currently delay loading */
  4072. static readonly DELAYLOADSTATE_LOADING: number;
  4073. /** Defines that the ressource is delayed and has not started loading */
  4074. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4075. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4076. static readonly NEVER: number;
  4077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4078. static readonly ALWAYS: number;
  4079. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4080. static readonly LESS: number;
  4081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4082. static readonly EQUAL: number;
  4083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4084. static readonly LEQUAL: number;
  4085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4086. static readonly GREATER: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4088. static readonly GEQUAL: number;
  4089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4090. static readonly NOTEQUAL: number;
  4091. /** Passed to stencilOperation to specify that stencil value must be kept */
  4092. static readonly KEEP: number;
  4093. /** Passed to stencilOperation to specify that stencil value must be zero */
  4094. static readonly ZERO: number;
  4095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4096. static readonly REPLACE: number;
  4097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4098. static readonly INCR: number;
  4099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4100. static readonly DECR: number;
  4101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4102. static readonly INVERT: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4104. static readonly INCR_WRAP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4106. static readonly DECR_WRAP: number;
  4107. /** Texture is not repeating outside of 0..1 UVs */
  4108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4109. /** Texture is repeating outside of 0..1 UVs */
  4110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4111. /** Texture is repeating and mirrored */
  4112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4113. /** ALPHA */
  4114. static readonly TEXTUREFORMAT_ALPHA: number;
  4115. /** LUMINANCE */
  4116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4117. /** LUMINANCE_ALPHA */
  4118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4119. /** RGB */
  4120. static readonly TEXTUREFORMAT_RGB: number;
  4121. /** RGBA */
  4122. static readonly TEXTUREFORMAT_RGBA: number;
  4123. /** RED */
  4124. static readonly TEXTUREFORMAT_RED: number;
  4125. /** RED (2nd reference) */
  4126. static readonly TEXTUREFORMAT_R: number;
  4127. /** RG */
  4128. static readonly TEXTUREFORMAT_RG: number;
  4129. /** RED_INTEGER */
  4130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4131. /** RED_INTEGER (2nd reference) */
  4132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4133. /** RG_INTEGER */
  4134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4135. /** RGB_INTEGER */
  4136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4137. /** RGBA_INTEGER */
  4138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4139. /** UNSIGNED_BYTE */
  4140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4141. /** UNSIGNED_BYTE (2nd reference) */
  4142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4143. /** FLOAT */
  4144. static readonly TEXTURETYPE_FLOAT: number;
  4145. /** HALF_FLOAT */
  4146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4147. /** BYTE */
  4148. static readonly TEXTURETYPE_BYTE: number;
  4149. /** SHORT */
  4150. static readonly TEXTURETYPE_SHORT: number;
  4151. /** UNSIGNED_SHORT */
  4152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4153. /** INT */
  4154. static readonly TEXTURETYPE_INT: number;
  4155. /** UNSIGNED_INT */
  4156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4157. /** UNSIGNED_SHORT_4_4_4_4 */
  4158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4159. /** UNSIGNED_SHORT_5_5_5_1 */
  4160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4161. /** UNSIGNED_SHORT_5_6_5 */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4163. /** UNSIGNED_INT_2_10_10_10_REV */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4165. /** UNSIGNED_INT_24_8 */
  4166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4167. /** UNSIGNED_INT_10F_11F_11F_REV */
  4168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4169. /** UNSIGNED_INT_5_9_9_9_REV */
  4170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4173. /** nearest is mag = nearest and min = nearest and mip = linear */
  4174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4177. /** Trilinear is mag = linear and min = linear and mip = linear */
  4178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4179. /** nearest is mag = nearest and min = nearest and mip = linear */
  4180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4183. /** Trilinear is mag = linear and min = linear and mip = linear */
  4184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4185. /** mag = nearest and min = nearest and mip = nearest */
  4186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4187. /** mag = nearest and min = linear and mip = nearest */
  4188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4189. /** mag = nearest and min = linear and mip = linear */
  4190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4191. /** mag = nearest and min = linear and mip = none */
  4192. static readonly TEXTURE_NEAREST_LINEAR: number;
  4193. /** mag = nearest and min = nearest and mip = none */
  4194. static readonly TEXTURE_NEAREST_NEAREST: number;
  4195. /** mag = linear and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4197. /** mag = linear and min = nearest and mip = linear */
  4198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4199. /** mag = linear and min = linear and mip = none */
  4200. static readonly TEXTURE_LINEAR_LINEAR: number;
  4201. /** mag = linear and min = nearest and mip = none */
  4202. static readonly TEXTURE_LINEAR_NEAREST: number;
  4203. /** Explicit coordinates mode */
  4204. static readonly TEXTURE_EXPLICIT_MODE: number;
  4205. /** Spherical coordinates mode */
  4206. static readonly TEXTURE_SPHERICAL_MODE: number;
  4207. /** Planar coordinates mode */
  4208. static readonly TEXTURE_PLANAR_MODE: number;
  4209. /** Cubic coordinates mode */
  4210. static readonly TEXTURE_CUBIC_MODE: number;
  4211. /** Projection coordinates mode */
  4212. static readonly TEXTURE_PROJECTION_MODE: number;
  4213. /** Skybox coordinates mode */
  4214. static readonly TEXTURE_SKYBOX_MODE: number;
  4215. /** Inverse Cubic coordinates mode */
  4216. static readonly TEXTURE_INVCUBIC_MODE: number;
  4217. /** Equirectangular coordinates mode */
  4218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4219. /** Equirectangular Fixed coordinates mode */
  4220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4221. /** Equirectangular Fixed Mirrored coordinates mode */
  4222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4224. static readonly SCALEMODE_FLOOR: number;
  4225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4226. static readonly SCALEMODE_NEAREST: number;
  4227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4228. static readonly SCALEMODE_CEILING: number;
  4229. /**
  4230. * The dirty texture flag value
  4231. */
  4232. static readonly MATERIAL_TextureDirtyFlag: number;
  4233. /**
  4234. * The dirty light flag value
  4235. */
  4236. static readonly MATERIAL_LightDirtyFlag: number;
  4237. /**
  4238. * The dirty fresnel flag value
  4239. */
  4240. static readonly MATERIAL_FresnelDirtyFlag: number;
  4241. /**
  4242. * The dirty attribute flag value
  4243. */
  4244. static readonly MATERIAL_AttributesDirtyFlag: number;
  4245. /**
  4246. * The dirty misc flag value
  4247. */
  4248. static readonly MATERIAL_MiscDirtyFlag: number;
  4249. /**
  4250. * The all dirty flag value
  4251. */
  4252. static readonly MATERIAL_AllDirtyFlag: number;
  4253. /**
  4254. * Returns the triangle fill mode
  4255. */
  4256. static readonly MATERIAL_TriangleFillMode: number;
  4257. /**
  4258. * Returns the wireframe mode
  4259. */
  4260. static readonly MATERIAL_WireFrameFillMode: number;
  4261. /**
  4262. * Returns the point fill mode
  4263. */
  4264. static readonly MATERIAL_PointFillMode: number;
  4265. /**
  4266. * Returns the point list draw mode
  4267. */
  4268. static readonly MATERIAL_PointListDrawMode: number;
  4269. /**
  4270. * Returns the line list draw mode
  4271. */
  4272. static readonly MATERIAL_LineListDrawMode: number;
  4273. /**
  4274. * Returns the line loop draw mode
  4275. */
  4276. static readonly MATERIAL_LineLoopDrawMode: number;
  4277. /**
  4278. * Returns the line strip draw mode
  4279. */
  4280. static readonly MATERIAL_LineStripDrawMode: number;
  4281. /**
  4282. * Returns the triangle strip draw mode
  4283. */
  4284. static readonly MATERIAL_TriangleStripDrawMode: number;
  4285. /**
  4286. * Returns the triangle fan draw mode
  4287. */
  4288. static readonly MATERIAL_TriangleFanDrawMode: number;
  4289. /**
  4290. * Stores the clock-wise side orientation
  4291. */
  4292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4293. /**
  4294. * Stores the counter clock-wise side orientation
  4295. */
  4296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4297. /**
  4298. * Nothing
  4299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4300. */
  4301. static readonly ACTION_NothingTrigger: number;
  4302. /**
  4303. * On pick
  4304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4305. */
  4306. static readonly ACTION_OnPickTrigger: number;
  4307. /**
  4308. * On left pick
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_OnLeftPickTrigger: number;
  4312. /**
  4313. * On right pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnRightPickTrigger: number;
  4317. /**
  4318. * On center pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnCenterPickTrigger: number;
  4322. /**
  4323. * On pick down
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnPickDownTrigger: number;
  4327. /**
  4328. * On double pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnDoublePickTrigger: number;
  4332. /**
  4333. * On pick up
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickUpTrigger: number;
  4337. /**
  4338. * On pick out.
  4339. * This trigger will only be raised if you also declared a OnPickDown
  4340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4341. */
  4342. static readonly ACTION_OnPickOutTrigger: number;
  4343. /**
  4344. * On long press
  4345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4346. */
  4347. static readonly ACTION_OnLongPressTrigger: number;
  4348. /**
  4349. * On pointer over
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPointerOverTrigger: number;
  4353. /**
  4354. * On pointer out
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnPointerOutTrigger: number;
  4358. /**
  4359. * On every frame
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnEveryFrameTrigger: number;
  4363. /**
  4364. * On intersection enter
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4368. /**
  4369. * On intersection exit
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnIntersectionExitTrigger: number;
  4373. /**
  4374. * On key down
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnKeyDownTrigger: number;
  4378. /**
  4379. * On key up
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnKeyUpTrigger: number;
  4383. /**
  4384. * Billboard mode will only apply to Y axis
  4385. */
  4386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4387. /**
  4388. * Billboard mode will apply to all axes
  4389. */
  4390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4391. /**
  4392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4393. */
  4394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4395. /**
  4396. * Gets or sets base Assets URL
  4397. */
  4398. static PARTICLES_BaseAssetsUrl: string;
  4399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4400. * Test order :
  4401. * Is the bounding sphere outside the frustum ?
  4402. * If not, are the bounding box vertices outside the frustum ?
  4403. * It not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4406. /** Culling strategy : Bounding Sphere Only.
  4407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4408. * It's also less accurate than the standard because some not visible objects can still be selected.
  4409. * Test : is the bounding sphere outside the frustum ?
  4410. * If not, then the cullable object is in the frustum.
  4411. */
  4412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4413. /** Culling strategy : Optimistic Inclusion.
  4414. * This in an inclusion test first, then the standard exclusion test.
  4415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4416. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4417. * Anyway, it's as accurate as the standard strategy.
  4418. * Test :
  4419. * Is the cullable object bounding sphere center in the frustum ?
  4420. * If not, apply the default culling strategy.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4426. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4433. /**
  4434. * No logging while loading
  4435. */
  4436. static readonly SCENELOADER_NO_LOGGING: number;
  4437. /**
  4438. * Minimal logging while loading
  4439. */
  4440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4441. /**
  4442. * Summary logging while loading
  4443. */
  4444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4445. /**
  4446. * Detailled logging while loading
  4447. */
  4448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to store and describe the pipeline context associated with an effect
  4454. */
  4455. export interface IPipelineContext {
  4456. /**
  4457. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4458. */
  4459. isAsync: boolean;
  4460. /**
  4461. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4462. */
  4463. isReady: boolean;
  4464. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4465. /** @hidden */ private _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  4466. [key: string]: number;
  4467. }, uniformsNames: string[], uniforms: {
  4468. [key: string]: Nullable<WebGLUniformLocation>;
  4469. }, samplerList: string[], samplers: {
  4470. [key: string]: number;
  4471. }, attributesNames: string[], attributes: number[]): void;
  4472. /** Releases the resources associated with the pipeline. */
  4473. dispose(): void;
  4474. /**
  4475. * Sets an interger value on a uniform variable.
  4476. * @param uniformName Name of the variable.
  4477. * @param value Value to be set.
  4478. */
  4479. setInt(uniformName: string, value: number): void;
  4480. /**
  4481. * Sets an int array on a uniform variable.
  4482. * @param uniformName Name of the variable.
  4483. * @param array array to be set.
  4484. */
  4485. setIntArray(uniformName: string, array: Int32Array): void;
  4486. /**
  4487. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  4488. * @param uniformName Name of the variable.
  4489. * @param array array to be set.
  4490. */
  4491. setIntArray2(uniformName: string, array: Int32Array): void;
  4492. /**
  4493. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  4494. * @param uniformName Name of the variable.
  4495. * @param array array to be set.
  4496. */
  4497. setIntArray3(uniformName: string, array: Int32Array): void;
  4498. /**
  4499. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  4500. * @param uniformName Name of the variable.
  4501. * @param array array to be set.
  4502. */
  4503. setIntArray4(uniformName: string, array: Int32Array): void;
  4504. /**
  4505. * Sets an float array on a uniform variable.
  4506. * @param uniformName Name of the variable.
  4507. * @param array array to be set.
  4508. */
  4509. setFloatArray(uniformName: string, array: Float32Array): void;
  4510. /**
  4511. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  4512. * @param uniformName Name of the variable.
  4513. * @param array array to be set.
  4514. */
  4515. setFloatArray2(uniformName: string, array: Float32Array): void;
  4516. /**
  4517. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  4518. * @param uniformName Name of the variable.
  4519. * @param array array to be set.
  4520. */
  4521. setFloatArray3(uniformName: string, array: Float32Array): void;
  4522. /**
  4523. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  4524. * @param uniformName Name of the variable.
  4525. * @param array array to be set.
  4526. */
  4527. setFloatArray4(uniformName: string, array: Float32Array): void;
  4528. /**
  4529. * Sets an array on a uniform variable.
  4530. * @param uniformName Name of the variable.
  4531. * @param array array to be set.
  4532. */
  4533. setArray(uniformName: string, array: number[]): void;
  4534. /**
  4535. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  4536. * @param uniformName Name of the variable.
  4537. * @param array array to be set.
  4538. */
  4539. setArray2(uniformName: string, array: number[]): void;
  4540. /**
  4541. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  4542. * @param uniformName Name of the variable.
  4543. * @param array array to be set.
  4544. */
  4545. setArray3(uniformName: string, array: number[]): void;
  4546. /**
  4547. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  4548. * @param uniformName Name of the variable.
  4549. * @param array array to be set.
  4550. */
  4551. setArray4(uniformName: string, array: number[]): void;
  4552. /**
  4553. * Sets matrices on a uniform variable.
  4554. * @param uniformName Name of the variable.
  4555. * @param matrices matrices to be set.
  4556. */
  4557. setMatrices(uniformName: string, matrices: Float32Array): void;
  4558. /**
  4559. * Sets matrix on a uniform variable.
  4560. * @param uniformName Name of the variable.
  4561. * @param matrix matrix to be set.
  4562. */
  4563. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  4564. /**
  4565. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  4566. * @param uniformName Name of the variable.
  4567. * @param matrix matrix to be set.
  4568. */
  4569. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  4570. /**
  4571. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  4572. * @param uniformName Name of the variable.
  4573. * @param matrix matrix to be set.
  4574. */
  4575. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  4576. /**
  4577. * Sets a float on a uniform variable.
  4578. * @param uniformName Name of the variable.
  4579. * @param value value to be set.
  4580. */
  4581. setFloat(uniformName: string, value: number): void;
  4582. /**
  4583. * Sets a boolean on a uniform variable.
  4584. * @param uniformName Name of the variable.
  4585. * @param bool value to be set.
  4586. */
  4587. setBool(uniformName: string, bool: boolean): void;
  4588. /**
  4589. * Sets a Vector2 on a uniform variable.
  4590. * @param uniformName Name of the variable.
  4591. * @param vector2 vector2 to be set.
  4592. */
  4593. setVector2(uniformName: string, vector2: IVector2Like): void;
  4594. /**
  4595. * Sets a float2 on a uniform variable.
  4596. * @param uniformName Name of the variable.
  4597. * @param x First float in float2.
  4598. * @param y Second float in float2.
  4599. */
  4600. setFloat2(uniformName: string, x: number, y: number): void;
  4601. /**
  4602. * Sets a Vector3 on a uniform variable.
  4603. * @param uniformName Name of the variable.
  4604. * @param vector3 Value to be set.
  4605. */
  4606. setVector3(uniformName: string, vector3: IVector3Like): void;
  4607. /**
  4608. * Sets a float3 on a uniform variable.
  4609. * @param uniformName Name of the variable.
  4610. * @param x First float in float3.
  4611. * @param y Second float in float3.
  4612. * @param z Third float in float3.
  4613. */
  4614. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  4615. /**
  4616. * Sets a Vector4 on a uniform variable.
  4617. * @param uniformName Name of the variable.
  4618. * @param vector4 Value to be set.
  4619. */
  4620. setVector4(uniformName: string, vector4: IVector4Like): void;
  4621. /**
  4622. * Sets a float4 on a uniform variable.
  4623. * @param uniformName Name of the variable.
  4624. * @param x First float in float4.
  4625. * @param y Second float in float4.
  4626. * @param z Third float in float4.
  4627. * @param w Fourth float in float4.
  4628. */
  4629. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  4630. /**
  4631. * Sets a Color3 on a uniform variable.
  4632. * @param uniformName Name of the variable.
  4633. * @param color3 Value to be set.
  4634. */
  4635. setColor3(uniformName: string, color3: IColor3Like): void;
  4636. /**
  4637. * Sets a Color4 on a uniform variable.
  4638. * @param uniformName Name of the variable.
  4639. * @param color3 Value to be set.
  4640. * @param alpha Alpha value to be set.
  4641. */
  4642. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  4643. /**
  4644. * Sets a Color4 on a uniform variable
  4645. * @param uniformName defines the name of the variable
  4646. * @param color4 defines the value to be set
  4647. */
  4648. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  4649. }
  4650. }
  4651. declare module BABYLON {
  4652. /** @hidden */
  4653. export interface IShaderProcessor {
  4654. attributeProcessor?: (attribute: string, processingContext: Nullable<ShaderProcessingContext>) => string;
  4655. varyingProcessor?: (varying: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  4656. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  4657. [key: string]: string;
  4658. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  4659. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  4660. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  4661. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  4662. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  4663. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  4664. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  4665. vertexCode: string;
  4666. fragmentCode: string;
  4667. };
  4668. }
  4669. }
  4670. declare module BABYLON {
  4671. /** @hidden */
  4672. export interface ShaderProcessingContext {
  4673. }
  4674. /** @hidden */
  4675. export interface ProcessingOptions {
  4676. defines: string[];
  4677. indexParameters: any;
  4678. isFragment: boolean;
  4679. shouldUseHighPrecisionShader: boolean;
  4680. supportsUniformBuffers: boolean;
  4681. shadersRepository: string;
  4682. includesShadersStore: {
  4683. [key: string]: string;
  4684. };
  4685. processor: Nullable<IShaderProcessor>;
  4686. version: string;
  4687. platformName: string;
  4688. lookForClosingBracketForUniformBuffer?: boolean;
  4689. processingContext: Nullable<ShaderProcessingContext>;
  4690. }
  4691. }
  4692. declare module BABYLON {
  4693. /**
  4694. * Helper to manipulate strings
  4695. */
  4696. export class StringTools {
  4697. /**
  4698. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4699. * @param str Source string
  4700. * @param suffix Suffix to search for in the source string
  4701. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4702. */
  4703. static EndsWith(str: string, suffix: string): boolean;
  4704. /**
  4705. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4706. * @param str Source string
  4707. * @param suffix Suffix to search for in the source string
  4708. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4709. */
  4710. static StartsWith(str: string, suffix: string): boolean;
  4711. }
  4712. }
  4713. declare module BABYLON {
  4714. /** @hidden */
  4715. export class ShaderCodeNode {
  4716. line: string;
  4717. children: ShaderCodeNode[];
  4718. additionalDefineKey?: string;
  4719. additionalDefineValue?: string;
  4720. isValid(preprocessors: {
  4721. [key: string]: string;
  4722. }): boolean;
  4723. process(preprocessors: {
  4724. [key: string]: string;
  4725. }, options: ProcessingOptions): string;
  4726. }
  4727. }
  4728. declare module BABYLON {
  4729. /** @hidden */
  4730. export class ShaderCodeCursor {
  4731. private _lines;
  4732. lineIndex: number;
  4733. readonly currentLine: string;
  4734. readonly canRead: boolean;
  4735. lines: string[];
  4736. }
  4737. }
  4738. declare module BABYLON {
  4739. /** @hidden */
  4740. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4741. process(preprocessors: {
  4742. [key: string]: string;
  4743. }, options: ProcessingOptions): string;
  4744. }
  4745. }
  4746. declare module BABYLON {
  4747. /** @hidden */
  4748. export class ShaderDefineExpression {
  4749. isTrue(preprocessors: {
  4750. [key: string]: string;
  4751. }): boolean;
  4752. }
  4753. }
  4754. declare module BABYLON {
  4755. /** @hidden */
  4756. export class ShaderCodeTestNode extends ShaderCodeNode {
  4757. testExpression: ShaderDefineExpression;
  4758. isValid(preprocessors: {
  4759. [key: string]: string;
  4760. }): boolean;
  4761. }
  4762. }
  4763. declare module BABYLON {
  4764. /** @hidden */
  4765. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4766. define: string;
  4767. not: boolean;
  4768. constructor(define: string, not?: boolean);
  4769. isTrue(preprocessors: {
  4770. [key: string]: string;
  4771. }): boolean;
  4772. }
  4773. }
  4774. declare module BABYLON {
  4775. /** @hidden */
  4776. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4777. leftOperand: ShaderDefineExpression;
  4778. rightOperand: ShaderDefineExpression;
  4779. isTrue(preprocessors: {
  4780. [key: string]: string;
  4781. }): boolean;
  4782. }
  4783. }
  4784. declare module BABYLON {
  4785. /** @hidden */
  4786. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4787. leftOperand: ShaderDefineExpression;
  4788. rightOperand: ShaderDefineExpression;
  4789. isTrue(preprocessors: {
  4790. [key: string]: string;
  4791. }): boolean;
  4792. }
  4793. }
  4794. declare module BABYLON {
  4795. /** @hidden */
  4796. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4797. define: string;
  4798. operand: string;
  4799. testValue: string;
  4800. constructor(define: string, operand: string, testValue: string);
  4801. isTrue(preprocessors: {
  4802. [key: string]: string;
  4803. }): boolean;
  4804. }
  4805. }
  4806. declare module BABYLON {
  4807. /**
  4808. * @ignore
  4809. * Application error to support additional information when loading a file
  4810. */
  4811. export class LoadFileError extends Error {
  4812. /** defines the optional web request */
  4813. request?: WebRequest | undefined;
  4814. private static _setPrototypeOf;
  4815. /**
  4816. * Creates a new LoadFileError
  4817. * @param message defines the message of the error
  4818. * @param request defines the optional web request
  4819. */
  4820. constructor(message: string,
  4821. /** defines the optional web request */
  4822. request?: WebRequest | undefined);
  4823. }
  4824. }
  4825. declare module BABYLON {
  4826. /**
  4827. * Class used to enable access to offline support
  4828. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4829. */
  4830. export interface IOfflineProvider {
  4831. /**
  4832. * Gets a boolean indicating if scene must be saved in the database
  4833. */
  4834. enableSceneOffline: boolean;
  4835. /**
  4836. * Gets a boolean indicating if textures must be saved in the database
  4837. */
  4838. enableTexturesOffline: boolean;
  4839. /**
  4840. * Open the offline support and make it available
  4841. * @param successCallback defines the callback to call on success
  4842. * @param errorCallback defines the callback to call on error
  4843. */
  4844. open(successCallback: () => void, errorCallback: () => void): void;
  4845. /**
  4846. * Loads an image from the offline support
  4847. * @param url defines the url to load from
  4848. * @param image defines the target DOM image
  4849. */
  4850. loadImage(url: string, image: HTMLImageElement): void;
  4851. /**
  4852. * Loads a file from offline support
  4853. * @param url defines the URL to load from
  4854. * @param sceneLoaded defines a callback to call on success
  4855. * @param progressCallBack defines a callback to call when progress changed
  4856. * @param errorCallback defines a callback to call on error
  4857. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4858. */
  4859. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4860. }
  4861. }
  4862. declare module BABYLON {
  4863. /**
  4864. * Class used to help managing file picking and drag'n'drop
  4865. * File Storage
  4866. */
  4867. export class FilesInputStore {
  4868. /**
  4869. * List of files ready to be loaded
  4870. */
  4871. static FilesToLoad: {
  4872. [key: string]: File;
  4873. };
  4874. }
  4875. }
  4876. declare module BABYLON {
  4877. /**
  4878. * Class used to define a retry strategy when error happens while loading assets
  4879. */
  4880. export class RetryStrategy {
  4881. /**
  4882. * Function used to defines an exponential back off strategy
  4883. * @param maxRetries defines the maximum number of retries (3 by default)
  4884. * @param baseInterval defines the interval between retries
  4885. * @returns the strategy function to use
  4886. */
  4887. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4888. }
  4889. }
  4890. declare module BABYLON {
  4891. /**
  4892. * @hidden
  4893. */
  4894. export class FileTools {
  4895. /**
  4896. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4897. */
  4898. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4899. /**
  4900. * Gets or sets the base URL to use to load assets
  4901. */
  4902. static BaseUrl: string;
  4903. /**
  4904. * Default behaviour for cors in the application.
  4905. * It can be a string if the expected behavior is identical in the entire app.
  4906. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4907. */
  4908. static CorsBehavior: string | ((url: string | string[]) => string);
  4909. /**
  4910. * Gets or sets a function used to pre-process url before using them to load assets
  4911. */
  4912. static PreprocessUrl: (url: string) => string;
  4913. /**
  4914. * Removes unwanted characters from an url
  4915. * @param url defines the url to clean
  4916. * @returns the cleaned url
  4917. */
  4918. private static _CleanUrl;
  4919. /**
  4920. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4921. * @param url define the url we are trying
  4922. * @param element define the dom element where to configure the cors policy
  4923. */
  4924. static SetCorsBehavior(url: string | string[], element: {
  4925. crossOrigin: string | null;
  4926. }): void;
  4927. /**
  4928. * Loads an image as an HTMLImageElement.
  4929. * @param input url string, ArrayBuffer, or Blob to load
  4930. * @param onLoad callback called when the image successfully loads
  4931. * @param onError callback called when the image fails to load
  4932. * @param offlineProvider offline provider for caching
  4933. * @returns the HTMLImageElement of the loaded image
  4934. */
  4935. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4936. /**
  4937. * Loads a file
  4938. * @param fileToLoad defines the file to load
  4939. * @param callback defines the callback to call when data is loaded
  4940. * @param progressCallBack defines the callback to call during loading process
  4941. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4942. * @returns a file request object
  4943. */
  4944. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4945. /**
  4946. * Loads a file
  4947. * @param url url string, ArrayBuffer, or Blob to load
  4948. * @param onSuccess callback called when the file successfully loads
  4949. * @param onProgress callback called while file is loading (if the server supports this mode)
  4950. * @param offlineProvider defines the offline provider for caching
  4951. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4952. * @param onError callback called when the file fails to load
  4953. * @returns a file request object
  4954. */
  4955. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4956. /**
  4957. * Checks if the loaded document was accessed via `file:`-Protocol.
  4958. * @returns boolean
  4959. */
  4960. static IsFileURL(): boolean;
  4961. }
  4962. }
  4963. declare module BABYLON {
  4964. /** @hidden */
  4965. export class ShaderProcessor {
  4966. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4967. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  4968. vertexCode: string;
  4969. fragmentCode: string;
  4970. };
  4971. private static _ProcessPrecision;
  4972. private static _ExtractOperation;
  4973. private static _BuildSubExpression;
  4974. private static _BuildExpression;
  4975. private static _MoveCursorWithinIf;
  4976. private static _MoveCursor;
  4977. private static _EvaluatePreProcessors;
  4978. private static _PreparePreProcessors;
  4979. private static _ProcessShaderConversion;
  4980. private static _ProcessIncludes;
  4981. }
  4982. }
  4983. declare module BABYLON {
  4984. /**
  4985. * Class used to hold a RBG color
  4986. */
  4987. export class Color3 {
  4988. /**
  4989. * Defines the red component (between 0 and 1, default is 0)
  4990. */
  4991. r: number;
  4992. /**
  4993. * Defines the green component (between 0 and 1, default is 0)
  4994. */
  4995. g: number;
  4996. /**
  4997. * Defines the blue component (between 0 and 1, default is 0)
  4998. */
  4999. b: number;
  5000. /**
  5001. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5002. * @param r defines the red component (between 0 and 1, default is 0)
  5003. * @param g defines the green component (between 0 and 1, default is 0)
  5004. * @param b defines the blue component (between 0 and 1, default is 0)
  5005. */
  5006. constructor(
  5007. /**
  5008. * Defines the red component (between 0 and 1, default is 0)
  5009. */
  5010. r?: number,
  5011. /**
  5012. * Defines the green component (between 0 and 1, default is 0)
  5013. */
  5014. g?: number,
  5015. /**
  5016. * Defines the blue component (between 0 and 1, default is 0)
  5017. */
  5018. b?: number);
  5019. /**
  5020. * Creates a string with the Color3 current values
  5021. * @returns the string representation of the Color3 object
  5022. */
  5023. toString(): string;
  5024. /**
  5025. * Returns the string "Color3"
  5026. * @returns "Color3"
  5027. */
  5028. getClassName(): string;
  5029. /**
  5030. * Compute the Color3 hash code
  5031. * @returns an unique number that can be used to hash Color3 objects
  5032. */
  5033. getHashCode(): number;
  5034. /**
  5035. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5036. * @param array defines the array where to store the r,g,b components
  5037. * @param index defines an optional index in the target array to define where to start storing values
  5038. * @returns the current Color3 object
  5039. */
  5040. toArray(array: FloatArray, index?: number): Color3;
  5041. /**
  5042. * Returns a new Color4 object from the current Color3 and the given alpha
  5043. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5044. * @returns a new Color4 object
  5045. */
  5046. toColor4(alpha?: number): Color4;
  5047. /**
  5048. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5049. * @returns the new array
  5050. */
  5051. asArray(): number[];
  5052. /**
  5053. * Returns the luminance value
  5054. * @returns a float value
  5055. */
  5056. toLuminance(): number;
  5057. /**
  5058. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5059. * @param otherColor defines the second operand
  5060. * @returns the new Color3 object
  5061. */
  5062. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5063. /**
  5064. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5065. * @param otherColor defines the second operand
  5066. * @param result defines the Color3 object where to store the result
  5067. * @returns the current Color3
  5068. */
  5069. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5070. /**
  5071. * Determines equality between Color3 objects
  5072. * @param otherColor defines the second operand
  5073. * @returns true if the rgb values are equal to the given ones
  5074. */
  5075. equals(otherColor: DeepImmutable<Color3>): boolean;
  5076. /**
  5077. * Determines equality between the current Color3 object and a set of r,b,g values
  5078. * @param r defines the red component to check
  5079. * @param g defines the green component to check
  5080. * @param b defines the blue component to check
  5081. * @returns true if the rgb values are equal to the given ones
  5082. */
  5083. equalsFloats(r: number, g: number, b: number): boolean;
  5084. /**
  5085. * Multiplies in place each rgb value by scale
  5086. * @param scale defines the scaling factor
  5087. * @returns the updated Color3
  5088. */
  5089. scale(scale: number): Color3;
  5090. /**
  5091. * Multiplies the rgb values by scale and stores the result into "result"
  5092. * @param scale defines the scaling factor
  5093. * @param result defines the Color3 object where to store the result
  5094. * @returns the unmodified current Color3
  5095. */
  5096. scaleToRef(scale: number, result: Color3): Color3;
  5097. /**
  5098. * Scale the current Color3 values by a factor and add the result to a given Color3
  5099. * @param scale defines the scale factor
  5100. * @param result defines color to store the result into
  5101. * @returns the unmodified current Color3
  5102. */
  5103. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5104. /**
  5105. * Clamps the rgb values by the min and max values and stores the result into "result"
  5106. * @param min defines minimum clamping value (default is 0)
  5107. * @param max defines maximum clamping value (default is 1)
  5108. * @param result defines color to store the result into
  5109. * @returns the original Color3
  5110. */
  5111. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5112. /**
  5113. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5114. * @param otherColor defines the second operand
  5115. * @returns the new Color3
  5116. */
  5117. add(otherColor: DeepImmutable<Color3>): Color3;
  5118. /**
  5119. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5120. * @param otherColor defines the second operand
  5121. * @param result defines Color3 object to store the result into
  5122. * @returns the unmodified current Color3
  5123. */
  5124. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5125. /**
  5126. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5127. * @param otherColor defines the second operand
  5128. * @returns the new Color3
  5129. */
  5130. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5131. /**
  5132. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5133. * @param otherColor defines the second operand
  5134. * @param result defines Color3 object to store the result into
  5135. * @returns the unmodified current Color3
  5136. */
  5137. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5138. /**
  5139. * Copy the current object
  5140. * @returns a new Color3 copied the current one
  5141. */
  5142. clone(): Color3;
  5143. /**
  5144. * Copies the rgb values from the source in the current Color3
  5145. * @param source defines the source Color3 object
  5146. * @returns the updated Color3 object
  5147. */
  5148. copyFrom(source: DeepImmutable<Color3>): Color3;
  5149. /**
  5150. * Updates the Color3 rgb values from the given floats
  5151. * @param r defines the red component to read from
  5152. * @param g defines the green component to read from
  5153. * @param b defines the blue component to read from
  5154. * @returns the current Color3 object
  5155. */
  5156. copyFromFloats(r: number, g: number, b: number): Color3;
  5157. /**
  5158. * Updates the Color3 rgb values from the given floats
  5159. * @param r defines the red component to read from
  5160. * @param g defines the green component to read from
  5161. * @param b defines the blue component to read from
  5162. * @returns the current Color3 object
  5163. */
  5164. set(r: number, g: number, b: number): Color3;
  5165. /**
  5166. * Compute the Color3 hexadecimal code as a string
  5167. * @returns a string containing the hexadecimal representation of the Color3 object
  5168. */
  5169. toHexString(): string;
  5170. /**
  5171. * Computes a new Color3 converted from the current one to linear space
  5172. * @returns a new Color3 object
  5173. */
  5174. toLinearSpace(): Color3;
  5175. /**
  5176. * Converts current color in rgb space to HSV values
  5177. * @returns a new color3 representing the HSV values
  5178. */
  5179. toHSV(): Color3;
  5180. /**
  5181. * Converts current color in rgb space to HSV values
  5182. * @param result defines the Color3 where to store the HSV values
  5183. */
  5184. toHSVToRef(result: Color3): void;
  5185. /**
  5186. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5187. * @param convertedColor defines the Color3 object where to store the linear space version
  5188. * @returns the unmodified Color3
  5189. */
  5190. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5191. /**
  5192. * Computes a new Color3 converted from the current one to gamma space
  5193. * @returns a new Color3 object
  5194. */
  5195. toGammaSpace(): Color3;
  5196. /**
  5197. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5198. * @param convertedColor defines the Color3 object where to store the gamma space version
  5199. * @returns the unmodified Color3
  5200. */
  5201. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5202. private static _BlackReadOnly;
  5203. /**
  5204. * Convert Hue, saturation and value to a Color3 (RGB)
  5205. * @param hue defines the hue
  5206. * @param saturation defines the saturation
  5207. * @param value defines the value
  5208. * @param result defines the Color3 where to store the RGB values
  5209. */
  5210. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5211. /**
  5212. * Creates a new Color3 from the string containing valid hexadecimal values
  5213. * @param hex defines a string containing valid hexadecimal values
  5214. * @returns a new Color3 object
  5215. */
  5216. static FromHexString(hex: string): Color3;
  5217. /**
  5218. * Creates a new Color3 from the starting index of the given array
  5219. * @param array defines the source array
  5220. * @param offset defines an offset in the source array
  5221. * @returns a new Color3 object
  5222. */
  5223. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5224. /**
  5225. * Creates a new Color3 from integer values (< 256)
  5226. * @param r defines the red component to read from (value between 0 and 255)
  5227. * @param g defines the green component to read from (value between 0 and 255)
  5228. * @param b defines the blue component to read from (value between 0 and 255)
  5229. * @returns a new Color3 object
  5230. */
  5231. static FromInts(r: number, g: number, b: number): Color3;
  5232. /**
  5233. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5234. * @param start defines the start Color3 value
  5235. * @param end defines the end Color3 value
  5236. * @param amount defines the gradient value between start and end
  5237. * @returns a new Color3 object
  5238. */
  5239. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5240. /**
  5241. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5242. * @param left defines the start value
  5243. * @param right defines the end value
  5244. * @param amount defines the gradient factor
  5245. * @param result defines the Color3 object where to store the result
  5246. */
  5247. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5248. /**
  5249. * Returns a Color3 value containing a red color
  5250. * @returns a new Color3 object
  5251. */
  5252. static Red(): Color3;
  5253. /**
  5254. * Returns a Color3 value containing a green color
  5255. * @returns a new Color3 object
  5256. */
  5257. static Green(): Color3;
  5258. /**
  5259. * Returns a Color3 value containing a blue color
  5260. * @returns a new Color3 object
  5261. */
  5262. static Blue(): Color3;
  5263. /**
  5264. * Returns a Color3 value containing a black color
  5265. * @returns a new Color3 object
  5266. */
  5267. static Black(): Color3;
  5268. /**
  5269. * Gets a Color3 value containing a black color that must not be updated
  5270. */
  5271. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5272. /**
  5273. * Returns a Color3 value containing a white color
  5274. * @returns a new Color3 object
  5275. */
  5276. static White(): Color3;
  5277. /**
  5278. * Returns a Color3 value containing a purple color
  5279. * @returns a new Color3 object
  5280. */
  5281. static Purple(): Color3;
  5282. /**
  5283. * Returns a Color3 value containing a magenta color
  5284. * @returns a new Color3 object
  5285. */
  5286. static Magenta(): Color3;
  5287. /**
  5288. * Returns a Color3 value containing a yellow color
  5289. * @returns a new Color3 object
  5290. */
  5291. static Yellow(): Color3;
  5292. /**
  5293. * Returns a Color3 value containing a gray color
  5294. * @returns a new Color3 object
  5295. */
  5296. static Gray(): Color3;
  5297. /**
  5298. * Returns a Color3 value containing a teal color
  5299. * @returns a new Color3 object
  5300. */
  5301. static Teal(): Color3;
  5302. /**
  5303. * Returns a Color3 value containing a random color
  5304. * @returns a new Color3 object
  5305. */
  5306. static Random(): Color3;
  5307. }
  5308. /**
  5309. * Class used to hold a RBGA color
  5310. */
  5311. export class Color4 {
  5312. /**
  5313. * Defines the red component (between 0 and 1, default is 0)
  5314. */
  5315. r: number;
  5316. /**
  5317. * Defines the green component (between 0 and 1, default is 0)
  5318. */
  5319. g: number;
  5320. /**
  5321. * Defines the blue component (between 0 and 1, default is 0)
  5322. */
  5323. b: number;
  5324. /**
  5325. * Defines the alpha component (between 0 and 1, default is 1)
  5326. */
  5327. a: number;
  5328. /**
  5329. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5330. * @param r defines the red component (between 0 and 1, default is 0)
  5331. * @param g defines the green component (between 0 and 1, default is 0)
  5332. * @param b defines the blue component (between 0 and 1, default is 0)
  5333. * @param a defines the alpha component (between 0 and 1, default is 1)
  5334. */
  5335. constructor(
  5336. /**
  5337. * Defines the red component (between 0 and 1, default is 0)
  5338. */
  5339. r?: number,
  5340. /**
  5341. * Defines the green component (between 0 and 1, default is 0)
  5342. */
  5343. g?: number,
  5344. /**
  5345. * Defines the blue component (between 0 and 1, default is 0)
  5346. */
  5347. b?: number,
  5348. /**
  5349. * Defines the alpha component (between 0 and 1, default is 1)
  5350. */
  5351. a?: number);
  5352. /**
  5353. * Adds in place the given Color4 values to the current Color4 object
  5354. * @param right defines the second operand
  5355. * @returns the current updated Color4 object
  5356. */
  5357. addInPlace(right: DeepImmutable<Color4>): Color4;
  5358. /**
  5359. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5360. * @returns the new array
  5361. */
  5362. asArray(): number[];
  5363. /**
  5364. * Stores from the starting index in the given array the Color4 successive values
  5365. * @param array defines the array where to store the r,g,b components
  5366. * @param index defines an optional index in the target array to define where to start storing values
  5367. * @returns the current Color4 object
  5368. */
  5369. toArray(array: number[], index?: number): Color4;
  5370. /**
  5371. * Determines equality between Color4 objects
  5372. * @param otherColor defines the second operand
  5373. * @returns true if the rgba values are equal to the given ones
  5374. */
  5375. equals(otherColor: DeepImmutable<Color4>): boolean;
  5376. /**
  5377. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5378. * @param right defines the second operand
  5379. * @returns a new Color4 object
  5380. */
  5381. add(right: DeepImmutable<Color4>): Color4;
  5382. /**
  5383. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5384. * @param right defines the second operand
  5385. * @returns a new Color4 object
  5386. */
  5387. subtract(right: DeepImmutable<Color4>): Color4;
  5388. /**
  5389. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5390. * @param right defines the second operand
  5391. * @param result defines the Color4 object where to store the result
  5392. * @returns the current Color4 object
  5393. */
  5394. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5395. /**
  5396. * Creates a new Color4 with the current Color4 values multiplied by scale
  5397. * @param scale defines the scaling factor to apply
  5398. * @returns a new Color4 object
  5399. */
  5400. scale(scale: number): Color4;
  5401. /**
  5402. * Multiplies the current Color4 values by scale and stores the result in "result"
  5403. * @param scale defines the scaling factor to apply
  5404. * @param result defines the Color4 object where to store the result
  5405. * @returns the current unmodified Color4
  5406. */
  5407. scaleToRef(scale: number, result: Color4): Color4;
  5408. /**
  5409. * Scale the current Color4 values by a factor and add the result to a given Color4
  5410. * @param scale defines the scale factor
  5411. * @param result defines the Color4 object where to store the result
  5412. * @returns the unmodified current Color4
  5413. */
  5414. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5415. /**
  5416. * Clamps the rgb values by the min and max values and stores the result into "result"
  5417. * @param min defines minimum clamping value (default is 0)
  5418. * @param max defines maximum clamping value (default is 1)
  5419. * @param result defines color to store the result into.
  5420. * @returns the cuurent Color4
  5421. */
  5422. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5423. /**
  5424. * Multipy an Color4 value by another and return a new Color4 object
  5425. * @param color defines the Color4 value to multiply by
  5426. * @returns a new Color4 object
  5427. */
  5428. multiply(color: Color4): Color4;
  5429. /**
  5430. * Multipy a Color4 value by another and push the result in a reference value
  5431. * @param color defines the Color4 value to multiply by
  5432. * @param result defines the Color4 to fill the result in
  5433. * @returns the result Color4
  5434. */
  5435. multiplyToRef(color: Color4, result: Color4): Color4;
  5436. /**
  5437. * Creates a string with the Color4 current values
  5438. * @returns the string representation of the Color4 object
  5439. */
  5440. toString(): string;
  5441. /**
  5442. * Returns the string "Color4"
  5443. * @returns "Color4"
  5444. */
  5445. getClassName(): string;
  5446. /**
  5447. * Compute the Color4 hash code
  5448. * @returns an unique number that can be used to hash Color4 objects
  5449. */
  5450. getHashCode(): number;
  5451. /**
  5452. * Creates a new Color4 copied from the current one
  5453. * @returns a new Color4 object
  5454. */
  5455. clone(): Color4;
  5456. /**
  5457. * Copies the given Color4 values into the current one
  5458. * @param source defines the source Color4 object
  5459. * @returns the current updated Color4 object
  5460. */
  5461. copyFrom(source: Color4): Color4;
  5462. /**
  5463. * Copies the given float values into the current one
  5464. * @param r defines the red component to read from
  5465. * @param g defines the green component to read from
  5466. * @param b defines the blue component to read from
  5467. * @param a defines the alpha component to read from
  5468. * @returns the current updated Color4 object
  5469. */
  5470. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5471. /**
  5472. * Copies the given float values into the current one
  5473. * @param r defines the red component to read from
  5474. * @param g defines the green component to read from
  5475. * @param b defines the blue component to read from
  5476. * @param a defines the alpha component to read from
  5477. * @returns the current updated Color4 object
  5478. */
  5479. set(r: number, g: number, b: number, a: number): Color4;
  5480. /**
  5481. * Compute the Color4 hexadecimal code as a string
  5482. * @returns a string containing the hexadecimal representation of the Color4 object
  5483. */
  5484. toHexString(): string;
  5485. /**
  5486. * Computes a new Color4 converted from the current one to linear space
  5487. * @returns a new Color4 object
  5488. */
  5489. toLinearSpace(): Color4;
  5490. /**
  5491. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5492. * @param convertedColor defines the Color4 object where to store the linear space version
  5493. * @returns the unmodified Color4
  5494. */
  5495. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5496. /**
  5497. * Computes a new Color4 converted from the current one to gamma space
  5498. * @returns a new Color4 object
  5499. */
  5500. toGammaSpace(): Color4;
  5501. /**
  5502. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5503. * @param convertedColor defines the Color4 object where to store the gamma space version
  5504. * @returns the unmodified Color4
  5505. */
  5506. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5507. /**
  5508. * Creates a new Color4 from the string containing valid hexadecimal values
  5509. * @param hex defines a string containing valid hexadecimal values
  5510. * @returns a new Color4 object
  5511. */
  5512. static FromHexString(hex: string): Color4;
  5513. /**
  5514. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5515. * @param left defines the start value
  5516. * @param right defines the end value
  5517. * @param amount defines the gradient factor
  5518. * @returns a new Color4 object
  5519. */
  5520. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5521. /**
  5522. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5523. * @param left defines the start value
  5524. * @param right defines the end value
  5525. * @param amount defines the gradient factor
  5526. * @param result defines the Color4 object where to store data
  5527. */
  5528. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5529. /**
  5530. * Creates a new Color4 from a Color3 and an alpha value
  5531. * @param color3 defines the source Color3 to read from
  5532. * @param alpha defines the alpha component (1.0 by default)
  5533. * @returns a new Color4 object
  5534. */
  5535. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5536. /**
  5537. * Creates a new Color4 from the starting index element of the given array
  5538. * @param array defines the source array to read from
  5539. * @param offset defines the offset in the source array
  5540. * @returns a new Color4 object
  5541. */
  5542. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5543. /**
  5544. * Creates a new Color3 from integer values (< 256)
  5545. * @param r defines the red component to read from (value between 0 and 255)
  5546. * @param g defines the green component to read from (value between 0 and 255)
  5547. * @param b defines the blue component to read from (value between 0 and 255)
  5548. * @param a defines the alpha component to read from (value between 0 and 255)
  5549. * @returns a new Color3 object
  5550. */
  5551. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5552. /**
  5553. * Check the content of a given array and convert it to an array containing RGBA data
  5554. * If the original array was already containing count * 4 values then it is returned directly
  5555. * @param colors defines the array to check
  5556. * @param count defines the number of RGBA data to expect
  5557. * @returns an array containing count * 4 values (RGBA)
  5558. */
  5559. static CheckColors4(colors: number[], count: number): number[];
  5560. }
  5561. /**
  5562. * @hidden
  5563. */
  5564. export class TmpColors {
  5565. static Color3: Color3[];
  5566. static Color4: Color4[];
  5567. }
  5568. }
  5569. declare module BABYLON {
  5570. /**
  5571. * Class representing spherical harmonics coefficients to the 3rd degree
  5572. */
  5573. export class SphericalHarmonics {
  5574. /**
  5575. * Defines whether or not the harmonics have been prescaled for rendering.
  5576. */
  5577. preScaled: boolean;
  5578. /**
  5579. * The l0,0 coefficients of the spherical harmonics
  5580. */
  5581. l00: Vector3;
  5582. /**
  5583. * The l1,-1 coefficients of the spherical harmonics
  5584. */
  5585. l1_1: Vector3;
  5586. /**
  5587. * The l1,0 coefficients of the spherical harmonics
  5588. */
  5589. l10: Vector3;
  5590. /**
  5591. * The l1,1 coefficients of the spherical harmonics
  5592. */
  5593. l11: Vector3;
  5594. /**
  5595. * The l2,-2 coefficients of the spherical harmonics
  5596. */
  5597. l2_2: Vector3;
  5598. /**
  5599. * The l2,-1 coefficients of the spherical harmonics
  5600. */
  5601. l2_1: Vector3;
  5602. /**
  5603. * The l2,0 coefficients of the spherical harmonics
  5604. */
  5605. l20: Vector3;
  5606. /**
  5607. * The l2,1 coefficients of the spherical harmonics
  5608. */
  5609. l21: Vector3;
  5610. /**
  5611. * The l2,2 coefficients of the spherical harmonics
  5612. */
  5613. l22: Vector3;
  5614. /**
  5615. * Adds a light to the spherical harmonics
  5616. * @param direction the direction of the light
  5617. * @param color the color of the light
  5618. * @param deltaSolidAngle the delta solid angle of the light
  5619. */
  5620. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5621. /**
  5622. * Scales the spherical harmonics by the given amount
  5623. * @param scale the amount to scale
  5624. */
  5625. scaleInPlace(scale: number): void;
  5626. /**
  5627. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5628. *
  5629. * ```
  5630. * E_lm = A_l * L_lm
  5631. * ```
  5632. *
  5633. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5634. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5635. * the scaling factors are given in equation 9.
  5636. */
  5637. convertIncidentRadianceToIrradiance(): void;
  5638. /**
  5639. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5640. *
  5641. * ```
  5642. * L = (1/pi) * E * rho
  5643. * ```
  5644. *
  5645. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5646. */
  5647. convertIrradianceToLambertianRadiance(): void;
  5648. /**
  5649. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5650. * required operations at run time.
  5651. *
  5652. * This is simply done by scaling back the SH with Ylm constants parameter.
  5653. * The trigonometric part being applied by the shader at run time.
  5654. */
  5655. preScaleForRendering(): void;
  5656. /**
  5657. * Constructs a spherical harmonics from an array.
  5658. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5659. * @returns the spherical harmonics
  5660. */
  5661. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5662. /**
  5663. * Gets the spherical harmonics from polynomial
  5664. * @param polynomial the spherical polynomial
  5665. * @returns the spherical harmonics
  5666. */
  5667. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5668. }
  5669. /**
  5670. * Class representing spherical polynomial coefficients to the 3rd degree
  5671. */
  5672. export class SphericalPolynomial {
  5673. private _harmonics;
  5674. /**
  5675. * The spherical harmonics used to create the polynomials.
  5676. */
  5677. readonly preScaledHarmonics: SphericalHarmonics;
  5678. /**
  5679. * The x coefficients of the spherical polynomial
  5680. */
  5681. x: Vector3;
  5682. /**
  5683. * The y coefficients of the spherical polynomial
  5684. */
  5685. y: Vector3;
  5686. /**
  5687. * The z coefficients of the spherical polynomial
  5688. */
  5689. z: Vector3;
  5690. /**
  5691. * The xx coefficients of the spherical polynomial
  5692. */
  5693. xx: Vector3;
  5694. /**
  5695. * The yy coefficients of the spherical polynomial
  5696. */
  5697. yy: Vector3;
  5698. /**
  5699. * The zz coefficients of the spherical polynomial
  5700. */
  5701. zz: Vector3;
  5702. /**
  5703. * The xy coefficients of the spherical polynomial
  5704. */
  5705. xy: Vector3;
  5706. /**
  5707. * The yz coefficients of the spherical polynomial
  5708. */
  5709. yz: Vector3;
  5710. /**
  5711. * The zx coefficients of the spherical polynomial
  5712. */
  5713. zx: Vector3;
  5714. /**
  5715. * Adds an ambient color to the spherical polynomial
  5716. * @param color the color to add
  5717. */
  5718. addAmbient(color: Color3): void;
  5719. /**
  5720. * Scales the spherical polynomial by the given amount
  5721. * @param scale the amount to scale
  5722. */
  5723. scaleInPlace(scale: number): void;
  5724. /**
  5725. * Gets the spherical polynomial from harmonics
  5726. * @param harmonics the spherical harmonics
  5727. * @returns the spherical polynomial
  5728. */
  5729. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5730. /**
  5731. * Constructs a spherical polynomial from an array.
  5732. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5733. * @returns the spherical polynomial
  5734. */
  5735. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5736. }
  5737. }
  5738. declare module BABYLON {
  5739. /**
  5740. * Define options used to create a render target texture
  5741. */
  5742. export class RenderTargetCreationOptions {
  5743. /**
  5744. * Specifies is mipmaps must be generated
  5745. */
  5746. generateMipMaps?: boolean;
  5747. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5748. generateDepthBuffer?: boolean;
  5749. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5750. generateStencilBuffer?: boolean;
  5751. /** Defines texture type (int by default) */
  5752. type?: number;
  5753. /** Defines sampling mode (trilinear by default) */
  5754. samplingMode?: number;
  5755. /** Defines format (RGBA by default) */
  5756. format?: number;
  5757. }
  5758. }
  5759. declare module BABYLON {
  5760. /**
  5761. * @hidden
  5762. **/
  5763. export class _AlphaState { private _blendFunctionParameters: Nullable<number>[]; private _blendEquationParameters: Nullable<number>[]; private _blendConstants: Nullable<number>[]; private _isBlendConstantsDirty: boolean;
  5764. private _alphaBlend;
  5765. private _isAlphaBlendDirty;
  5766. private _isBlendFunctionParametersDirty;
  5767. private _isBlendEquationParametersDirty;
  5768. /**
  5769. * Initializes the state.
  5770. */
  5771. constructor();
  5772. readonly isDirty: boolean;
  5773. alphaBlend: boolean;
  5774. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5775. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5776. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5777. reset(): void;
  5778. apply(gl: WebGLRenderingContext): void;
  5779. }
  5780. }
  5781. declare module BABYLON {
  5782. /**
  5783. * @hidden
  5784. **/
  5785. export class _DepthCullingState {
  5786. private _isDepthTestDirty;
  5787. private _isDepthMaskDirty;
  5788. private _isDepthFuncDirty;
  5789. private _isCullFaceDirty;
  5790. private _isCullDirty;
  5791. private _isZOffsetDirty;
  5792. private _isFrontFaceDirty;
  5793. private _depthTest;
  5794. private _depthMask;
  5795. private _depthFunc;
  5796. private _cull;
  5797. private _cullFace;
  5798. private _zOffset;
  5799. private _frontFace;
  5800. /**
  5801. * Initializes the state.
  5802. */
  5803. constructor();
  5804. readonly isDirty: boolean;
  5805. zOffset: number;
  5806. cullFace: Nullable<number>;
  5807. cull: Nullable<boolean>;
  5808. depthFunc: Nullable<number>;
  5809. depthMask: boolean;
  5810. depthTest: boolean;
  5811. frontFace: Nullable<number>;
  5812. reset(): void;
  5813. apply(gl: WebGLRenderingContext): void;
  5814. }
  5815. }
  5816. declare module BABYLON {
  5817. /**
  5818. * @hidden
  5819. **/
  5820. export class _StencilState {
  5821. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5822. static readonly ALWAYS: number;
  5823. /** Passed to stencilOperation to specify that stencil value must be kept */
  5824. static readonly KEEP: number;
  5825. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5826. static readonly REPLACE: number;
  5827. private _isStencilTestDirty;
  5828. private _isStencilMaskDirty;
  5829. private _isStencilFuncDirty;
  5830. private _isStencilOpDirty;
  5831. private _stencilTest;
  5832. private _stencilMask;
  5833. private _stencilFunc;
  5834. private _stencilFuncRef;
  5835. private _stencilFuncMask;
  5836. private _stencilOpStencilFail;
  5837. private _stencilOpDepthFail;
  5838. private _stencilOpStencilDepthPass;
  5839. readonly isDirty: boolean;
  5840. stencilFunc: number;
  5841. stencilFuncRef: number;
  5842. stencilFuncMask: number;
  5843. stencilOpStencilFail: number;
  5844. stencilOpDepthFail: number;
  5845. stencilOpStencilDepthPass: number;
  5846. stencilMask: number;
  5847. stencilTest: boolean;
  5848. constructor();
  5849. reset(): void;
  5850. apply(gl: WebGLRenderingContext): void;
  5851. }
  5852. }
  5853. declare module BABYLON {
  5854. /**
  5855. * @hidden
  5856. **/
  5857. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  5858. }
  5859. }
  5860. declare module BABYLON {
  5861. /**
  5862. * Class used to evalaute queries containing `and` and `or` operators
  5863. */
  5864. export class AndOrNotEvaluator {
  5865. /**
  5866. * Evaluate a query
  5867. * @param query defines the query to evaluate
  5868. * @param evaluateCallback defines the callback used to filter result
  5869. * @returns true if the query matches
  5870. */
  5871. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5872. private static _HandleParenthesisContent;
  5873. private static _SimplifyNegation;
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Class used to store custom tags
  5879. */
  5880. export class Tags {
  5881. /**
  5882. * Adds support for tags on the given object
  5883. * @param obj defines the object to use
  5884. */
  5885. static EnableFor(obj: any): void;
  5886. /**
  5887. * Removes tags support
  5888. * @param obj defines the object to use
  5889. */
  5890. static DisableFor(obj: any): void;
  5891. /**
  5892. * Gets a boolean indicating if the given object has tags
  5893. * @param obj defines the object to use
  5894. * @returns a boolean
  5895. */
  5896. static HasTags(obj: any): boolean;
  5897. /**
  5898. * Gets the tags available on a given object
  5899. * @param obj defines the object to use
  5900. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5901. * @returns the tags
  5902. */
  5903. static GetTags(obj: any, asString?: boolean): any;
  5904. /**
  5905. * Adds tags to an object
  5906. * @param obj defines the object to use
  5907. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5908. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5909. */
  5910. static AddTagsTo(obj: any, tagsString: string): void;
  5911. /**
  5912. * @hidden
  5913. */ private static _AddTagTo(obj: any, tag: string): void;
  5914. /**
  5915. * Removes specific tags from a specific object
  5916. * @param obj defines the object to use
  5917. * @param tagsString defines the tags to remove
  5918. */
  5919. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5920. /**
  5921. * @hidden
  5922. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5923. /**
  5924. * Defines if tags hosted on an object match a given query
  5925. * @param obj defines the object to use
  5926. * @param tagsQuery defines the tag query
  5927. * @returns a boolean
  5928. */
  5929. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5930. }
  5931. }
  5932. declare module BABYLON {
  5933. /**
  5934. * Defines potential orientation for back face culling
  5935. */
  5936. export enum Orientation {
  5937. /**
  5938. * Clockwise
  5939. */
  5940. CW = 0,
  5941. /** Counter clockwise */
  5942. CCW = 1
  5943. }
  5944. /** Class used to represent a Bezier curve */
  5945. export class BezierCurve {
  5946. /**
  5947. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5948. * @param t defines the time
  5949. * @param x1 defines the left coordinate on X axis
  5950. * @param y1 defines the left coordinate on Y axis
  5951. * @param x2 defines the right coordinate on X axis
  5952. * @param y2 defines the right coordinate on Y axis
  5953. * @returns the interpolated value
  5954. */
  5955. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5956. }
  5957. /**
  5958. * Defines angle representation
  5959. */
  5960. export class Angle {
  5961. private _radians;
  5962. /**
  5963. * Creates an Angle object of "radians" radians (float).
  5964. * @param radians the angle in radians
  5965. */
  5966. constructor(radians: number);
  5967. /**
  5968. * Get value in degrees
  5969. * @returns the Angle value in degrees (float)
  5970. */
  5971. degrees(): number;
  5972. /**
  5973. * Get value in radians
  5974. * @returns the Angle value in radians (float)
  5975. */
  5976. radians(): number;
  5977. /**
  5978. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5979. * @param a defines first vector
  5980. * @param b defines second vector
  5981. * @returns a new Angle
  5982. */
  5983. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5984. /**
  5985. * Gets a new Angle object from the given float in radians
  5986. * @param radians defines the angle value in radians
  5987. * @returns a new Angle
  5988. */
  5989. static FromRadians(radians: number): Angle;
  5990. /**
  5991. * Gets a new Angle object from the given float in degrees
  5992. * @param degrees defines the angle value in degrees
  5993. * @returns a new Angle
  5994. */
  5995. static FromDegrees(degrees: number): Angle;
  5996. }
  5997. /**
  5998. * This represents an arc in a 2d space.
  5999. */
  6000. export class Arc2 {
  6001. /** Defines the start point of the arc */
  6002. startPoint: Vector2;
  6003. /** Defines the mid point of the arc */
  6004. midPoint: Vector2;
  6005. /** Defines the end point of the arc */
  6006. endPoint: Vector2;
  6007. /**
  6008. * Defines the center point of the arc.
  6009. */
  6010. centerPoint: Vector2;
  6011. /**
  6012. * Defines the radius of the arc.
  6013. */
  6014. radius: number;
  6015. /**
  6016. * Defines the angle of the arc (from mid point to end point).
  6017. */
  6018. angle: Angle;
  6019. /**
  6020. * Defines the start angle of the arc (from start point to middle point).
  6021. */
  6022. startAngle: Angle;
  6023. /**
  6024. * Defines the orientation of the arc (clock wise/counter clock wise).
  6025. */
  6026. orientation: Orientation;
  6027. /**
  6028. * Creates an Arc object from the three given points : start, middle and end.
  6029. * @param startPoint Defines the start point of the arc
  6030. * @param midPoint Defines the midlle point of the arc
  6031. * @param endPoint Defines the end point of the arc
  6032. */
  6033. constructor(
  6034. /** Defines the start point of the arc */
  6035. startPoint: Vector2,
  6036. /** Defines the mid point of the arc */
  6037. midPoint: Vector2,
  6038. /** Defines the end point of the arc */
  6039. endPoint: Vector2);
  6040. }
  6041. /**
  6042. * Represents a 2D path made up of multiple 2D points
  6043. */
  6044. export class Path2 {
  6045. private _points;
  6046. private _length;
  6047. /**
  6048. * If the path start and end point are the same
  6049. */
  6050. closed: boolean;
  6051. /**
  6052. * Creates a Path2 object from the starting 2D coordinates x and y.
  6053. * @param x the starting points x value
  6054. * @param y the starting points y value
  6055. */
  6056. constructor(x: number, y: number);
  6057. /**
  6058. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  6059. * @param x the added points x value
  6060. * @param y the added points y value
  6061. * @returns the updated Path2.
  6062. */
  6063. addLineTo(x: number, y: number): Path2;
  6064. /**
  6065. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  6066. * @param midX middle point x value
  6067. * @param midY middle point y value
  6068. * @param endX end point x value
  6069. * @param endY end point y value
  6070. * @param numberOfSegments (default: 36)
  6071. * @returns the updated Path2.
  6072. */
  6073. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  6074. /**
  6075. * Closes the Path2.
  6076. * @returns the Path2.
  6077. */
  6078. close(): Path2;
  6079. /**
  6080. * Gets the sum of the distance between each sequential point in the path
  6081. * @returns the Path2 total length (float).
  6082. */
  6083. length(): number;
  6084. /**
  6085. * Gets the points which construct the path
  6086. * @returns the Path2 internal array of points.
  6087. */
  6088. getPoints(): Vector2[];
  6089. /**
  6090. * Retreives the point at the distance aways from the starting point
  6091. * @param normalizedLengthPosition the length along the path to retreive the point from
  6092. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  6093. */
  6094. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  6095. /**
  6096. * Creates a new path starting from an x and y position
  6097. * @param x starting x value
  6098. * @param y starting y value
  6099. * @returns a new Path2 starting at the coordinates (x, y).
  6100. */
  6101. static StartingAt(x: number, y: number): Path2;
  6102. }
  6103. /**
  6104. * Represents a 3D path made up of multiple 3D points
  6105. */
  6106. export class Path3D {
  6107. /**
  6108. * an array of Vector3, the curve axis of the Path3D
  6109. */
  6110. path: Vector3[];
  6111. private _curve;
  6112. private _distances;
  6113. private _tangents;
  6114. private _normals;
  6115. private _binormals;
  6116. private _raw;
  6117. /**
  6118. * new Path3D(path, normal, raw)
  6119. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  6120. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  6121. * @param path an array of Vector3, the curve axis of the Path3D
  6122. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  6123. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  6124. */
  6125. constructor(
  6126. /**
  6127. * an array of Vector3, the curve axis of the Path3D
  6128. */
  6129. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  6130. /**
  6131. * Returns the Path3D array of successive Vector3 designing its curve.
  6132. * @returns the Path3D array of successive Vector3 designing its curve.
  6133. */
  6134. getCurve(): Vector3[];
  6135. /**
  6136. * Returns an array populated with tangent vectors on each Path3D curve point.
  6137. * @returns an array populated with tangent vectors on each Path3D curve point.
  6138. */
  6139. getTangents(): Vector3[];
  6140. /**
  6141. * Returns an array populated with normal vectors on each Path3D curve point.
  6142. * @returns an array populated with normal vectors on each Path3D curve point.
  6143. */
  6144. getNormals(): Vector3[];
  6145. /**
  6146. * Returns an array populated with binormal vectors on each Path3D curve point.
  6147. * @returns an array populated with binormal vectors on each Path3D curve point.
  6148. */
  6149. getBinormals(): Vector3[];
  6150. /**
  6151. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6152. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6153. */
  6154. getDistances(): number[];
  6155. /**
  6156. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6157. * @param path path which all values are copied into the curves points
  6158. * @param firstNormal which should be projected onto the curve
  6159. * @returns the same object updated.
  6160. */
  6161. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6162. private _compute;
  6163. private _getFirstNonNullVector;
  6164. private _getLastNonNullVector;
  6165. private _normalVector;
  6166. }
  6167. /**
  6168. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6169. * A Curve3 is designed from a series of successive Vector3.
  6170. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6171. */
  6172. export class Curve3 {
  6173. private _points;
  6174. private _length;
  6175. /**
  6176. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6177. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6178. * @param v1 (Vector3) the control point
  6179. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6180. * @param nbPoints (integer) the wanted number of points in the curve
  6181. * @returns the created Curve3
  6182. */
  6183. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6184. /**
  6185. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6186. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6187. * @param v1 (Vector3) the first control point
  6188. * @param v2 (Vector3) the second control point
  6189. * @param v3 (Vector3) the end point of the Cubic Bezier
  6190. * @param nbPoints (integer) the wanted number of points in the curve
  6191. * @returns the created Curve3
  6192. */
  6193. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6194. /**
  6195. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6196. * @param p1 (Vector3) the origin point of the Hermite Spline
  6197. * @param t1 (Vector3) the tangent vector at the origin point
  6198. * @param p2 (Vector3) the end point of the Hermite Spline
  6199. * @param t2 (Vector3) the tangent vector at the end point
  6200. * @param nbPoints (integer) the wanted number of points in the curve
  6201. * @returns the created Curve3
  6202. */
  6203. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6204. /**
  6205. * Returns a Curve3 object along a CatmullRom Spline curve :
  6206. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6207. * @param nbPoints (integer) the wanted number of points between each curve control points
  6208. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6209. * @returns the created Curve3
  6210. */
  6211. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6212. /**
  6213. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6214. * A Curve3 is designed from a series of successive Vector3.
  6215. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6216. * @param points points which make up the curve
  6217. */
  6218. constructor(points: Vector3[]);
  6219. /**
  6220. * @returns the Curve3 stored array of successive Vector3
  6221. */
  6222. getPoints(): Vector3[];
  6223. /**
  6224. * @returns the computed length (float) of the curve.
  6225. */
  6226. length(): number;
  6227. /**
  6228. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6229. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6230. * curveA and curveB keep unchanged.
  6231. * @param curve the curve to continue from this curve
  6232. * @returns the newly constructed curve
  6233. */
  6234. continue(curve: DeepImmutable<Curve3>): Curve3;
  6235. private _computeLength;
  6236. }
  6237. }
  6238. declare module BABYLON {
  6239. /**
  6240. * This represents the main contract an easing function should follow.
  6241. * Easing functions are used throughout the animation system.
  6242. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6243. */
  6244. export interface IEasingFunction {
  6245. /**
  6246. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6247. * of the easing function.
  6248. * The link below provides some of the most common examples of easing functions.
  6249. * @see https://easings.net/
  6250. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6251. * @returns the corresponding value on the curve defined by the easing function
  6252. */
  6253. ease(gradient: number): number;
  6254. }
  6255. /**
  6256. * Base class used for every default easing function.
  6257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6258. */
  6259. export class EasingFunction implements IEasingFunction {
  6260. /**
  6261. * Interpolation follows the mathematical formula associated with the easing function.
  6262. */
  6263. static readonly EASINGMODE_EASEIN: number;
  6264. /**
  6265. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6266. */
  6267. static readonly EASINGMODE_EASEOUT: number;
  6268. /**
  6269. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6270. */
  6271. static readonly EASINGMODE_EASEINOUT: number;
  6272. private _easingMode;
  6273. /**
  6274. * Sets the easing mode of the current function.
  6275. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6276. */
  6277. setEasingMode(easingMode: number): void;
  6278. /**
  6279. * Gets the current easing mode.
  6280. * @returns the easing mode
  6281. */
  6282. getEasingMode(): number;
  6283. /**
  6284. * @hidden
  6285. */
  6286. easeInCore(gradient: number): number;
  6287. /**
  6288. * Given an input gradient between 0 and 1, this returns the corresponding value
  6289. * of the easing function.
  6290. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6291. * @returns the corresponding value on the curve defined by the easing function
  6292. */
  6293. ease(gradient: number): number;
  6294. }
  6295. /**
  6296. * Easing function with a circle shape (see link below).
  6297. * @see https://easings.net/#easeInCirc
  6298. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6299. */
  6300. export class CircleEase extends EasingFunction implements IEasingFunction {
  6301. /** @hidden */
  6302. easeInCore(gradient: number): number;
  6303. }
  6304. /**
  6305. * Easing function with a ease back shape (see link below).
  6306. * @see https://easings.net/#easeInBack
  6307. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6308. */
  6309. export class BackEase extends EasingFunction implements IEasingFunction {
  6310. /** Defines the amplitude of the function */
  6311. amplitude: number;
  6312. /**
  6313. * Instantiates a back ease easing
  6314. * @see https://easings.net/#easeInBack
  6315. * @param amplitude Defines the amplitude of the function
  6316. */
  6317. constructor(
  6318. /** Defines the amplitude of the function */
  6319. amplitude?: number);
  6320. /** @hidden */
  6321. easeInCore(gradient: number): number;
  6322. }
  6323. /**
  6324. * Easing function with a bouncing shape (see link below).
  6325. * @see https://easings.net/#easeInBounce
  6326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6327. */
  6328. export class BounceEase extends EasingFunction implements IEasingFunction {
  6329. /** Defines the number of bounces */
  6330. bounces: number;
  6331. /** Defines the amplitude of the bounce */
  6332. bounciness: number;
  6333. /**
  6334. * Instantiates a bounce easing
  6335. * @see https://easings.net/#easeInBounce
  6336. * @param bounces Defines the number of bounces
  6337. * @param bounciness Defines the amplitude of the bounce
  6338. */
  6339. constructor(
  6340. /** Defines the number of bounces */
  6341. bounces?: number,
  6342. /** Defines the amplitude of the bounce */
  6343. bounciness?: number);
  6344. /** @hidden */
  6345. easeInCore(gradient: number): number;
  6346. }
  6347. /**
  6348. * Easing function with a power of 3 shape (see link below).
  6349. * @see https://easings.net/#easeInCubic
  6350. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6351. */
  6352. export class CubicEase extends EasingFunction implements IEasingFunction {
  6353. /** @hidden */
  6354. easeInCore(gradient: number): number;
  6355. }
  6356. /**
  6357. * Easing function with an elastic shape (see link below).
  6358. * @see https://easings.net/#easeInElastic
  6359. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6360. */
  6361. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6362. /** Defines the number of oscillations*/
  6363. oscillations: number;
  6364. /** Defines the amplitude of the oscillations*/
  6365. springiness: number;
  6366. /**
  6367. * Instantiates an elastic easing function
  6368. * @see https://easings.net/#easeInElastic
  6369. * @param oscillations Defines the number of oscillations
  6370. * @param springiness Defines the amplitude of the oscillations
  6371. */
  6372. constructor(
  6373. /** Defines the number of oscillations*/
  6374. oscillations?: number,
  6375. /** Defines the amplitude of the oscillations*/
  6376. springiness?: number);
  6377. /** @hidden */
  6378. easeInCore(gradient: number): number;
  6379. }
  6380. /**
  6381. * Easing function with an exponential shape (see link below).
  6382. * @see https://easings.net/#easeInExpo
  6383. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6384. */
  6385. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6386. /** Defines the exponent of the function */
  6387. exponent: number;
  6388. /**
  6389. * Instantiates an exponential easing function
  6390. * @see https://easings.net/#easeInExpo
  6391. * @param exponent Defines the exponent of the function
  6392. */
  6393. constructor(
  6394. /** Defines the exponent of the function */
  6395. exponent?: number);
  6396. /** @hidden */
  6397. easeInCore(gradient: number): number;
  6398. }
  6399. /**
  6400. * Easing function with a power shape (see link below).
  6401. * @see https://easings.net/#easeInQuad
  6402. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6403. */
  6404. export class PowerEase extends EasingFunction implements IEasingFunction {
  6405. /** Defines the power of the function */
  6406. power: number;
  6407. /**
  6408. * Instantiates an power base easing function
  6409. * @see https://easings.net/#easeInQuad
  6410. * @param power Defines the power of the function
  6411. */
  6412. constructor(
  6413. /** Defines the power of the function */
  6414. power?: number);
  6415. /** @hidden */
  6416. easeInCore(gradient: number): number;
  6417. }
  6418. /**
  6419. * Easing function with a power of 2 shape (see link below).
  6420. * @see https://easings.net/#easeInQuad
  6421. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6422. */
  6423. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6424. /** @hidden */
  6425. easeInCore(gradient: number): number;
  6426. }
  6427. /**
  6428. * Easing function with a power of 4 shape (see link below).
  6429. * @see https://easings.net/#easeInQuart
  6430. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6431. */
  6432. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6433. /** @hidden */
  6434. easeInCore(gradient: number): number;
  6435. }
  6436. /**
  6437. * Easing function with a power of 5 shape (see link below).
  6438. * @see https://easings.net/#easeInQuint
  6439. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6440. */
  6441. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6442. /** @hidden */
  6443. easeInCore(gradient: number): number;
  6444. }
  6445. /**
  6446. * Easing function with a sin shape (see link below).
  6447. * @see https://easings.net/#easeInSine
  6448. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6449. */
  6450. export class SineEase extends EasingFunction implements IEasingFunction {
  6451. /** @hidden */
  6452. easeInCore(gradient: number): number;
  6453. }
  6454. /**
  6455. * Easing function with a bezier shape (see link below).
  6456. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6457. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6458. */
  6459. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6460. /** Defines the x component of the start tangent in the bezier curve */
  6461. x1: number;
  6462. /** Defines the y component of the start tangent in the bezier curve */
  6463. y1: number;
  6464. /** Defines the x component of the end tangent in the bezier curve */
  6465. x2: number;
  6466. /** Defines the y component of the end tangent in the bezier curve */
  6467. y2: number;
  6468. /**
  6469. * Instantiates a bezier function
  6470. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6471. * @param x1 Defines the x component of the start tangent in the bezier curve
  6472. * @param y1 Defines the y component of the start tangent in the bezier curve
  6473. * @param x2 Defines the x component of the end tangent in the bezier curve
  6474. * @param y2 Defines the y component of the end tangent in the bezier curve
  6475. */
  6476. constructor(
  6477. /** Defines the x component of the start tangent in the bezier curve */
  6478. x1?: number,
  6479. /** Defines the y component of the start tangent in the bezier curve */
  6480. y1?: number,
  6481. /** Defines the x component of the end tangent in the bezier curve */
  6482. x2?: number,
  6483. /** Defines the y component of the end tangent in the bezier curve */
  6484. y2?: number);
  6485. /** @hidden */
  6486. easeInCore(gradient: number): number;
  6487. }
  6488. }
  6489. declare module BABYLON {
  6490. /**
  6491. * Defines an interface which represents an animation key frame
  6492. */
  6493. export interface IAnimationKey {
  6494. /**
  6495. * Frame of the key frame
  6496. */
  6497. frame: number;
  6498. /**
  6499. * Value at the specifies key frame
  6500. */
  6501. value: any;
  6502. /**
  6503. * The input tangent for the cubic hermite spline
  6504. */
  6505. inTangent?: any;
  6506. /**
  6507. * The output tangent for the cubic hermite spline
  6508. */
  6509. outTangent?: any;
  6510. /**
  6511. * The animation interpolation type
  6512. */
  6513. interpolation?: AnimationKeyInterpolation;
  6514. }
  6515. /**
  6516. * Enum for the animation key frame interpolation type
  6517. */
  6518. export enum AnimationKeyInterpolation {
  6519. /**
  6520. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6521. */
  6522. STEP = 1
  6523. }
  6524. }
  6525. declare module BABYLON {
  6526. /**
  6527. * Represents the range of an animation
  6528. */
  6529. export class AnimationRange {
  6530. /**The name of the animation range**/
  6531. name: string;
  6532. /**The starting frame of the animation */
  6533. from: number;
  6534. /**The ending frame of the animation*/
  6535. to: number;
  6536. /**
  6537. * Initializes the range of an animation
  6538. * @param name The name of the animation range
  6539. * @param from The starting frame of the animation
  6540. * @param to The ending frame of the animation
  6541. */
  6542. constructor(
  6543. /**The name of the animation range**/
  6544. name: string,
  6545. /**The starting frame of the animation */
  6546. from: number,
  6547. /**The ending frame of the animation*/
  6548. to: number);
  6549. /**
  6550. * Makes a copy of the animation range
  6551. * @returns A copy of the animation range
  6552. */
  6553. clone(): AnimationRange;
  6554. }
  6555. }
  6556. declare module BABYLON {
  6557. /**
  6558. * Composed of a frame, and an action function
  6559. */
  6560. export class AnimationEvent {
  6561. /** The frame for which the event is triggered **/
  6562. frame: number;
  6563. /** The event to perform when triggered **/
  6564. action: (currentFrame: number) => void;
  6565. /** Specifies if the event should be triggered only once**/
  6566. onlyOnce?: boolean | undefined;
  6567. /**
  6568. * Specifies if the animation event is done
  6569. */
  6570. isDone: boolean;
  6571. /**
  6572. * Initializes the animation event
  6573. * @param frame The frame for which the event is triggered
  6574. * @param action The event to perform when triggered
  6575. * @param onlyOnce Specifies if the event should be triggered only once
  6576. */
  6577. constructor(
  6578. /** The frame for which the event is triggered **/
  6579. frame: number,
  6580. /** The event to perform when triggered **/
  6581. action: (currentFrame: number) => void,
  6582. /** Specifies if the event should be triggered only once**/
  6583. onlyOnce?: boolean | undefined);
  6584. /** @hidden */ private _clone(): AnimationEvent;
  6585. }
  6586. }
  6587. declare module BABYLON {
  6588. /**
  6589. * Interface used to define a behavior
  6590. */
  6591. export interface Behavior<T> {
  6592. /** gets or sets behavior's name */
  6593. name: string;
  6594. /**
  6595. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6596. */
  6597. init(): void;
  6598. /**
  6599. * Called when the behavior is attached to a target
  6600. * @param target defines the target where the behavior is attached to
  6601. */
  6602. attach(target: T): void;
  6603. /**
  6604. * Called when the behavior is detached from its target
  6605. */
  6606. detach(): void;
  6607. }
  6608. /**
  6609. * Interface implemented by classes supporting behaviors
  6610. */
  6611. export interface IBehaviorAware<T> {
  6612. /**
  6613. * Attach a behavior
  6614. * @param behavior defines the behavior to attach
  6615. * @returns the current host
  6616. */
  6617. addBehavior(behavior: Behavior<T>): T;
  6618. /**
  6619. * Remove a behavior from the current object
  6620. * @param behavior defines the behavior to detach
  6621. * @returns the current host
  6622. */
  6623. removeBehavior(behavior: Behavior<T>): T;
  6624. /**
  6625. * Gets a behavior using its name to search
  6626. * @param name defines the name to search
  6627. * @returns the behavior or null if not found
  6628. */
  6629. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6630. }
  6631. }
  6632. declare module BABYLON {
  6633. /**
  6634. * Defines an array and its length.
  6635. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6636. */
  6637. export interface ISmartArrayLike<T> {
  6638. /**
  6639. * The data of the array.
  6640. */
  6641. data: Array<T>;
  6642. /**
  6643. * The active length of the array.
  6644. */
  6645. length: number;
  6646. }
  6647. /**
  6648. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6649. */
  6650. export class SmartArray<T> implements ISmartArrayLike<T> {
  6651. /**
  6652. * The full set of data from the array.
  6653. */
  6654. data: Array<T>;
  6655. /**
  6656. * The active length of the array.
  6657. */
  6658. length: number;
  6659. protected _id: number;
  6660. /**
  6661. * Instantiates a Smart Array.
  6662. * @param capacity defines the default capacity of the array.
  6663. */
  6664. constructor(capacity: number);
  6665. /**
  6666. * Pushes a value at the end of the active data.
  6667. * @param value defines the object to push in the array.
  6668. */
  6669. push(value: T): void;
  6670. /**
  6671. * Iterates over the active data and apply the lambda to them.
  6672. * @param func defines the action to apply on each value.
  6673. */
  6674. forEach(func: (content: T) => void): void;
  6675. /**
  6676. * Sorts the full sets of data.
  6677. * @param compareFn defines the comparison function to apply.
  6678. */
  6679. sort(compareFn: (a: T, b: T) => number): void;
  6680. /**
  6681. * Resets the active data to an empty array.
  6682. */
  6683. reset(): void;
  6684. /**
  6685. * Releases all the data from the array as well as the array.
  6686. */
  6687. dispose(): void;
  6688. /**
  6689. * Concats the active data with a given array.
  6690. * @param array defines the data to concatenate with.
  6691. */
  6692. concat(array: any): void;
  6693. /**
  6694. * Returns the position of a value in the active data.
  6695. * @param value defines the value to find the index for
  6696. * @returns the index if found in the active data otherwise -1
  6697. */
  6698. indexOf(value: T): number;
  6699. /**
  6700. * Returns whether an element is part of the active data.
  6701. * @param value defines the value to look for
  6702. * @returns true if found in the active data otherwise false
  6703. */
  6704. contains(value: T): boolean;
  6705. private static _GlobalId;
  6706. }
  6707. /**
  6708. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6709. * The data in this array can only be present once
  6710. */
  6711. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6712. private _duplicateId;
  6713. /**
  6714. * Pushes a value at the end of the active data.
  6715. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6716. * @param value defines the object to push in the array.
  6717. */
  6718. push(value: T): void;
  6719. /**
  6720. * Pushes a value at the end of the active data.
  6721. * If the data is already present, it won t be added again
  6722. * @param value defines the object to push in the array.
  6723. * @returns true if added false if it was already present
  6724. */
  6725. pushNoDuplicate(value: T): boolean;
  6726. /**
  6727. * Resets the active data to an empty array.
  6728. */
  6729. reset(): void;
  6730. /**
  6731. * Concats the active data with a given array.
  6732. * This ensures no dupplicate will be present in the result.
  6733. * @param array defines the data to concatenate with.
  6734. */
  6735. concatWithNoDuplicate(array: any): void;
  6736. }
  6737. }
  6738. declare module BABYLON {
  6739. /**
  6740. * @ignore
  6741. * This is a list of all the different input types that are available in the application.
  6742. * Fo instance: ArcRotateCameraGamepadInput...
  6743. */
  6744. export var CameraInputTypes: {};
  6745. /**
  6746. * This is the contract to implement in order to create a new input class.
  6747. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6748. */
  6749. export interface ICameraInput<TCamera extends Camera> {
  6750. /**
  6751. * Defines the camera the input is attached to.
  6752. */
  6753. camera: Nullable<TCamera>;
  6754. /**
  6755. * Gets the class name of the current intput.
  6756. * @returns the class name
  6757. */
  6758. getClassName(): string;
  6759. /**
  6760. * Get the friendly name associated with the input class.
  6761. * @returns the input friendly name
  6762. */
  6763. getSimpleName(): string;
  6764. /**
  6765. * Attach the input controls to a specific dom element to get the input from.
  6766. * @param element Defines the element the controls should be listened from
  6767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6768. */
  6769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6770. /**
  6771. * Detach the current controls from the specified dom element.
  6772. * @param element Defines the element to stop listening the inputs from
  6773. */
  6774. detachControl(element: Nullable<HTMLElement>): void;
  6775. /**
  6776. * Update the current camera state depending on the inputs that have been used this frame.
  6777. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6778. */
  6779. checkInputs?: () => void;
  6780. }
  6781. /**
  6782. * Represents a map of input types to input instance or input index to input instance.
  6783. */
  6784. export interface CameraInputsMap<TCamera extends Camera> {
  6785. /**
  6786. * Accessor to the input by input type.
  6787. */
  6788. [name: string]: ICameraInput<TCamera>;
  6789. /**
  6790. * Accessor to the input by input index.
  6791. */
  6792. [idx: number]: ICameraInput<TCamera>;
  6793. }
  6794. /**
  6795. * This represents the input manager used within a camera.
  6796. * It helps dealing with all the different kind of input attached to a camera.
  6797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6798. */
  6799. export class CameraInputsManager<TCamera extends Camera> {
  6800. /**
  6801. * Defines the list of inputs attahed to the camera.
  6802. */
  6803. attached: CameraInputsMap<TCamera>;
  6804. /**
  6805. * Defines the dom element the camera is collecting inputs from.
  6806. * This is null if the controls have not been attached.
  6807. */
  6808. attachedElement: Nullable<HTMLElement>;
  6809. /**
  6810. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6811. */
  6812. noPreventDefault: boolean;
  6813. /**
  6814. * Defined the camera the input manager belongs to.
  6815. */
  6816. camera: TCamera;
  6817. /**
  6818. * Update the current camera state depending on the inputs that have been used this frame.
  6819. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6820. */
  6821. checkInputs: () => void;
  6822. /**
  6823. * Instantiate a new Camera Input Manager.
  6824. * @param camera Defines the camera the input manager blongs to
  6825. */
  6826. constructor(camera: TCamera);
  6827. /**
  6828. * Add an input method to a camera
  6829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6830. * @param input camera input method
  6831. */
  6832. add(input: ICameraInput<TCamera>): void;
  6833. /**
  6834. * Remove a specific input method from a camera
  6835. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6836. * @param inputToRemove camera input method
  6837. */
  6838. remove(inputToRemove: ICameraInput<TCamera>): void;
  6839. /**
  6840. * Remove a specific input type from a camera
  6841. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6842. * @param inputType the type of the input to remove
  6843. */
  6844. removeByType(inputType: string): void;
  6845. private _addCheckInputs;
  6846. /**
  6847. * Attach the input controls to the currently attached dom element to listen the events from.
  6848. * @param input Defines the input to attach
  6849. */
  6850. attachInput(input: ICameraInput<TCamera>): void;
  6851. /**
  6852. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6853. * @param element Defines the dom element to collect the events from
  6854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6855. */
  6856. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6857. /**
  6858. * Detach the current manager inputs controls from a specific dom element.
  6859. * @param element Defines the dom element to collect the events from
  6860. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6861. */
  6862. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6863. /**
  6864. * Rebuild the dynamic inputCheck function from the current list of
  6865. * defined inputs in the manager.
  6866. */
  6867. rebuildInputCheck(): void;
  6868. /**
  6869. * Remove all attached input methods from a camera
  6870. */
  6871. clear(): void;
  6872. /**
  6873. * Serialize the current input manager attached to a camera.
  6874. * This ensures than once parsed,
  6875. * the input associated to the camera will be identical to the current ones
  6876. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6877. */
  6878. serialize(serializedCamera: any): void;
  6879. /**
  6880. * Parses an input manager serialized JSON to restore the previous list of inputs
  6881. * and states associated to a camera.
  6882. * @param parsedCamera Defines the JSON to parse
  6883. */
  6884. parse(parsedCamera: any): void;
  6885. }
  6886. }
  6887. declare module BABYLON {
  6888. /**
  6889. * @hidden
  6890. */
  6891. export class IntersectionInfo {
  6892. bu: Nullable<number>;
  6893. bv: Nullable<number>;
  6894. distance: number;
  6895. faceId: number;
  6896. subMeshId: number;
  6897. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6898. }
  6899. }
  6900. declare module BABYLON {
  6901. /**
  6902. * Represens a plane by the equation ax + by + cz + d = 0
  6903. */
  6904. export class Plane {
  6905. private static _TmpMatrix;
  6906. /**
  6907. * Normal of the plane (a,b,c)
  6908. */
  6909. normal: Vector3;
  6910. /**
  6911. * d component of the plane
  6912. */
  6913. d: number;
  6914. /**
  6915. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6916. * @param a a component of the plane
  6917. * @param b b component of the plane
  6918. * @param c c component of the plane
  6919. * @param d d component of the plane
  6920. */
  6921. constructor(a: number, b: number, c: number, d: number);
  6922. /**
  6923. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6924. */
  6925. asArray(): number[];
  6926. /**
  6927. * @returns a new plane copied from the current Plane.
  6928. */
  6929. clone(): Plane;
  6930. /**
  6931. * @returns the string "Plane".
  6932. */
  6933. getClassName(): string;
  6934. /**
  6935. * @returns the Plane hash code.
  6936. */
  6937. getHashCode(): number;
  6938. /**
  6939. * Normalize the current Plane in place.
  6940. * @returns the updated Plane.
  6941. */
  6942. normalize(): Plane;
  6943. /**
  6944. * Applies a transformation the plane and returns the result
  6945. * @param transformation the transformation matrix to be applied to the plane
  6946. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6947. */
  6948. transform(transformation: DeepImmutable<Matrix>): Plane;
  6949. /**
  6950. * Calcualtte the dot product between the point and the plane normal
  6951. * @param point point to calculate the dot product with
  6952. * @returns the dot product (float) of the point coordinates and the plane normal.
  6953. */
  6954. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6955. /**
  6956. * Updates the current Plane from the plane defined by the three given points.
  6957. * @param point1 one of the points used to contruct the plane
  6958. * @param point2 one of the points used to contruct the plane
  6959. * @param point3 one of the points used to contruct the plane
  6960. * @returns the updated Plane.
  6961. */
  6962. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6963. /**
  6964. * Checks if the plane is facing a given direction
  6965. * @param direction the direction to check if the plane is facing
  6966. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6967. * @returns True is the vector "direction" is the same side than the plane normal.
  6968. */
  6969. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6970. /**
  6971. * Calculates the distance to a point
  6972. * @param point point to calculate distance to
  6973. * @returns the signed distance (float) from the given point to the Plane.
  6974. */
  6975. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6976. /**
  6977. * Creates a plane from an array
  6978. * @param array the array to create a plane from
  6979. * @returns a new Plane from the given array.
  6980. */
  6981. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6982. /**
  6983. * Creates a plane from three points
  6984. * @param point1 point used to create the plane
  6985. * @param point2 point used to create the plane
  6986. * @param point3 point used to create the plane
  6987. * @returns a new Plane defined by the three given points.
  6988. */
  6989. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6990. /**
  6991. * Creates a plane from an origin point and a normal
  6992. * @param origin origin of the plane to be constructed
  6993. * @param normal normal of the plane to be constructed
  6994. * @returns a new Plane the normal vector to this plane at the given origin point.
  6995. * Note : the vector "normal" is updated because normalized.
  6996. */
  6997. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6998. /**
  6999. * Calculates the distance from a plane and a point
  7000. * @param origin origin of the plane to be constructed
  7001. * @param normal normal of the plane to be constructed
  7002. * @param point point to calculate distance to
  7003. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  7004. */
  7005. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  7006. }
  7007. }
  7008. declare module BABYLON {
  7009. /**
  7010. * Class used to store bounding sphere information
  7011. */
  7012. export class BoundingSphere {
  7013. /**
  7014. * Gets the center of the bounding sphere in local space
  7015. */
  7016. readonly center: Vector3;
  7017. /**
  7018. * Radius of the bounding sphere in local space
  7019. */
  7020. radius: number;
  7021. /**
  7022. * Gets the center of the bounding sphere in world space
  7023. */
  7024. readonly centerWorld: Vector3;
  7025. /**
  7026. * Radius of the bounding sphere in world space
  7027. */
  7028. radiusWorld: number;
  7029. /**
  7030. * Gets the minimum vector in local space
  7031. */
  7032. readonly minimum: Vector3;
  7033. /**
  7034. * Gets the maximum vector in local space
  7035. */
  7036. readonly maximum: Vector3;
  7037. private _worldMatrix;
  7038. private static readonly TmpVector3;
  7039. /**
  7040. * Creates a new bounding sphere
  7041. * @param min defines the minimum vector (in local space)
  7042. * @param max defines the maximum vector (in local space)
  7043. * @param worldMatrix defines the new world matrix
  7044. */
  7045. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7046. /**
  7047. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7048. * @param min defines the new minimum vector (in local space)
  7049. * @param max defines the new maximum vector (in local space)
  7050. * @param worldMatrix defines the new world matrix
  7051. */
  7052. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Scale the current bounding sphere by applying a scale factor
  7055. * @param factor defines the scale factor to apply
  7056. * @returns the current bounding box
  7057. */
  7058. scale(factor: number): BoundingSphere;
  7059. /**
  7060. * Gets the world matrix of the bounding box
  7061. * @returns a matrix
  7062. */
  7063. getWorldMatrix(): DeepImmutable<Matrix>;
  7064. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * Tests if the bounding sphere is intersecting the frustum planes
  7067. * @param frustumPlanes defines the frustum planes to test
  7068. * @returns true if there is an intersection
  7069. */
  7070. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7071. /**
  7072. * Tests if the bounding sphere center is in between the frustum planes.
  7073. * Used for optimistic fast inclusion.
  7074. * @param frustumPlanes defines the frustum planes to test
  7075. * @returns true if the sphere center is in between the frustum planes
  7076. */
  7077. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7078. /**
  7079. * Tests if a point is inside the bounding sphere
  7080. * @param point defines the point to test
  7081. * @returns true if the point is inside the bounding sphere
  7082. */
  7083. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Checks if two sphere intersct
  7086. * @param sphere0 sphere 0
  7087. * @param sphere1 sphere 1
  7088. * @returns true if the speres intersect
  7089. */
  7090. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7091. }
  7092. }
  7093. declare module BABYLON {
  7094. /**
  7095. * Class used to store bounding box information
  7096. */
  7097. export class BoundingBox implements ICullable {
  7098. /**
  7099. * Gets the 8 vectors representing the bounding box in local space
  7100. */
  7101. readonly vectors: Vector3[];
  7102. /**
  7103. * Gets the center of the bounding box in local space
  7104. */
  7105. readonly center: Vector3;
  7106. /**
  7107. * Gets the center of the bounding box in world space
  7108. */
  7109. readonly centerWorld: Vector3;
  7110. /**
  7111. * Gets the extend size in local space
  7112. */
  7113. readonly extendSize: Vector3;
  7114. /**
  7115. * Gets the extend size in world space
  7116. */
  7117. readonly extendSizeWorld: Vector3;
  7118. /**
  7119. * Gets the OBB (object bounding box) directions
  7120. */
  7121. readonly directions: Vector3[];
  7122. /**
  7123. * Gets the 8 vectors representing the bounding box in world space
  7124. */
  7125. readonly vectorsWorld: Vector3[];
  7126. /**
  7127. * Gets the minimum vector in world space
  7128. */
  7129. readonly minimumWorld: Vector3;
  7130. /**
  7131. * Gets the maximum vector in world space
  7132. */
  7133. readonly maximumWorld: Vector3;
  7134. /**
  7135. * Gets the minimum vector in local space
  7136. */
  7137. readonly minimum: Vector3;
  7138. /**
  7139. * Gets the maximum vector in local space
  7140. */
  7141. readonly maximum: Vector3;
  7142. private _worldMatrix;
  7143. private static readonly TmpVector3;
  7144. /**
  7145. * @hidden
  7146. */ private _tag: number;
  7147. /**
  7148. * Creates a new bounding box
  7149. * @param min defines the minimum vector (in local space)
  7150. * @param max defines the maximum vector (in local space)
  7151. * @param worldMatrix defines the new world matrix
  7152. */
  7153. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7154. /**
  7155. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7156. * @param min defines the new minimum vector (in local space)
  7157. * @param max defines the new maximum vector (in local space)
  7158. * @param worldMatrix defines the new world matrix
  7159. */
  7160. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7161. /**
  7162. * Scale the current bounding box by applying a scale factor
  7163. * @param factor defines the scale factor to apply
  7164. * @returns the current bounding box
  7165. */
  7166. scale(factor: number): BoundingBox;
  7167. /**
  7168. * Gets the world matrix of the bounding box
  7169. * @returns a matrix
  7170. */
  7171. getWorldMatrix(): DeepImmutable<Matrix>;
  7172. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  7173. /**
  7174. * Tests if the bounding box is intersecting the frustum planes
  7175. * @param frustumPlanes defines the frustum planes to test
  7176. * @returns true if there is an intersection
  7177. */
  7178. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7179. /**
  7180. * Tests if the bounding box is entirely inside the frustum planes
  7181. * @param frustumPlanes defines the frustum planes to test
  7182. * @returns true if there is an inclusion
  7183. */
  7184. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7185. /**
  7186. * Tests if a point is inside the bounding box
  7187. * @param point defines the point to test
  7188. * @returns true if the point is inside the bounding box
  7189. */
  7190. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7191. /**
  7192. * Tests if the bounding box intersects with a bounding sphere
  7193. * @param sphere defines the sphere to test
  7194. * @returns true if there is an intersection
  7195. */
  7196. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7197. /**
  7198. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7199. * @param min defines the min vector to use
  7200. * @param max defines the max vector to use
  7201. * @returns true if there is an intersection
  7202. */
  7203. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7204. /**
  7205. * Tests if two bounding boxes are intersections
  7206. * @param box0 defines the first box to test
  7207. * @param box1 defines the second box to test
  7208. * @returns true if there is an intersection
  7209. */
  7210. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7211. /**
  7212. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7213. * @param minPoint defines the minimum vector of the bounding box
  7214. * @param maxPoint defines the maximum vector of the bounding box
  7215. * @param sphereCenter defines the sphere center
  7216. * @param sphereRadius defines the sphere radius
  7217. * @returns true if there is an intersection
  7218. */
  7219. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7220. /**
  7221. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7222. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7223. * @param frustumPlanes defines the frustum planes to test
  7224. * @return true if there is an inclusion
  7225. */
  7226. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7227. /**
  7228. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7229. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7230. * @param frustumPlanes defines the frustum planes to test
  7231. * @return true if there is an intersection
  7232. */
  7233. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7234. }
  7235. }
  7236. declare module BABYLON {
  7237. /** @hidden */
  7238. export class Collider {
  7239. /** Define if a collision was found */
  7240. collisionFound: boolean;
  7241. /**
  7242. * Define last intersection point in local space
  7243. */
  7244. intersectionPoint: Vector3;
  7245. /**
  7246. * Define last collided mesh
  7247. */
  7248. collidedMesh: Nullable<AbstractMesh>;
  7249. private _collisionPoint;
  7250. private _planeIntersectionPoint;
  7251. private _tempVector;
  7252. private _tempVector2;
  7253. private _tempVector3;
  7254. private _tempVector4;
  7255. private _edge;
  7256. private _baseToVertex;
  7257. private _destinationPoint;
  7258. private _slidePlaneNormal;
  7259. private _displacementVector;
  7260. /** @hidden */ private _radius: Vector3;
  7261. /** @hidden */ private _retry: number;
  7262. private _velocity;
  7263. private _basePoint;
  7264. private _epsilon;
  7265. /** @hidden */ private _velocityWorldLength: number;
  7266. /** @hidden */ private _basePointWorld: Vector3;
  7267. private _velocityWorld;
  7268. private _normalizedVelocity;
  7269. /** @hidden */ private _initialVelocity: Vector3;
  7270. /** @hidden */ private _initialPosition: Vector3;
  7271. private _nearestDistance;
  7272. private _collisionMask;
  7273. collisionMask: number;
  7274. /**
  7275. * Gets the plane normal used to compute the sliding response (in local space)
  7276. */
  7277. readonly slidePlaneNormal: Vector3;
  7278. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7279. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7280. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7281. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7282. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7283. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7284. }
  7285. }
  7286. declare module BABYLON {
  7287. /**
  7288. * Interface for cullable objects
  7289. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7290. */
  7291. export interface ICullable {
  7292. /**
  7293. * Checks if the object or part of the object is in the frustum
  7294. * @param frustumPlanes Camera near/planes
  7295. * @returns true if the object is in frustum otherwise false
  7296. */
  7297. isInFrustum(frustumPlanes: Plane[]): boolean;
  7298. /**
  7299. * Checks if a cullable object (mesh...) is in the camera frustum
  7300. * Unlike isInFrustum this cheks the full bounding box
  7301. * @param frustumPlanes Camera near/planes
  7302. * @returns true if the object is in frustum otherwise false
  7303. */
  7304. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7305. }
  7306. /**
  7307. * Info for a bounding data of a mesh
  7308. */
  7309. export class BoundingInfo implements ICullable {
  7310. /**
  7311. * Bounding box for the mesh
  7312. */
  7313. readonly boundingBox: BoundingBox;
  7314. /**
  7315. * Bounding sphere for the mesh
  7316. */
  7317. readonly boundingSphere: BoundingSphere;
  7318. private _isLocked;
  7319. private static readonly TmpVector3;
  7320. /**
  7321. * Constructs bounding info
  7322. * @param minimum min vector of the bounding box/sphere
  7323. * @param maximum max vector of the bounding box/sphere
  7324. * @param worldMatrix defines the new world matrix
  7325. */
  7326. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7327. /**
  7328. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7329. * @param min defines the new minimum vector (in local space)
  7330. * @param max defines the new maximum vector (in local space)
  7331. * @param worldMatrix defines the new world matrix
  7332. */
  7333. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7334. /**
  7335. * min vector of the bounding box/sphere
  7336. */
  7337. readonly minimum: Vector3;
  7338. /**
  7339. * max vector of the bounding box/sphere
  7340. */
  7341. readonly maximum: Vector3;
  7342. /**
  7343. * If the info is locked and won't be updated to avoid perf overhead
  7344. */
  7345. isLocked: boolean;
  7346. /**
  7347. * Updates the bounding sphere and box
  7348. * @param world world matrix to be used to update
  7349. */
  7350. update(world: DeepImmutable<Matrix>): void;
  7351. /**
  7352. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7353. * @param center New center of the bounding info
  7354. * @param extend New extend of the bounding info
  7355. * @returns the current bounding info
  7356. */
  7357. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7358. /**
  7359. * Scale the current bounding info by applying a scale factor
  7360. * @param factor defines the scale factor to apply
  7361. * @returns the current bounding info
  7362. */
  7363. scale(factor: number): BoundingInfo;
  7364. /**
  7365. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7366. * @param frustumPlanes defines the frustum to test
  7367. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7368. * @returns true if the bounding info is in the frustum planes
  7369. */
  7370. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7371. /**
  7372. * Gets the world distance between the min and max points of the bounding box
  7373. */
  7374. readonly diagonalLength: number;
  7375. /**
  7376. * Checks if a cullable object (mesh...) is in the camera frustum
  7377. * Unlike isInFrustum this cheks the full bounding box
  7378. * @param frustumPlanes Camera near/planes
  7379. * @returns true if the object is in frustum otherwise false
  7380. */
  7381. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7382. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7383. /**
  7384. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7385. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7386. * @param point the point to check intersection with
  7387. * @returns if the point intersects
  7388. */
  7389. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7390. /**
  7391. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7392. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7393. * @param boundingInfo the bounding info to check intersection with
  7394. * @param precise if the intersection should be done using OBB
  7395. * @returns if the bounding info intersects
  7396. */
  7397. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7398. }
  7399. }
  7400. declare module BABYLON {
  7401. /**
  7402. * Extracts minimum and maximum values from a list of indexed positions
  7403. * @param positions defines the positions to use
  7404. * @param indices defines the indices to the positions
  7405. * @param indexStart defines the start index
  7406. * @param indexCount defines the end index
  7407. * @param bias defines bias value to add to the result
  7408. * @return minimum and maximum values
  7409. */
  7410. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7411. minimum: Vector3;
  7412. maximum: Vector3;
  7413. };
  7414. /**
  7415. * Extracts minimum and maximum values from a list of positions
  7416. * @param positions defines the positions to use
  7417. * @param start defines the start index in the positions array
  7418. * @param count defines the number of positions to handle
  7419. * @param bias defines bias value to add to the result
  7420. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7421. * @return minimum and maximum values
  7422. */
  7423. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7424. minimum: Vector3;
  7425. maximum: Vector3;
  7426. };
  7427. }
  7428. declare module BABYLON {
  7429. /**
  7430. * Enum that determines the text-wrapping mode to use.
  7431. */
  7432. export enum InspectableType {
  7433. /**
  7434. * Checkbox for booleans
  7435. */
  7436. Checkbox = 0,
  7437. /**
  7438. * Sliders for numbers
  7439. */
  7440. Slider = 1,
  7441. /**
  7442. * Vector3
  7443. */
  7444. Vector3 = 2,
  7445. /**
  7446. * Quaternions
  7447. */
  7448. Quaternion = 3,
  7449. /**
  7450. * Color3
  7451. */
  7452. Color3 = 4,
  7453. /**
  7454. * String
  7455. */
  7456. String = 5
  7457. }
  7458. /**
  7459. * Interface used to define custom inspectable properties.
  7460. * This interface is used by the inspector to display custom property grids
  7461. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7462. */
  7463. export interface IInspectable {
  7464. /**
  7465. * Gets the label to display
  7466. */
  7467. label: string;
  7468. /**
  7469. * Gets the name of the property to edit
  7470. */
  7471. propertyName: string;
  7472. /**
  7473. * Gets the type of the editor to use
  7474. */
  7475. type: InspectableType;
  7476. /**
  7477. * Gets the minimum value of the property when using in "slider" mode
  7478. */
  7479. min?: number;
  7480. /**
  7481. * Gets the maximum value of the property when using in "slider" mode
  7482. */
  7483. max?: number;
  7484. /**
  7485. * Gets the setp to use when using in "slider" mode
  7486. */
  7487. step?: number;
  7488. }
  7489. }
  7490. declare module BABYLON {
  7491. /**
  7492. * Class used to provide helper for timing
  7493. */
  7494. export class TimingTools {
  7495. /**
  7496. * Polyfill for setImmediate
  7497. * @param action defines the action to execute after the current execution block
  7498. */
  7499. static SetImmediate(action: () => void): void;
  7500. }
  7501. }
  7502. declare module BABYLON {
  7503. /**
  7504. * Class used to enable instatition of objects by class name
  7505. */
  7506. export class InstantiationTools {
  7507. /**
  7508. * Use this object to register external classes like custom textures or material
  7509. * to allow the laoders to instantiate them
  7510. */
  7511. static RegisteredExternalClasses: {
  7512. [key: string]: Object;
  7513. };
  7514. /**
  7515. * Tries to instantiate a new object from a given class name
  7516. * @param className defines the class name to instantiate
  7517. * @returns the new object or null if the system was not able to do the instantiation
  7518. */
  7519. static Instantiate(className: string): any;
  7520. }
  7521. }
  7522. declare module BABYLON {
  7523. /**
  7524. * This represents the required contract to create a new type of texture loader.
  7525. */
  7526. export interface IInternalTextureLoader {
  7527. /**
  7528. * Defines wether the loader supports cascade loading the different faces.
  7529. */
  7530. supportCascades: boolean;
  7531. /**
  7532. * This returns if the loader support the current file information.
  7533. * @param extension defines the file extension of the file being loaded
  7534. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7535. * @param fallback defines the fallback internal texture if any
  7536. * @param isBase64 defines whether the texture is encoded as a base64
  7537. * @param isBuffer defines whether the texture data are stored as a buffer
  7538. * @returns true if the loader can load the specified file
  7539. */
  7540. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7541. /**
  7542. * Transform the url before loading if required.
  7543. * @param rootUrl the url of the texture
  7544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7545. * @returns the transformed texture
  7546. */
  7547. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7548. /**
  7549. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7550. * @param rootUrl the url of the texture
  7551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7552. * @returns the fallback texture
  7553. */
  7554. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7555. /**
  7556. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7557. * @param data contains the texture data
  7558. * @param texture defines the BabylonJS internal texture
  7559. * @param createPolynomials will be true if polynomials have been requested
  7560. * @param onLoad defines the callback to trigger once the texture is ready
  7561. * @param onError defines the callback to trigger in case of error
  7562. */
  7563. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7564. /**
  7565. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7566. * @param data contains the texture data
  7567. * @param texture defines the BabylonJS internal texture
  7568. * @param callback defines the method to call once ready to upload
  7569. */
  7570. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7571. }
  7572. }
  7573. declare module BABYLON {
  7574. interface Engine {
  7575. /**
  7576. * Creates a depth stencil cube texture.
  7577. * This is only available in WebGL 2.
  7578. * @param size The size of face edge in the cube texture.
  7579. * @param options The options defining the cube texture.
  7580. * @returns The cube texture
  7581. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7582. /**
  7583. * Creates a cube texture
  7584. * @param rootUrl defines the url where the files to load is located
  7585. * @param scene defines the current scene
  7586. * @param files defines the list of files to load (1 per face)
  7587. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7588. * @param onLoad defines an optional callback raised when the texture is loaded
  7589. * @param onError defines an optional callback raised if there is an issue to load the texture
  7590. * @param format defines the format of the data
  7591. * @param forcedExtension defines the extension to use to pick the right loader
  7592. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7593. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7594. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7595. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7596. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7597. * @returns the cube texture as an InternalTexture
  7598. */
  7599. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7600. /**
  7601. * Creates a cube texture
  7602. * @param rootUrl defines the url where the files to load is located
  7603. * @param scene defines the current scene
  7604. * @param files defines the list of files to load (1 per face)
  7605. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7606. * @param onLoad defines an optional callback raised when the texture is loaded
  7607. * @param onError defines an optional callback raised if there is an issue to load the texture
  7608. * @param format defines the format of the data
  7609. * @param forcedExtension defines the extension to use to pick the right loader
  7610. * @returns the cube texture as an InternalTexture
  7611. */
  7612. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7613. /**
  7614. * Creates a cube texture
  7615. * @param rootUrl defines the url where the files to load is located
  7616. * @param scene defines the current scene
  7617. * @param files defines the list of files to load (1 per face)
  7618. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7619. * @param onLoad defines an optional callback raised when the texture is loaded
  7620. * @param onError defines an optional callback raised if there is an issue to load the texture
  7621. * @param format defines the format of the data
  7622. * @param forcedExtension defines the extension to use to pick the right loader
  7623. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7624. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7625. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7626. * @returns the cube texture as an InternalTexture
  7627. */
  7628. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7629. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7630. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7631. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7632. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7633. }
  7634. }
  7635. declare module BABYLON {
  7636. /**
  7637. * Class for creating a cube texture
  7638. */
  7639. export class CubeTexture extends BaseTexture {
  7640. private _delayedOnLoad;
  7641. /**
  7642. * The url of the texture
  7643. */
  7644. url: string;
  7645. /**
  7646. * Gets or sets the center of the bounding box associated with the cube texture.
  7647. * It must define where the camera used to render the texture was set
  7648. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7649. */
  7650. boundingBoxPosition: Vector3;
  7651. private _boundingBoxSize;
  7652. /**
  7653. * Gets or sets the size of the bounding box associated with the cube texture
  7654. * When defined, the cubemap will switch to local mode
  7655. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7656. * @example https://www.babylonjs-playground.com/#RNASML
  7657. */
  7658. /**
  7659. * Returns the bounding box size
  7660. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7661. */
  7662. boundingBoxSize: Vector3;
  7663. protected _rotationY: number;
  7664. /**
  7665. * Sets texture matrix rotation angle around Y axis in radians.
  7666. */
  7667. /**
  7668. * Gets texture matrix rotation angle around Y axis radians.
  7669. */
  7670. rotationY: number;
  7671. /**
  7672. * Are mip maps generated for this texture or not.
  7673. */
  7674. readonly noMipmap: boolean;
  7675. private _noMipmap;
  7676. private _files;
  7677. private _extensions;
  7678. private _textureMatrix;
  7679. private _format;
  7680. private _createPolynomials;
  7681. /** @hidden */ private _prefiltered: boolean;
  7682. /**
  7683. * Creates a cube texture from an array of image urls
  7684. * @param files defines an array of image urls
  7685. * @param scene defines the hosting scene
  7686. * @param noMipmap specifies if mip maps are not used
  7687. * @returns a cube texture
  7688. */
  7689. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7690. /**
  7691. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7692. * @param url defines the url of the prefiltered texture
  7693. * @param scene defines the scene the texture is attached to
  7694. * @param forcedExtension defines the extension of the file if different from the url
  7695. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7696. * @return the prefiltered texture
  7697. */
  7698. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7699. /**
  7700. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7701. * as prefiltered data.
  7702. * @param rootUrl defines the url of the texture or the root name of the six images
  7703. * @param scene defines the scene the texture is attached to
  7704. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7705. * @param noMipmap defines if mipmaps should be created or not
  7706. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7707. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7708. * @param onError defines a callback triggered in case of error during load
  7709. * @param format defines the internal format to use for the texture once loaded
  7710. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7711. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7712. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7713. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7714. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7715. * @return the cube texture
  7716. */
  7717. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7718. /**
  7719. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7720. */
  7721. readonly isPrefiltered: boolean;
  7722. /**
  7723. * Get the current class name of the texture useful for serialization or dynamic coding.
  7724. * @returns "CubeTexture"
  7725. */
  7726. getClassName(): string;
  7727. /**
  7728. * Update the url (and optional buffer) of this texture if url was null during construction.
  7729. * @param url the url of the texture
  7730. * @param forcedExtension defines the extension to use
  7731. * @param onLoad callback called when the texture is loaded (defaults to null)
  7732. */
  7733. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7734. /**
  7735. * Delays loading of the cube texture
  7736. * @param forcedExtension defines the extension to use
  7737. */
  7738. delayLoad(forcedExtension?: string): void;
  7739. /**
  7740. * Returns the reflection texture matrix
  7741. * @returns the reflection texture matrix
  7742. */
  7743. getReflectionTextureMatrix(): Matrix;
  7744. /**
  7745. * Sets the reflection texture matrix
  7746. * @param value Reflection texture matrix
  7747. */
  7748. setReflectionTextureMatrix(value: Matrix): void;
  7749. /**
  7750. * Parses text to create a cube texture
  7751. * @param parsedTexture define the serialized text to read from
  7752. * @param scene defines the hosting scene
  7753. * @param rootUrl defines the root url of the cube texture
  7754. * @returns a cube texture
  7755. */
  7756. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7757. /**
  7758. * Makes a clone, or deep copy, of the cube texture
  7759. * @returns a new cube texture
  7760. */
  7761. clone(): CubeTexture;
  7762. }
  7763. }
  7764. declare module BABYLON {
  7765. /**
  7766. * Manages the defines for the Material
  7767. */
  7768. export class MaterialDefines {
  7769. /** @hidden */
  7770. protected _keys: string[];
  7771. private _isDirty;
  7772. /** @hidden */ private _renderId: number;
  7773. /** @hidden */ private _areLightsDirty: boolean;
  7774. /** @hidden */ private _areLightsDisposed: boolean;
  7775. /** @hidden */ private _areAttributesDirty: boolean;
  7776. /** @hidden */ private _areTexturesDirty: boolean;
  7777. /** @hidden */ private _areFresnelDirty: boolean;
  7778. /** @hidden */ private _areMiscDirty: boolean;
  7779. /** @hidden */ private _areImageProcessingDirty: boolean;
  7780. /** @hidden */ private _normals: boolean;
  7781. /** @hidden */ private _uvs: boolean;
  7782. /** @hidden */ private _needNormals: boolean;
  7783. /** @hidden */ private _needUVs: boolean;
  7784. [id: string]: any;
  7785. /**
  7786. * Specifies if the material needs to be re-calculated
  7787. */
  7788. readonly isDirty: boolean;
  7789. /**
  7790. * Marks the material to indicate that it has been re-calculated
  7791. */
  7792. markAsProcessed(): void;
  7793. /**
  7794. * Marks the material to indicate that it needs to be re-calculated
  7795. */
  7796. markAsUnprocessed(): void;
  7797. /**
  7798. * Marks the material to indicate all of its defines need to be re-calculated
  7799. */
  7800. markAllAsDirty(): void;
  7801. /**
  7802. * Marks the material to indicate that image processing needs to be re-calculated
  7803. */
  7804. markAsImageProcessingDirty(): void;
  7805. /**
  7806. * Marks the material to indicate the lights need to be re-calculated
  7807. * @param disposed Defines whether the light is dirty due to dispose or not
  7808. */
  7809. markAsLightDirty(disposed?: boolean): void;
  7810. /**
  7811. * Marks the attribute state as changed
  7812. */
  7813. markAsAttributesDirty(): void;
  7814. /**
  7815. * Marks the texture state as changed
  7816. */
  7817. markAsTexturesDirty(): void;
  7818. /**
  7819. * Marks the fresnel state as changed
  7820. */
  7821. markAsFresnelDirty(): void;
  7822. /**
  7823. * Marks the misc state as changed
  7824. */
  7825. markAsMiscDirty(): void;
  7826. /**
  7827. * Rebuilds the material defines
  7828. */
  7829. rebuild(): void;
  7830. /**
  7831. * Specifies if two material defines are equal
  7832. * @param other - A material define instance to compare to
  7833. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7834. */
  7835. isEqual(other: MaterialDefines): boolean;
  7836. /**
  7837. * Clones this instance's defines to another instance
  7838. * @param other - material defines to clone values to
  7839. */
  7840. cloneTo(other: MaterialDefines): void;
  7841. /**
  7842. * Resets the material define values
  7843. */
  7844. reset(): void;
  7845. /**
  7846. * Converts the material define values to a string
  7847. * @returns - String of material define information
  7848. */
  7849. toString(): string;
  7850. }
  7851. }
  7852. declare module BABYLON {
  7853. /**
  7854. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7855. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7856. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7857. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7858. */
  7859. export class ColorCurves {
  7860. private _dirty;
  7861. private _tempColor;
  7862. private _globalCurve;
  7863. private _highlightsCurve;
  7864. private _midtonesCurve;
  7865. private _shadowsCurve;
  7866. private _positiveCurve;
  7867. private _negativeCurve;
  7868. private _globalHue;
  7869. private _globalDensity;
  7870. private _globalSaturation;
  7871. private _globalExposure;
  7872. /**
  7873. * Gets the global Hue value.
  7874. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7875. */
  7876. /**
  7877. * Sets the global Hue value.
  7878. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7879. */
  7880. globalHue: number;
  7881. /**
  7882. * Gets the global Density value.
  7883. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7884. * Values less than zero provide a filter of opposite hue.
  7885. */
  7886. /**
  7887. * Sets the global Density value.
  7888. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7889. * Values less than zero provide a filter of opposite hue.
  7890. */
  7891. globalDensity: number;
  7892. /**
  7893. * Gets the global Saturation value.
  7894. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7895. */
  7896. /**
  7897. * Sets the global Saturation value.
  7898. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7899. */
  7900. globalSaturation: number;
  7901. /**
  7902. * Gets the global Exposure value.
  7903. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7904. */
  7905. /**
  7906. * Sets the global Exposure value.
  7907. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7908. */
  7909. globalExposure: number;
  7910. private _highlightsHue;
  7911. private _highlightsDensity;
  7912. private _highlightsSaturation;
  7913. private _highlightsExposure;
  7914. /**
  7915. * Gets the highlights Hue value.
  7916. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7917. */
  7918. /**
  7919. * Sets the highlights Hue value.
  7920. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7921. */
  7922. highlightsHue: number;
  7923. /**
  7924. * Gets the highlights Density value.
  7925. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7926. * Values less than zero provide a filter of opposite hue.
  7927. */
  7928. /**
  7929. * Sets the highlights Density value.
  7930. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7931. * Values less than zero provide a filter of opposite hue.
  7932. */
  7933. highlightsDensity: number;
  7934. /**
  7935. * Gets the highlights Saturation value.
  7936. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7937. */
  7938. /**
  7939. * Sets the highlights Saturation value.
  7940. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7941. */
  7942. highlightsSaturation: number;
  7943. /**
  7944. * Gets the highlights Exposure value.
  7945. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7946. */
  7947. /**
  7948. * Sets the highlights Exposure value.
  7949. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7950. */
  7951. highlightsExposure: number;
  7952. private _midtonesHue;
  7953. private _midtonesDensity;
  7954. private _midtonesSaturation;
  7955. private _midtonesExposure;
  7956. /**
  7957. * Gets the midtones Hue value.
  7958. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7959. */
  7960. /**
  7961. * Sets the midtones Hue value.
  7962. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7963. */
  7964. midtonesHue: number;
  7965. /**
  7966. * Gets the midtones Density value.
  7967. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. /**
  7971. * Sets the midtones Density value.
  7972. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7973. * Values less than zero provide a filter of opposite hue.
  7974. */
  7975. midtonesDensity: number;
  7976. /**
  7977. * Gets the midtones Saturation value.
  7978. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7979. */
  7980. /**
  7981. * Sets the midtones Saturation value.
  7982. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7983. */
  7984. midtonesSaturation: number;
  7985. /**
  7986. * Gets the midtones Exposure value.
  7987. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7988. */
  7989. /**
  7990. * Sets the midtones Exposure value.
  7991. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7992. */
  7993. midtonesExposure: number;
  7994. private _shadowsHue;
  7995. private _shadowsDensity;
  7996. private _shadowsSaturation;
  7997. private _shadowsExposure;
  7998. /**
  7999. * Gets the shadows Hue value.
  8000. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8001. */
  8002. /**
  8003. * Sets the shadows Hue value.
  8004. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8005. */
  8006. shadowsHue: number;
  8007. /**
  8008. * Gets the shadows Density value.
  8009. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8010. * Values less than zero provide a filter of opposite hue.
  8011. */
  8012. /**
  8013. * Sets the shadows Density value.
  8014. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8015. * Values less than zero provide a filter of opposite hue.
  8016. */
  8017. shadowsDensity: number;
  8018. /**
  8019. * Gets the shadows Saturation value.
  8020. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8021. */
  8022. /**
  8023. * Sets the shadows Saturation value.
  8024. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8025. */
  8026. shadowsSaturation: number;
  8027. /**
  8028. * Gets the shadows Exposure value.
  8029. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8030. */
  8031. /**
  8032. * Sets the shadows Exposure value.
  8033. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8034. */
  8035. shadowsExposure: number;
  8036. /**
  8037. * Returns the class name
  8038. * @returns The class name
  8039. */
  8040. getClassName(): string;
  8041. /**
  8042. * Binds the color curves to the shader.
  8043. * @param colorCurves The color curve to bind
  8044. * @param effect The effect to bind to
  8045. * @param positiveUniform The positive uniform shader parameter
  8046. * @param neutralUniform The neutral uniform shader parameter
  8047. * @param negativeUniform The negative uniform shader parameter
  8048. */
  8049. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8050. /**
  8051. * Prepare the list of uniforms associated with the ColorCurves effects.
  8052. * @param uniformsList The list of uniforms used in the effect
  8053. */
  8054. static PrepareUniforms(uniformsList: string[]): void;
  8055. /**
  8056. * Returns color grading data based on a hue, density, saturation and exposure value.
  8057. * @param filterHue The hue of the color filter.
  8058. * @param filterDensity The density of the color filter.
  8059. * @param saturation The saturation.
  8060. * @param exposure The exposure.
  8061. * @param result The result data container.
  8062. */
  8063. private getColorGradingDataToRef;
  8064. /**
  8065. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8066. * @param value The input slider value in range [-100,100].
  8067. * @returns Adjusted value.
  8068. */
  8069. private static applyColorGradingSliderNonlinear;
  8070. /**
  8071. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8072. * @param hue The hue (H) input.
  8073. * @param saturation The saturation (S) input.
  8074. * @param brightness The brightness (B) input.
  8075. * @result An RGBA color represented as Vector4.
  8076. */
  8077. private static fromHSBToRef;
  8078. /**
  8079. * Returns a value clamped between min and max
  8080. * @param value The value to clamp
  8081. * @param min The minimum of value
  8082. * @param max The maximum of value
  8083. * @returns The clamped value.
  8084. */
  8085. private static clamp;
  8086. /**
  8087. * Clones the current color curve instance.
  8088. * @return The cloned curves
  8089. */
  8090. clone(): ColorCurves;
  8091. /**
  8092. * Serializes the current color curve instance to a json representation.
  8093. * @return a JSON representation
  8094. */
  8095. serialize(): any;
  8096. /**
  8097. * Parses the color curve from a json representation.
  8098. * @param source the JSON source to parse
  8099. * @return The parsed curves
  8100. */
  8101. static Parse(source: any): ColorCurves;
  8102. }
  8103. }
  8104. declare module BABYLON {
  8105. /**
  8106. * Interface to follow in your material defines to integrate easily the
  8107. * Image proccessing functions.
  8108. * @hidden
  8109. */
  8110. export interface IImageProcessingConfigurationDefines {
  8111. IMAGEPROCESSING: boolean;
  8112. VIGNETTE: boolean;
  8113. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8114. VIGNETTEBLENDMODEOPAQUE: boolean;
  8115. TONEMAPPING: boolean;
  8116. TONEMAPPING_ACES: boolean;
  8117. CONTRAST: boolean;
  8118. EXPOSURE: boolean;
  8119. COLORCURVES: boolean;
  8120. COLORGRADING: boolean;
  8121. COLORGRADING3D: boolean;
  8122. SAMPLER3DGREENDEPTH: boolean;
  8123. SAMPLER3DBGRMAP: boolean;
  8124. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8125. }
  8126. /**
  8127. * @hidden
  8128. */
  8129. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8130. IMAGEPROCESSING: boolean;
  8131. VIGNETTE: boolean;
  8132. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8133. VIGNETTEBLENDMODEOPAQUE: boolean;
  8134. TONEMAPPING: boolean;
  8135. TONEMAPPING_ACES: boolean;
  8136. CONTRAST: boolean;
  8137. COLORCURVES: boolean;
  8138. COLORGRADING: boolean;
  8139. COLORGRADING3D: boolean;
  8140. SAMPLER3DGREENDEPTH: boolean;
  8141. SAMPLER3DBGRMAP: boolean;
  8142. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8143. EXPOSURE: boolean;
  8144. constructor();
  8145. }
  8146. /**
  8147. * This groups together the common properties used for image processing either in direct forward pass
  8148. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8149. * or not.
  8150. */
  8151. export class ImageProcessingConfiguration {
  8152. /**
  8153. * Default tone mapping applied in BabylonJS.
  8154. */
  8155. static readonly TONEMAPPING_STANDARD: number;
  8156. /**
  8157. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8158. * to other engines rendering to increase portability.
  8159. */
  8160. static readonly TONEMAPPING_ACES: number;
  8161. /**
  8162. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8163. */
  8164. colorCurves: Nullable<ColorCurves>;
  8165. private _colorCurvesEnabled;
  8166. /**
  8167. * Gets wether the color curves effect is enabled.
  8168. */
  8169. /**
  8170. * Sets wether the color curves effect is enabled.
  8171. */
  8172. colorCurvesEnabled: boolean;
  8173. private _colorGradingTexture;
  8174. /**
  8175. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8176. */
  8177. /**
  8178. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8179. */
  8180. colorGradingTexture: Nullable<BaseTexture>;
  8181. private _colorGradingEnabled;
  8182. /**
  8183. * Gets wether the color grading effect is enabled.
  8184. */
  8185. /**
  8186. * Sets wether the color grading effect is enabled.
  8187. */
  8188. colorGradingEnabled: boolean;
  8189. private _colorGradingWithGreenDepth;
  8190. /**
  8191. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8192. */
  8193. /**
  8194. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8195. */
  8196. colorGradingWithGreenDepth: boolean;
  8197. private _colorGradingBGR;
  8198. /**
  8199. * Gets wether the color grading texture contains BGR values.
  8200. */
  8201. /**
  8202. * Sets wether the color grading texture contains BGR values.
  8203. */
  8204. colorGradingBGR: boolean;
  8205. /** @hidden */ private _exposure: number;
  8206. /**
  8207. * Gets the Exposure used in the effect.
  8208. */
  8209. /**
  8210. * Sets the Exposure used in the effect.
  8211. */
  8212. exposure: number;
  8213. private _toneMappingEnabled;
  8214. /**
  8215. * Gets wether the tone mapping effect is enabled.
  8216. */
  8217. /**
  8218. * Sets wether the tone mapping effect is enabled.
  8219. */
  8220. toneMappingEnabled: boolean;
  8221. private _toneMappingType;
  8222. /**
  8223. * Gets the type of tone mapping effect.
  8224. */
  8225. /**
  8226. * Sets the type of tone mapping effect used in BabylonJS.
  8227. */
  8228. toneMappingType: number;
  8229. protected _contrast: number;
  8230. /**
  8231. * Gets the contrast used in the effect.
  8232. */
  8233. /**
  8234. * Sets the contrast used in the effect.
  8235. */
  8236. contrast: number;
  8237. /**
  8238. * Vignette stretch size.
  8239. */
  8240. vignetteStretch: number;
  8241. /**
  8242. * Vignette centre X Offset.
  8243. */
  8244. vignetteCentreX: number;
  8245. /**
  8246. * Vignette centre Y Offset.
  8247. */
  8248. vignetteCentreY: number;
  8249. /**
  8250. * Vignette weight or intensity of the vignette effect.
  8251. */
  8252. vignetteWeight: number;
  8253. /**
  8254. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8255. * if vignetteEnabled is set to true.
  8256. */
  8257. vignetteColor: Color4;
  8258. /**
  8259. * Camera field of view used by the Vignette effect.
  8260. */
  8261. vignetteCameraFov: number;
  8262. private _vignetteBlendMode;
  8263. /**
  8264. * Gets the vignette blend mode allowing different kind of effect.
  8265. */
  8266. /**
  8267. * Sets the vignette blend mode allowing different kind of effect.
  8268. */
  8269. vignetteBlendMode: number;
  8270. private _vignetteEnabled;
  8271. /**
  8272. * Gets wether the vignette effect is enabled.
  8273. */
  8274. /**
  8275. * Sets wether the vignette effect is enabled.
  8276. */
  8277. vignetteEnabled: boolean;
  8278. private _applyByPostProcess;
  8279. /**
  8280. * Gets wether the image processing is applied through a post process or not.
  8281. */
  8282. /**
  8283. * Sets wether the image processing is applied through a post process or not.
  8284. */
  8285. applyByPostProcess: boolean;
  8286. private _isEnabled;
  8287. /**
  8288. * Gets wether the image processing is enabled or not.
  8289. */
  8290. /**
  8291. * Sets wether the image processing is enabled or not.
  8292. */
  8293. isEnabled: boolean;
  8294. /**
  8295. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8296. */
  8297. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8298. /**
  8299. * Method called each time the image processing information changes requires to recompile the effect.
  8300. */
  8301. protected _updateParameters(): void;
  8302. /**
  8303. * Gets the current class name.
  8304. * @return "ImageProcessingConfiguration"
  8305. */
  8306. getClassName(): string;
  8307. /**
  8308. * Prepare the list of uniforms associated with the Image Processing effects.
  8309. * @param uniforms The list of uniforms used in the effect
  8310. * @param defines the list of defines currently in use
  8311. */
  8312. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8313. /**
  8314. * Prepare the list of samplers associated with the Image Processing effects.
  8315. * @param samplersList The list of uniforms used in the effect
  8316. * @param defines the list of defines currently in use
  8317. */
  8318. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8319. /**
  8320. * Prepare the list of defines associated to the shader.
  8321. * @param defines the list of defines to complete
  8322. * @param forPostProcess Define if we are currently in post process mode or not
  8323. */
  8324. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8325. /**
  8326. * Returns true if all the image processing information are ready.
  8327. * @returns True if ready, otherwise, false
  8328. */
  8329. isReady(): boolean;
  8330. /**
  8331. * Binds the image processing to the shader.
  8332. * @param effect The effect to bind to
  8333. * @param aspectRatio Define the current aspect ratio of the effect
  8334. */
  8335. bind(effect: Effect, aspectRatio?: number): void;
  8336. /**
  8337. * Clones the current image processing instance.
  8338. * @return The cloned image processing
  8339. */
  8340. clone(): ImageProcessingConfiguration;
  8341. /**
  8342. * Serializes the current image processing instance to a json representation.
  8343. * @return a JSON representation
  8344. */
  8345. serialize(): any;
  8346. /**
  8347. * Parses the image processing from a json representation.
  8348. * @param source the JSON source to parse
  8349. * @return The parsed image processing
  8350. */
  8351. static Parse(source: any): ImageProcessingConfiguration;
  8352. private static _VIGNETTEMODE_MULTIPLY;
  8353. private static _VIGNETTEMODE_OPAQUE;
  8354. /**
  8355. * Used to apply the vignette as a mix with the pixel color.
  8356. */
  8357. static readonly VIGNETTEMODE_MULTIPLY: number;
  8358. /**
  8359. * Used to apply the vignette as a replacement of the pixel color.
  8360. */
  8361. static readonly VIGNETTEMODE_OPAQUE: number;
  8362. }
  8363. }
  8364. declare module BABYLON {
  8365. /** @hidden */
  8366. export var postprocessVertexShader: {
  8367. name: string;
  8368. shader: string;
  8369. };
  8370. }
  8371. declare module BABYLON {
  8372. /** Defines supported spaces */
  8373. export enum Space {
  8374. /** Local (object) space */
  8375. LOCAL = 0,
  8376. /** World space */
  8377. WORLD = 1,
  8378. /** Bone space */
  8379. BONE = 2
  8380. }
  8381. /** Defines the 3 main axes */
  8382. export class Axis {
  8383. /** X axis */
  8384. static X: Vector3;
  8385. /** Y axis */
  8386. static Y: Vector3;
  8387. /** Z axis */
  8388. static Z: Vector3;
  8389. }
  8390. }
  8391. declare module BABYLON {
  8392. /**
  8393. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8394. * This is the base of the follow, arc rotate cameras and Free camera
  8395. * @see http://doc.babylonjs.com/features/cameras
  8396. */
  8397. export class TargetCamera extends Camera {
  8398. private static _RigCamTransformMatrix;
  8399. private static _TargetTransformMatrix;
  8400. private static _TargetFocalPoint;
  8401. /**
  8402. * Define the current direction the camera is moving to
  8403. */
  8404. cameraDirection: Vector3;
  8405. /**
  8406. * Define the current rotation the camera is rotating to
  8407. */
  8408. cameraRotation: Vector2;
  8409. /**
  8410. * When set, the up vector of the camera will be updated by the rotation of the camera
  8411. */
  8412. updateUpVectorFromRotation: boolean;
  8413. private _tmpQuaternion;
  8414. /**
  8415. * Define the current rotation of the camera
  8416. */
  8417. rotation: Vector3;
  8418. /**
  8419. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8420. */
  8421. rotationQuaternion: Quaternion;
  8422. /**
  8423. * Define the current speed of the camera
  8424. */
  8425. speed: number;
  8426. /**
  8427. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8428. * around all axis.
  8429. */
  8430. noRotationConstraint: boolean;
  8431. /**
  8432. * Define the current target of the camera as an object or a position.
  8433. */
  8434. lockedTarget: any;
  8435. /** @hidden */ private _currentTarget: Vector3;
  8436. /** @hidden */ private _initialFocalDistance: number;
  8437. /** @hidden */ private _viewMatrix: Matrix;
  8438. /** @hidden */ private _camMatrix: Matrix;
  8439. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8440. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8441. /** @hidden */ private _referencePoint: Vector3;
  8442. /** @hidden */ private _transformedReferencePoint: Vector3;
  8443. protected _globalCurrentTarget: Vector3;
  8444. protected _globalCurrentUpVector: Vector3;
  8445. /** @hidden */ private _reset: () => void;
  8446. private _defaultUp;
  8447. /**
  8448. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8449. * This is the base of the follow, arc rotate cameras and Free camera
  8450. * @see http://doc.babylonjs.com/features/cameras
  8451. * @param name Defines the name of the camera in the scene
  8452. * @param position Defines the start position of the camera in the scene
  8453. * @param scene Defines the scene the camera belongs to
  8454. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8455. */
  8456. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8457. /**
  8458. * Gets the position in front of the camera at a given distance.
  8459. * @param distance The distance from the camera we want the position to be
  8460. * @returns the position
  8461. */
  8462. getFrontPosition(distance: number): Vector3;
  8463. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8464. private _storedPosition;
  8465. private _storedRotation;
  8466. private _storedRotationQuaternion;
  8467. /**
  8468. * Store current camera state of the camera (fov, position, rotation, etc..)
  8469. * @returns the camera
  8470. */
  8471. storeState(): Camera;
  8472. /**
  8473. * Restored camera state. You must call storeState() first
  8474. * @returns whether it was successful or not
  8475. * @hidden
  8476. */ private _restoreStateValues(): boolean;
  8477. /** @hidden */ private _initCache(): void;
  8478. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8479. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8480. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8481. /**
  8482. * Defines the target the camera should look at.
  8483. * @param target Defines the new target as a Vector or a mesh
  8484. */
  8485. setTarget(target: Vector3): void;
  8486. /**
  8487. * Return the current target position of the camera. This value is expressed in local space.
  8488. * @returns the target position
  8489. */
  8490. getTarget(): Vector3;
  8491. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8492. /** @hidden */ private _updatePosition(): void;
  8493. /** @hidden */ private _checkInputs(): void;
  8494. protected _updateCameraRotationMatrix(): void;
  8495. /**
  8496. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8497. * @returns the current camera
  8498. */
  8499. private _rotateUpVectorWithCameraRotationMatrix;
  8500. private _cachedRotationZ;
  8501. private _cachedQuaternionRotationZ;
  8502. /** @hidden */ private _getViewMatrix(): Matrix;
  8503. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8504. /**
  8505. * @hidden
  8506. */
  8507. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8508. /**
  8509. * @hidden
  8510. */ private _updateRigCameras(): void;
  8511. private _getRigCamPositionAndTarget;
  8512. /**
  8513. * Gets the current object class name.
  8514. * @return the class name
  8515. */
  8516. getClassName(): string;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * Gather the list of keyboard event types as constants.
  8522. */
  8523. export class KeyboardEventTypes {
  8524. /**
  8525. * The keydown event is fired when a key becomes active (pressed).
  8526. */
  8527. static readonly KEYDOWN: number;
  8528. /**
  8529. * The keyup event is fired when a key has been released.
  8530. */
  8531. static readonly KEYUP: number;
  8532. }
  8533. /**
  8534. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8535. */
  8536. export class KeyboardInfo {
  8537. /**
  8538. * Defines the type of event (KeyboardEventTypes)
  8539. */
  8540. type: number;
  8541. /**
  8542. * Defines the related dom event
  8543. */
  8544. event: KeyboardEvent;
  8545. /**
  8546. * Instantiates a new keyboard info.
  8547. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8548. * @param type Defines the type of event (KeyboardEventTypes)
  8549. * @param event Defines the related dom event
  8550. */
  8551. constructor(
  8552. /**
  8553. * Defines the type of event (KeyboardEventTypes)
  8554. */
  8555. type: number,
  8556. /**
  8557. * Defines the related dom event
  8558. */
  8559. event: KeyboardEvent);
  8560. }
  8561. /**
  8562. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8563. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8564. */
  8565. export class KeyboardInfoPre extends KeyboardInfo {
  8566. /**
  8567. * Defines the type of event (KeyboardEventTypes)
  8568. */
  8569. type: number;
  8570. /**
  8571. * Defines the related dom event
  8572. */
  8573. event: KeyboardEvent;
  8574. /**
  8575. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8576. */
  8577. skipOnPointerObservable: boolean;
  8578. /**
  8579. * Instantiates a new keyboard pre info.
  8580. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8581. * @param type Defines the type of event (KeyboardEventTypes)
  8582. * @param event Defines the related dom event
  8583. */
  8584. constructor(
  8585. /**
  8586. * Defines the type of event (KeyboardEventTypes)
  8587. */
  8588. type: number,
  8589. /**
  8590. * Defines the related dom event
  8591. */
  8592. event: KeyboardEvent);
  8593. }
  8594. }
  8595. declare module BABYLON {
  8596. /**
  8597. * Manage the keyboard inputs to control the movement of a free camera.
  8598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8599. */
  8600. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8601. /**
  8602. * Defines the camera the input is attached to.
  8603. */
  8604. camera: FreeCamera;
  8605. /**
  8606. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8607. */
  8608. keysUp: number[];
  8609. /**
  8610. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8611. */
  8612. keysDown: number[];
  8613. /**
  8614. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8615. */
  8616. keysLeft: number[];
  8617. /**
  8618. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8619. */
  8620. keysRight: number[];
  8621. private _keys;
  8622. private _onCanvasBlurObserver;
  8623. private _onKeyboardObserver;
  8624. private _engine;
  8625. private _scene;
  8626. /**
  8627. * Attach the input controls to a specific dom element to get the input from.
  8628. * @param element Defines the element the controls should be listened from
  8629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8630. */
  8631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8632. /**
  8633. * Detach the current controls from the specified dom element.
  8634. * @param element Defines the element to stop listening the inputs from
  8635. */
  8636. detachControl(element: Nullable<HTMLElement>): void;
  8637. /**
  8638. * Update the current camera state depending on the inputs that have been used this frame.
  8639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8640. */
  8641. checkInputs(): void;
  8642. /**
  8643. * Gets the class name of the current intput.
  8644. * @returns the class name
  8645. */
  8646. getClassName(): string;
  8647. /** @hidden */ private _onLostFocus(): void;
  8648. /**
  8649. * Get the friendly name associated with the input class.
  8650. * @returns the input friendly name
  8651. */
  8652. getSimpleName(): string;
  8653. }
  8654. }
  8655. declare module BABYLON {
  8656. /**
  8657. * Interface describing all the common properties and methods a shadow light needs to implement.
  8658. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8659. * as well as binding the different shadow properties to the effects.
  8660. */
  8661. export interface IShadowLight extends Light {
  8662. /**
  8663. * The light id in the scene (used in scene.findLighById for instance)
  8664. */
  8665. id: string;
  8666. /**
  8667. * The position the shdow will be casted from.
  8668. */
  8669. position: Vector3;
  8670. /**
  8671. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8672. */
  8673. direction: Vector3;
  8674. /**
  8675. * The transformed position. Position of the light in world space taking parenting in account.
  8676. */
  8677. transformedPosition: Vector3;
  8678. /**
  8679. * The transformed direction. Direction of the light in world space taking parenting in account.
  8680. */
  8681. transformedDirection: Vector3;
  8682. /**
  8683. * The friendly name of the light in the scene.
  8684. */
  8685. name: string;
  8686. /**
  8687. * Defines the shadow projection clipping minimum z value.
  8688. */
  8689. shadowMinZ: number;
  8690. /**
  8691. * Defines the shadow projection clipping maximum z value.
  8692. */
  8693. shadowMaxZ: number;
  8694. /**
  8695. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8696. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8697. */
  8698. computeTransformedInformation(): boolean;
  8699. /**
  8700. * Gets the scene the light belongs to.
  8701. * @returns The scene
  8702. */
  8703. getScene(): Scene;
  8704. /**
  8705. * Callback defining a custom Projection Matrix Builder.
  8706. * This can be used to override the default projection matrix computation.
  8707. */
  8708. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8709. /**
  8710. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8711. * @param matrix The materix to updated with the projection information
  8712. * @param viewMatrix The transform matrix of the light
  8713. * @param renderList The list of mesh to render in the map
  8714. * @returns The current light
  8715. */
  8716. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8717. /**
  8718. * Gets the current depth scale used in ESM.
  8719. * @returns The scale
  8720. */
  8721. getDepthScale(): number;
  8722. /**
  8723. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8724. * @returns true if a cube texture needs to be use
  8725. */
  8726. needCube(): boolean;
  8727. /**
  8728. * Detects if the projection matrix requires to be recomputed this frame.
  8729. * @returns true if it requires to be recomputed otherwise, false.
  8730. */
  8731. needProjectionMatrixCompute(): boolean;
  8732. /**
  8733. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8734. */
  8735. forceProjectionMatrixCompute(): void;
  8736. /**
  8737. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8738. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8739. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8740. */
  8741. getShadowDirection(faceIndex?: number): Vector3;
  8742. /**
  8743. * Gets the minZ used for shadow according to both the scene and the light.
  8744. * @param activeCamera The camera we are returning the min for
  8745. * @returns the depth min z
  8746. */
  8747. getDepthMinZ(activeCamera: Camera): number;
  8748. /**
  8749. * Gets the maxZ used for shadow according to both the scene and the light.
  8750. * @param activeCamera The camera we are returning the max for
  8751. * @returns the depth max z
  8752. */
  8753. getDepthMaxZ(activeCamera: Camera): number;
  8754. }
  8755. /**
  8756. * Base implementation IShadowLight
  8757. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8758. */
  8759. export abstract class ShadowLight extends Light implements IShadowLight {
  8760. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8761. protected _position: Vector3;
  8762. protected _setPosition(value: Vector3): void;
  8763. /**
  8764. * Sets the position the shadow will be casted from. Also use as the light position for both
  8765. * point and spot lights.
  8766. */
  8767. /**
  8768. * Sets the position the shadow will be casted from. Also use as the light position for both
  8769. * point and spot lights.
  8770. */
  8771. position: Vector3;
  8772. protected _direction: Vector3;
  8773. protected _setDirection(value: Vector3): void;
  8774. /**
  8775. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8776. * Also use as the light direction on spot and directional lights.
  8777. */
  8778. /**
  8779. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8780. * Also use as the light direction on spot and directional lights.
  8781. */
  8782. direction: Vector3;
  8783. private _shadowMinZ;
  8784. /**
  8785. * Gets the shadow projection clipping minimum z value.
  8786. */
  8787. /**
  8788. * Sets the shadow projection clipping minimum z value.
  8789. */
  8790. shadowMinZ: number;
  8791. private _shadowMaxZ;
  8792. /**
  8793. * Sets the shadow projection clipping maximum z value.
  8794. */
  8795. /**
  8796. * Gets the shadow projection clipping maximum z value.
  8797. */
  8798. shadowMaxZ: number;
  8799. /**
  8800. * Callback defining a custom Projection Matrix Builder.
  8801. * This can be used to override the default projection matrix computation.
  8802. */
  8803. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8804. /**
  8805. * The transformed position. Position of the light in world space taking parenting in account.
  8806. */
  8807. transformedPosition: Vector3;
  8808. /**
  8809. * The transformed direction. Direction of the light in world space taking parenting in account.
  8810. */
  8811. transformedDirection: Vector3;
  8812. private _needProjectionMatrixCompute;
  8813. /**
  8814. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8815. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8816. */
  8817. computeTransformedInformation(): boolean;
  8818. /**
  8819. * Return the depth scale used for the shadow map.
  8820. * @returns the depth scale.
  8821. */
  8822. getDepthScale(): number;
  8823. /**
  8824. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8825. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8826. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8827. */
  8828. getShadowDirection(faceIndex?: number): Vector3;
  8829. /**
  8830. * Returns the ShadowLight absolute position in the World.
  8831. * @returns the position vector in world space
  8832. */
  8833. getAbsolutePosition(): Vector3;
  8834. /**
  8835. * Sets the ShadowLight direction toward the passed target.
  8836. * @param target The point to target in local space
  8837. * @returns the updated ShadowLight direction
  8838. */
  8839. setDirectionToTarget(target: Vector3): Vector3;
  8840. /**
  8841. * Returns the light rotation in euler definition.
  8842. * @returns the x y z rotation in local space.
  8843. */
  8844. getRotation(): Vector3;
  8845. /**
  8846. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8847. * @returns true if a cube texture needs to be use
  8848. */
  8849. needCube(): boolean;
  8850. /**
  8851. * Detects if the projection matrix requires to be recomputed this frame.
  8852. * @returns true if it requires to be recomputed otherwise, false.
  8853. */
  8854. needProjectionMatrixCompute(): boolean;
  8855. /**
  8856. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8857. */
  8858. forceProjectionMatrixCompute(): void;
  8859. /** @hidden */ private _initCache(): void;
  8860. /** @hidden */ private _isSynchronized(): boolean;
  8861. /**
  8862. * Computes the world matrix of the node
  8863. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8864. * @returns the world matrix
  8865. */
  8866. computeWorldMatrix(force?: boolean): Matrix;
  8867. /**
  8868. * Gets the minZ used for shadow according to both the scene and the light.
  8869. * @param activeCamera The camera we are returning the min for
  8870. * @returns the depth min z
  8871. */
  8872. getDepthMinZ(activeCamera: Camera): number;
  8873. /**
  8874. * Gets the maxZ used for shadow according to both the scene and the light.
  8875. * @param activeCamera The camera we are returning the max for
  8876. * @returns the depth max z
  8877. */
  8878. getDepthMaxZ(activeCamera: Camera): number;
  8879. /**
  8880. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8881. * @param matrix The materix to updated with the projection information
  8882. * @param viewMatrix The transform matrix of the light
  8883. * @param renderList The list of mesh to render in the map
  8884. * @returns The current light
  8885. */
  8886. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8887. }
  8888. }
  8889. declare module BABYLON {
  8890. /**
  8891. * "Static Class" containing the most commonly used helper while dealing with material for
  8892. * rendering purpose.
  8893. *
  8894. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8895. *
  8896. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8897. */
  8898. export class MaterialHelper {
  8899. /**
  8900. * Bind the current view position to an effect.
  8901. * @param effect The effect to be bound
  8902. * @param scene The scene the eyes position is used from
  8903. */
  8904. static BindEyePosition(effect: Effect, scene: Scene): void;
  8905. /**
  8906. * Helps preparing the defines values about the UVs in used in the effect.
  8907. * UVs are shared as much as we can accross channels in the shaders.
  8908. * @param texture The texture we are preparing the UVs for
  8909. * @param defines The defines to update
  8910. * @param key The channel key "diffuse", "specular"... used in the shader
  8911. */
  8912. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8913. /**
  8914. * Binds a texture matrix value to its corrsponding uniform
  8915. * @param texture The texture to bind the matrix for
  8916. * @param uniformBuffer The uniform buffer receivin the data
  8917. * @param key The channel key "diffuse", "specular"... used in the shader
  8918. */
  8919. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8920. /**
  8921. * Gets the current status of the fog (should it be enabled?)
  8922. * @param mesh defines the mesh to evaluate for fog support
  8923. * @param scene defines the hosting scene
  8924. * @returns true if fog must be enabled
  8925. */
  8926. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8927. /**
  8928. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8929. * @param mesh defines the current mesh
  8930. * @param scene defines the current scene
  8931. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8932. * @param pointsCloud defines if point cloud rendering has to be turned on
  8933. * @param fogEnabled defines if fog has to be turned on
  8934. * @param alphaTest defines if alpha testing has to be turned on
  8935. * @param defines defines the current list of defines
  8936. */
  8937. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8938. /**
  8939. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8940. * @param scene defines the current scene
  8941. * @param engine defines the current engine
  8942. * @param defines specifies the list of active defines
  8943. * @param useInstances defines if instances have to be turned on
  8944. * @param useClipPlane defines if clip plane have to be turned on
  8945. */
  8946. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8947. /**
  8948. * Prepares the defines for bones
  8949. * @param mesh The mesh containing the geometry data we will draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8953. /**
  8954. * Prepares the defines for morph targets
  8955. * @param mesh The mesh containing the geometry data we will draw
  8956. * @param defines The defines to update
  8957. */
  8958. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8959. /**
  8960. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8961. * @param mesh The mesh containing the geometry data we will draw
  8962. * @param defines The defines to update
  8963. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8964. * @param useBones Precise whether bones should be used or not (override mesh info)
  8965. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8966. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8967. * @returns false if defines are considered not dirty and have not been checked
  8968. */
  8969. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8970. /**
  8971. * Prepares the defines related to multiview
  8972. * @param scene The scene we are intending to draw
  8973. * @param defines The defines to update
  8974. */
  8975. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8976. /**
  8977. * Prepares the defines related to the light information passed in parameter
  8978. * @param scene The scene we are intending to draw
  8979. * @param mesh The mesh the effect is compiling for
  8980. * @param light The light the effect is compiling for
  8981. * @param lightIndex The index of the light
  8982. * @param defines The defines to update
  8983. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8984. * @param state Defines the current state regarding what is needed (normals, etc...)
  8985. */
  8986. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8987. needNormals: boolean;
  8988. needRebuild: boolean;
  8989. shadowEnabled: boolean;
  8990. specularEnabled: boolean;
  8991. lightmapMode: boolean;
  8992. }): void;
  8993. /**
  8994. * Prepares the defines related to the light information passed in parameter
  8995. * @param scene The scene we are intending to draw
  8996. * @param mesh The mesh the effect is compiling for
  8997. * @param defines The defines to update
  8998. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8999. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9000. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9001. * @returns true if normals will be required for the rest of the effect
  9002. */
  9003. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9004. /**
  9005. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9006. * @param lightIndex defines the light index
  9007. * @param uniformsList The uniform list
  9008. * @param samplersList The sampler list
  9009. * @param projectedLightTexture defines if projected texture must be used
  9010. * @param uniformBuffersList defines an optional list of uniform buffers
  9011. */
  9012. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9013. /**
  9014. * Prepares the uniforms and samplers list to be used in the effect
  9015. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9016. * @param samplersList The sampler list
  9017. * @param defines The defines helping in the list generation
  9018. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9019. */
  9020. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9021. /**
  9022. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9023. * @param defines The defines to update while falling back
  9024. * @param fallbacks The authorized effect fallbacks
  9025. * @param maxSimultaneousLights The maximum number of lights allowed
  9026. * @param rank the current rank of the Effect
  9027. * @returns The newly affected rank
  9028. */
  9029. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9030. private static _TmpMorphInfluencers;
  9031. /**
  9032. * Prepares the list of attributes required for morph targets according to the effect defines.
  9033. * @param attribs The current list of supported attribs
  9034. * @param mesh The mesh to prepare the morph targets attributes for
  9035. * @param influencers The number of influencers
  9036. */
  9037. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9038. /**
  9039. * Prepares the list of attributes required for morph targets according to the effect defines.
  9040. * @param attribs The current list of supported attribs
  9041. * @param mesh The mesh to prepare the morph targets attributes for
  9042. * @param defines The current Defines of the effect
  9043. */
  9044. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9045. /**
  9046. * Prepares the list of attributes required for bones according to the effect defines.
  9047. * @param attribs The current list of supported attribs
  9048. * @param mesh The mesh to prepare the bones attributes for
  9049. * @param defines The current Defines of the effect
  9050. * @param fallbacks The current efffect fallback strategy
  9051. */
  9052. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9053. /**
  9054. * Check and prepare the list of attributes required for instances according to the effect defines.
  9055. * @param attribs The current list of supported attribs
  9056. * @param defines The current MaterialDefines of the effect
  9057. */
  9058. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9059. /**
  9060. * Add the list of attributes required for instances to the attribs array.
  9061. * @param attribs The current list of supported attribs
  9062. */
  9063. static PushAttributesForInstances(attribs: string[]): void;
  9064. /**
  9065. * Binds the light shadow information to the effect for the given mesh.
  9066. * @param light The light containing the generator
  9067. * @param scene The scene the lights belongs to
  9068. * @param mesh The mesh we are binding the information to render
  9069. * @param lightIndex The light index in the effect used to render the mesh
  9070. * @param effect The effect we are binding the data to
  9071. */
  9072. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9073. /**
  9074. * Binds the light information to the effect.
  9075. * @param light The light containing the generator
  9076. * @param effect The effect we are binding the data to
  9077. * @param lightIndex The light index in the effect used to render
  9078. */
  9079. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9080. /**
  9081. * Binds the lights information from the scene to the effect for the given mesh.
  9082. * @param light Light to bind
  9083. * @param lightIndex Light index
  9084. * @param scene The scene where the light belongs to
  9085. * @param mesh The mesh we are binding the information to render
  9086. * @param effect The effect we are binding the data to
  9087. * @param useSpecular Defines if specular is supported
  9088. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9089. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9090. */
  9091. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9092. /**
  9093. * Binds the lights information from the scene to the effect for the given mesh.
  9094. * @param scene The scene the lights belongs to
  9095. * @param mesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. * @param defines The generated defines for the effect
  9098. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9099. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9100. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9101. */
  9102. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9103. private static _tempFogColor;
  9104. /**
  9105. * Binds the fog information from the scene to the effect for the given mesh.
  9106. * @param scene The scene the lights belongs to
  9107. * @param mesh The mesh we are binding the information to render
  9108. * @param effect The effect we are binding the data to
  9109. * @param linearSpace Defines if the fog effect is applied in linear space
  9110. */
  9111. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9112. /**
  9113. * Binds the bones information from the mesh to the effect.
  9114. * @param mesh The mesh we are binding the information to render
  9115. * @param effect The effect we are binding the data to
  9116. */
  9117. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9118. /**
  9119. * Binds the morph targets information from the mesh to the effect.
  9120. * @param abstractMesh The mesh we are binding the information to render
  9121. * @param effect The effect we are binding the data to
  9122. */
  9123. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9124. /**
  9125. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9126. * @param defines The generated defines used in the effect
  9127. * @param effect The effect we are binding the data to
  9128. * @param scene The scene we are willing to render with logarithmic scale for
  9129. */
  9130. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9131. /**
  9132. * Binds the clip plane information from the scene to the effect.
  9133. * @param scene The scene the clip plane information are extracted from
  9134. * @param effect The effect we are binding the data to
  9135. */
  9136. static BindClipPlane(effect: Effect, scene: Scene): void;
  9137. }
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var packingFunctions: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var shadowMapPixelShader: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var bonesDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexGlobalDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var morphTargetsVertexDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var instancesDeclaration: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var helperFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var morphTargetsVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var instancesVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var bonesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var shadowMapVertexShader: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var depthBoxBlurPixelShader: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /**
  9225. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9226. */
  9227. export interface ICustomShaderOptions {
  9228. /**
  9229. * Gets or sets the custom shader name to use
  9230. */
  9231. shaderName: string;
  9232. /**
  9233. * The list of attribute names used in the shader
  9234. */
  9235. attributes?: string[];
  9236. /**
  9237. * The list of unifrom names used in the shader
  9238. */
  9239. uniforms?: string[];
  9240. /**
  9241. * The list of sampler names used in the shader
  9242. */
  9243. samplers?: string[];
  9244. /**
  9245. * The list of defines used in the shader
  9246. */
  9247. defines?: string[];
  9248. }
  9249. /**
  9250. * Interface to implement to create a shadow generator compatible with BJS.
  9251. */
  9252. export interface IShadowGenerator {
  9253. /**
  9254. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9255. * @returns The render target texture if present otherwise, null
  9256. */
  9257. getShadowMap(): Nullable<RenderTargetTexture>;
  9258. /**
  9259. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9260. * @returns The render target texture if the shadow map is present otherwise, null
  9261. */
  9262. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9263. /**
  9264. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9265. * @param subMesh The submesh we want to render in the shadow map
  9266. * @param useInstances Defines wether will draw in the map using instances
  9267. * @returns true if ready otherwise, false
  9268. */
  9269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9270. /**
  9271. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9272. * @param defines Defines of the material we want to update
  9273. * @param lightIndex Index of the light in the enabled light list of the material
  9274. */
  9275. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9276. /**
  9277. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9278. * defined in the generator but impacting the effect).
  9279. * It implies the unifroms available on the materials are the standard BJS ones.
  9280. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9281. * @param effect The effect we are binfing the information for
  9282. */
  9283. bindShadowLight(lightIndex: string, effect: Effect): void;
  9284. /**
  9285. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9286. * (eq to shadow prjection matrix * light transform matrix)
  9287. * @returns The transform matrix used to create the shadow map
  9288. */
  9289. getTransformMatrix(): Matrix;
  9290. /**
  9291. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9292. * Cube and 2D textures for instance.
  9293. */
  9294. recreateShadowMap(): void;
  9295. /**
  9296. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9297. * @param onCompiled Callback triggered at the and of the effects compilation
  9298. * @param options Sets of optional options forcing the compilation with different modes
  9299. */
  9300. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9301. useInstances: boolean;
  9302. }>): void;
  9303. /**
  9304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9305. * @param options Sets of optional options forcing the compilation with different modes
  9306. * @returns A promise that resolves when the compilation completes
  9307. */
  9308. forceCompilationAsync(options?: Partial<{
  9309. useInstances: boolean;
  9310. }>): Promise<void>;
  9311. /**
  9312. * Serializes the shadow generator setup to a json object.
  9313. * @returns The serialized JSON object
  9314. */
  9315. serialize(): any;
  9316. /**
  9317. * Disposes the Shadow map and related Textures and effects.
  9318. */
  9319. dispose(): void;
  9320. }
  9321. /**
  9322. * Default implementation IShadowGenerator.
  9323. * This is the main object responsible of generating shadows in the framework.
  9324. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9325. */
  9326. export class ShadowGenerator implements IShadowGenerator {
  9327. /**
  9328. * Shadow generator mode None: no filtering applied.
  9329. */
  9330. static readonly FILTER_NONE: number;
  9331. /**
  9332. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9333. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9334. */
  9335. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9336. /**
  9337. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9338. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9339. */
  9340. static readonly FILTER_POISSONSAMPLING: number;
  9341. /**
  9342. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9343. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9344. */
  9345. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9346. /**
  9347. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9348. * edge artifacts on steep falloff.
  9349. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9350. */
  9351. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9352. /**
  9353. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9354. * edge artifacts on steep falloff.
  9355. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9356. */
  9357. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9358. /**
  9359. * Shadow generator mode PCF: Percentage Closer Filtering
  9360. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9361. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9362. */
  9363. static readonly FILTER_PCF: number;
  9364. /**
  9365. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9366. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9367. * Contact Hardening
  9368. */
  9369. static readonly FILTER_PCSS: number;
  9370. /**
  9371. * Reserved for PCF and PCSS
  9372. * Highest Quality.
  9373. *
  9374. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9375. *
  9376. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9377. */
  9378. static readonly QUALITY_HIGH: number;
  9379. /**
  9380. * Reserved for PCF and PCSS
  9381. * Good tradeoff for quality/perf cross devices
  9382. *
  9383. * Execute PCF on a 3*3 kernel.
  9384. *
  9385. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9386. */
  9387. static readonly QUALITY_MEDIUM: number;
  9388. /**
  9389. * Reserved for PCF and PCSS
  9390. * The lowest quality but the fastest.
  9391. *
  9392. * Execute PCF on a 1*1 kernel.
  9393. *
  9394. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9395. */
  9396. static readonly QUALITY_LOW: number;
  9397. /** Gets or sets the custom shader name to use */
  9398. customShaderOptions: ICustomShaderOptions;
  9399. /**
  9400. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9401. */
  9402. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9403. /**
  9404. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9405. */
  9406. onAfterShadowMapRenderObservable: Observable<Effect>;
  9407. /**
  9408. * Observable triggered before a mesh is rendered in the shadow map.
  9409. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9410. */
  9411. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9412. /**
  9413. * Observable triggered after a mesh is rendered in the shadow map.
  9414. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9415. */
  9416. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9417. private _bias;
  9418. /**
  9419. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9420. */
  9421. /**
  9422. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9423. */
  9424. bias: number;
  9425. private _normalBias;
  9426. /**
  9427. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9428. */
  9429. /**
  9430. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9431. */
  9432. normalBias: number;
  9433. private _blurBoxOffset;
  9434. /**
  9435. * Gets the blur box offset: offset applied during the blur pass.
  9436. * Only useful if useKernelBlur = false
  9437. */
  9438. /**
  9439. * Sets the blur box offset: offset applied during the blur pass.
  9440. * Only useful if useKernelBlur = false
  9441. */
  9442. blurBoxOffset: number;
  9443. private _blurScale;
  9444. /**
  9445. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9446. * 2 means half of the size.
  9447. */
  9448. /**
  9449. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9450. * 2 means half of the size.
  9451. */
  9452. blurScale: number;
  9453. private _blurKernel;
  9454. /**
  9455. * Gets the blur kernel: kernel size of the blur pass.
  9456. * Only useful if useKernelBlur = true
  9457. */
  9458. /**
  9459. * Sets the blur kernel: kernel size of the blur pass.
  9460. * Only useful if useKernelBlur = true
  9461. */
  9462. blurKernel: number;
  9463. private _useKernelBlur;
  9464. /**
  9465. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9466. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9467. */
  9468. /**
  9469. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9470. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9471. */
  9472. useKernelBlur: boolean;
  9473. private _depthScale;
  9474. /**
  9475. * Gets the depth scale used in ESM mode.
  9476. */
  9477. /**
  9478. * Sets the depth scale used in ESM mode.
  9479. * This can override the scale stored on the light.
  9480. */
  9481. depthScale: number;
  9482. private _filter;
  9483. /**
  9484. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9485. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9486. */
  9487. /**
  9488. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9489. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9490. */
  9491. filter: number;
  9492. /**
  9493. * Gets if the current filter is set to Poisson Sampling.
  9494. */
  9495. /**
  9496. * Sets the current filter to Poisson Sampling.
  9497. */
  9498. usePoissonSampling: boolean;
  9499. /**
  9500. * Gets if the current filter is set to ESM.
  9501. */
  9502. /**
  9503. * Sets the current filter is to ESM.
  9504. */
  9505. useExponentialShadowMap: boolean;
  9506. /**
  9507. * Gets if the current filter is set to filtered ESM.
  9508. */
  9509. /**
  9510. * Gets if the current filter is set to filtered ESM.
  9511. */
  9512. useBlurExponentialShadowMap: boolean;
  9513. /**
  9514. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9515. * exponential to prevent steep falloff artifacts).
  9516. */
  9517. /**
  9518. * Sets the current filter to "close ESM" (using the inverse of the
  9519. * exponential to prevent steep falloff artifacts).
  9520. */
  9521. useCloseExponentialShadowMap: boolean;
  9522. /**
  9523. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9524. * exponential to prevent steep falloff artifacts).
  9525. */
  9526. /**
  9527. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9528. * exponential to prevent steep falloff artifacts).
  9529. */
  9530. useBlurCloseExponentialShadowMap: boolean;
  9531. /**
  9532. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9533. */
  9534. /**
  9535. * Sets the current filter to "PCF" (percentage closer filtering).
  9536. */
  9537. usePercentageCloserFiltering: boolean;
  9538. private _filteringQuality;
  9539. /**
  9540. * Gets the PCF or PCSS Quality.
  9541. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9542. */
  9543. /**
  9544. * Sets the PCF or PCSS Quality.
  9545. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9546. */
  9547. filteringQuality: number;
  9548. /**
  9549. * Gets if the current filter is set to "PCSS" (contact hardening).
  9550. */
  9551. /**
  9552. * Sets the current filter to "PCSS" (contact hardening).
  9553. */
  9554. useContactHardeningShadow: boolean;
  9555. private _contactHardeningLightSizeUVRatio;
  9556. /**
  9557. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9558. * Using a ratio helps keeping shape stability independently of the map size.
  9559. *
  9560. * It does not account for the light projection as it was having too much
  9561. * instability during the light setup or during light position changes.
  9562. *
  9563. * Only valid if useContactHardeningShadow is true.
  9564. */
  9565. /**
  9566. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9567. * Using a ratio helps keeping shape stability independently of the map size.
  9568. *
  9569. * It does not account for the light projection as it was having too much
  9570. * instability during the light setup or during light position changes.
  9571. *
  9572. * Only valid if useContactHardeningShadow is true.
  9573. */
  9574. contactHardeningLightSizeUVRatio: number;
  9575. private _darkness;
  9576. /** Gets or sets the actual darkness of a shadow */
  9577. darkness: number;
  9578. /**
  9579. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9580. * 0 means strongest and 1 would means no shadow.
  9581. * @returns the darkness.
  9582. */
  9583. getDarkness(): number;
  9584. /**
  9585. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9586. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9587. * @returns the shadow generator allowing fluent coding.
  9588. */
  9589. setDarkness(darkness: number): ShadowGenerator;
  9590. private _transparencyShadow;
  9591. /** Gets or sets the ability to have transparent shadow */
  9592. transparencyShadow: boolean;
  9593. /**
  9594. * Sets the ability to have transparent shadow (boolean).
  9595. * @param transparent True if transparent else False
  9596. * @returns the shadow generator allowing fluent coding
  9597. */
  9598. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9599. private _shadowMap;
  9600. private _shadowMap2;
  9601. /**
  9602. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9603. * @returns The render target texture if present otherwise, null
  9604. */
  9605. getShadowMap(): Nullable<RenderTargetTexture>;
  9606. /**
  9607. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9608. * @returns The render target texture if the shadow map is present otherwise, null
  9609. */
  9610. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9611. /**
  9612. * Gets the class name of that object
  9613. * @returns "ShadowGenerator"
  9614. */
  9615. getClassName(): string;
  9616. /**
  9617. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9618. * @param mesh Mesh to add
  9619. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9620. * @returns the Shadow Generator itself
  9621. */
  9622. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9623. /**
  9624. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9625. * @param mesh Mesh to remove
  9626. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9627. * @returns the Shadow Generator itself
  9628. */
  9629. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9630. /**
  9631. * Controls the extent to which the shadows fade out at the edge of the frustum
  9632. * Used only by directionals and spots
  9633. */
  9634. frustumEdgeFalloff: number;
  9635. private _light;
  9636. /**
  9637. * Returns the associated light object.
  9638. * @returns the light generating the shadow
  9639. */
  9640. getLight(): IShadowLight;
  9641. /**
  9642. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9643. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9644. * It might on the other hand introduce peter panning.
  9645. */
  9646. forceBackFacesOnly: boolean;
  9647. private _scene;
  9648. private _lightDirection;
  9649. private _effect;
  9650. private _viewMatrix;
  9651. private _projectionMatrix;
  9652. private _transformMatrix;
  9653. private _cachedPosition;
  9654. private _cachedDirection;
  9655. private _cachedDefines;
  9656. private _currentRenderID;
  9657. private _boxBlurPostprocess;
  9658. private _kernelBlurXPostprocess;
  9659. private _kernelBlurYPostprocess;
  9660. private _blurPostProcesses;
  9661. private _mapSize;
  9662. private _currentFaceIndex;
  9663. private _currentFaceIndexCache;
  9664. private _textureType;
  9665. private _defaultTextureMatrix;
  9666. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9667. /**
  9668. * Creates a ShadowGenerator object.
  9669. * A ShadowGenerator is the required tool to use the shadows.
  9670. * Each light casting shadows needs to use its own ShadowGenerator.
  9671. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9672. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9673. * @param light The light object generating the shadows.
  9674. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9675. */
  9676. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9677. private _initializeGenerator;
  9678. private _initializeShadowMap;
  9679. private _initializeBlurRTTAndPostProcesses;
  9680. private _renderForShadowMap;
  9681. private _renderSubMeshForShadowMap;
  9682. private _applyFilterValues;
  9683. /**
  9684. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9685. * @param onCompiled Callback triggered at the and of the effects compilation
  9686. * @param options Sets of optional options forcing the compilation with different modes
  9687. */
  9688. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9689. useInstances: boolean;
  9690. }>): void;
  9691. /**
  9692. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9693. * @param options Sets of optional options forcing the compilation with different modes
  9694. * @returns A promise that resolves when the compilation completes
  9695. */
  9696. forceCompilationAsync(options?: Partial<{
  9697. useInstances: boolean;
  9698. }>): Promise<void>;
  9699. /**
  9700. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9701. * @param subMesh The submesh we want to render in the shadow map
  9702. * @param useInstances Defines wether will draw in the map using instances
  9703. * @returns true if ready otherwise, false
  9704. */
  9705. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9706. /**
  9707. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9708. * @param defines Defines of the material we want to update
  9709. * @param lightIndex Index of the light in the enabled light list of the material
  9710. */
  9711. prepareDefines(defines: any, lightIndex: number): void;
  9712. /**
  9713. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9714. * defined in the generator but impacting the effect).
  9715. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9716. * @param effect The effect we are binfing the information for
  9717. */
  9718. bindShadowLight(lightIndex: string, effect: Effect): void;
  9719. /**
  9720. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9721. * (eq to shadow prjection matrix * light transform matrix)
  9722. * @returns The transform matrix used to create the shadow map
  9723. */
  9724. getTransformMatrix(): Matrix;
  9725. /**
  9726. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9727. * Cube and 2D textures for instance.
  9728. */
  9729. recreateShadowMap(): void;
  9730. private _disposeBlurPostProcesses;
  9731. private _disposeRTTandPostProcesses;
  9732. /**
  9733. * Disposes the ShadowGenerator.
  9734. * Returns nothing.
  9735. */
  9736. dispose(): void;
  9737. /**
  9738. * Serializes the shadow generator setup to a json object.
  9739. * @returns The serialized JSON object
  9740. */
  9741. serialize(): any;
  9742. /**
  9743. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9744. * @param parsedShadowGenerator The JSON object to parse
  9745. * @param scene The scene to create the shadow map for
  9746. * @returns The parsed shadow generator
  9747. */
  9748. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9749. }
  9750. }
  9751. declare module BABYLON {
  9752. /**
  9753. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9754. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9755. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9756. */
  9757. export abstract class Light extends Node {
  9758. /**
  9759. * Falloff Default: light is falling off following the material specification:
  9760. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9761. */
  9762. static readonly FALLOFF_DEFAULT: number;
  9763. /**
  9764. * Falloff Physical: light is falling off following the inverse squared distance law.
  9765. */
  9766. static readonly FALLOFF_PHYSICAL: number;
  9767. /**
  9768. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9769. * to enhance interoperability with other engines.
  9770. */
  9771. static readonly FALLOFF_GLTF: number;
  9772. /**
  9773. * Falloff Standard: light is falling off like in the standard material
  9774. * to enhance interoperability with other materials.
  9775. */
  9776. static readonly FALLOFF_STANDARD: number;
  9777. /**
  9778. * If every light affecting the material is in this lightmapMode,
  9779. * material.lightmapTexture adds or multiplies
  9780. * (depends on material.useLightmapAsShadowmap)
  9781. * after every other light calculations.
  9782. */
  9783. static readonly LIGHTMAP_DEFAULT: number;
  9784. /**
  9785. * material.lightmapTexture as only diffuse lighting from this light
  9786. * adds only specular lighting from this light
  9787. * adds dynamic shadows
  9788. */
  9789. static readonly LIGHTMAP_SPECULAR: number;
  9790. /**
  9791. * material.lightmapTexture as only lighting
  9792. * no light calculation from this light
  9793. * only adds dynamic shadows from this light
  9794. */
  9795. static readonly LIGHTMAP_SHADOWSONLY: number;
  9796. /**
  9797. * Each light type uses the default quantity according to its type:
  9798. * point/spot lights use luminous intensity
  9799. * directional lights use illuminance
  9800. */
  9801. static readonly INTENSITYMODE_AUTOMATIC: number;
  9802. /**
  9803. * lumen (lm)
  9804. */
  9805. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9806. /**
  9807. * candela (lm/sr)
  9808. */
  9809. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9810. /**
  9811. * lux (lm/m^2)
  9812. */
  9813. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9814. /**
  9815. * nit (cd/m^2)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINANCE: number;
  9818. /**
  9819. * Light type const id of the point light.
  9820. */
  9821. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9822. /**
  9823. * Light type const id of the directional light.
  9824. */
  9825. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9826. /**
  9827. * Light type const id of the spot light.
  9828. */
  9829. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9830. /**
  9831. * Light type const id of the hemispheric light.
  9832. */
  9833. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9834. /**
  9835. * Diffuse gives the basic color to an object.
  9836. */
  9837. diffuse: Color3;
  9838. /**
  9839. * Specular produces a highlight color on an object.
  9840. * Note: This is note affecting PBR materials.
  9841. */
  9842. specular: Color3;
  9843. /**
  9844. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9845. * falling off base on range or angle.
  9846. * This can be set to any values in Light.FALLOFF_x.
  9847. *
  9848. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9849. * other types of materials.
  9850. */
  9851. falloffType: number;
  9852. /**
  9853. * Strength of the light.
  9854. * Note: By default it is define in the framework own unit.
  9855. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9856. */
  9857. intensity: number;
  9858. private _range;
  9859. protected _inverseSquaredRange: number;
  9860. /**
  9861. * Defines how far from the source the light is impacting in scene units.
  9862. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9863. */
  9864. /**
  9865. * Defines how far from the source the light is impacting in scene units.
  9866. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9867. */
  9868. range: number;
  9869. /**
  9870. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9871. * of light.
  9872. */
  9873. private _photometricScale;
  9874. private _intensityMode;
  9875. /**
  9876. * Gets the photometric scale used to interpret the intensity.
  9877. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9878. */
  9879. /**
  9880. * Sets the photometric scale used to interpret the intensity.
  9881. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9882. */
  9883. intensityMode: number;
  9884. private _radius;
  9885. /**
  9886. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9887. */
  9888. /**
  9889. * sets the light radius used by PBR Materials to simulate soft area lights.
  9890. */
  9891. radius: number;
  9892. private _renderPriority;
  9893. /**
  9894. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9895. * exceeding the number allowed of the materials.
  9896. */
  9897. renderPriority: number;
  9898. private _shadowEnabled;
  9899. /**
  9900. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9901. * the current shadow generator.
  9902. */
  9903. /**
  9904. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9905. * the current shadow generator.
  9906. */
  9907. shadowEnabled: boolean;
  9908. private _includedOnlyMeshes;
  9909. /**
  9910. * Gets the only meshes impacted by this light.
  9911. */
  9912. /**
  9913. * Sets the only meshes impacted by this light.
  9914. */
  9915. includedOnlyMeshes: AbstractMesh[];
  9916. private _excludedMeshes;
  9917. /**
  9918. * Gets the meshes not impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the meshes not impacted by this light.
  9922. */
  9923. excludedMeshes: AbstractMesh[];
  9924. private _excludeWithLayerMask;
  9925. /**
  9926. * Gets the layer id use to find what meshes are not impacted by the light.
  9927. * Inactive if 0
  9928. */
  9929. /**
  9930. * Sets the layer id use to find what meshes are not impacted by the light.
  9931. * Inactive if 0
  9932. */
  9933. excludeWithLayerMask: number;
  9934. private _includeOnlyWithLayerMask;
  9935. /**
  9936. * Gets the layer id use to find what meshes are impacted by the light.
  9937. * Inactive if 0
  9938. */
  9939. /**
  9940. * Sets the layer id use to find what meshes are impacted by the light.
  9941. * Inactive if 0
  9942. */
  9943. includeOnlyWithLayerMask: number;
  9944. private _lightmapMode;
  9945. /**
  9946. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9947. */
  9948. /**
  9949. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9950. */
  9951. lightmapMode: number;
  9952. /**
  9953. * Shadow generator associted to the light.
  9954. * @hidden Internal use only.
  9955. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9956. /**
  9957. * @hidden Internal use only.
  9958. */ private _excludedMeshesIds: string[];
  9959. /**
  9960. * @hidden Internal use only.
  9961. */ private _includedOnlyMeshesIds: string[];
  9962. /**
  9963. * The current light unifom buffer.
  9964. * @hidden Internal use only.
  9965. */ private _uniformBuffer: UniformBuffer;
  9966. /**
  9967. * Creates a Light object in the scene.
  9968. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9969. * @param name The firendly name of the light
  9970. * @param scene The scene the light belongs too
  9971. */
  9972. constructor(name: string, scene: Scene);
  9973. protected abstract _buildUniformLayout(): void;
  9974. /**
  9975. * Sets the passed Effect "effect" with the Light information.
  9976. * @param effect The effect to update
  9977. * @param lightIndex The index of the light in the effect to update
  9978. * @returns The light
  9979. */
  9980. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9981. /**
  9982. * Sets the passed Effect "effect" with the Light information.
  9983. * @param effect The effect to update
  9984. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9985. * @returns The light
  9986. */
  9987. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9988. /**
  9989. * Returns the string "Light".
  9990. * @returns the class name
  9991. */
  9992. getClassName(): string;
  9993. /** @hidden */ protected readonly _isLight: boolean;
  9994. /**
  9995. * Converts the light information to a readable string for debug purpose.
  9996. * @param fullDetails Supports for multiple levels of logging within scene loading
  9997. * @returns the human readable light info
  9998. */
  9999. toString(fullDetails?: boolean): string;
  10000. /** @hidden */
  10001. protected _syncParentEnabledState(): void;
  10002. /**
  10003. * Set the enabled state of this node.
  10004. * @param value - the new enabled state
  10005. */
  10006. setEnabled(value: boolean): void;
  10007. /**
  10008. * Returns the Light associated shadow generator if any.
  10009. * @return the associated shadow generator.
  10010. */
  10011. getShadowGenerator(): Nullable<IShadowGenerator>;
  10012. /**
  10013. * Returns a Vector3, the absolute light position in the World.
  10014. * @returns the world space position of the light
  10015. */
  10016. getAbsolutePosition(): Vector3;
  10017. /**
  10018. * Specifies if the light will affect the passed mesh.
  10019. * @param mesh The mesh to test against the light
  10020. * @return true the mesh is affected otherwise, false.
  10021. */
  10022. canAffectMesh(mesh: AbstractMesh): boolean;
  10023. /**
  10024. * Sort function to order lights for rendering.
  10025. * @param a First Light object to compare to second.
  10026. * @param b Second Light object to compare first.
  10027. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10028. */
  10029. static CompareLightsPriority(a: Light, b: Light): number;
  10030. /**
  10031. * Releases resources associated with this node.
  10032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10034. */
  10035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10036. /**
  10037. * Returns the light type ID (integer).
  10038. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10039. */
  10040. getTypeID(): number;
  10041. /**
  10042. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10043. * @returns the scaled intensity in intensity mode unit
  10044. */
  10045. getScaledIntensity(): number;
  10046. /**
  10047. * Returns a new Light object, named "name", from the current one.
  10048. * @param name The name of the cloned light
  10049. * @returns the new created light
  10050. */
  10051. clone(name: string): Nullable<Light>;
  10052. /**
  10053. * Serializes the current light into a Serialization object.
  10054. * @returns the serialized object.
  10055. */
  10056. serialize(): any;
  10057. /**
  10058. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10059. * This new light is named "name" and added to the passed scene.
  10060. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10061. * @param name The friendly name of the light
  10062. * @param scene The scene the new light will belong to
  10063. * @returns the constructor function
  10064. */
  10065. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10066. /**
  10067. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10068. * @param parsedLight The JSON representation of the light
  10069. * @param scene The scene to create the parsed light in
  10070. * @returns the created light after parsing
  10071. */
  10072. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10073. private _hookArrayForExcluded;
  10074. private _hookArrayForIncludedOnly;
  10075. private _resyncMeshes;
  10076. /**
  10077. * Forces the meshes to update their light related information in their rendering used effects
  10078. * @hidden Internal Use Only
  10079. */ private _markMeshesAsLightDirty(): void;
  10080. /**
  10081. * Recomputes the cached photometric scale if needed.
  10082. */
  10083. private _computePhotometricScale;
  10084. /**
  10085. * Returns the Photometric Scale according to the light type and intensity mode.
  10086. */
  10087. private _getPhotometricScale;
  10088. /**
  10089. * Reorder the light in the scene according to their defined priority.
  10090. * @hidden Internal Use Only
  10091. */ private _reorderLightsInScene(): void;
  10092. /**
  10093. * Prepares the list of defines specific to the light type.
  10094. * @param defines the list of defines
  10095. * @param lightIndex defines the index of the light for the effect
  10096. */
  10097. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10098. }
  10099. }
  10100. declare module BABYLON {
  10101. /**
  10102. * Interface used to define Action
  10103. */
  10104. export interface IAction {
  10105. /**
  10106. * Trigger for the action
  10107. */
  10108. trigger: number;
  10109. /** Options of the trigger */
  10110. triggerOptions: any;
  10111. /**
  10112. * Gets the trigger parameters
  10113. * @returns the trigger parameters
  10114. */
  10115. getTriggerParameter(): any;
  10116. /**
  10117. * Internal only - executes current action event
  10118. * @hidden
  10119. */ private _executeCurrent(evt?: ActionEvent): void;
  10120. /**
  10121. * Serialize placeholder for child classes
  10122. * @param parent of child
  10123. * @returns the serialized object
  10124. */
  10125. serialize(parent: any): any;
  10126. /**
  10127. * Internal only
  10128. * @hidden
  10129. */ private _prepare(): void;
  10130. /**
  10131. * Internal only - manager for action
  10132. * @hidden
  10133. */ private _actionManager: AbstractActionManager;
  10134. /**
  10135. * Adds action to chain of actions, may be a DoNothingAction
  10136. * @param action defines the next action to execute
  10137. * @returns The action passed in
  10138. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10139. */
  10140. then(action: IAction): IAction;
  10141. }
  10142. /**
  10143. * The action to be carried out following a trigger
  10144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10145. */
  10146. export class Action implements IAction {
  10147. /** the trigger, with or without parameters, for the action */
  10148. triggerOptions: any;
  10149. /**
  10150. * Trigger for the action
  10151. */
  10152. trigger: number;
  10153. /**
  10154. * Internal only - manager for action
  10155. * @hidden
  10156. */ private _actionManager: ActionManager;
  10157. private _nextActiveAction;
  10158. private _child;
  10159. private _condition?;
  10160. private _triggerParameter;
  10161. /**
  10162. * An event triggered prior to action being executed.
  10163. */
  10164. onBeforeExecuteObservable: Observable<Action>;
  10165. /**
  10166. * Creates a new Action
  10167. * @param triggerOptions the trigger, with or without parameters, for the action
  10168. * @param condition an optional determinant of action
  10169. */
  10170. constructor(
  10171. /** the trigger, with or without parameters, for the action */
  10172. triggerOptions: any, condition?: Condition);
  10173. /**
  10174. * Internal only
  10175. * @hidden
  10176. */ private _prepare(): void;
  10177. /**
  10178. * Gets the trigger parameters
  10179. * @returns the trigger parameters
  10180. */
  10181. getTriggerParameter(): any;
  10182. /**
  10183. * Internal only - executes current action event
  10184. * @hidden
  10185. */ private _executeCurrent(evt?: ActionEvent): void;
  10186. /**
  10187. * Execute placeholder for child classes
  10188. * @param evt optional action event
  10189. */
  10190. execute(evt?: ActionEvent): void;
  10191. /**
  10192. * Skips to next active action
  10193. */
  10194. skipToNextActiveAction(): void;
  10195. /**
  10196. * Adds action to chain of actions, may be a DoNothingAction
  10197. * @param action defines the next action to execute
  10198. * @returns The action passed in
  10199. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10200. */
  10201. then(action: Action): Action;
  10202. /**
  10203. * Internal only
  10204. * @hidden
  10205. */ private _getProperty(propertyPath: string): string;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10210. /**
  10211. * Serialize placeholder for child classes
  10212. * @param parent of child
  10213. * @returns the serialized object
  10214. */
  10215. serialize(parent: any): any;
  10216. /**
  10217. * Internal only called by serialize
  10218. * @hidden
  10219. */
  10220. protected _serialize(serializedAction: any, parent?: any): any;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */ private static _SerializeValueAsString: (value: any) => string;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10229. name: string;
  10230. targetType: string;
  10231. value: string;
  10232. };
  10233. }
  10234. }
  10235. declare module BABYLON {
  10236. /**
  10237. * A Condition applied to an Action
  10238. */
  10239. export class Condition {
  10240. /**
  10241. * Internal only - manager for action
  10242. * @hidden
  10243. */ private _actionManager: ActionManager;
  10244. /**
  10245. * Internal only
  10246. * @hidden
  10247. */ private _evaluationId: number;
  10248. /**
  10249. * Internal only
  10250. * @hidden
  10251. */ private _currentResult: boolean;
  10252. /**
  10253. * Creates a new Condition
  10254. * @param actionManager the manager of the action the condition is applied to
  10255. */
  10256. constructor(actionManager: ActionManager);
  10257. /**
  10258. * Check if the current condition is valid
  10259. * @returns a boolean
  10260. */
  10261. isValid(): boolean;
  10262. /**
  10263. * Internal only
  10264. * @hidden
  10265. */ private _getProperty(propertyPath: string): string;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10270. /**
  10271. * Serialize placeholder for child classes
  10272. * @returns the serialized object
  10273. */
  10274. serialize(): any;
  10275. /**
  10276. * Internal only
  10277. * @hidden
  10278. */
  10279. protected _serialize(serializedCondition: any): any;
  10280. }
  10281. /**
  10282. * Defines specific conditional operators as extensions of Condition
  10283. */
  10284. export class ValueCondition extends Condition {
  10285. /** path to specify the property of the target the conditional operator uses */
  10286. propertyPath: string;
  10287. /** the value compared by the conditional operator against the current value of the property */
  10288. value: any;
  10289. /** the conditional operator, default ValueCondition.IsEqual */
  10290. operator: number;
  10291. /**
  10292. * Internal only
  10293. * @hidden
  10294. */
  10295. private static _IsEqual;
  10296. /**
  10297. * Internal only
  10298. * @hidden
  10299. */
  10300. private static _IsDifferent;
  10301. /**
  10302. * Internal only
  10303. * @hidden
  10304. */
  10305. private static _IsGreater;
  10306. /**
  10307. * Internal only
  10308. * @hidden
  10309. */
  10310. private static _IsLesser;
  10311. /**
  10312. * returns the number for IsEqual
  10313. */
  10314. static readonly IsEqual: number;
  10315. /**
  10316. * Returns the number for IsDifferent
  10317. */
  10318. static readonly IsDifferent: number;
  10319. /**
  10320. * Returns the number for IsGreater
  10321. */
  10322. static readonly IsGreater: number;
  10323. /**
  10324. * Returns the number for IsLesser
  10325. */
  10326. static readonly IsLesser: number;
  10327. /**
  10328. * Internal only The action manager for the condition
  10329. * @hidden
  10330. */ private _actionManager: ActionManager;
  10331. /**
  10332. * Internal only
  10333. * @hidden
  10334. */
  10335. private _target;
  10336. /**
  10337. * Internal only
  10338. * @hidden
  10339. */
  10340. private _effectiveTarget;
  10341. /**
  10342. * Internal only
  10343. * @hidden
  10344. */
  10345. private _property;
  10346. /**
  10347. * Creates a new ValueCondition
  10348. * @param actionManager manager for the action the condition applies to
  10349. * @param target for the action
  10350. * @param propertyPath path to specify the property of the target the conditional operator uses
  10351. * @param value the value compared by the conditional operator against the current value of the property
  10352. * @param operator the conditional operator, default ValueCondition.IsEqual
  10353. */
  10354. constructor(actionManager: ActionManager, target: any,
  10355. /** path to specify the property of the target the conditional operator uses */
  10356. propertyPath: string,
  10357. /** the value compared by the conditional operator against the current value of the property */
  10358. value: any,
  10359. /** the conditional operator, default ValueCondition.IsEqual */
  10360. operator?: number);
  10361. /**
  10362. * Compares the given value with the property value for the specified conditional operator
  10363. * @returns the result of the comparison
  10364. */
  10365. isValid(): boolean;
  10366. /**
  10367. * Serialize the ValueCondition into a JSON compatible object
  10368. * @returns serialization object
  10369. */
  10370. serialize(): any;
  10371. /**
  10372. * Gets the name of the conditional operator for the ValueCondition
  10373. * @param operator the conditional operator
  10374. * @returns the name
  10375. */
  10376. static GetOperatorName(operator: number): string;
  10377. }
  10378. /**
  10379. * Defines a predicate condition as an extension of Condition
  10380. */
  10381. export class PredicateCondition extends Condition {
  10382. /** defines the predicate function used to validate the condition */
  10383. predicate: () => boolean;
  10384. /**
  10385. * Internal only - manager for action
  10386. * @hidden
  10387. */ private _actionManager: ActionManager;
  10388. /**
  10389. * Creates a new PredicateCondition
  10390. * @param actionManager manager for the action the condition applies to
  10391. * @param predicate defines the predicate function used to validate the condition
  10392. */
  10393. constructor(actionManager: ActionManager,
  10394. /** defines the predicate function used to validate the condition */
  10395. predicate: () => boolean);
  10396. /**
  10397. * @returns the validity of the predicate condition
  10398. */
  10399. isValid(): boolean;
  10400. }
  10401. /**
  10402. * Defines a state condition as an extension of Condition
  10403. */
  10404. export class StateCondition extends Condition {
  10405. /** Value to compare with target state */
  10406. value: string;
  10407. /**
  10408. * Internal only - manager for action
  10409. * @hidden
  10410. */ private _actionManager: ActionManager;
  10411. /**
  10412. * Internal only
  10413. * @hidden
  10414. */
  10415. private _target;
  10416. /**
  10417. * Creates a new StateCondition
  10418. * @param actionManager manager for the action the condition applies to
  10419. * @param target of the condition
  10420. * @param value to compare with target state
  10421. */
  10422. constructor(actionManager: ActionManager, target: any,
  10423. /** Value to compare with target state */
  10424. value: string);
  10425. /**
  10426. * Gets a boolean indicating if the current condition is met
  10427. * @returns the validity of the state
  10428. */
  10429. isValid(): boolean;
  10430. /**
  10431. * Serialize the StateCondition into a JSON compatible object
  10432. * @returns serialization object
  10433. */
  10434. serialize(): any;
  10435. }
  10436. }
  10437. declare module BABYLON {
  10438. /**
  10439. * This defines an action responsible to toggle a boolean once triggered.
  10440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10441. */
  10442. export class SwitchBooleanAction extends Action {
  10443. /**
  10444. * The path to the boolean property in the target object
  10445. */
  10446. propertyPath: string;
  10447. private _target;
  10448. private _effectiveTarget;
  10449. private _property;
  10450. /**
  10451. * Instantiate the action
  10452. * @param triggerOptions defines the trigger options
  10453. * @param target defines the object containing the boolean
  10454. * @param propertyPath defines the path to the boolean property in the target object
  10455. * @param condition defines the trigger related conditions
  10456. */
  10457. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10458. /** @hidden */ private _prepare(): void;
  10459. /**
  10460. * Execute the action toggle the boolean value.
  10461. */
  10462. execute(): void;
  10463. /**
  10464. * Serializes the actions and its related information.
  10465. * @param parent defines the object to serialize in
  10466. * @returns the serialized object
  10467. */
  10468. serialize(parent: any): any;
  10469. }
  10470. /**
  10471. * This defines an action responsible to set a the state field of the target
  10472. * to a desired value once triggered.
  10473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10474. */
  10475. export class SetStateAction extends Action {
  10476. /**
  10477. * The value to store in the state field.
  10478. */
  10479. value: string;
  10480. private _target;
  10481. /**
  10482. * Instantiate the action
  10483. * @param triggerOptions defines the trigger options
  10484. * @param target defines the object containing the state property
  10485. * @param value defines the value to store in the state field
  10486. * @param condition defines the trigger related conditions
  10487. */
  10488. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10489. /**
  10490. * Execute the action and store the value on the target state property.
  10491. */
  10492. execute(): void;
  10493. /**
  10494. * Serializes the actions and its related information.
  10495. * @param parent defines the object to serialize in
  10496. * @returns the serialized object
  10497. */
  10498. serialize(parent: any): any;
  10499. }
  10500. /**
  10501. * This defines an action responsible to set a property of the target
  10502. * to a desired value once triggered.
  10503. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10504. */
  10505. export class SetValueAction extends Action {
  10506. /**
  10507. * The path of the property to set in the target.
  10508. */
  10509. propertyPath: string;
  10510. /**
  10511. * The value to set in the property
  10512. */
  10513. value: any;
  10514. private _target;
  10515. private _effectiveTarget;
  10516. private _property;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the property
  10521. * @param propertyPath defines the path of the property to set in the target
  10522. * @param value defines the value to set in the property
  10523. * @param condition defines the trigger related conditions
  10524. */
  10525. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10526. /** @hidden */ private _prepare(): void;
  10527. /**
  10528. * Execute the action and set the targetted property to the desired value.
  10529. */
  10530. execute(): void;
  10531. /**
  10532. * Serializes the actions and its related information.
  10533. * @param parent defines the object to serialize in
  10534. * @returns the serialized object
  10535. */
  10536. serialize(parent: any): any;
  10537. }
  10538. /**
  10539. * This defines an action responsible to increment the target value
  10540. * to a desired value once triggered.
  10541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10542. */
  10543. export class IncrementValueAction extends Action {
  10544. /**
  10545. * The path of the property to increment in the target.
  10546. */
  10547. propertyPath: string;
  10548. /**
  10549. * The value we should increment the property by.
  10550. */
  10551. value: any;
  10552. private _target;
  10553. private _effectiveTarget;
  10554. private _property;
  10555. /**
  10556. * Instantiate the action
  10557. * @param triggerOptions defines the trigger options
  10558. * @param target defines the object containing the property
  10559. * @param propertyPath defines the path of the property to increment in the target
  10560. * @param value defines the value value we should increment the property by
  10561. * @param condition defines the trigger related conditions
  10562. */
  10563. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10564. /** @hidden */ private _prepare(): void;
  10565. /**
  10566. * Execute the action and increment the target of the value amount.
  10567. */
  10568. execute(): void;
  10569. /**
  10570. * Serializes the actions and its related information.
  10571. * @param parent defines the object to serialize in
  10572. * @returns the serialized object
  10573. */
  10574. serialize(parent: any): any;
  10575. }
  10576. /**
  10577. * This defines an action responsible to start an animation once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class PlayAnimationAction extends Action {
  10581. /**
  10582. * Where the animation should start (animation frame)
  10583. */
  10584. from: number;
  10585. /**
  10586. * Where the animation should stop (animation frame)
  10587. */
  10588. to: number;
  10589. /**
  10590. * Define if the animation should loop or stop after the first play.
  10591. */
  10592. loop?: boolean;
  10593. private _target;
  10594. /**
  10595. * Instantiate the action
  10596. * @param triggerOptions defines the trigger options
  10597. * @param target defines the target animation or animation name
  10598. * @param from defines from where the animation should start (animation frame)
  10599. * @param end defines where the animation should stop (animation frame)
  10600. * @param loop defines if the animation should loop or stop after the first play
  10601. * @param condition defines the trigger related conditions
  10602. */
  10603. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10604. /** @hidden */ private _prepare(): void;
  10605. /**
  10606. * Execute the action and play the animation.
  10607. */
  10608. execute(): void;
  10609. /**
  10610. * Serializes the actions and its related information.
  10611. * @param parent defines the object to serialize in
  10612. * @returns the serialized object
  10613. */
  10614. serialize(parent: any): any;
  10615. }
  10616. /**
  10617. * This defines an action responsible to stop an animation once triggered.
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10619. */
  10620. export class StopAnimationAction extends Action {
  10621. private _target;
  10622. /**
  10623. * Instantiate the action
  10624. * @param triggerOptions defines the trigger options
  10625. * @param target defines the target animation or animation name
  10626. * @param condition defines the trigger related conditions
  10627. */
  10628. constructor(triggerOptions: any, target: any, condition?: Condition);
  10629. /** @hidden */ private _prepare(): void;
  10630. /**
  10631. * Execute the action and stop the animation.
  10632. */
  10633. execute(): void;
  10634. /**
  10635. * Serializes the actions and its related information.
  10636. * @param parent defines the object to serialize in
  10637. * @returns the serialized object
  10638. */
  10639. serialize(parent: any): any;
  10640. }
  10641. /**
  10642. * This defines an action responsible that does nothing once triggered.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class DoNothingAction extends Action {
  10646. /**
  10647. * Instantiate the action
  10648. * @param triggerOptions defines the trigger options
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions?: any, condition?: Condition);
  10652. /**
  10653. * Execute the action and do nothing.
  10654. */
  10655. execute(): void;
  10656. /**
  10657. * Serializes the actions and its related information.
  10658. * @param parent defines the object to serialize in
  10659. * @returns the serialized object
  10660. */
  10661. serialize(parent: any): any;
  10662. }
  10663. /**
  10664. * This defines an action responsible to trigger several actions once triggered.
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10666. */
  10667. export class CombineAction extends Action {
  10668. /**
  10669. * The list of aggregated animations to run.
  10670. */
  10671. children: Action[];
  10672. /**
  10673. * Instantiate the action
  10674. * @param triggerOptions defines the trigger options
  10675. * @param children defines the list of aggregated animations to run
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10679. /** @hidden */ private _prepare(): void;
  10680. /**
  10681. * Execute the action and executes all the aggregated actions.
  10682. */
  10683. execute(evt: ActionEvent): void;
  10684. /**
  10685. * Serializes the actions and its related information.
  10686. * @param parent defines the object to serialize in
  10687. * @returns the serialized object
  10688. */
  10689. serialize(parent: any): any;
  10690. }
  10691. /**
  10692. * This defines an action responsible to run code (external event) once triggered.
  10693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10694. */
  10695. export class ExecuteCodeAction extends Action {
  10696. /**
  10697. * The callback function to run.
  10698. */
  10699. func: (evt: ActionEvent) => void;
  10700. /**
  10701. * Instantiate the action
  10702. * @param triggerOptions defines the trigger options
  10703. * @param func defines the callback function to run
  10704. * @param condition defines the trigger related conditions
  10705. */
  10706. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10707. /**
  10708. * Execute the action and run the attached code.
  10709. */
  10710. execute(evt: ActionEvent): void;
  10711. }
  10712. /**
  10713. * This defines an action responsible to set the parent property of the target once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class SetParentAction extends Action {
  10717. private _parent;
  10718. private _target;
  10719. /**
  10720. * Instantiate the action
  10721. * @param triggerOptions defines the trigger options
  10722. * @param target defines the target containing the parent property
  10723. * @param parent defines from where the animation should start (animation frame)
  10724. * @param condition defines the trigger related conditions
  10725. */
  10726. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10727. /** @hidden */ private _prepare(): void;
  10728. /**
  10729. * Execute the action and set the parent property.
  10730. */
  10731. execute(): void;
  10732. /**
  10733. * Serializes the actions and its related information.
  10734. * @param parent defines the object to serialize in
  10735. * @returns the serialized object
  10736. */
  10737. serialize(parent: any): any;
  10738. }
  10739. }
  10740. declare module BABYLON {
  10741. /**
  10742. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10743. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10745. */
  10746. export class ActionManager extends AbstractActionManager {
  10747. /**
  10748. * Nothing
  10749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10750. */
  10751. static readonly NothingTrigger: number;
  10752. /**
  10753. * On pick
  10754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10755. */
  10756. static readonly OnPickTrigger: number;
  10757. /**
  10758. * On left pick
  10759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10760. */
  10761. static readonly OnLeftPickTrigger: number;
  10762. /**
  10763. * On right pick
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10765. */
  10766. static readonly OnRightPickTrigger: number;
  10767. /**
  10768. * On center pick
  10769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10770. */
  10771. static readonly OnCenterPickTrigger: number;
  10772. /**
  10773. * On pick down
  10774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10775. */
  10776. static readonly OnPickDownTrigger: number;
  10777. /**
  10778. * On double pick
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10780. */
  10781. static readonly OnDoublePickTrigger: number;
  10782. /**
  10783. * On pick up
  10784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10785. */
  10786. static readonly OnPickUpTrigger: number;
  10787. /**
  10788. * On pick out.
  10789. * This trigger will only be raised if you also declared a OnPickDown
  10790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10791. */
  10792. static readonly OnPickOutTrigger: number;
  10793. /**
  10794. * On long press
  10795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10796. */
  10797. static readonly OnLongPressTrigger: number;
  10798. /**
  10799. * On pointer over
  10800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10801. */
  10802. static readonly OnPointerOverTrigger: number;
  10803. /**
  10804. * On pointer out
  10805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10806. */
  10807. static readonly OnPointerOutTrigger: number;
  10808. /**
  10809. * On every frame
  10810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10811. */
  10812. static readonly OnEveryFrameTrigger: number;
  10813. /**
  10814. * On intersection enter
  10815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10816. */
  10817. static readonly OnIntersectionEnterTrigger: number;
  10818. /**
  10819. * On intersection exit
  10820. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10821. */
  10822. static readonly OnIntersectionExitTrigger: number;
  10823. /**
  10824. * On key down
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10826. */
  10827. static readonly OnKeyDownTrigger: number;
  10828. /**
  10829. * On key up
  10830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10831. */
  10832. static readonly OnKeyUpTrigger: number;
  10833. private _scene;
  10834. /**
  10835. * Creates a new action manager
  10836. * @param scene defines the hosting scene
  10837. */
  10838. constructor(scene: Scene);
  10839. /**
  10840. * Releases all associated resources
  10841. */
  10842. dispose(): void;
  10843. /**
  10844. * Gets hosting scene
  10845. * @returns the hosting scene
  10846. */
  10847. getScene(): Scene;
  10848. /**
  10849. * Does this action manager handles actions of any of the given triggers
  10850. * @param triggers defines the triggers to be tested
  10851. * @return a boolean indicating whether one (or more) of the triggers is handled
  10852. */
  10853. hasSpecificTriggers(triggers: number[]): boolean;
  10854. /**
  10855. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10856. * speed.
  10857. * @param triggerA defines the trigger to be tested
  10858. * @param triggerB defines the trigger to be tested
  10859. * @return a boolean indicating whether one (or more) of the triggers is handled
  10860. */
  10861. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10862. /**
  10863. * Does this action manager handles actions of a given trigger
  10864. * @param trigger defines the trigger to be tested
  10865. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10866. * @return whether the trigger is handled
  10867. */
  10868. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10869. /**
  10870. * Does this action manager has pointer triggers
  10871. */
  10872. readonly hasPointerTriggers: boolean;
  10873. /**
  10874. * Does this action manager has pick triggers
  10875. */
  10876. readonly hasPickTriggers: boolean;
  10877. /**
  10878. * Registers an action to this action manager
  10879. * @param action defines the action to be registered
  10880. * @return the action amended (prepared) after registration
  10881. */
  10882. registerAction(action: IAction): Nullable<IAction>;
  10883. /**
  10884. * Unregisters an action to this action manager
  10885. * @param action defines the action to be unregistered
  10886. * @return a boolean indicating whether the action has been unregistered
  10887. */
  10888. unregisterAction(action: IAction): Boolean;
  10889. /**
  10890. * Process a specific trigger
  10891. * @param trigger defines the trigger to process
  10892. * @param evt defines the event details to be processed
  10893. */
  10894. processTrigger(trigger: number, evt?: IActionEvent): void;
  10895. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10896. /** @hidden */ private _getProperty(propertyPath: string): string;
  10897. /**
  10898. * Serialize this manager to a JSON object
  10899. * @param name defines the property name to store this manager
  10900. * @returns a JSON representation of this manager
  10901. */
  10902. serialize(name: string): any;
  10903. /**
  10904. * Creates a new ActionManager from a JSON data
  10905. * @param parsedActions defines the JSON data to read from
  10906. * @param object defines the hosting mesh
  10907. * @param scene defines the hosting scene
  10908. */
  10909. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10910. /**
  10911. * Get a trigger name by index
  10912. * @param trigger defines the trigger index
  10913. * @returns a trigger name
  10914. */
  10915. static GetTriggerName(trigger: number): string;
  10916. }
  10917. }
  10918. declare module BABYLON {
  10919. /**
  10920. * Class representing a ray with position and direction
  10921. */
  10922. export class Ray {
  10923. /** origin point */
  10924. origin: Vector3;
  10925. /** direction */
  10926. direction: Vector3;
  10927. /** length of the ray */
  10928. length: number;
  10929. private static readonly TmpVector3;
  10930. private _tmpRay;
  10931. /**
  10932. * Creates a new ray
  10933. * @param origin origin point
  10934. * @param direction direction
  10935. * @param length length of the ray
  10936. */
  10937. constructor(
  10938. /** origin point */
  10939. origin: Vector3,
  10940. /** direction */
  10941. direction: Vector3,
  10942. /** length of the ray */
  10943. length?: number);
  10944. /**
  10945. * Checks if the ray intersects a box
  10946. * @param minimum bound of the box
  10947. * @param maximum bound of the box
  10948. * @param intersectionTreshold extra extend to be added to the box in all direction
  10949. * @returns if the box was hit
  10950. */
  10951. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10952. /**
  10953. * Checks if the ray intersects a box
  10954. * @param box the bounding box to check
  10955. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10956. * @returns if the box was hit
  10957. */
  10958. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10959. /**
  10960. * If the ray hits a sphere
  10961. * @param sphere the bounding sphere to check
  10962. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10963. * @returns true if it hits the sphere
  10964. */
  10965. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10966. /**
  10967. * If the ray hits a triange
  10968. * @param vertex0 triangle vertex
  10969. * @param vertex1 triangle vertex
  10970. * @param vertex2 triangle vertex
  10971. * @returns intersection information if hit
  10972. */
  10973. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10974. /**
  10975. * Checks if ray intersects a plane
  10976. * @param plane the plane to check
  10977. * @returns the distance away it was hit
  10978. */
  10979. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10980. /**
  10981. * Calculate the intercept of a ray on a given axis
  10982. * @param axis to check 'x' | 'y' | 'z'
  10983. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10984. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10985. */
  10986. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10987. /**
  10988. * Checks if ray intersects a mesh
  10989. * @param mesh the mesh to check
  10990. * @param fastCheck if only the bounding box should checked
  10991. * @returns picking info of the intersecton
  10992. */
  10993. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10994. /**
  10995. * Checks if ray intersects a mesh
  10996. * @param meshes the meshes to check
  10997. * @param fastCheck if only the bounding box should checked
  10998. * @param results array to store result in
  10999. * @returns Array of picking infos
  11000. */
  11001. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11002. private _comparePickingInfo;
  11003. private static smallnum;
  11004. private static rayl;
  11005. /**
  11006. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11007. * @param sega the first point of the segment to test the intersection against
  11008. * @param segb the second point of the segment to test the intersection against
  11009. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11010. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11011. */
  11012. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11013. /**
  11014. * Update the ray from viewport position
  11015. * @param x position
  11016. * @param y y position
  11017. * @param viewportWidth viewport width
  11018. * @param viewportHeight viewport height
  11019. * @param world world matrix
  11020. * @param view view matrix
  11021. * @param projection projection matrix
  11022. * @returns this ray updated
  11023. */
  11024. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11025. /**
  11026. * Creates a ray with origin and direction of 0,0,0
  11027. * @returns the new ray
  11028. */
  11029. static Zero(): Ray;
  11030. /**
  11031. * Creates a new ray from screen space and viewport
  11032. * @param x position
  11033. * @param y y position
  11034. * @param viewportWidth viewport width
  11035. * @param viewportHeight viewport height
  11036. * @param world world matrix
  11037. * @param view view matrix
  11038. * @param projection projection matrix
  11039. * @returns new ray
  11040. */
  11041. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11042. /**
  11043. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11044. * transformed to the given world matrix.
  11045. * @param origin The origin point
  11046. * @param end The end point
  11047. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11048. * @returns the new ray
  11049. */
  11050. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11051. /**
  11052. * Transforms a ray by a matrix
  11053. * @param ray ray to transform
  11054. * @param matrix matrix to apply
  11055. * @returns the resulting new ray
  11056. */
  11057. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11058. /**
  11059. * Transforms a ray by a matrix
  11060. * @param ray ray to transform
  11061. * @param matrix matrix to apply
  11062. * @param result ray to store result in
  11063. */
  11064. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11065. /**
  11066. * Unproject a ray from screen space to object space
  11067. * @param sourceX defines the screen space x coordinate to use
  11068. * @param sourceY defines the screen space y coordinate to use
  11069. * @param viewportWidth defines the current width of the viewport
  11070. * @param viewportHeight defines the current height of the viewport
  11071. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11072. * @param view defines the view matrix to use
  11073. * @param projection defines the projection matrix to use
  11074. */
  11075. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11076. }
  11077. /**
  11078. * Type used to define predicate used to select faces when a mesh intersection is detected
  11079. */
  11080. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11081. interface Scene {
  11082. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  11083. /** @hidden */ private _cachedRayForTransform: Ray;
  11084. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  11085. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11086. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11087. }
  11088. }
  11089. declare module BABYLON {
  11090. /**
  11091. * Groups all the scene component constants in one place to ease maintenance.
  11092. * @hidden
  11093. */
  11094. export class SceneComponentConstants {
  11095. static readonly NAME_EFFECTLAYER: string;
  11096. static readonly NAME_LAYER: string;
  11097. static readonly NAME_LENSFLARESYSTEM: string;
  11098. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11099. static readonly NAME_PARTICLESYSTEM: string;
  11100. static readonly NAME_GAMEPAD: string;
  11101. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11102. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11103. static readonly NAME_DEPTHRENDERER: string;
  11104. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11105. static readonly NAME_SPRITE: string;
  11106. static readonly NAME_OUTLINERENDERER: string;
  11107. static readonly NAME_PROCEDURALTEXTURE: string;
  11108. static readonly NAME_SHADOWGENERATOR: string;
  11109. static readonly NAME_OCTREE: string;
  11110. static readonly NAME_PHYSICSENGINE: string;
  11111. static readonly NAME_AUDIO: string;
  11112. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11113. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11114. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11115. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11116. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11117. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11118. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11119. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11120. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11121. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11122. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11123. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11124. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11125. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11126. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11127. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11128. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11129. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11130. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11131. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11132. static readonly STEP_AFTERRENDER_AUDIO: number;
  11133. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11134. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11135. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11136. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11137. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11138. static readonly STEP_POINTERMOVE_SPRITE: number;
  11139. static readonly STEP_POINTERDOWN_SPRITE: number;
  11140. static readonly STEP_POINTERUP_SPRITE: number;
  11141. }
  11142. /**
  11143. * This represents a scene component.
  11144. *
  11145. * This is used to decouple the dependency the scene is having on the different workloads like
  11146. * layers, post processes...
  11147. */
  11148. export interface ISceneComponent {
  11149. /**
  11150. * The name of the component. Each component must have a unique name.
  11151. */
  11152. name: string;
  11153. /**
  11154. * The scene the component belongs to.
  11155. */
  11156. scene: Scene;
  11157. /**
  11158. * Register the component to one instance of a scene.
  11159. */
  11160. register(): void;
  11161. /**
  11162. * Rebuilds the elements related to this component in case of
  11163. * context lost for instance.
  11164. */
  11165. rebuild(): void;
  11166. /**
  11167. * Disposes the component and the associated ressources.
  11168. */
  11169. dispose(): void;
  11170. }
  11171. /**
  11172. * This represents a SERIALIZABLE scene component.
  11173. *
  11174. * This extends Scene Component to add Serialization methods on top.
  11175. */
  11176. export interface ISceneSerializableComponent extends ISceneComponent {
  11177. /**
  11178. * Adds all the elements from the container to the scene
  11179. * @param container the container holding the elements
  11180. */
  11181. addFromContainer(container: AbstractScene): void;
  11182. /**
  11183. * Removes all the elements in the container from the scene
  11184. * @param container contains the elements to remove
  11185. * @param dispose if the removed element should be disposed (default: false)
  11186. */
  11187. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11188. /**
  11189. * Serializes the component data to the specified json object
  11190. * @param serializationObject The object to serialize to
  11191. */
  11192. serialize(serializationObject: any): void;
  11193. }
  11194. /**
  11195. * Strong typing of a Mesh related stage step action
  11196. */
  11197. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11198. /**
  11199. * Strong typing of a Evaluate Sub Mesh related stage step action
  11200. */
  11201. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11202. /**
  11203. * Strong typing of a Active Mesh related stage step action
  11204. */
  11205. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11206. /**
  11207. * Strong typing of a Camera related stage step action
  11208. */
  11209. export type CameraStageAction = (camera: Camera) => void;
  11210. /**
  11211. * Strong typing of a Camera Frame buffer related stage step action
  11212. */
  11213. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11214. /**
  11215. * Strong typing of a Render Target related stage step action
  11216. */
  11217. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11218. /**
  11219. * Strong typing of a RenderingGroup related stage step action
  11220. */
  11221. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11222. /**
  11223. * Strong typing of a Mesh Render related stage step action
  11224. */
  11225. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11226. /**
  11227. * Strong typing of a simple stage step action
  11228. */
  11229. export type SimpleStageAction = () => void;
  11230. /**
  11231. * Strong typing of a render target action.
  11232. */
  11233. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11234. /**
  11235. * Strong typing of a pointer move action.
  11236. */
  11237. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11238. /**
  11239. * Strong typing of a pointer up/down action.
  11240. */
  11241. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11242. /**
  11243. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11244. * @hidden
  11245. */
  11246. export class Stage<T extends Function> extends Array<{
  11247. index: number;
  11248. component: ISceneComponent;
  11249. action: T;
  11250. }> {
  11251. /**
  11252. * Hide ctor from the rest of the world.
  11253. * @param items The items to add.
  11254. */
  11255. private constructor();
  11256. /**
  11257. * Creates a new Stage.
  11258. * @returns A new instance of a Stage
  11259. */
  11260. static Create<T extends Function>(): Stage<T>;
  11261. /**
  11262. * Registers a step in an ordered way in the targeted stage.
  11263. * @param index Defines the position to register the step in
  11264. * @param component Defines the component attached to the step
  11265. * @param action Defines the action to launch during the step
  11266. */
  11267. registerStep(index: number, component: ISceneComponent, action: T): void;
  11268. /**
  11269. * Clears all the steps from the stage.
  11270. */
  11271. clear(): void;
  11272. }
  11273. }
  11274. declare module BABYLON {
  11275. interface Scene {
  11276. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11277. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11278. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11279. /**
  11280. * All of the sprite managers added to this scene
  11281. * @see http://doc.babylonjs.com/babylon101/sprites
  11282. */
  11283. spriteManagers: Array<ISpriteManager>;
  11284. /**
  11285. * An event triggered when sprites rendering is about to start
  11286. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11287. */
  11288. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11289. /**
  11290. * An event triggered when sprites rendering is done
  11291. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11292. */
  11293. onAfterSpritesRenderingObservable: Observable<Scene>;
  11294. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11295. /** Launch a ray to try to pick a sprite in the scene
  11296. * @param x position on screen
  11297. * @param y position on screen
  11298. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11299. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11300. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11301. * @returns a PickingInfo
  11302. */
  11303. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11304. /** Use the given ray to pick a sprite in the scene
  11305. * @param ray The ray (in world space) to use to pick meshes
  11306. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11307. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11308. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11309. * @returns a PickingInfo
  11310. */
  11311. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11312. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11313. /** Launch a ray to try to pick sprites in the scene
  11314. * @param x position on screen
  11315. * @param y position on screen
  11316. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11317. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11318. * @returns a PickingInfo array
  11319. */
  11320. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11321. /** Use the given ray to pick sprites in the scene
  11322. * @param ray The ray (in world space) to use to pick meshes
  11323. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11324. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11325. * @returns a PickingInfo array
  11326. */
  11327. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11328. /**
  11329. * Force the sprite under the pointer
  11330. * @param sprite defines the sprite to use
  11331. */
  11332. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11333. /**
  11334. * Gets the sprite under the pointer
  11335. * @returns a Sprite or null if no sprite is under the pointer
  11336. */
  11337. getPointerOverSprite(): Nullable<Sprite>;
  11338. }
  11339. /**
  11340. * Defines the sprite scene component responsible to manage sprites
  11341. * in a given scene.
  11342. */
  11343. export class SpriteSceneComponent implements ISceneComponent {
  11344. /**
  11345. * The component name helpfull to identify the component in the list of scene components.
  11346. */
  11347. readonly name: string;
  11348. /**
  11349. * The scene the component belongs to.
  11350. */
  11351. scene: Scene;
  11352. /** @hidden */
  11353. private _spritePredicate;
  11354. /**
  11355. * Creates a new instance of the component for the given scene
  11356. * @param scene Defines the scene to register the component in
  11357. */
  11358. constructor(scene: Scene);
  11359. /**
  11360. * Registers the component in a given scene
  11361. */
  11362. register(): void;
  11363. /**
  11364. * Rebuilds the elements related to this component in case of
  11365. * context lost for instance.
  11366. */
  11367. rebuild(): void;
  11368. /**
  11369. * Disposes the component and the associated ressources.
  11370. */
  11371. dispose(): void;
  11372. private _pickSpriteButKeepRay;
  11373. private _pointerMove;
  11374. private _pointerDown;
  11375. private _pointerUp;
  11376. }
  11377. }
  11378. declare module BABYLON {
  11379. /** @hidden */
  11380. export var fogFragmentDeclaration: {
  11381. name: string;
  11382. shader: string;
  11383. };
  11384. }
  11385. declare module BABYLON {
  11386. /** @hidden */
  11387. export var fogFragment: {
  11388. name: string;
  11389. shader: string;
  11390. };
  11391. }
  11392. declare module BABYLON {
  11393. /** @hidden */
  11394. export var spritesPixelShader: {
  11395. name: string;
  11396. shader: string;
  11397. };
  11398. }
  11399. declare module BABYLON {
  11400. /** @hidden */
  11401. export var fogVertexDeclaration: {
  11402. name: string;
  11403. shader: string;
  11404. };
  11405. }
  11406. declare module BABYLON {
  11407. /** @hidden */
  11408. export var spritesVertexShader: {
  11409. name: string;
  11410. shader: string;
  11411. };
  11412. }
  11413. declare module BABYLON {
  11414. /**
  11415. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11416. */
  11417. export interface ISpriteManager extends IDisposable {
  11418. /**
  11419. * Restricts the camera to viewing objects with the same layerMask.
  11420. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11421. */
  11422. layerMask: number;
  11423. /**
  11424. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11425. */
  11426. isPickable: boolean;
  11427. /**
  11428. * Specifies the rendering group id for this mesh (0 by default)
  11429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11430. */
  11431. renderingGroupId: number;
  11432. /**
  11433. * Defines the list of sprites managed by the manager.
  11434. */
  11435. sprites: Array<Sprite>;
  11436. /**
  11437. * Tests the intersection of a sprite with a specific ray.
  11438. * @param ray The ray we are sending to test the collision
  11439. * @param camera The camera space we are sending rays in
  11440. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11441. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11442. * @returns picking info or null.
  11443. */
  11444. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11445. /**
  11446. * Intersects the sprites with a ray
  11447. * @param ray defines the ray to intersect with
  11448. * @param camera defines the current active camera
  11449. * @param predicate defines a predicate used to select candidate sprites
  11450. * @returns null if no hit or a PickingInfo array
  11451. */
  11452. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11453. /**
  11454. * Renders the list of sprites on screen.
  11455. */
  11456. render(): void;
  11457. }
  11458. /**
  11459. * Class used to manage multiple sprites on the same spritesheet
  11460. * @see http://doc.babylonjs.com/babylon101/sprites
  11461. */
  11462. export class SpriteManager implements ISpriteManager {
  11463. /** defines the manager's name */
  11464. name: string;
  11465. /** Gets the list of sprites */
  11466. sprites: Sprite[];
  11467. /** Gets or sets the rendering group id (0 by default) */
  11468. renderingGroupId: number;
  11469. /** Gets or sets camera layer mask */
  11470. layerMask: number;
  11471. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11472. fogEnabled: boolean;
  11473. /** Gets or sets a boolean indicating if the sprites are pickable */
  11474. isPickable: boolean;
  11475. /** Defines the default width of a cell in the spritesheet */
  11476. cellWidth: number;
  11477. /** Defines the default height of a cell in the spritesheet */
  11478. cellHeight: number;
  11479. /** Associative array from JSON sprite data file */
  11480. private _cellData;
  11481. /** Array of sprite names from JSON sprite data file */
  11482. private _spriteMap;
  11483. /** True when packed cell data from JSON file is ready*/
  11484. private _packedAndReady;
  11485. /**
  11486. * An event triggered when the manager is disposed.
  11487. */
  11488. onDisposeObservable: Observable<SpriteManager>;
  11489. private _onDisposeObserver;
  11490. /**
  11491. * Callback called when the manager is disposed
  11492. */
  11493. onDispose: () => void;
  11494. private _capacity;
  11495. private _fromPacked;
  11496. private _spriteTexture;
  11497. private _epsilon;
  11498. private _scene;
  11499. private _vertexData;
  11500. private _buffer;
  11501. private _vertexBuffers;
  11502. private _indexBuffer;
  11503. private _effectBase;
  11504. private _effectFog;
  11505. /**
  11506. * Gets or sets the spritesheet texture
  11507. */
  11508. texture: Texture;
  11509. /**
  11510. * Creates a new sprite manager
  11511. * @param name defines the manager's name
  11512. * @param imgUrl defines the sprite sheet url
  11513. * @param capacity defines the maximum allowed number of sprites
  11514. * @param cellSize defines the size of a sprite cell
  11515. * @param scene defines the hosting scene
  11516. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11517. * @param samplingMode defines the smapling mode to use with spritesheet
  11518. * @param fromPacked set to false; do not alter
  11519. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11520. */
  11521. constructor(
  11522. /** defines the manager's name */
  11523. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11524. private _makePacked;
  11525. private _appendSpriteVertex;
  11526. /**
  11527. * Intersects the sprites with a ray
  11528. * @param ray defines the ray to intersect with
  11529. * @param camera defines the current active camera
  11530. * @param predicate defines a predicate used to select candidate sprites
  11531. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11532. * @returns null if no hit or a PickingInfo
  11533. */
  11534. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11535. /**
  11536. * Intersects the sprites with a ray
  11537. * @param ray defines the ray to intersect with
  11538. * @param camera defines the current active camera
  11539. * @param predicate defines a predicate used to select candidate sprites
  11540. * @returns null if no hit or a PickingInfo array
  11541. */
  11542. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11543. /**
  11544. * Render all child sprites
  11545. */
  11546. render(): void;
  11547. /**
  11548. * Release associated resources
  11549. */
  11550. dispose(): void;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Class used to represent a sprite
  11556. * @see http://doc.babylonjs.com/babylon101/sprites
  11557. */
  11558. export class Sprite {
  11559. /** defines the name */
  11560. name: string;
  11561. /** Gets or sets the current world position */
  11562. position: Vector3;
  11563. /** Gets or sets the main color */
  11564. color: Color4;
  11565. /** Gets or sets the width */
  11566. width: number;
  11567. /** Gets or sets the height */
  11568. height: number;
  11569. /** Gets or sets rotation angle */
  11570. angle: number;
  11571. /** Gets or sets the cell index in the sprite sheet */
  11572. cellIndex: number;
  11573. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11574. cellRef: string;
  11575. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11576. invertU: number;
  11577. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11578. invertV: number;
  11579. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11580. disposeWhenFinishedAnimating: boolean;
  11581. /** Gets the list of attached animations */
  11582. animations: Animation[];
  11583. /** Gets or sets a boolean indicating if the sprite can be picked */
  11584. isPickable: boolean;
  11585. /**
  11586. * Gets or sets the associated action manager
  11587. */
  11588. actionManager: Nullable<ActionManager>;
  11589. private _animationStarted;
  11590. private _loopAnimation;
  11591. private _fromIndex;
  11592. private _toIndex;
  11593. private _delay;
  11594. private _direction;
  11595. private _manager;
  11596. private _time;
  11597. private _onAnimationEnd;
  11598. /**
  11599. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11600. */
  11601. isVisible: boolean;
  11602. /**
  11603. * Gets or sets the sprite size
  11604. */
  11605. size: number;
  11606. /**
  11607. * Creates a new Sprite
  11608. * @param name defines the name
  11609. * @param manager defines the manager
  11610. */
  11611. constructor(
  11612. /** defines the name */
  11613. name: string, manager: ISpriteManager);
  11614. /**
  11615. * Starts an animation
  11616. * @param from defines the initial key
  11617. * @param to defines the end key
  11618. * @param loop defines if the animation must loop
  11619. * @param delay defines the start delay (in ms)
  11620. * @param onAnimationEnd defines a callback to call when animation ends
  11621. */
  11622. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11623. /** Stops current animation (if any) */
  11624. stopAnimation(): void;
  11625. /** @hidden */ private _animate(deltaTime: number): void;
  11626. /** Release associated resources */
  11627. dispose(): void;
  11628. }
  11629. }
  11630. declare module BABYLON {
  11631. /**
  11632. * Information about the result of picking within a scene
  11633. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11634. */
  11635. export class PickingInfo {
  11636. /** @hidden */ private _pickingUnavailable: boolean;
  11637. /**
  11638. * If the pick collided with an object
  11639. */
  11640. hit: boolean;
  11641. /**
  11642. * Distance away where the pick collided
  11643. */
  11644. distance: number;
  11645. /**
  11646. * The location of pick collision
  11647. */
  11648. pickedPoint: Nullable<Vector3>;
  11649. /**
  11650. * The mesh corresponding the the pick collision
  11651. */
  11652. pickedMesh: Nullable<AbstractMesh>;
  11653. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11654. bu: number;
  11655. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11656. bv: number;
  11657. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11658. faceId: number;
  11659. /** Id of the the submesh that was picked */
  11660. subMeshId: number;
  11661. /** If a sprite was picked, this will be the sprite the pick collided with */
  11662. pickedSprite: Nullable<Sprite>;
  11663. /**
  11664. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11665. */
  11666. originMesh: Nullable<AbstractMesh>;
  11667. /**
  11668. * The ray that was used to perform the picking.
  11669. */
  11670. ray: Nullable<Ray>;
  11671. /**
  11672. * Gets the normal correspodning to the face the pick collided with
  11673. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11674. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11675. * @returns The normal correspodning to the face the pick collided with
  11676. */
  11677. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11678. /**
  11679. * Gets the texture coordinates of where the pick occured
  11680. * @returns the vector containing the coordnates of the texture
  11681. */
  11682. getTextureCoordinates(): Nullable<Vector2>;
  11683. }
  11684. }
  11685. declare module BABYLON {
  11686. /**
  11687. * Gather the list of pointer event types as constants.
  11688. */
  11689. export class PointerEventTypes {
  11690. /**
  11691. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11692. */
  11693. static readonly POINTERDOWN: number;
  11694. /**
  11695. * The pointerup event is fired when a pointer is no longer active.
  11696. */
  11697. static readonly POINTERUP: number;
  11698. /**
  11699. * The pointermove event is fired when a pointer changes coordinates.
  11700. */
  11701. static readonly POINTERMOVE: number;
  11702. /**
  11703. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11704. */
  11705. static readonly POINTERWHEEL: number;
  11706. /**
  11707. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11708. */
  11709. static readonly POINTERPICK: number;
  11710. /**
  11711. * The pointertap event is fired when a the object has been touched and released without drag.
  11712. */
  11713. static readonly POINTERTAP: number;
  11714. /**
  11715. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11716. */
  11717. static readonly POINTERDOUBLETAP: number;
  11718. }
  11719. /**
  11720. * Base class of pointer info types.
  11721. */
  11722. export class PointerInfoBase {
  11723. /**
  11724. * Defines the type of event (PointerEventTypes)
  11725. */
  11726. type: number;
  11727. /**
  11728. * Defines the related dom event
  11729. */
  11730. event: PointerEvent | MouseWheelEvent;
  11731. /**
  11732. * Instantiates the base class of pointers info.
  11733. * @param type Defines the type of event (PointerEventTypes)
  11734. * @param event Defines the related dom event
  11735. */
  11736. constructor(
  11737. /**
  11738. * Defines the type of event (PointerEventTypes)
  11739. */
  11740. type: number,
  11741. /**
  11742. * Defines the related dom event
  11743. */
  11744. event: PointerEvent | MouseWheelEvent);
  11745. }
  11746. /**
  11747. * This class is used to store pointer related info for the onPrePointerObservable event.
  11748. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11749. */
  11750. export class PointerInfoPre extends PointerInfoBase {
  11751. /**
  11752. * Ray from a pointer if availible (eg. 6dof controller)
  11753. */
  11754. ray: Nullable<Ray>;
  11755. /**
  11756. * Defines the local position of the pointer on the canvas.
  11757. */
  11758. localPosition: Vector2;
  11759. /**
  11760. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11761. */
  11762. skipOnPointerObservable: boolean;
  11763. /**
  11764. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11765. * @param type Defines the type of event (PointerEventTypes)
  11766. * @param event Defines the related dom event
  11767. * @param localX Defines the local x coordinates of the pointer when the event occured
  11768. * @param localY Defines the local y coordinates of the pointer when the event occured
  11769. */
  11770. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11771. }
  11772. /**
  11773. * This type contains all the data related to a pointer event in Babylon.js.
  11774. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11775. */
  11776. export class PointerInfo extends PointerInfoBase {
  11777. /**
  11778. * Defines the picking info associated to the info (if any)\
  11779. */
  11780. pickInfo: Nullable<PickingInfo>;
  11781. /**
  11782. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11783. * @param type Defines the type of event (PointerEventTypes)
  11784. * @param event Defines the related dom event
  11785. * @param pickInfo Defines the picking info associated to the info (if any)\
  11786. */
  11787. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11788. /**
  11789. * Defines the picking info associated to the info (if any)\
  11790. */
  11791. pickInfo: Nullable<PickingInfo>);
  11792. }
  11793. /**
  11794. * Data relating to a touch event on the screen.
  11795. */
  11796. export interface PointerTouch {
  11797. /**
  11798. * X coordinate of touch.
  11799. */
  11800. x: number;
  11801. /**
  11802. * Y coordinate of touch.
  11803. */
  11804. y: number;
  11805. /**
  11806. * Id of touch. Unique for each finger.
  11807. */
  11808. pointerId: number;
  11809. /**
  11810. * Event type passed from DOM.
  11811. */
  11812. type: any;
  11813. }
  11814. }
  11815. declare module BABYLON {
  11816. /**
  11817. * Manage the mouse inputs to control the movement of a free camera.
  11818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11819. */
  11820. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11821. /**
  11822. * Define if touch is enabled in the mouse input
  11823. */
  11824. touchEnabled: boolean;
  11825. /**
  11826. * Defines the camera the input is attached to.
  11827. */
  11828. camera: FreeCamera;
  11829. /**
  11830. * Defines the buttons associated with the input to handle camera move.
  11831. */
  11832. buttons: number[];
  11833. /**
  11834. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11835. */
  11836. angularSensibility: number;
  11837. private _pointerInput;
  11838. private _onMouseMove;
  11839. private _observer;
  11840. private previousPosition;
  11841. /**
  11842. * Observable for when a pointer move event occurs containing the move offset
  11843. */
  11844. onPointerMovedObservable: Observable<{
  11845. offsetX: number;
  11846. offsetY: number;
  11847. }>;
  11848. /**
  11849. * @hidden
  11850. * If the camera should be rotated automatically based on pointer movement
  11851. */ private _allowCameraRotation: boolean;
  11852. /**
  11853. * Manage the mouse inputs to control the movement of a free camera.
  11854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11855. * @param touchEnabled Defines if touch is enabled or not
  11856. */
  11857. constructor(
  11858. /**
  11859. * Define if touch is enabled in the mouse input
  11860. */
  11861. touchEnabled?: boolean);
  11862. /**
  11863. * Attach the input controls to a specific dom element to get the input from.
  11864. * @param element Defines the element the controls should be listened from
  11865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11866. */
  11867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11868. /**
  11869. * Called on JS contextmenu event.
  11870. * Override this method to provide functionality.
  11871. */
  11872. protected onContextMenu(evt: PointerEvent): void;
  11873. /**
  11874. * Detach the current controls from the specified dom element.
  11875. * @param element Defines the element to stop listening the inputs from
  11876. */
  11877. detachControl(element: Nullable<HTMLElement>): void;
  11878. /**
  11879. * Gets the class name of the current intput.
  11880. * @returns the class name
  11881. */
  11882. getClassName(): string;
  11883. /**
  11884. * Get the friendly name associated with the input class.
  11885. * @returns the input friendly name
  11886. */
  11887. getSimpleName(): string;
  11888. }
  11889. }
  11890. declare module BABYLON {
  11891. /**
  11892. * Manage the touch inputs to control the movement of a free camera.
  11893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11894. */
  11895. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11896. /**
  11897. * Defines the camera the input is attached to.
  11898. */
  11899. camera: FreeCamera;
  11900. /**
  11901. * Defines the touch sensibility for rotation.
  11902. * The higher the faster.
  11903. */
  11904. touchAngularSensibility: number;
  11905. /**
  11906. * Defines the touch sensibility for move.
  11907. * The higher the faster.
  11908. */
  11909. touchMoveSensibility: number;
  11910. private _offsetX;
  11911. private _offsetY;
  11912. private _pointerPressed;
  11913. private _pointerInput;
  11914. private _observer;
  11915. private _onLostFocus;
  11916. /**
  11917. * Attach the input controls to a specific dom element to get the input from.
  11918. * @param element Defines the element the controls should be listened from
  11919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11920. */
  11921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11922. /**
  11923. * Detach the current controls from the specified dom element.
  11924. * @param element Defines the element to stop listening the inputs from
  11925. */
  11926. detachControl(element: Nullable<HTMLElement>): void;
  11927. /**
  11928. * Update the current camera state depending on the inputs that have been used this frame.
  11929. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11930. */
  11931. checkInputs(): void;
  11932. /**
  11933. * Gets the class name of the current intput.
  11934. * @returns the class name
  11935. */
  11936. getClassName(): string;
  11937. /**
  11938. * Get the friendly name associated with the input class.
  11939. * @returns the input friendly name
  11940. */
  11941. getSimpleName(): string;
  11942. }
  11943. }
  11944. declare module BABYLON {
  11945. /**
  11946. * Default Inputs manager for the FreeCamera.
  11947. * It groups all the default supported inputs for ease of use.
  11948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11949. */
  11950. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11951. /**
  11952. * @hidden
  11953. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11954. /**
  11955. * Instantiates a new FreeCameraInputsManager.
  11956. * @param camera Defines the camera the inputs belong to
  11957. */
  11958. constructor(camera: FreeCamera);
  11959. /**
  11960. * Add keyboard input support to the input manager.
  11961. * @returns the current input manager
  11962. */
  11963. addKeyboard(): FreeCameraInputsManager;
  11964. /**
  11965. * Add mouse input support to the input manager.
  11966. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11967. * @returns the current input manager
  11968. */
  11969. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11970. /**
  11971. * Removes the mouse input support from the manager
  11972. * @returns the current input manager
  11973. */
  11974. removeMouse(): FreeCameraInputsManager;
  11975. /**
  11976. * Add touch input support to the input manager.
  11977. * @returns the current input manager
  11978. */
  11979. addTouch(): FreeCameraInputsManager;
  11980. /**
  11981. * Remove all attached input methods from a camera
  11982. */
  11983. clear(): void;
  11984. }
  11985. }
  11986. declare module BABYLON {
  11987. /**
  11988. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11989. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11990. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11991. */
  11992. export class FreeCamera extends TargetCamera {
  11993. /**
  11994. * Define the collision ellipsoid of the camera.
  11995. * This is helpful to simulate a camera body like the player body around the camera
  11996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11997. */
  11998. ellipsoid: Vector3;
  11999. /**
  12000. * Define an offset for the position of the ellipsoid around the camera.
  12001. * This can be helpful to determine the center of the body near the gravity center of the body
  12002. * instead of its head.
  12003. */
  12004. ellipsoidOffset: Vector3;
  12005. /**
  12006. * Enable or disable collisions of the camera with the rest of the scene objects.
  12007. */
  12008. checkCollisions: boolean;
  12009. /**
  12010. * Enable or disable gravity on the camera.
  12011. */
  12012. applyGravity: boolean;
  12013. /**
  12014. * Define the input manager associated to the camera.
  12015. */
  12016. inputs: FreeCameraInputsManager;
  12017. /**
  12018. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12019. * Higher values reduce sensitivity.
  12020. */
  12021. /**
  12022. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12023. * Higher values reduce sensitivity.
  12024. */
  12025. angularSensibility: number;
  12026. /**
  12027. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12028. */
  12029. keysUp: number[];
  12030. /**
  12031. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12032. */
  12033. keysDown: number[];
  12034. /**
  12035. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12036. */
  12037. keysLeft: number[];
  12038. /**
  12039. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12040. */
  12041. keysRight: number[];
  12042. /**
  12043. * Event raised when the camera collide with a mesh in the scene.
  12044. */
  12045. onCollide: (collidedMesh: AbstractMesh) => void;
  12046. private _collider;
  12047. private _needMoveForGravity;
  12048. private _oldPosition;
  12049. private _diffPosition;
  12050. private _newPosition;
  12051. /** @hidden */ private _localDirection: Vector3;
  12052. /** @hidden */ private _transformedDirection: Vector3;
  12053. /**
  12054. * Instantiates a Free Camera.
  12055. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12056. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12057. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12058. * @param name Define the name of the camera in the scene
  12059. * @param position Define the start position of the camera in the scene
  12060. * @param scene Define the scene the camera belongs to
  12061. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12062. */
  12063. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12064. /**
  12065. * Attached controls to the current camera.
  12066. * @param element Defines the element the controls should be listened from
  12067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12068. */
  12069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12070. /**
  12071. * Detach the current controls from the camera.
  12072. * The camera will stop reacting to inputs.
  12073. * @param element Defines the element to stop listening the inputs from
  12074. */
  12075. detachControl(element: HTMLElement): void;
  12076. private _collisionMask;
  12077. /**
  12078. * Define a collision mask to limit the list of object the camera can collide with
  12079. */
  12080. collisionMask: number;
  12081. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  12082. private _onCollisionPositionChange;
  12083. /** @hidden */ private _checkInputs(): void;
  12084. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  12085. /** @hidden */ private _updatePosition(): void;
  12086. /**
  12087. * Destroy the camera and release the current resources hold by it.
  12088. */
  12089. dispose(): void;
  12090. /**
  12091. * Gets the current object class name.
  12092. * @return the class name
  12093. */
  12094. getClassName(): string;
  12095. }
  12096. }
  12097. declare module BABYLON {
  12098. /**
  12099. * Represents a gamepad control stick position
  12100. */
  12101. export class StickValues {
  12102. /**
  12103. * The x component of the control stick
  12104. */
  12105. x: number;
  12106. /**
  12107. * The y component of the control stick
  12108. */
  12109. y: number;
  12110. /**
  12111. * Initializes the gamepad x and y control stick values
  12112. * @param x The x component of the gamepad control stick value
  12113. * @param y The y component of the gamepad control stick value
  12114. */
  12115. constructor(
  12116. /**
  12117. * The x component of the control stick
  12118. */
  12119. x: number,
  12120. /**
  12121. * The y component of the control stick
  12122. */
  12123. y: number);
  12124. }
  12125. /**
  12126. * An interface which manages callbacks for gamepad button changes
  12127. */
  12128. export interface GamepadButtonChanges {
  12129. /**
  12130. * Called when a gamepad has been changed
  12131. */
  12132. changed: boolean;
  12133. /**
  12134. * Called when a gamepad press event has been triggered
  12135. */
  12136. pressChanged: boolean;
  12137. /**
  12138. * Called when a touch event has been triggered
  12139. */
  12140. touchChanged: boolean;
  12141. /**
  12142. * Called when a value has changed
  12143. */
  12144. valueChanged: boolean;
  12145. }
  12146. /**
  12147. * Represents a gamepad
  12148. */
  12149. export class Gamepad {
  12150. /**
  12151. * The id of the gamepad
  12152. */
  12153. id: string;
  12154. /**
  12155. * The index of the gamepad
  12156. */
  12157. index: number;
  12158. /**
  12159. * The browser gamepad
  12160. */
  12161. browserGamepad: any;
  12162. /**
  12163. * Specifies what type of gamepad this represents
  12164. */
  12165. type: number;
  12166. private _leftStick;
  12167. private _rightStick;
  12168. /** @hidden */ private _isConnected: boolean;
  12169. private _leftStickAxisX;
  12170. private _leftStickAxisY;
  12171. private _rightStickAxisX;
  12172. private _rightStickAxisY;
  12173. /**
  12174. * Triggered when the left control stick has been changed
  12175. */
  12176. private _onleftstickchanged;
  12177. /**
  12178. * Triggered when the right control stick has been changed
  12179. */
  12180. private _onrightstickchanged;
  12181. /**
  12182. * Represents a gamepad controller
  12183. */
  12184. static GAMEPAD: number;
  12185. /**
  12186. * Represents a generic controller
  12187. */
  12188. static GENERIC: number;
  12189. /**
  12190. * Represents an XBox controller
  12191. */
  12192. static XBOX: number;
  12193. /**
  12194. * Represents a pose-enabled controller
  12195. */
  12196. static POSE_ENABLED: number;
  12197. /**
  12198. * Represents an Dual Shock controller
  12199. */
  12200. static DUALSHOCK: number;
  12201. /**
  12202. * Specifies whether the left control stick should be Y-inverted
  12203. */
  12204. protected _invertLeftStickY: boolean;
  12205. /**
  12206. * Specifies if the gamepad has been connected
  12207. */
  12208. readonly isConnected: boolean;
  12209. /**
  12210. * Initializes the gamepad
  12211. * @param id The id of the gamepad
  12212. * @param index The index of the gamepad
  12213. * @param browserGamepad The browser gamepad
  12214. * @param leftStickX The x component of the left joystick
  12215. * @param leftStickY The y component of the left joystick
  12216. * @param rightStickX The x component of the right joystick
  12217. * @param rightStickY The y component of the right joystick
  12218. */
  12219. constructor(
  12220. /**
  12221. * The id of the gamepad
  12222. */
  12223. id: string,
  12224. /**
  12225. * The index of the gamepad
  12226. */
  12227. index: number,
  12228. /**
  12229. * The browser gamepad
  12230. */
  12231. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12232. /**
  12233. * Callback triggered when the left joystick has changed
  12234. * @param callback
  12235. */
  12236. onleftstickchanged(callback: (values: StickValues) => void): void;
  12237. /**
  12238. * Callback triggered when the right joystick has changed
  12239. * @param callback
  12240. */
  12241. onrightstickchanged(callback: (values: StickValues) => void): void;
  12242. /**
  12243. * Gets the left joystick
  12244. */
  12245. /**
  12246. * Sets the left joystick values
  12247. */
  12248. leftStick: StickValues;
  12249. /**
  12250. * Gets the right joystick
  12251. */
  12252. /**
  12253. * Sets the right joystick value
  12254. */
  12255. rightStick: StickValues;
  12256. /**
  12257. * Updates the gamepad joystick positions
  12258. */
  12259. update(): void;
  12260. /**
  12261. * Disposes the gamepad
  12262. */
  12263. dispose(): void;
  12264. }
  12265. /**
  12266. * Represents a generic gamepad
  12267. */
  12268. export class GenericPad extends Gamepad {
  12269. private _buttons;
  12270. private _onbuttondown;
  12271. private _onbuttonup;
  12272. /**
  12273. * Observable triggered when a button has been pressed
  12274. */
  12275. onButtonDownObservable: Observable<number>;
  12276. /**
  12277. * Observable triggered when a button has been released
  12278. */
  12279. onButtonUpObservable: Observable<number>;
  12280. /**
  12281. * Callback triggered when a button has been pressed
  12282. * @param callback Called when a button has been pressed
  12283. */
  12284. onbuttondown(callback: (buttonPressed: number) => void): void;
  12285. /**
  12286. * Callback triggered when a button has been released
  12287. * @param callback Called when a button has been released
  12288. */
  12289. onbuttonup(callback: (buttonReleased: number) => void): void;
  12290. /**
  12291. * Initializes the generic gamepad
  12292. * @param id The id of the generic gamepad
  12293. * @param index The index of the generic gamepad
  12294. * @param browserGamepad The browser gamepad
  12295. */
  12296. constructor(id: string, index: number, browserGamepad: any);
  12297. private _setButtonValue;
  12298. /**
  12299. * Updates the generic gamepad
  12300. */
  12301. update(): void;
  12302. /**
  12303. * Disposes the generic gamepad
  12304. */
  12305. dispose(): void;
  12306. }
  12307. }
  12308. declare module BABYLON {
  12309. interface Engine {
  12310. /**
  12311. * Creates a raw texture
  12312. * @param data defines the data to store in the texture
  12313. * @param width defines the width of the texture
  12314. * @param height defines the height of the texture
  12315. * @param format defines the format of the data
  12316. * @param generateMipMaps defines if the engine should generate the mip levels
  12317. * @param invertY defines if data must be stored with Y axis inverted
  12318. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12319. * @param compression defines the compression used (null by default)
  12320. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12321. * @returns the raw texture inside an InternalTexture
  12322. */
  12323. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12324. /**
  12325. * Update a raw texture
  12326. * @param texture defines the texture to update
  12327. * @param data defines the data to store in the texture
  12328. * @param format defines the format of the data
  12329. * @param invertY defines if data must be stored with Y axis inverted
  12330. */
  12331. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12332. /**
  12333. * Update a raw texture
  12334. * @param texture defines the texture to update
  12335. * @param data defines the data to store in the texture
  12336. * @param format defines the format of the data
  12337. * @param invertY defines if data must be stored with Y axis inverted
  12338. * @param compression defines the compression used (null by default)
  12339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12340. */
  12341. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12342. /**
  12343. * Creates a new raw cube texture
  12344. * @param data defines the array of data to use to create each face
  12345. * @param size defines the size of the textures
  12346. * @param format defines the format of the data
  12347. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12348. * @param generateMipMaps defines if the engine should generate the mip levels
  12349. * @param invertY defines if data must be stored with Y axis inverted
  12350. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12351. * @param compression defines the compression used (null by default)
  12352. * @returns the cube texture as an InternalTexture
  12353. */
  12354. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12355. /**
  12356. * Update a raw cube texture
  12357. * @param texture defines the texture to udpdate
  12358. * @param data defines the data to store
  12359. * @param format defines the data format
  12360. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12361. * @param invertY defines if data must be stored with Y axis inverted
  12362. */
  12363. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12364. /**
  12365. * Update a raw cube texture
  12366. * @param texture defines the texture to udpdate
  12367. * @param data defines the data to store
  12368. * @param format defines the data format
  12369. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12370. * @param invertY defines if data must be stored with Y axis inverted
  12371. * @param compression defines the compression used (null by default)
  12372. */
  12373. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12374. /**
  12375. * Update a raw cube texture
  12376. * @param texture defines the texture to udpdate
  12377. * @param data defines the data to store
  12378. * @param format defines the data format
  12379. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12380. * @param invertY defines if data must be stored with Y axis inverted
  12381. * @param compression defines the compression used (null by default)
  12382. * @param level defines which level of the texture to update
  12383. */
  12384. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12385. /**
  12386. * Creates a new raw cube texture from a specified url
  12387. * @param url defines the url where the data is located
  12388. * @param scene defines the current scene
  12389. * @param size defines the size of the textures
  12390. * @param format defines the format of the data
  12391. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12392. * @param noMipmap defines if the engine should avoid generating the mip levels
  12393. * @param callback defines a callback used to extract texture data from loaded data
  12394. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12395. * @param onLoad defines a callback called when texture is loaded
  12396. * @param onError defines a callback called if there is an error
  12397. * @returns the cube texture as an InternalTexture
  12398. */
  12399. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12400. /**
  12401. * Creates a new raw cube texture from a specified url
  12402. * @param url defines the url where the data is located
  12403. * @param scene defines the current scene
  12404. * @param size defines the size of the textures
  12405. * @param format defines the format of the data
  12406. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12407. * @param noMipmap defines if the engine should avoid generating the mip levels
  12408. * @param callback defines a callback used to extract texture data from loaded data
  12409. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12410. * @param onLoad defines a callback called when texture is loaded
  12411. * @param onError defines a callback called if there is an error
  12412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12413. * @param invertY defines if data must be stored with Y axis inverted
  12414. * @returns the cube texture as an InternalTexture
  12415. */
  12416. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12417. /**
  12418. * Creates a new raw 3D texture
  12419. * @param data defines the data used to create the texture
  12420. * @param width defines the width of the texture
  12421. * @param height defines the height of the texture
  12422. * @param depth defines the depth of the texture
  12423. * @param format defines the format of the texture
  12424. * @param generateMipMaps defines if the engine must generate mip levels
  12425. * @param invertY defines if data must be stored with Y axis inverted
  12426. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12427. * @param compression defines the compressed used (can be null)
  12428. * @param textureType defines the compressed used (can be null)
  12429. * @returns a new raw 3D texture (stored in an InternalTexture)
  12430. */
  12431. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12432. /**
  12433. * Update a raw 3D texture
  12434. * @param texture defines the texture to update
  12435. * @param data defines the data to store
  12436. * @param format defines the data format
  12437. * @param invertY defines if data must be stored with Y axis inverted
  12438. */
  12439. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12440. /**
  12441. * Update a raw 3D texture
  12442. * @param texture defines the texture to update
  12443. * @param data defines the data to store
  12444. * @param format defines the data format
  12445. * @param invertY defines if data must be stored with Y axis inverted
  12446. * @param compression defines the used compression (can be null)
  12447. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12448. */
  12449. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12450. }
  12451. }
  12452. declare module BABYLON {
  12453. /**
  12454. * Raw texture can help creating a texture directly from an array of data.
  12455. * This can be super useful if you either get the data from an uncompressed source or
  12456. * if you wish to create your texture pixel by pixel.
  12457. */
  12458. export class RawTexture extends Texture {
  12459. /**
  12460. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12461. */
  12462. format: number;
  12463. private _engine;
  12464. /**
  12465. * Instantiates a new RawTexture.
  12466. * Raw texture can help creating a texture directly from an array of data.
  12467. * This can be super useful if you either get the data from an uncompressed source or
  12468. * if you wish to create your texture pixel by pixel.
  12469. * @param data define the array of data to use to create the texture
  12470. * @param width define the width of the texture
  12471. * @param height define the height of the texture
  12472. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12473. * @param scene define the scene the texture belongs to
  12474. * @param generateMipMaps define whether mip maps should be generated or not
  12475. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12476. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12477. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12478. */
  12479. constructor(data: ArrayBufferView, width: number, height: number,
  12480. /**
  12481. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12482. */
  12483. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12484. /**
  12485. * Updates the texture underlying data.
  12486. * @param data Define the new data of the texture
  12487. */
  12488. update(data: ArrayBufferView): void;
  12489. /**
  12490. * Creates a luminance texture from some data.
  12491. * @param data Define the texture data
  12492. * @param width Define the width of the texture
  12493. * @param height Define the height of the texture
  12494. * @param scene Define the scene the texture belongs to
  12495. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12496. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12497. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12498. * @returns the luminance texture
  12499. */
  12500. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12501. /**
  12502. * Creates a luminance alpha texture from some data.
  12503. * @param data Define the texture data
  12504. * @param width Define the width of the texture
  12505. * @param height Define the height of the texture
  12506. * @param scene Define the scene the texture belongs to
  12507. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12510. * @returns the luminance alpha texture
  12511. */
  12512. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12513. /**
  12514. * Creates an alpha texture from some data.
  12515. * @param data Define the texture data
  12516. * @param width Define the width of the texture
  12517. * @param height Define the height of the texture
  12518. * @param scene Define the scene the texture belongs to
  12519. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12520. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12521. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12522. * @returns the alpha texture
  12523. */
  12524. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12525. /**
  12526. * Creates a RGB texture from some data.
  12527. * @param data Define the texture data
  12528. * @param width Define the width of the texture
  12529. * @param height Define the height of the texture
  12530. * @param scene Define the scene the texture belongs to
  12531. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12532. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12533. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12534. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12535. * @returns the RGB alpha texture
  12536. */
  12537. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12538. /**
  12539. * Creates a RGBA texture from some data.
  12540. * @param data Define the texture data
  12541. * @param width Define the width of the texture
  12542. * @param height Define the height of the texture
  12543. * @param scene Define the scene the texture belongs to
  12544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12547. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12548. * @returns the RGBA texture
  12549. */
  12550. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12551. /**
  12552. * Creates a R texture from some data.
  12553. * @param data Define the texture data
  12554. * @param width Define the width of the texture
  12555. * @param height Define the height of the texture
  12556. * @param scene Define the scene the texture belongs to
  12557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12560. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12561. * @returns the R texture
  12562. */
  12563. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12564. }
  12565. }
  12566. declare module BABYLON {
  12567. /**
  12568. * Interface for the size containing width and height
  12569. */
  12570. export interface ISize {
  12571. /**
  12572. * Width
  12573. */
  12574. width: number;
  12575. /**
  12576. * Heighht
  12577. */
  12578. height: number;
  12579. }
  12580. /**
  12581. * Size containing widht and height
  12582. */
  12583. export class Size implements ISize {
  12584. /**
  12585. * Width
  12586. */
  12587. width: number;
  12588. /**
  12589. * Height
  12590. */
  12591. height: number;
  12592. /**
  12593. * Creates a Size object from the given width and height (floats).
  12594. * @param width width of the new size
  12595. * @param height height of the new size
  12596. */
  12597. constructor(width: number, height: number);
  12598. /**
  12599. * Returns a string with the Size width and height
  12600. * @returns a string with the Size width and height
  12601. */
  12602. toString(): string;
  12603. /**
  12604. * "Size"
  12605. * @returns the string "Size"
  12606. */
  12607. getClassName(): string;
  12608. /**
  12609. * Returns the Size hash code.
  12610. * @returns a hash code for a unique width and height
  12611. */
  12612. getHashCode(): number;
  12613. /**
  12614. * Updates the current size from the given one.
  12615. * @param src the given size
  12616. */
  12617. copyFrom(src: Size): void;
  12618. /**
  12619. * Updates in place the current Size from the given floats.
  12620. * @param width width of the new size
  12621. * @param height height of the new size
  12622. * @returns the updated Size.
  12623. */
  12624. copyFromFloats(width: number, height: number): Size;
  12625. /**
  12626. * Updates in place the current Size from the given floats.
  12627. * @param width width to set
  12628. * @param height height to set
  12629. * @returns the updated Size.
  12630. */
  12631. set(width: number, height: number): Size;
  12632. /**
  12633. * Multiplies the width and height by numbers
  12634. * @param w factor to multiple the width by
  12635. * @param h factor to multiple the height by
  12636. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12637. */
  12638. multiplyByFloats(w: number, h: number): Size;
  12639. /**
  12640. * Clones the size
  12641. * @returns a new Size copied from the given one.
  12642. */
  12643. clone(): Size;
  12644. /**
  12645. * True if the current Size and the given one width and height are strictly equal.
  12646. * @param other the other size to compare against
  12647. * @returns True if the current Size and the given one width and height are strictly equal.
  12648. */
  12649. equals(other: Size): boolean;
  12650. /**
  12651. * The surface of the Size : width * height (float).
  12652. */
  12653. readonly surface: number;
  12654. /**
  12655. * Create a new size of zero
  12656. * @returns a new Size set to (0.0, 0.0)
  12657. */
  12658. static Zero(): Size;
  12659. /**
  12660. * Sums the width and height of two sizes
  12661. * @param otherSize size to add to this size
  12662. * @returns a new Size set as the addition result of the current Size and the given one.
  12663. */
  12664. add(otherSize: Size): Size;
  12665. /**
  12666. * Subtracts the width and height of two
  12667. * @param otherSize size to subtract to this size
  12668. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12669. */
  12670. subtract(otherSize: Size): Size;
  12671. /**
  12672. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12673. * @param start starting size to lerp between
  12674. * @param end end size to lerp between
  12675. * @param amount amount to lerp between the start and end values
  12676. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12677. */
  12678. static Lerp(start: Size, end: Size, amount: number): Size;
  12679. }
  12680. }
  12681. declare module BABYLON {
  12682. /**
  12683. * Defines a runtime animation
  12684. */
  12685. export class RuntimeAnimation {
  12686. private _events;
  12687. /**
  12688. * The current frame of the runtime animation
  12689. */
  12690. private _currentFrame;
  12691. /**
  12692. * The animation used by the runtime animation
  12693. */
  12694. private _animation;
  12695. /**
  12696. * The target of the runtime animation
  12697. */
  12698. private _target;
  12699. /**
  12700. * The initiating animatable
  12701. */
  12702. private _host;
  12703. /**
  12704. * The original value of the runtime animation
  12705. */
  12706. private _originalValue;
  12707. /**
  12708. * The original blend value of the runtime animation
  12709. */
  12710. private _originalBlendValue;
  12711. /**
  12712. * The offsets cache of the runtime animation
  12713. */
  12714. private _offsetsCache;
  12715. /**
  12716. * The high limits cache of the runtime animation
  12717. */
  12718. private _highLimitsCache;
  12719. /**
  12720. * Specifies if the runtime animation has been stopped
  12721. */
  12722. private _stopped;
  12723. /**
  12724. * The blending factor of the runtime animation
  12725. */
  12726. private _blendingFactor;
  12727. /**
  12728. * The BabylonJS scene
  12729. */
  12730. private _scene;
  12731. /**
  12732. * The current value of the runtime animation
  12733. */
  12734. private _currentValue;
  12735. /** @hidden */ private _animationState: _IAnimationState;
  12736. /**
  12737. * The active target of the runtime animation
  12738. */
  12739. private _activeTargets;
  12740. private _currentActiveTarget;
  12741. private _directTarget;
  12742. /**
  12743. * The target path of the runtime animation
  12744. */
  12745. private _targetPath;
  12746. /**
  12747. * The weight of the runtime animation
  12748. */
  12749. private _weight;
  12750. /**
  12751. * The ratio offset of the runtime animation
  12752. */
  12753. private _ratioOffset;
  12754. /**
  12755. * The previous delay of the runtime animation
  12756. */
  12757. private _previousDelay;
  12758. /**
  12759. * The previous ratio of the runtime animation
  12760. */
  12761. private _previousRatio;
  12762. private _enableBlending;
  12763. private _keys;
  12764. private _minFrame;
  12765. private _maxFrame;
  12766. private _minValue;
  12767. private _maxValue;
  12768. private _targetIsArray;
  12769. /**
  12770. * Gets the current frame of the runtime animation
  12771. */
  12772. readonly currentFrame: number;
  12773. /**
  12774. * Gets the weight of the runtime animation
  12775. */
  12776. readonly weight: number;
  12777. /**
  12778. * Gets the current value of the runtime animation
  12779. */
  12780. readonly currentValue: any;
  12781. /**
  12782. * Gets the target path of the runtime animation
  12783. */
  12784. readonly targetPath: string;
  12785. /**
  12786. * Gets the actual target of the runtime animation
  12787. */
  12788. readonly target: any;
  12789. /** @hidden */ private _onLoop: () => void;
  12790. /**
  12791. * Create a new RuntimeAnimation object
  12792. * @param target defines the target of the animation
  12793. * @param animation defines the source animation object
  12794. * @param scene defines the hosting scene
  12795. * @param host defines the initiating Animatable
  12796. */
  12797. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12798. private _preparePath;
  12799. /**
  12800. * Gets the animation from the runtime animation
  12801. */
  12802. readonly animation: Animation;
  12803. /**
  12804. * Resets the runtime animation to the beginning
  12805. * @param restoreOriginal defines whether to restore the target property to the original value
  12806. */
  12807. reset(restoreOriginal?: boolean): void;
  12808. /**
  12809. * Specifies if the runtime animation is stopped
  12810. * @returns Boolean specifying if the runtime animation is stopped
  12811. */
  12812. isStopped(): boolean;
  12813. /**
  12814. * Disposes of the runtime animation
  12815. */
  12816. dispose(): void;
  12817. /**
  12818. * Apply the interpolated value to the target
  12819. * @param currentValue defines the value computed by the animation
  12820. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12821. */
  12822. setValue(currentValue: any, weight: number): void;
  12823. private _getOriginalValues;
  12824. private _setValue;
  12825. /**
  12826. * Gets the loop pmode of the runtime animation
  12827. * @returns Loop Mode
  12828. */
  12829. private _getCorrectLoopMode;
  12830. /**
  12831. * Move the current animation to a given frame
  12832. * @param frame defines the frame to move to
  12833. */
  12834. goToFrame(frame: number): void;
  12835. /**
  12836. * @hidden Internal use only
  12837. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12838. /**
  12839. * Execute the current animation
  12840. * @param delay defines the delay to add to the current frame
  12841. * @param from defines the lower bound of the animation range
  12842. * @param to defines the upper bound of the animation range
  12843. * @param loop defines if the current animation must loop
  12844. * @param speedRatio defines the current speed ratio
  12845. * @param weight defines the weight of the animation (default is -1 so no weight)
  12846. * @param onLoop optional callback called when animation loops
  12847. * @returns a boolean indicating if the animation is running
  12848. */
  12849. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12850. }
  12851. }
  12852. declare module BABYLON {
  12853. /**
  12854. * Class used to store an actual running animation
  12855. */
  12856. export class Animatable {
  12857. /** defines the target object */
  12858. target: any;
  12859. /** defines the starting frame number (default is 0) */
  12860. fromFrame: number;
  12861. /** defines the ending frame number (default is 100) */
  12862. toFrame: number;
  12863. /** defines if the animation must loop (default is false) */
  12864. loopAnimation: boolean;
  12865. /** defines a callback to call when animation ends if it is not looping */
  12866. onAnimationEnd?: (() => void) | null | undefined;
  12867. /** defines a callback to call when animation loops */
  12868. onAnimationLoop?: (() => void) | null | undefined;
  12869. private _localDelayOffset;
  12870. private _pausedDelay;
  12871. private _runtimeAnimations;
  12872. private _paused;
  12873. private _scene;
  12874. private _speedRatio;
  12875. private _weight;
  12876. private _syncRoot;
  12877. /**
  12878. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12879. * This will only apply for non looping animation (default is true)
  12880. */
  12881. disposeOnEnd: boolean;
  12882. /**
  12883. * Gets a boolean indicating if the animation has started
  12884. */
  12885. animationStarted: boolean;
  12886. /**
  12887. * Observer raised when the animation ends
  12888. */
  12889. onAnimationEndObservable: Observable<Animatable>;
  12890. /**
  12891. * Observer raised when the animation loops
  12892. */
  12893. onAnimationLoopObservable: Observable<Animatable>;
  12894. /**
  12895. * Gets the root Animatable used to synchronize and normalize animations
  12896. */
  12897. readonly syncRoot: Nullable<Animatable>;
  12898. /**
  12899. * Gets the current frame of the first RuntimeAnimation
  12900. * Used to synchronize Animatables
  12901. */
  12902. readonly masterFrame: number;
  12903. /**
  12904. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12905. */
  12906. weight: number;
  12907. /**
  12908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12909. */
  12910. speedRatio: number;
  12911. /**
  12912. * Creates a new Animatable
  12913. * @param scene defines the hosting scene
  12914. * @param target defines the target object
  12915. * @param fromFrame defines the starting frame number (default is 0)
  12916. * @param toFrame defines the ending frame number (default is 100)
  12917. * @param loopAnimation defines if the animation must loop (default is false)
  12918. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12919. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12920. * @param animations defines a group of animation to add to the new Animatable
  12921. * @param onAnimationLoop defines a callback to call when animation loops
  12922. */
  12923. constructor(scene: Scene,
  12924. /** defines the target object */
  12925. target: any,
  12926. /** defines the starting frame number (default is 0) */
  12927. fromFrame?: number,
  12928. /** defines the ending frame number (default is 100) */
  12929. toFrame?: number,
  12930. /** defines if the animation must loop (default is false) */
  12931. loopAnimation?: boolean, speedRatio?: number,
  12932. /** defines a callback to call when animation ends if it is not looping */
  12933. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12934. /** defines a callback to call when animation loops */
  12935. onAnimationLoop?: (() => void) | null | undefined);
  12936. /**
  12937. * Synchronize and normalize current Animatable with a source Animatable
  12938. * This is useful when using animation weights and when animations are not of the same length
  12939. * @param root defines the root Animatable to synchronize with
  12940. * @returns the current Animatable
  12941. */
  12942. syncWith(root: Animatable): Animatable;
  12943. /**
  12944. * Gets the list of runtime animations
  12945. * @returns an array of RuntimeAnimation
  12946. */
  12947. getAnimations(): RuntimeAnimation[];
  12948. /**
  12949. * Adds more animations to the current animatable
  12950. * @param target defines the target of the animations
  12951. * @param animations defines the new animations to add
  12952. */
  12953. appendAnimations(target: any, animations: Animation[]): void;
  12954. /**
  12955. * Gets the source animation for a specific property
  12956. * @param property defines the propertyu to look for
  12957. * @returns null or the source animation for the given property
  12958. */
  12959. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12960. /**
  12961. * Gets the runtime animation for a specific property
  12962. * @param property defines the propertyu to look for
  12963. * @returns null or the runtime animation for the given property
  12964. */
  12965. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12966. /**
  12967. * Resets the animatable to its original state
  12968. */
  12969. reset(): void;
  12970. /**
  12971. * Allows the animatable to blend with current running animations
  12972. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12973. * @param blendingSpeed defines the blending speed to use
  12974. */
  12975. enableBlending(blendingSpeed: number): void;
  12976. /**
  12977. * Disable animation blending
  12978. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12979. */
  12980. disableBlending(): void;
  12981. /**
  12982. * Jump directly to a given frame
  12983. * @param frame defines the frame to jump to
  12984. */
  12985. goToFrame(frame: number): void;
  12986. /**
  12987. * Pause the animation
  12988. */
  12989. pause(): void;
  12990. /**
  12991. * Restart the animation
  12992. */
  12993. restart(): void;
  12994. private _raiseOnAnimationEnd;
  12995. /**
  12996. * Stop and delete the current animation
  12997. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12998. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  12999. */
  13000. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13001. /**
  13002. * Wait asynchronously for the animation to end
  13003. * @returns a promise which will be fullfilled when the animation ends
  13004. */
  13005. waitAsync(): Promise<Animatable>;
  13006. /** @hidden */ private _animate(delay: number): boolean;
  13007. }
  13008. interface Scene {
  13009. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13010. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  13011. totalWeight: number;
  13012. animations: RuntimeAnimation[];
  13013. originalValue: Matrix;
  13014. }): any;
  13015. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  13016. totalWeight: number;
  13017. animations: RuntimeAnimation[];
  13018. originalValue: Quaternion;
  13019. }, refQuaternion: Quaternion): Quaternion;
  13020. /** @hidden */ private _processLateAnimationBindings(): void;
  13021. /**
  13022. * Will start the animation sequence of a given target
  13023. * @param target defines the target
  13024. * @param from defines from which frame should animation start
  13025. * @param to defines until which frame should animation run.
  13026. * @param weight defines the weight to apply to the animation (1.0 by default)
  13027. * @param loop defines if the animation loops
  13028. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13029. * @param onAnimationEnd defines the function to be executed when the animation ends
  13030. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13031. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13032. * @param onAnimationLoop defines the callback to call when an animation loops
  13033. * @returns the animatable object created for this animation
  13034. */
  13035. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13036. /**
  13037. * Will start the animation sequence of a given target
  13038. * @param target defines the target
  13039. * @param from defines from which frame should animation start
  13040. * @param to defines until which frame should animation run.
  13041. * @param loop defines if the animation loops
  13042. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13043. * @param onAnimationEnd defines the function to be executed when the animation ends
  13044. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13045. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13046. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13047. * @param onAnimationLoop defines the callback to call when an animation loops
  13048. * @returns the animatable object created for this animation
  13049. */
  13050. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13051. /**
  13052. * Will start the animation sequence of a given target and its hierarchy
  13053. * @param target defines the target
  13054. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13055. * @param from defines from which frame should animation start
  13056. * @param to defines until which frame should animation run.
  13057. * @param loop defines if the animation loops
  13058. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13059. * @param onAnimationEnd defines the function to be executed when the animation ends
  13060. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13061. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13062. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13063. * @param onAnimationLoop defines the callback to call when an animation loops
  13064. * @returns the list of created animatables
  13065. */
  13066. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13067. /**
  13068. * Begin a new animation on a given node
  13069. * @param target defines the target where the animation will take place
  13070. * @param animations defines the list of animations to start
  13071. * @param from defines the initial value
  13072. * @param to defines the final value
  13073. * @param loop defines if you want animation to loop (off by default)
  13074. * @param speedRatio defines the speed ratio to apply to all animations
  13075. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13076. * @param onAnimationLoop defines the callback to call when an animation loops
  13077. * @returns the list of created animatables
  13078. */
  13079. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13080. /**
  13081. * Begin a new animation on a given node and its hierarchy
  13082. * @param target defines the root node where the animation will take place
  13083. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13084. * @param animations defines the list of animations to start
  13085. * @param from defines the initial value
  13086. * @param to defines the final value
  13087. * @param loop defines if you want animation to loop (off by default)
  13088. * @param speedRatio defines the speed ratio to apply to all animations
  13089. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13090. * @param onAnimationLoop defines the callback to call when an animation loops
  13091. * @returns the list of animatables created for all nodes
  13092. */
  13093. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13094. /**
  13095. * Gets the animatable associated with a specific target
  13096. * @param target defines the target of the animatable
  13097. * @returns the required animatable if found
  13098. */
  13099. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13100. /**
  13101. * Gets all animatables associated with a given target
  13102. * @param target defines the target to look animatables for
  13103. * @returns an array of Animatables
  13104. */
  13105. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13106. /**
  13107. * Stops and removes all animations that have been applied to the scene
  13108. */
  13109. stopAllAnimations(): void;
  13110. }
  13111. interface Bone {
  13112. /**
  13113. * Copy an animation range from another bone
  13114. * @param source defines the source bone
  13115. * @param rangeName defines the range name to copy
  13116. * @param frameOffset defines the frame offset
  13117. * @param rescaleAsRequired defines if rescaling must be applied if required
  13118. * @param skelDimensionsRatio defines the scaling ratio
  13119. * @returns true if operation was successful
  13120. */
  13121. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13122. }
  13123. }
  13124. declare module BABYLON {
  13125. /**
  13126. * Class used to override all child animations of a given target
  13127. */
  13128. export class AnimationPropertiesOverride {
  13129. /**
  13130. * Gets or sets a value indicating if animation blending must be used
  13131. */
  13132. enableBlending: boolean;
  13133. /**
  13134. * Gets or sets the blending speed to use when enableBlending is true
  13135. */
  13136. blendingSpeed: number;
  13137. /**
  13138. * Gets or sets the default loop mode to use
  13139. */
  13140. loopMode: number;
  13141. }
  13142. }
  13143. declare module BABYLON {
  13144. /**
  13145. * Class used to handle skinning animations
  13146. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13147. */
  13148. export class Skeleton implements IAnimatable {
  13149. /** defines the skeleton name */
  13150. name: string;
  13151. /** defines the skeleton Id */
  13152. id: string;
  13153. /**
  13154. * Defines the list of child bones
  13155. */
  13156. bones: Bone[];
  13157. /**
  13158. * Defines an estimate of the dimension of the skeleton at rest
  13159. */
  13160. dimensionsAtRest: Vector3;
  13161. /**
  13162. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13163. */
  13164. needInitialSkinMatrix: boolean;
  13165. /**
  13166. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13167. */
  13168. overrideMesh: Nullable<AbstractMesh>;
  13169. /**
  13170. * Gets the list of animations attached to this skeleton
  13171. */
  13172. animations: Array<Animation>;
  13173. private _scene;
  13174. private _isDirty;
  13175. private _transformMatrices;
  13176. private _transformMatrixTexture;
  13177. private _meshesWithPoseMatrix;
  13178. private _animatables;
  13179. private _identity;
  13180. private _synchronizedWithMesh;
  13181. private _ranges;
  13182. private _lastAbsoluteTransformsUpdateId;
  13183. private _canUseTextureForBones;
  13184. private _uniqueId;
  13185. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13186. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13187. /**
  13188. * Specifies if the skeleton should be serialized
  13189. */
  13190. doNotSerialize: boolean;
  13191. private _useTextureToStoreBoneMatrices;
  13192. /**
  13193. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13194. * Please note that this option is not available if the hardware does not support it
  13195. */
  13196. useTextureToStoreBoneMatrices: boolean;
  13197. private _animationPropertiesOverride;
  13198. /**
  13199. * Gets or sets the animation properties override
  13200. */
  13201. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13202. /**
  13203. * List of inspectable custom properties (used by the Inspector)
  13204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13205. */
  13206. inspectableCustomProperties: IInspectable[];
  13207. /**
  13208. * An observable triggered before computing the skeleton's matrices
  13209. */
  13210. onBeforeComputeObservable: Observable<Skeleton>;
  13211. /**
  13212. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13213. */
  13214. readonly isUsingTextureForMatrices: boolean;
  13215. /**
  13216. * Gets the unique ID of this skeleton
  13217. */
  13218. readonly uniqueId: number;
  13219. /**
  13220. * Creates a new skeleton
  13221. * @param name defines the skeleton name
  13222. * @param id defines the skeleton Id
  13223. * @param scene defines the hosting scene
  13224. */
  13225. constructor(
  13226. /** defines the skeleton name */
  13227. name: string,
  13228. /** defines the skeleton Id */
  13229. id: string, scene: Scene);
  13230. /**
  13231. * Gets the current object class name.
  13232. * @return the class name
  13233. */
  13234. getClassName(): string;
  13235. /**
  13236. * Returns an array containing the root bones
  13237. * @returns an array containing the root bones
  13238. */
  13239. getChildren(): Array<Bone>;
  13240. /**
  13241. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13242. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13243. * @returns a Float32Array containing matrices data
  13244. */
  13245. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13246. /**
  13247. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13248. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13249. * @returns a raw texture containing the data
  13250. */
  13251. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13252. /**
  13253. * Gets the current hosting scene
  13254. * @returns a scene object
  13255. */
  13256. getScene(): Scene;
  13257. /**
  13258. * Gets a string representing the current skeleton data
  13259. * @param fullDetails defines a boolean indicating if we want a verbose version
  13260. * @returns a string representing the current skeleton data
  13261. */
  13262. toString(fullDetails?: boolean): string;
  13263. /**
  13264. * Get bone's index searching by name
  13265. * @param name defines bone's name to search for
  13266. * @return the indice of the bone. Returns -1 if not found
  13267. */
  13268. getBoneIndexByName(name: string): number;
  13269. /**
  13270. * Creater a new animation range
  13271. * @param name defines the name of the range
  13272. * @param from defines the start key
  13273. * @param to defines the end key
  13274. */
  13275. createAnimationRange(name: string, from: number, to: number): void;
  13276. /**
  13277. * Delete a specific animation range
  13278. * @param name defines the name of the range
  13279. * @param deleteFrames defines if frames must be removed as well
  13280. */
  13281. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13282. /**
  13283. * Gets a specific animation range
  13284. * @param name defines the name of the range to look for
  13285. * @returns the requested animation range or null if not found
  13286. */
  13287. getAnimationRange(name: string): Nullable<AnimationRange>;
  13288. /**
  13289. * Gets the list of all animation ranges defined on this skeleton
  13290. * @returns an array
  13291. */
  13292. getAnimationRanges(): Nullable<AnimationRange>[];
  13293. /**
  13294. * Copy animation range from a source skeleton.
  13295. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13296. * @param source defines the source skeleton
  13297. * @param name defines the name of the range to copy
  13298. * @param rescaleAsRequired defines if rescaling must be applied if required
  13299. * @returns true if operation was successful
  13300. */
  13301. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13302. /**
  13303. * Forces the skeleton to go to rest pose
  13304. */
  13305. returnToRest(): void;
  13306. private _getHighestAnimationFrame;
  13307. /**
  13308. * Begin a specific animation range
  13309. * @param name defines the name of the range to start
  13310. * @param loop defines if looping must be turned on (false by default)
  13311. * @param speedRatio defines the speed ratio to apply (1 by default)
  13312. * @param onAnimationEnd defines a callback which will be called when animation will end
  13313. * @returns a new animatable
  13314. */
  13315. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13316. /** @hidden */ private _markAsDirty(): void;
  13317. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13318. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13319. private _computeTransformMatrices;
  13320. /**
  13321. * Build all resources required to render a skeleton
  13322. */
  13323. prepare(): void;
  13324. /**
  13325. * Gets the list of animatables currently running for this skeleton
  13326. * @returns an array of animatables
  13327. */
  13328. getAnimatables(): IAnimatable[];
  13329. /**
  13330. * Clone the current skeleton
  13331. * @param name defines the name of the new skeleton
  13332. * @param id defines the id of the new skeleton
  13333. * @returns the new skeleton
  13334. */
  13335. clone(name: string, id: string): Skeleton;
  13336. /**
  13337. * Enable animation blending for this skeleton
  13338. * @param blendingSpeed defines the blending speed to apply
  13339. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13340. */
  13341. enableBlending(blendingSpeed?: number): void;
  13342. /**
  13343. * Releases all resources associated with the current skeleton
  13344. */
  13345. dispose(): void;
  13346. /**
  13347. * Serialize the skeleton in a JSON object
  13348. * @returns a JSON object
  13349. */
  13350. serialize(): any;
  13351. /**
  13352. * Creates a new skeleton from serialized data
  13353. * @param parsedSkeleton defines the serialized data
  13354. * @param scene defines the hosting scene
  13355. * @returns a new skeleton
  13356. */
  13357. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13358. /**
  13359. * Compute all node absolute transforms
  13360. * @param forceUpdate defines if computation must be done even if cache is up to date
  13361. */
  13362. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13363. /**
  13364. * Gets the root pose matrix
  13365. * @returns a matrix
  13366. */
  13367. getPoseMatrix(): Nullable<Matrix>;
  13368. /**
  13369. * Sorts bones per internal index
  13370. */
  13371. sortBones(): void;
  13372. private _sortBones;
  13373. }
  13374. }
  13375. declare module BABYLON {
  13376. /**
  13377. * Class used to store bone information
  13378. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13379. */
  13380. export class Bone extends Node {
  13381. /**
  13382. * defines the bone name
  13383. */
  13384. name: string;
  13385. private static _tmpVecs;
  13386. private static _tmpQuat;
  13387. private static _tmpMats;
  13388. /**
  13389. * Gets the list of child bones
  13390. */
  13391. children: Bone[];
  13392. /** Gets the animations associated with this bone */
  13393. animations: Animation[];
  13394. /**
  13395. * Gets or sets bone length
  13396. */
  13397. length: number;
  13398. /**
  13399. * @hidden Internal only
  13400. * Set this value to map this bone to a different index in the transform matrices
  13401. * Set this value to -1 to exclude the bone from the transform matrices
  13402. */ private _index: Nullable<number>;
  13403. private _skeleton;
  13404. private _localMatrix;
  13405. private _restPose;
  13406. private _baseMatrix;
  13407. private _absoluteTransform;
  13408. private _invertedAbsoluteTransform;
  13409. private _parent;
  13410. private _scalingDeterminant;
  13411. private _worldTransform;
  13412. private _localScaling;
  13413. private _localRotation;
  13414. private _localPosition;
  13415. private _needToDecompose;
  13416. private _needToCompose;
  13417. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13418. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13419. /** @hidden */
  13420. /** @hidden */ private _matrix: Matrix;
  13421. /**
  13422. * Create a new bone
  13423. * @param name defines the bone name
  13424. * @param skeleton defines the parent skeleton
  13425. * @param parentBone defines the parent (can be null if the bone is the root)
  13426. * @param localMatrix defines the local matrix
  13427. * @param restPose defines the rest pose matrix
  13428. * @param baseMatrix defines the base matrix
  13429. * @param index defines index of the bone in the hiearchy
  13430. */
  13431. constructor(
  13432. /**
  13433. * defines the bone name
  13434. */
  13435. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13436. /**
  13437. * Gets the current object class name.
  13438. * @return the class name
  13439. */
  13440. getClassName(): string;
  13441. /**
  13442. * Gets the parent skeleton
  13443. * @returns a skeleton
  13444. */
  13445. getSkeleton(): Skeleton;
  13446. /**
  13447. * Gets parent bone
  13448. * @returns a bone or null if the bone is the root of the bone hierarchy
  13449. */
  13450. getParent(): Nullable<Bone>;
  13451. /**
  13452. * Returns an array containing the root bones
  13453. * @returns an array containing the root bones
  13454. */
  13455. getChildren(): Array<Bone>;
  13456. /**
  13457. * Sets the parent bone
  13458. * @param parent defines the parent (can be null if the bone is the root)
  13459. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13460. */
  13461. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13462. /**
  13463. * Gets the local matrix
  13464. * @returns a matrix
  13465. */
  13466. getLocalMatrix(): Matrix;
  13467. /**
  13468. * Gets the base matrix (initial matrix which remains unchanged)
  13469. * @returns a matrix
  13470. */
  13471. getBaseMatrix(): Matrix;
  13472. /**
  13473. * Gets the rest pose matrix
  13474. * @returns a matrix
  13475. */
  13476. getRestPose(): Matrix;
  13477. /**
  13478. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13479. */
  13480. getWorldMatrix(): Matrix;
  13481. /**
  13482. * Sets the local matrix to rest pose matrix
  13483. */
  13484. returnToRest(): void;
  13485. /**
  13486. * Gets the inverse of the absolute transform matrix.
  13487. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13488. * @returns a matrix
  13489. */
  13490. getInvertedAbsoluteTransform(): Matrix;
  13491. /**
  13492. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13493. * @returns a matrix
  13494. */
  13495. getAbsoluteTransform(): Matrix;
  13496. /**
  13497. * Links with the given transform node.
  13498. * The local matrix of this bone is copied from the transform node every frame.
  13499. * @param transformNode defines the transform node to link to
  13500. */
  13501. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13502. /**
  13503. * Gets the node used to drive the bone's transformation
  13504. * @returns a transform node or null
  13505. */
  13506. getTransformNode(): Nullable<TransformNode>;
  13507. /** Gets or sets current position (in local space) */
  13508. position: Vector3;
  13509. /** Gets or sets current rotation (in local space) */
  13510. rotation: Vector3;
  13511. /** Gets or sets current rotation quaternion (in local space) */
  13512. rotationQuaternion: Quaternion;
  13513. /** Gets or sets current scaling (in local space) */
  13514. scaling: Vector3;
  13515. /**
  13516. * Gets the animation properties override
  13517. */
  13518. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13519. private _decompose;
  13520. private _compose;
  13521. /**
  13522. * Update the base and local matrices
  13523. * @param matrix defines the new base or local matrix
  13524. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13525. * @param updateLocalMatrix defines if the local matrix should be updated
  13526. */
  13527. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13528. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13529. /**
  13530. * Flag the bone as dirty (Forcing it to update everything)
  13531. */
  13532. markAsDirty(): void;
  13533. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13534. private _markAsDirtyAndDecompose;
  13535. /**
  13536. * Translate the bone in local or world space
  13537. * @param vec The amount to translate the bone
  13538. * @param space The space that the translation is in
  13539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13540. */
  13541. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13542. /**
  13543. * Set the postion of the bone in local or world space
  13544. * @param position The position to set the bone
  13545. * @param space The space that the position is in
  13546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13547. */
  13548. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13549. /**
  13550. * Set the absolute position of the bone (world space)
  13551. * @param position The position to set the bone
  13552. * @param mesh The mesh that this bone is attached to
  13553. */
  13554. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13555. /**
  13556. * Scale the bone on the x, y and z axes (in local space)
  13557. * @param x The amount to scale the bone on the x axis
  13558. * @param y The amount to scale the bone on the y axis
  13559. * @param z The amount to scale the bone on the z axis
  13560. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13561. */
  13562. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13563. /**
  13564. * Set the bone scaling in local space
  13565. * @param scale defines the scaling vector
  13566. */
  13567. setScale(scale: Vector3): void;
  13568. /**
  13569. * Gets the current scaling in local space
  13570. * @returns the current scaling vector
  13571. */
  13572. getScale(): Vector3;
  13573. /**
  13574. * Gets the current scaling in local space and stores it in a target vector
  13575. * @param result defines the target vector
  13576. */
  13577. getScaleToRef(result: Vector3): void;
  13578. /**
  13579. * Set the yaw, pitch, and roll of the bone in local or world space
  13580. * @param yaw The rotation of the bone on the y axis
  13581. * @param pitch The rotation of the bone on the x axis
  13582. * @param roll The rotation of the bone on the z axis
  13583. * @param space The space that the axes of rotation are in
  13584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13585. */
  13586. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13587. /**
  13588. * Add a rotation to the bone on an axis in local or world space
  13589. * @param axis The axis to rotate the bone on
  13590. * @param amount The amount to rotate the bone
  13591. * @param space The space that the axis is in
  13592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13593. */
  13594. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13595. /**
  13596. * Set the rotation of the bone to a particular axis angle in local or world space
  13597. * @param axis The axis to rotate the bone on
  13598. * @param angle The angle that the bone should be rotated to
  13599. * @param space The space that the axis is in
  13600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13601. */
  13602. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13603. /**
  13604. * Set the euler rotation of the bone in local of world space
  13605. * @param rotation The euler rotation that the bone should be set to
  13606. * @param space The space that the rotation is in
  13607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13608. */
  13609. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13610. /**
  13611. * Set the quaternion rotation of the bone in local of world space
  13612. * @param quat The quaternion rotation that the bone should be set to
  13613. * @param space The space that the rotation is in
  13614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13615. */
  13616. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13617. /**
  13618. * Set the rotation matrix of the bone in local of world space
  13619. * @param rotMat The rotation matrix that the bone should be set to
  13620. * @param space The space that the rotation is in
  13621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13622. */
  13623. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13624. private _rotateWithMatrix;
  13625. private _getNegativeRotationToRef;
  13626. /**
  13627. * Get the position of the bone in local or world space
  13628. * @param space The space that the returned position is in
  13629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13630. * @returns The position of the bone
  13631. */
  13632. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13633. /**
  13634. * Copy the position of the bone to a vector3 in local or world space
  13635. * @param space The space that the returned position is in
  13636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13637. * @param result The vector3 to copy the position to
  13638. */
  13639. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13640. /**
  13641. * Get the absolute position of the bone (world space)
  13642. * @param mesh The mesh that this bone is attached to
  13643. * @returns The absolute position of the bone
  13644. */
  13645. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13646. /**
  13647. * Copy the absolute position of the bone (world space) to the result param
  13648. * @param mesh The mesh that this bone is attached to
  13649. * @param result The vector3 to copy the absolute position to
  13650. */
  13651. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13652. /**
  13653. * Compute the absolute transforms of this bone and its children
  13654. */
  13655. computeAbsoluteTransforms(): void;
  13656. /**
  13657. * Get the world direction from an axis that is in the local space of the bone
  13658. * @param localAxis The local direction that is used to compute the world direction
  13659. * @param mesh The mesh that this bone is attached to
  13660. * @returns The world direction
  13661. */
  13662. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13663. /**
  13664. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13665. * @param localAxis The local direction that is used to compute the world direction
  13666. * @param mesh The mesh that this bone is attached to
  13667. * @param result The vector3 that the world direction will be copied to
  13668. */
  13669. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13670. /**
  13671. * Get the euler rotation of the bone in local or world space
  13672. * @param space The space that the rotation should be in
  13673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13674. * @returns The euler rotation
  13675. */
  13676. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13677. /**
  13678. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13679. * @param space The space that the rotation should be in
  13680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13681. * @param result The vector3 that the rotation should be copied to
  13682. */
  13683. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13684. /**
  13685. * Get the quaternion rotation of the bone in either local or world space
  13686. * @param space The space that the rotation should be in
  13687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13688. * @returns The quaternion rotation
  13689. */
  13690. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13691. /**
  13692. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13693. * @param space The space that the rotation should be in
  13694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13695. * @param result The quaternion that the rotation should be copied to
  13696. */
  13697. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13698. /**
  13699. * Get the rotation matrix of the bone in local or world space
  13700. * @param space The space that the rotation should be in
  13701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13702. * @returns The rotation matrix
  13703. */
  13704. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13705. /**
  13706. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13707. * @param space The space that the rotation should be in
  13708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13709. * @param result The quaternion that the rotation should be copied to
  13710. */
  13711. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13712. /**
  13713. * Get the world position of a point that is in the local space of the bone
  13714. * @param position The local position
  13715. * @param mesh The mesh that this bone is attached to
  13716. * @returns The world position
  13717. */
  13718. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13719. /**
  13720. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13721. * @param position The local position
  13722. * @param mesh The mesh that this bone is attached to
  13723. * @param result The vector3 that the world position should be copied to
  13724. */
  13725. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13726. /**
  13727. * Get the local position of a point that is in world space
  13728. * @param position The world position
  13729. * @param mesh The mesh that this bone is attached to
  13730. * @returns The local position
  13731. */
  13732. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13733. /**
  13734. * Get the local position of a point that is in world space and copy it to the result param
  13735. * @param position The world position
  13736. * @param mesh The mesh that this bone is attached to
  13737. * @param result The vector3 that the local position should be copied to
  13738. */
  13739. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13740. }
  13741. }
  13742. declare module BABYLON {
  13743. /**
  13744. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13745. * @see https://doc.babylonjs.com/how_to/transformnode
  13746. */
  13747. export class TransformNode extends Node {
  13748. /**
  13749. * Object will not rotate to face the camera
  13750. */
  13751. static BILLBOARDMODE_NONE: number;
  13752. /**
  13753. * Object will rotate to face the camera but only on the x axis
  13754. */
  13755. static BILLBOARDMODE_X: number;
  13756. /**
  13757. * Object will rotate to face the camera but only on the y axis
  13758. */
  13759. static BILLBOARDMODE_Y: number;
  13760. /**
  13761. * Object will rotate to face the camera but only on the z axis
  13762. */
  13763. static BILLBOARDMODE_Z: number;
  13764. /**
  13765. * Object will rotate to face the camera
  13766. */
  13767. static BILLBOARDMODE_ALL: number;
  13768. /**
  13769. * Object will rotate to face the camera's position instead of orientation
  13770. */
  13771. static BILLBOARDMODE_USE_POSITION: number;
  13772. private _forward;
  13773. private _forwardInverted;
  13774. private _up;
  13775. private _right;
  13776. private _rightInverted;
  13777. private _position;
  13778. private _rotation;
  13779. private _rotationQuaternion;
  13780. protected _scaling: Vector3;
  13781. protected _isDirty: boolean;
  13782. private _transformToBoneReferal;
  13783. private _isAbsoluteSynced;
  13784. private _billboardMode;
  13785. /**
  13786. * Gets or sets the billboard mode. Default is 0.
  13787. *
  13788. * | Value | Type | Description |
  13789. * | --- | --- | --- |
  13790. * | 0 | BILLBOARDMODE_NONE | |
  13791. * | 1 | BILLBOARDMODE_X | |
  13792. * | 2 | BILLBOARDMODE_Y | |
  13793. * | 4 | BILLBOARDMODE_Z | |
  13794. * | 7 | BILLBOARDMODE_ALL | |
  13795. *
  13796. */
  13797. billboardMode: number;
  13798. private _preserveParentRotationForBillboard;
  13799. /**
  13800. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13801. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13802. */
  13803. preserveParentRotationForBillboard: boolean;
  13804. /**
  13805. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13806. */
  13807. scalingDeterminant: number;
  13808. private _infiniteDistance;
  13809. /**
  13810. * Gets or sets the distance of the object to max, often used by skybox
  13811. */
  13812. infiniteDistance: boolean;
  13813. /**
  13814. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13815. * By default the system will update normals to compensate
  13816. */
  13817. ignoreNonUniformScaling: boolean;
  13818. /**
  13819. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13820. */
  13821. reIntegrateRotationIntoRotationQuaternion: boolean;
  13822. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13823. /** @hidden */ private _localMatrix: Matrix;
  13824. private _usePivotMatrix;
  13825. private _absolutePosition;
  13826. private _absoluteScaling;
  13827. private _absoluteRotationQuaternion;
  13828. private _pivotMatrix;
  13829. private _pivotMatrixInverse;
  13830. protected _postMultiplyPivotMatrix: boolean;
  13831. protected _isWorldMatrixFrozen: boolean;
  13832. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13833. /**
  13834. * An event triggered after the world matrix is updated
  13835. */
  13836. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13837. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13838. /**
  13839. * Gets a string identifying the name of the class
  13840. * @returns "TransformNode" string
  13841. */
  13842. getClassName(): string;
  13843. /**
  13844. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13845. */
  13846. position: Vector3;
  13847. /**
  13848. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13849. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13850. */
  13851. rotation: Vector3;
  13852. /**
  13853. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13854. */
  13855. scaling: Vector3;
  13856. /**
  13857. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13858. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13859. */
  13860. rotationQuaternion: Nullable<Quaternion>;
  13861. /**
  13862. * The forward direction of that transform in world space.
  13863. */
  13864. readonly forward: Vector3;
  13865. /**
  13866. * The up direction of that transform in world space.
  13867. */
  13868. readonly up: Vector3;
  13869. /**
  13870. * The right direction of that transform in world space.
  13871. */
  13872. readonly right: Vector3;
  13873. /**
  13874. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13875. * @param matrix the matrix to copy the pose from
  13876. * @returns this TransformNode.
  13877. */
  13878. updatePoseMatrix(matrix: Matrix): TransformNode;
  13879. /**
  13880. * Returns the mesh Pose matrix.
  13881. * @returns the pose matrix
  13882. */
  13883. getPoseMatrix(): Matrix;
  13884. /** @hidden */ private _isSynchronized(): boolean;
  13885. /** @hidden */ private _initCache(): void;
  13886. /**
  13887. * Flag the transform node as dirty (Forcing it to update everything)
  13888. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13889. * @returns this transform node
  13890. */
  13891. markAsDirty(property: string): TransformNode;
  13892. /**
  13893. * Returns the current mesh absolute position.
  13894. * Returns a Vector3.
  13895. */
  13896. readonly absolutePosition: Vector3;
  13897. /**
  13898. * Returns the current mesh absolute scaling.
  13899. * Returns a Vector3.
  13900. */
  13901. readonly absoluteScaling: Vector3;
  13902. /**
  13903. * Returns the current mesh absolute rotation.
  13904. * Returns a Quaternion.
  13905. */
  13906. readonly absoluteRotationQuaternion: Quaternion;
  13907. /**
  13908. * Sets a new matrix to apply before all other transformation
  13909. * @param matrix defines the transform matrix
  13910. * @returns the current TransformNode
  13911. */
  13912. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13913. /**
  13914. * Sets a new pivot matrix to the current node
  13915. * @param matrix defines the new pivot matrix to use
  13916. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13917. * @returns the current TransformNode
  13918. */
  13919. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13920. /**
  13921. * Returns the mesh pivot matrix.
  13922. * Default : Identity.
  13923. * @returns the matrix
  13924. */
  13925. getPivotMatrix(): Matrix;
  13926. /**
  13927. * Instantiate (when possible) or clone that node with its hierarchy
  13928. * @param newParent defines the new parent to use for the instance (or clone)
  13929. * @returns an instance (or a clone) of the current node with its hiearchy
  13930. */
  13931. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13932. /**
  13933. * Prevents the World matrix to be computed any longer
  13934. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13935. * @returns the TransformNode.
  13936. */
  13937. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13938. /**
  13939. * Allows back the World matrix computation.
  13940. * @returns the TransformNode.
  13941. */
  13942. unfreezeWorldMatrix(): this;
  13943. /**
  13944. * True if the World matrix has been frozen.
  13945. */
  13946. readonly isWorldMatrixFrozen: boolean;
  13947. /**
  13948. * Retuns the mesh absolute position in the World.
  13949. * @returns a Vector3.
  13950. */
  13951. getAbsolutePosition(): Vector3;
  13952. /**
  13953. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13954. * @param absolutePosition the absolute position to set
  13955. * @returns the TransformNode.
  13956. */
  13957. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13958. /**
  13959. * Sets the mesh position in its local space.
  13960. * @param vector3 the position to set in localspace
  13961. * @returns the TransformNode.
  13962. */
  13963. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13964. /**
  13965. * Returns the mesh position in the local space from the current World matrix values.
  13966. * @returns a new Vector3.
  13967. */
  13968. getPositionExpressedInLocalSpace(): Vector3;
  13969. /**
  13970. * Translates the mesh along the passed Vector3 in its local space.
  13971. * @param vector3 the distance to translate in localspace
  13972. * @returns the TransformNode.
  13973. */
  13974. locallyTranslate(vector3: Vector3): TransformNode;
  13975. private static _lookAtVectorCache;
  13976. /**
  13977. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13978. * @param targetPoint the position (must be in same space as current mesh) to look at
  13979. * @param yawCor optional yaw (y-axis) correction in radians
  13980. * @param pitchCor optional pitch (x-axis) correction in radians
  13981. * @param rollCor optional roll (z-axis) correction in radians
  13982. * @param space the choosen space of the target
  13983. * @returns the TransformNode.
  13984. */
  13985. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13986. /**
  13987. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13988. * This Vector3 is expressed in the World space.
  13989. * @param localAxis axis to rotate
  13990. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13991. */
  13992. getDirection(localAxis: Vector3): Vector3;
  13993. /**
  13994. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13995. * localAxis is expressed in the mesh local space.
  13996. * result is computed in the Wordl space from the mesh World matrix.
  13997. * @param localAxis axis to rotate
  13998. * @param result the resulting transformnode
  13999. * @returns this TransformNode.
  14000. */
  14001. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14002. /**
  14003. * Sets this transform node rotation to the given local axis.
  14004. * @param localAxis the axis in local space
  14005. * @param yawCor optional yaw (y-axis) correction in radians
  14006. * @param pitchCor optional pitch (x-axis) correction in radians
  14007. * @param rollCor optional roll (z-axis) correction in radians
  14008. * @returns this TransformNode
  14009. */
  14010. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14011. /**
  14012. * Sets a new pivot point to the current node
  14013. * @param point defines the new pivot point to use
  14014. * @param space defines if the point is in world or local space (local by default)
  14015. * @returns the current TransformNode
  14016. */
  14017. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14018. /**
  14019. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14020. * @returns the pivot point
  14021. */
  14022. getPivotPoint(): Vector3;
  14023. /**
  14024. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14025. * @param result the vector3 to store the result
  14026. * @returns this TransformNode.
  14027. */
  14028. getPivotPointToRef(result: Vector3): TransformNode;
  14029. /**
  14030. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14031. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14032. */
  14033. getAbsolutePivotPoint(): Vector3;
  14034. /**
  14035. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14036. * @param result vector3 to store the result
  14037. * @returns this TransformNode.
  14038. */
  14039. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14040. /**
  14041. * Defines the passed node as the parent of the current node.
  14042. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14043. * @see https://doc.babylonjs.com/how_to/parenting
  14044. * @param node the node ot set as the parent
  14045. * @returns this TransformNode.
  14046. */
  14047. setParent(node: Nullable<Node>): TransformNode;
  14048. private _nonUniformScaling;
  14049. /**
  14050. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14051. */
  14052. readonly nonUniformScaling: boolean;
  14053. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  14054. /**
  14055. * Attach the current TransformNode to another TransformNode associated with a bone
  14056. * @param bone Bone affecting the TransformNode
  14057. * @param affectedTransformNode TransformNode associated with the bone
  14058. * @returns this object
  14059. */
  14060. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14061. /**
  14062. * Detach the transform node if its associated with a bone
  14063. * @returns this object
  14064. */
  14065. detachFromBone(): TransformNode;
  14066. private static _rotationAxisCache;
  14067. /**
  14068. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14069. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14070. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14071. * The passed axis is also normalized.
  14072. * @param axis the axis to rotate around
  14073. * @param amount the amount to rotate in radians
  14074. * @param space Space to rotate in (Default: local)
  14075. * @returns the TransformNode.
  14076. */
  14077. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14078. /**
  14079. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14080. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14081. * The passed axis is also normalized. .
  14082. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14083. * @param point the point to rotate around
  14084. * @param axis the axis to rotate around
  14085. * @param amount the amount to rotate in radians
  14086. * @returns the TransformNode
  14087. */
  14088. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14089. /**
  14090. * Translates the mesh along the axis vector for the passed distance in the given space.
  14091. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14092. * @param axis the axis to translate in
  14093. * @param distance the distance to translate
  14094. * @param space Space to rotate in (Default: local)
  14095. * @returns the TransformNode.
  14096. */
  14097. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14098. /**
  14099. * Adds a rotation step to the mesh current rotation.
  14100. * x, y, z are Euler angles expressed in radians.
  14101. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14102. * This means this rotation is made in the mesh local space only.
  14103. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14104. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14105. * ```javascript
  14106. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14107. * ```
  14108. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14109. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14110. * @param x Rotation to add
  14111. * @param y Rotation to add
  14112. * @param z Rotation to add
  14113. * @returns the TransformNode.
  14114. */
  14115. addRotation(x: number, y: number, z: number): TransformNode;
  14116. /**
  14117. * @hidden
  14118. */
  14119. protected _getEffectiveParent(): Nullable<Node>;
  14120. /**
  14121. * Computes the world matrix of the node
  14122. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14123. * @returns the world matrix
  14124. */
  14125. computeWorldMatrix(force?: boolean): Matrix;
  14126. protected _afterComputeWorldMatrix(): void;
  14127. /**
  14128. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14129. * @param func callback function to add
  14130. *
  14131. * @returns the TransformNode.
  14132. */
  14133. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14134. /**
  14135. * Removes a registered callback function.
  14136. * @param func callback function to remove
  14137. * @returns the TransformNode.
  14138. */
  14139. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14140. /**
  14141. * Gets the position of the current mesh in camera space
  14142. * @param camera defines the camera to use
  14143. * @returns a position
  14144. */
  14145. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14146. /**
  14147. * Returns the distance from the mesh to the active camera
  14148. * @param camera defines the camera to use
  14149. * @returns the distance
  14150. */
  14151. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14152. /**
  14153. * Clone the current transform node
  14154. * @param name Name of the new clone
  14155. * @param newParent New parent for the clone
  14156. * @param doNotCloneChildren Do not clone children hierarchy
  14157. * @returns the new transform node
  14158. */
  14159. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14160. /**
  14161. * Serializes the objects information.
  14162. * @param currentSerializationObject defines the object to serialize in
  14163. * @returns the serialized object
  14164. */
  14165. serialize(currentSerializationObject?: any): any;
  14166. /**
  14167. * Returns a new TransformNode object parsed from the source provided.
  14168. * @param parsedTransformNode is the source.
  14169. * @param scene the scne the object belongs to
  14170. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14171. * @returns a new TransformNode object parsed from the source provided.
  14172. */
  14173. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14174. /**
  14175. * Get all child-transformNodes of this node
  14176. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14177. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14178. * @returns an array of TransformNode
  14179. */
  14180. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14181. /**
  14182. * Releases resources associated with this transform node.
  14183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14185. */
  14186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14187. /**
  14188. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14189. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14190. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14191. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14192. * @returns the current mesh
  14193. */
  14194. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14195. private _syncAbsoluteScalingAndRotation;
  14196. }
  14197. }
  14198. declare module BABYLON {
  14199. /**
  14200. * Defines the types of pose enabled controllers that are supported
  14201. */
  14202. export enum PoseEnabledControllerType {
  14203. /**
  14204. * HTC Vive
  14205. */
  14206. VIVE = 0,
  14207. /**
  14208. * Oculus Rift
  14209. */
  14210. OCULUS = 1,
  14211. /**
  14212. * Windows mixed reality
  14213. */
  14214. WINDOWS = 2,
  14215. /**
  14216. * Samsung gear VR
  14217. */
  14218. GEAR_VR = 3,
  14219. /**
  14220. * Google Daydream
  14221. */
  14222. DAYDREAM = 4,
  14223. /**
  14224. * Generic
  14225. */
  14226. GENERIC = 5
  14227. }
  14228. /**
  14229. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14230. */
  14231. export interface MutableGamepadButton {
  14232. /**
  14233. * Value of the button/trigger
  14234. */
  14235. value: number;
  14236. /**
  14237. * If the button/trigger is currently touched
  14238. */
  14239. touched: boolean;
  14240. /**
  14241. * If the button/trigger is currently pressed
  14242. */
  14243. pressed: boolean;
  14244. }
  14245. /**
  14246. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14247. * @hidden
  14248. */
  14249. export interface ExtendedGamepadButton extends GamepadButton {
  14250. /**
  14251. * If the button/trigger is currently pressed
  14252. */
  14253. readonly pressed: boolean;
  14254. /**
  14255. * If the button/trigger is currently touched
  14256. */
  14257. readonly touched: boolean;
  14258. /**
  14259. * Value of the button/trigger
  14260. */
  14261. readonly value: number;
  14262. }
  14263. /** @hidden */
  14264. export interface _GamePadFactory {
  14265. /**
  14266. * Returns wether or not the current gamepad can be created for this type of controller.
  14267. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14268. * @returns true if it can be created, otherwise false
  14269. */
  14270. canCreate(gamepadInfo: any): boolean;
  14271. /**
  14272. * Creates a new instance of the Gamepad.
  14273. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14274. * @returns the new gamepad instance
  14275. */
  14276. create(gamepadInfo: any): Gamepad;
  14277. }
  14278. /**
  14279. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14280. */
  14281. export class PoseEnabledControllerHelper {
  14282. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14283. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14284. /**
  14285. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14286. * @param vrGamepad the gamepad to initialized
  14287. * @returns a vr controller of the type the gamepad identified as
  14288. */
  14289. static InitiateController(vrGamepad: any): Gamepad;
  14290. }
  14291. /**
  14292. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14293. */
  14294. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14295. /**
  14296. * If the controller is used in a webXR session
  14297. */
  14298. isXR: boolean;
  14299. private _deviceRoomPosition;
  14300. private _deviceRoomRotationQuaternion;
  14301. /**
  14302. * The device position in babylon space
  14303. */
  14304. devicePosition: Vector3;
  14305. /**
  14306. * The device rotation in babylon space
  14307. */
  14308. deviceRotationQuaternion: Quaternion;
  14309. /**
  14310. * The scale factor of the device in babylon space
  14311. */
  14312. deviceScaleFactor: number;
  14313. /**
  14314. * (Likely devicePosition should be used instead) The device position in its room space
  14315. */
  14316. position: Vector3;
  14317. /**
  14318. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14319. */
  14320. rotationQuaternion: Quaternion;
  14321. /**
  14322. * The type of controller (Eg. Windows mixed reality)
  14323. */
  14324. controllerType: PoseEnabledControllerType;
  14325. protected _calculatedPosition: Vector3;
  14326. private _calculatedRotation;
  14327. /**
  14328. * The raw pose from the device
  14329. */
  14330. rawPose: DevicePose;
  14331. private _trackPosition;
  14332. private _maxRotationDistFromHeadset;
  14333. private _draggedRoomRotation;
  14334. /**
  14335. * @hidden
  14336. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14337. /**
  14338. * Internal, the mesh attached to the controller
  14339. * @hidden
  14340. */ private _mesh: Nullable<AbstractMesh>;
  14341. private _poseControlledCamera;
  14342. private _leftHandSystemQuaternion;
  14343. /**
  14344. * Internal, matrix used to convert room space to babylon space
  14345. * @hidden
  14346. */ private _deviceToWorld: Matrix;
  14347. /**
  14348. * Node to be used when casting a ray from the controller
  14349. * @hidden
  14350. */ private _pointingPoseNode: Nullable<TransformNode>;
  14351. /**
  14352. * Name of the child mesh that can be used to cast a ray from the controller
  14353. */
  14354. static readonly POINTING_POSE: string;
  14355. /**
  14356. * Creates a new PoseEnabledController from a gamepad
  14357. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14358. */
  14359. constructor(browserGamepad: any);
  14360. private _workingMatrix;
  14361. /**
  14362. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14363. */
  14364. update(): void;
  14365. /**
  14366. * Updates only the pose device and mesh without doing any button event checking
  14367. */
  14368. protected _updatePoseAndMesh(): void;
  14369. /**
  14370. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14371. * @param poseData raw pose fromthe device
  14372. */
  14373. updateFromDevice(poseData: DevicePose): void;
  14374. /**
  14375. * @hidden
  14376. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14377. /**
  14378. * Attaches a mesh to the controller
  14379. * @param mesh the mesh to be attached
  14380. */
  14381. attachToMesh(mesh: AbstractMesh): void;
  14382. /**
  14383. * Attaches the controllers mesh to a camera
  14384. * @param camera the camera the mesh should be attached to
  14385. */
  14386. attachToPoseControlledCamera(camera: TargetCamera): void;
  14387. /**
  14388. * Disposes of the controller
  14389. */
  14390. dispose(): void;
  14391. /**
  14392. * The mesh that is attached to the controller
  14393. */
  14394. readonly mesh: Nullable<AbstractMesh>;
  14395. /**
  14396. * Gets the ray of the controller in the direction the controller is pointing
  14397. * @param length the length the resulting ray should be
  14398. * @returns a ray in the direction the controller is pointing
  14399. */
  14400. getForwardRay(length?: number): Ray;
  14401. }
  14402. }
  14403. declare module BABYLON {
  14404. /**
  14405. * Defines the WebVRController object that represents controllers tracked in 3D space
  14406. */
  14407. export abstract class WebVRController extends PoseEnabledController {
  14408. /**
  14409. * Internal, the default controller model for the controller
  14410. */
  14411. protected _defaultModel: AbstractMesh;
  14412. /**
  14413. * Fired when the trigger state has changed
  14414. */
  14415. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14416. /**
  14417. * Fired when the main button state has changed
  14418. */
  14419. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14420. /**
  14421. * Fired when the secondary button state has changed
  14422. */
  14423. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14424. /**
  14425. * Fired when the pad state has changed
  14426. */
  14427. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14428. /**
  14429. * Fired when controllers stick values have changed
  14430. */
  14431. onPadValuesChangedObservable: Observable<StickValues>;
  14432. /**
  14433. * Array of button availible on the controller
  14434. */
  14435. protected _buttons: Array<MutableGamepadButton>;
  14436. private _onButtonStateChange;
  14437. /**
  14438. * Fired when a controller button's state has changed
  14439. * @param callback the callback containing the button that was modified
  14440. */
  14441. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14442. /**
  14443. * X and Y axis corresponding to the controllers joystick
  14444. */
  14445. pad: StickValues;
  14446. /**
  14447. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14448. */
  14449. hand: string;
  14450. /**
  14451. * The default controller model for the controller
  14452. */
  14453. readonly defaultModel: AbstractMesh;
  14454. /**
  14455. * Creates a new WebVRController from a gamepad
  14456. * @param vrGamepad the gamepad that the WebVRController should be created from
  14457. */
  14458. constructor(vrGamepad: any);
  14459. /**
  14460. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14461. */
  14462. update(): void;
  14463. /**
  14464. * Function to be called when a button is modified
  14465. */
  14466. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14467. /**
  14468. * Loads a mesh and attaches it to the controller
  14469. * @param scene the scene the mesh should be added to
  14470. * @param meshLoaded callback for when the mesh has been loaded
  14471. */
  14472. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14473. private _setButtonValue;
  14474. private _changes;
  14475. private _checkChanges;
  14476. /**
  14477. * Disposes of th webVRCOntroller
  14478. */
  14479. dispose(): void;
  14480. }
  14481. }
  14482. declare module BABYLON {
  14483. /**
  14484. * The HemisphericLight simulates the ambient environment light,
  14485. * so the passed direction is the light reflection direction, not the incoming direction.
  14486. */
  14487. export class HemisphericLight extends Light {
  14488. /**
  14489. * The groundColor is the light in the opposite direction to the one specified during creation.
  14490. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14491. */
  14492. groundColor: Color3;
  14493. /**
  14494. * The light reflection direction, not the incoming direction.
  14495. */
  14496. direction: Vector3;
  14497. /**
  14498. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14499. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14500. * The HemisphericLight can't cast shadows.
  14501. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14502. * @param name The friendly name of the light
  14503. * @param direction The direction of the light reflection
  14504. * @param scene The scene the light belongs to
  14505. */
  14506. constructor(name: string, direction: Vector3, scene: Scene);
  14507. protected _buildUniformLayout(): void;
  14508. /**
  14509. * Returns the string "HemisphericLight".
  14510. * @return The class name
  14511. */
  14512. getClassName(): string;
  14513. /**
  14514. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14515. * Returns the updated direction.
  14516. * @param target The target the direction should point to
  14517. * @return The computed direction
  14518. */
  14519. setDirectionToTarget(target: Vector3): Vector3;
  14520. /**
  14521. * Returns the shadow generator associated to the light.
  14522. * @returns Always null for hemispheric lights because it does not support shadows.
  14523. */
  14524. getShadowGenerator(): Nullable<IShadowGenerator>;
  14525. /**
  14526. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14527. * @param effect The effect to update
  14528. * @param lightIndex The index of the light in the effect to update
  14529. * @returns The hemispheric light
  14530. */
  14531. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14532. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14533. /**
  14534. * Computes the world matrix of the node
  14535. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14536. * @param useWasUpdatedFlag defines a reserved property
  14537. * @returns the world matrix
  14538. */
  14539. computeWorldMatrix(): Matrix;
  14540. /**
  14541. * Returns the integer 3.
  14542. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14543. */
  14544. getTypeID(): number;
  14545. /**
  14546. * Prepares the list of defines specific to the light type.
  14547. * @param defines the list of defines
  14548. * @param lightIndex defines the index of the light for the effect
  14549. */
  14550. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14551. }
  14552. }
  14553. declare module BABYLON {
  14554. /** @hidden */
  14555. export var vrMultiviewToSingleviewPixelShader: {
  14556. name: string;
  14557. shader: string;
  14558. };
  14559. }
  14560. declare module BABYLON {
  14561. /**
  14562. * Renders to multiple views with a single draw call
  14563. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14564. */
  14565. export class MultiviewRenderTarget extends RenderTargetTexture {
  14566. /**
  14567. * Creates a multiview render target
  14568. * @param scene scene used with the render target
  14569. * @param size the size of the render target (used for each view)
  14570. */
  14571. constructor(scene: Scene, size?: number | {
  14572. width: number;
  14573. height: number;
  14574. } | {
  14575. ratio: number;
  14576. });
  14577. /**
  14578. * @hidden
  14579. * @param faceIndex the face index, if its a cube texture
  14580. */ private _bindFrameBuffer(faceIndex?: number): void;
  14581. /**
  14582. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14583. * @returns the view count
  14584. */
  14585. getViewCount(): number;
  14586. }
  14587. }
  14588. declare module BABYLON {
  14589. /**
  14590. * Reprasents a camera frustum
  14591. */
  14592. export class Frustum {
  14593. /**
  14594. * Gets the planes representing the frustum
  14595. * @param transform matrix to be applied to the returned planes
  14596. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14597. */
  14598. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14599. /**
  14600. * Gets the near frustum plane transformed by the transform matrix
  14601. * @param transform transformation matrix to be applied to the resulting frustum plane
  14602. * @param frustumPlane the resuling frustum plane
  14603. */
  14604. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14605. /**
  14606. * Gets the far frustum plane transformed by the transform matrix
  14607. * @param transform transformation matrix to be applied to the resulting frustum plane
  14608. * @param frustumPlane the resuling frustum plane
  14609. */
  14610. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14611. /**
  14612. * Gets the left frustum plane transformed by the transform matrix
  14613. * @param transform transformation matrix to be applied to the resulting frustum plane
  14614. * @param frustumPlane the resuling frustum plane
  14615. */
  14616. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14617. /**
  14618. * Gets the right frustum plane transformed by the transform matrix
  14619. * @param transform transformation matrix to be applied to the resulting frustum plane
  14620. * @param frustumPlane the resuling frustum plane
  14621. */
  14622. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14623. /**
  14624. * Gets the top frustum plane transformed by the transform matrix
  14625. * @param transform transformation matrix to be applied to the resulting frustum plane
  14626. * @param frustumPlane the resuling frustum plane
  14627. */
  14628. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14629. /**
  14630. * Gets the bottom frustum plane transformed by the transform matrix
  14631. * @param transform transformation matrix to be applied to the resulting frustum plane
  14632. * @param frustumPlane the resuling frustum plane
  14633. */
  14634. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14635. /**
  14636. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14637. * @param transform transformation matrix to be applied to the resulting frustum planes
  14638. * @param frustumPlanes the resuling frustum planes
  14639. */
  14640. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14641. }
  14642. }
  14643. declare module BABYLON {
  14644. interface Engine {
  14645. /**
  14646. * Creates a new multiview render target
  14647. * @param width defines the width of the texture
  14648. * @param height defines the height of the texture
  14649. * @returns the created multiview texture
  14650. */
  14651. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14652. /**
  14653. * Binds a multiview framebuffer to be drawn to
  14654. * @param multiviewTexture texture to bind
  14655. */
  14656. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14657. }
  14658. interface Camera {
  14659. /**
  14660. * @hidden
  14661. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14662. */ private _useMultiviewToSingleView: boolean;
  14663. /**
  14664. * @hidden
  14665. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14666. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14667. /**
  14668. * @hidden
  14669. * ensures the multiview texture of the camera exists and has the specified width/height
  14670. * @param width height to set on the multiview texture
  14671. * @param height width to set on the multiview texture
  14672. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14673. }
  14674. interface Scene {
  14675. /** @hidden */ private _transformMatrixR: Matrix;
  14676. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14677. /** @hidden */ private _createMultiviewUbo(): void;
  14678. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14679. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14680. }
  14681. }
  14682. declare module BABYLON {
  14683. /**
  14684. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14685. * This will not be used for webXR as it supports displaying texture arrays directly
  14686. */
  14687. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14688. /**
  14689. * Initializes a VRMultiviewToSingleview
  14690. * @param name name of the post process
  14691. * @param camera camera to be applied to
  14692. * @param scaleFactor scaling factor to the size of the output texture
  14693. */
  14694. constructor(name: string, camera: Camera, scaleFactor: number);
  14695. }
  14696. }
  14697. declare module BABYLON {
  14698. interface Engine {
  14699. /** @hidden */ private _vrDisplay: any;
  14700. /** @hidden */ private _vrSupported: boolean;
  14701. /** @hidden */ private _oldSize: Size;
  14702. /** @hidden */ private _oldHardwareScaleFactor: number;
  14703. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14704. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14705. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14706. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14707. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14708. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14709. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14710. /**
  14711. * Observable signaled when VR display mode changes
  14712. */
  14713. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14714. /**
  14715. * Observable signaled when VR request present is complete
  14716. */
  14717. onVRRequestPresentComplete: Observable<boolean>;
  14718. /**
  14719. * Observable signaled when VR request present starts
  14720. */
  14721. onVRRequestPresentStart: Observable<Engine>;
  14722. /**
  14723. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14724. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14725. */
  14726. isInVRExclusivePointerMode: boolean;
  14727. /**
  14728. * Gets a boolean indicating if a webVR device was detected
  14729. * @returns true if a webVR device was detected
  14730. */
  14731. isVRDevicePresent(): boolean;
  14732. /**
  14733. * Gets the current webVR device
  14734. * @returns the current webVR device (or null)
  14735. */
  14736. getVRDevice(): any;
  14737. /**
  14738. * Initializes a webVR display and starts listening to display change events
  14739. * The onVRDisplayChangedObservable will be notified upon these changes
  14740. * @returns A promise containing a VRDisplay and if vr is supported
  14741. */
  14742. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14743. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14744. /**
  14745. * Call this function to switch to webVR mode
  14746. * Will do nothing if webVR is not supported or if there is no webVR device
  14747. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14748. */
  14749. enableVR(): void;
  14750. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14751. }
  14752. }
  14753. declare module BABYLON {
  14754. /**
  14755. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14756. * IMPORTANT!! The data is right-hand data.
  14757. * @export
  14758. * @interface DevicePose
  14759. */
  14760. export interface DevicePose {
  14761. /**
  14762. * The position of the device, values in array are [x,y,z].
  14763. */
  14764. readonly position: Nullable<Float32Array>;
  14765. /**
  14766. * The linearVelocity of the device, values in array are [x,y,z].
  14767. */
  14768. readonly linearVelocity: Nullable<Float32Array>;
  14769. /**
  14770. * The linearAcceleration of the device, values in array are [x,y,z].
  14771. */
  14772. readonly linearAcceleration: Nullable<Float32Array>;
  14773. /**
  14774. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14775. */
  14776. readonly orientation: Nullable<Float32Array>;
  14777. /**
  14778. * The angularVelocity of the device, values in array are [x,y,z].
  14779. */
  14780. readonly angularVelocity: Nullable<Float32Array>;
  14781. /**
  14782. * The angularAcceleration of the device, values in array are [x,y,z].
  14783. */
  14784. readonly angularAcceleration: Nullable<Float32Array>;
  14785. }
  14786. /**
  14787. * Interface representing a pose controlled object in Babylon.
  14788. * A pose controlled object has both regular pose values as well as pose values
  14789. * from an external device such as a VR head mounted display
  14790. */
  14791. export interface PoseControlled {
  14792. /**
  14793. * The position of the object in babylon space.
  14794. */
  14795. position: Vector3;
  14796. /**
  14797. * The rotation quaternion of the object in babylon space.
  14798. */
  14799. rotationQuaternion: Quaternion;
  14800. /**
  14801. * The position of the device in babylon space.
  14802. */
  14803. devicePosition?: Vector3;
  14804. /**
  14805. * The rotation quaternion of the device in babylon space.
  14806. */
  14807. deviceRotationQuaternion: Quaternion;
  14808. /**
  14809. * The raw pose coming from the device.
  14810. */
  14811. rawPose: Nullable<DevicePose>;
  14812. /**
  14813. * The scale of the device to be used when translating from device space to babylon space.
  14814. */
  14815. deviceScaleFactor: number;
  14816. /**
  14817. * Updates the poseControlled values based on the input device pose.
  14818. * @param poseData the pose data to update the object with
  14819. */
  14820. updateFromDevice(poseData: DevicePose): void;
  14821. }
  14822. /**
  14823. * Set of options to customize the webVRCamera
  14824. */
  14825. export interface WebVROptions {
  14826. /**
  14827. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14828. */
  14829. trackPosition?: boolean;
  14830. /**
  14831. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14832. */
  14833. positionScale?: number;
  14834. /**
  14835. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14836. */
  14837. displayName?: string;
  14838. /**
  14839. * Should the native controller meshes be initialized. (default: true)
  14840. */
  14841. controllerMeshes?: boolean;
  14842. /**
  14843. * Creating a default HemiLight only on controllers. (default: true)
  14844. */
  14845. defaultLightingOnControllers?: boolean;
  14846. /**
  14847. * If you don't want to use the default VR button of the helper. (default: false)
  14848. */
  14849. useCustomVRButton?: boolean;
  14850. /**
  14851. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14852. */
  14853. customVRButton?: HTMLButtonElement;
  14854. /**
  14855. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14856. */
  14857. rayLength?: number;
  14858. /**
  14859. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14860. */
  14861. defaultHeight?: number;
  14862. /**
  14863. * If multiview should be used if availible (default: false)
  14864. */
  14865. useMultiview?: boolean;
  14866. }
  14867. /**
  14868. * This represents a WebVR camera.
  14869. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14870. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14871. */
  14872. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14873. private webVROptions;
  14874. /**
  14875. * @hidden
  14876. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14877. */ private _vrDevice: any;
  14878. /**
  14879. * The rawPose of the vrDevice.
  14880. */
  14881. rawPose: Nullable<DevicePose>;
  14882. private _onVREnabled;
  14883. private _specsVersion;
  14884. private _attached;
  14885. private _frameData;
  14886. protected _descendants: Array<Node>;
  14887. private _deviceRoomPosition;
  14888. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14889. private _standingMatrix;
  14890. /**
  14891. * Represents device position in babylon space.
  14892. */
  14893. devicePosition: Vector3;
  14894. /**
  14895. * Represents device rotation in babylon space.
  14896. */
  14897. deviceRotationQuaternion: Quaternion;
  14898. /**
  14899. * The scale of the device to be used when translating from device space to babylon space.
  14900. */
  14901. deviceScaleFactor: number;
  14902. private _deviceToWorld;
  14903. private _worldToDevice;
  14904. /**
  14905. * References to the webVR controllers for the vrDevice.
  14906. */
  14907. controllers: Array<WebVRController>;
  14908. /**
  14909. * Emits an event when a controller is attached.
  14910. */
  14911. onControllersAttachedObservable: Observable<WebVRController[]>;
  14912. /**
  14913. * Emits an event when a controller's mesh has been loaded;
  14914. */
  14915. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14916. /**
  14917. * Emits an event when the HMD's pose has been updated.
  14918. */
  14919. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14920. private _poseSet;
  14921. /**
  14922. * If the rig cameras be used as parent instead of this camera.
  14923. */
  14924. rigParenting: boolean;
  14925. private _lightOnControllers;
  14926. private _defaultHeight?;
  14927. /**
  14928. * Instantiates a WebVRFreeCamera.
  14929. * @param name The name of the WebVRFreeCamera
  14930. * @param position The starting anchor position for the camera
  14931. * @param scene The scene the camera belongs to
  14932. * @param webVROptions a set of customizable options for the webVRCamera
  14933. */
  14934. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14935. /**
  14936. * Gets the device distance from the ground in meters.
  14937. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  14938. */
  14939. deviceDistanceToRoomGround(): number;
  14940. /**
  14941. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14942. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14943. */
  14944. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14945. /**
  14946. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14947. * @returns A promise with a boolean set to if the standing matrix is supported.
  14948. */
  14949. useStandingMatrixAsync(): Promise<boolean>;
  14950. /**
  14951. * Disposes the camera
  14952. */
  14953. dispose(): void;
  14954. /**
  14955. * Gets a vrController by name.
  14956. * @param name The name of the controller to retreive
  14957. * @returns the controller matching the name specified or null if not found
  14958. */
  14959. getControllerByName(name: string): Nullable<WebVRController>;
  14960. private _leftController;
  14961. /**
  14962. * The controller corresponding to the users left hand.
  14963. */
  14964. readonly leftController: Nullable<WebVRController>;
  14965. private _rightController;
  14966. /**
  14967. * The controller corresponding to the users right hand.
  14968. */
  14969. readonly rightController: Nullable<WebVRController>;
  14970. /**
  14971. * Casts a ray forward from the vrCamera's gaze.
  14972. * @param length Length of the ray (default: 100)
  14973. * @returns the ray corresponding to the gaze
  14974. */
  14975. getForwardRay(length?: number): Ray;
  14976. /**
  14977. * @hidden
  14978. * Updates the camera based on device's frame data
  14979. */ private _checkInputs(): void;
  14980. /**
  14981. * Updates the poseControlled values based on the input device pose.
  14982. * @param poseData Pose coming from the device
  14983. */
  14984. updateFromDevice(poseData: DevicePose): void;
  14985. private _htmlElementAttached;
  14986. private _detachIfAttached;
  14987. /**
  14988. * WebVR's attach control will start broadcasting frames to the device.
  14989. * Note that in certain browsers (chrome for example) this function must be called
  14990. * within a user-interaction callback. Example:
  14991. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14992. *
  14993. * @param element html element to attach the vrDevice to
  14994. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14995. */
  14996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14997. /**
  14998. * Detaches the camera from the html element and disables VR
  14999. *
  15000. * @param element html element to detach from
  15001. */
  15002. detachControl(element: HTMLElement): void;
  15003. /**
  15004. * @returns the name of this class
  15005. */
  15006. getClassName(): string;
  15007. /**
  15008. * Calls resetPose on the vrDisplay
  15009. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15010. */
  15011. resetToCurrentRotation(): void;
  15012. /**
  15013. * @hidden
  15014. * Updates the rig cameras (left and right eye)
  15015. */ private _updateRigCameras(): void;
  15016. private _workingVector;
  15017. private _oneVector;
  15018. private _workingMatrix;
  15019. private updateCacheCalled;
  15020. private _correctPositionIfNotTrackPosition;
  15021. /**
  15022. * @hidden
  15023. * Updates the cached values of the camera
  15024. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15025. */ private _updateCache(ignoreParentClass?: boolean): void;
  15026. /**
  15027. * @hidden
  15028. * Get current device position in babylon world
  15029. */ private _computeDevicePosition(): void;
  15030. /**
  15031. * Updates the current device position and rotation in the babylon world
  15032. */
  15033. update(): void;
  15034. /**
  15035. * @hidden
  15036. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15037. * @returns an identity matrix
  15038. */ private _getViewMatrix(): Matrix;
  15039. private _tmpMatrix;
  15040. /**
  15041. * This function is called by the two RIG cameras.
  15042. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15043. * @hidden
  15044. */ private _getWebVRViewMatrix(): Matrix;
  15045. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  15046. private _onGamepadConnectedObserver;
  15047. private _onGamepadDisconnectedObserver;
  15048. private _updateCacheWhenTrackingDisabledObserver;
  15049. /**
  15050. * Initializes the controllers and their meshes
  15051. */
  15052. initControllers(): void;
  15053. }
  15054. }
  15055. declare module BABYLON {
  15056. /**
  15057. * Size options for a post process
  15058. */
  15059. export type PostProcessOptions = {
  15060. width: number;
  15061. height: number;
  15062. };
  15063. /**
  15064. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15065. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15066. */
  15067. export class PostProcess {
  15068. /** Name of the PostProcess. */
  15069. name: string;
  15070. /**
  15071. * Gets or sets the unique id of the post process
  15072. */
  15073. uniqueId: number;
  15074. /**
  15075. * Width of the texture to apply the post process on
  15076. */
  15077. width: number;
  15078. /**
  15079. * Height of the texture to apply the post process on
  15080. */
  15081. height: number;
  15082. /**
  15083. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15084. * @hidden
  15085. */ private _outputTexture: Nullable<InternalTexture>;
  15086. /**
  15087. * Sampling mode used by the shader
  15088. * See https://doc.babylonjs.com/classes/3.1/texture
  15089. */
  15090. renderTargetSamplingMode: number;
  15091. /**
  15092. * Clear color to use when screen clearing
  15093. */
  15094. clearColor: Color4;
  15095. /**
  15096. * If the buffer needs to be cleared before applying the post process. (default: true)
  15097. * Should be set to false if shader will overwrite all previous pixels.
  15098. */
  15099. autoClear: boolean;
  15100. /**
  15101. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15102. */
  15103. alphaMode: number;
  15104. /**
  15105. * Sets the setAlphaBlendConstants of the babylon engine
  15106. */
  15107. alphaConstants: Color4;
  15108. /**
  15109. * Animations to be used for the post processing
  15110. */
  15111. animations: Animation[];
  15112. /**
  15113. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15114. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15115. */
  15116. enablePixelPerfectMode: boolean;
  15117. /**
  15118. * Force the postprocess to be applied without taking in account viewport
  15119. */
  15120. forceFullscreenViewport: boolean;
  15121. /**
  15122. * List of inspectable custom properties (used by the Inspector)
  15123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15124. */
  15125. inspectableCustomProperties: IInspectable[];
  15126. /**
  15127. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15128. *
  15129. * | Value | Type | Description |
  15130. * | ----- | ----------------------------------- | ----------- |
  15131. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15132. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15133. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15134. *
  15135. */
  15136. scaleMode: number;
  15137. /**
  15138. * Force textures to be a power of two (default: false)
  15139. */
  15140. alwaysForcePOT: boolean;
  15141. private _samples;
  15142. /**
  15143. * Number of sample textures (default: 1)
  15144. */
  15145. samples: number;
  15146. /**
  15147. * Modify the scale of the post process to be the same as the viewport (default: false)
  15148. */
  15149. adaptScaleToCurrentViewport: boolean;
  15150. private _camera;
  15151. private _scene;
  15152. private _engine;
  15153. private _options;
  15154. private _reusable;
  15155. private _textureType;
  15156. /**
  15157. * Smart array of input and output textures for the post process.
  15158. * @hidden
  15159. */ private _textures: SmartArray<InternalTexture>;
  15160. /**
  15161. * The index in _textures that corresponds to the output texture.
  15162. * @hidden
  15163. */ private _currentRenderTextureInd: number;
  15164. private _effect;
  15165. private _samplers;
  15166. private _fragmentUrl;
  15167. private _vertexUrl;
  15168. private _parameters;
  15169. private _scaleRatio;
  15170. protected _indexParameters: any;
  15171. private _shareOutputWithPostProcess;
  15172. private _texelSize;
  15173. private _forcedOutputTexture;
  15174. /**
  15175. * Returns the fragment url or shader name used in the post process.
  15176. * @returns the fragment url or name in the shader store.
  15177. */
  15178. getEffectName(): string;
  15179. /**
  15180. * An event triggered when the postprocess is activated.
  15181. */
  15182. onActivateObservable: Observable<Camera>;
  15183. private _onActivateObserver;
  15184. /**
  15185. * A function that is added to the onActivateObservable
  15186. */
  15187. onActivate: Nullable<(camera: Camera) => void>;
  15188. /**
  15189. * An event triggered when the postprocess changes its size.
  15190. */
  15191. onSizeChangedObservable: Observable<PostProcess>;
  15192. private _onSizeChangedObserver;
  15193. /**
  15194. * A function that is added to the onSizeChangedObservable
  15195. */
  15196. onSizeChanged: (postProcess: PostProcess) => void;
  15197. /**
  15198. * An event triggered when the postprocess applies its effect.
  15199. */
  15200. onApplyObservable: Observable<Effect>;
  15201. private _onApplyObserver;
  15202. /**
  15203. * A function that is added to the onApplyObservable
  15204. */
  15205. onApply: (effect: Effect) => void;
  15206. /**
  15207. * An event triggered before rendering the postprocess
  15208. */
  15209. onBeforeRenderObservable: Observable<Effect>;
  15210. private _onBeforeRenderObserver;
  15211. /**
  15212. * A function that is added to the onBeforeRenderObservable
  15213. */
  15214. onBeforeRender: (effect: Effect) => void;
  15215. /**
  15216. * An event triggered after rendering the postprocess
  15217. */
  15218. onAfterRenderObservable: Observable<Effect>;
  15219. private _onAfterRenderObserver;
  15220. /**
  15221. * A function that is added to the onAfterRenderObservable
  15222. */
  15223. onAfterRender: (efect: Effect) => void;
  15224. /**
  15225. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15226. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15227. */
  15228. inputTexture: InternalTexture;
  15229. /**
  15230. * Gets the camera which post process is applied to.
  15231. * @returns The camera the post process is applied to.
  15232. */
  15233. getCamera(): Camera;
  15234. /**
  15235. * Gets the texel size of the postprocess.
  15236. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15237. */
  15238. readonly texelSize: Vector2;
  15239. /**
  15240. * Creates a new instance PostProcess
  15241. * @param name The name of the PostProcess.
  15242. * @param fragmentUrl The url of the fragment shader to be used.
  15243. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15244. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15245. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15246. * @param camera The camera to apply the render pass to.
  15247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15248. * @param engine The engine which the post process will be applied. (default: current engine)
  15249. * @param reusable If the post process can be reused on the same frame. (default: false)
  15250. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15251. * @param textureType Type of textures used when performing the post process. (default: 0)
  15252. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15253. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15254. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15255. */
  15256. constructor(
  15257. /** Name of the PostProcess. */
  15258. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15259. /**
  15260. * Gets a string idenfifying the name of the class
  15261. * @returns "PostProcess" string
  15262. */
  15263. getClassName(): string;
  15264. /**
  15265. * Gets the engine which this post process belongs to.
  15266. * @returns The engine the post process was enabled with.
  15267. */
  15268. getEngine(): Engine;
  15269. /**
  15270. * The effect that is created when initializing the post process.
  15271. * @returns The created effect corresponding the the postprocess.
  15272. */
  15273. getEffect(): Effect;
  15274. /**
  15275. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15276. * @param postProcess The post process to share the output with.
  15277. * @returns This post process.
  15278. */
  15279. shareOutputWith(postProcess: PostProcess): PostProcess;
  15280. /**
  15281. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15282. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15283. */
  15284. useOwnOutput(): void;
  15285. /**
  15286. * Updates the effect with the current post process compile time values and recompiles the shader.
  15287. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15288. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15289. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15290. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15291. * @param onCompiled Called when the shader has been compiled.
  15292. * @param onError Called if there is an error when compiling a shader.
  15293. */
  15294. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15295. /**
  15296. * The post process is reusable if it can be used multiple times within one frame.
  15297. * @returns If the post process is reusable
  15298. */
  15299. isReusable(): boolean;
  15300. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15301. markTextureDirty(): void;
  15302. /**
  15303. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15304. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15305. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15306. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15307. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15308. * @returns The target texture that was bound to be written to.
  15309. */
  15310. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15311. /**
  15312. * If the post process is supported.
  15313. */
  15314. readonly isSupported: boolean;
  15315. /**
  15316. * The aspect ratio of the output texture.
  15317. */
  15318. readonly aspectRatio: number;
  15319. /**
  15320. * Get a value indicating if the post-process is ready to be used
  15321. * @returns true if the post-process is ready (shader is compiled)
  15322. */
  15323. isReady(): boolean;
  15324. /**
  15325. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15326. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15327. */
  15328. apply(): Nullable<Effect>;
  15329. private _disposeTextures;
  15330. /**
  15331. * Disposes the post process.
  15332. * @param camera The camera to dispose the post process on.
  15333. */
  15334. dispose(camera?: Camera): void;
  15335. }
  15336. }
  15337. declare module BABYLON {
  15338. /** @hidden */
  15339. export var kernelBlurVaryingDeclaration: {
  15340. name: string;
  15341. shader: string;
  15342. };
  15343. }
  15344. declare module BABYLON {
  15345. /** @hidden */
  15346. export var kernelBlurFragment: {
  15347. name: string;
  15348. shader: string;
  15349. };
  15350. }
  15351. declare module BABYLON {
  15352. /** @hidden */
  15353. export var kernelBlurFragment2: {
  15354. name: string;
  15355. shader: string;
  15356. };
  15357. }
  15358. declare module BABYLON {
  15359. /** @hidden */
  15360. export var kernelBlurPixelShader: {
  15361. name: string;
  15362. shader: string;
  15363. };
  15364. }
  15365. declare module BABYLON {
  15366. /** @hidden */
  15367. export var kernelBlurVertex: {
  15368. name: string;
  15369. shader: string;
  15370. };
  15371. }
  15372. declare module BABYLON {
  15373. /** @hidden */
  15374. export var kernelBlurVertexShader: {
  15375. name: string;
  15376. shader: string;
  15377. };
  15378. }
  15379. declare module BABYLON {
  15380. /**
  15381. * The Blur Post Process which blurs an image based on a kernel and direction.
  15382. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15383. */
  15384. export class BlurPostProcess extends PostProcess {
  15385. /** The direction in which to blur the image. */
  15386. direction: Vector2;
  15387. private blockCompilation;
  15388. protected _kernel: number;
  15389. protected _idealKernel: number;
  15390. protected _packedFloat: boolean;
  15391. private _staticDefines;
  15392. /**
  15393. * Sets the length in pixels of the blur sample region
  15394. */
  15395. /**
  15396. * Gets the length in pixels of the blur sample region
  15397. */
  15398. kernel: number;
  15399. /**
  15400. * Sets wether or not the blur needs to unpack/repack floats
  15401. */
  15402. /**
  15403. * Gets wether or not the blur is unpacking/repacking floats
  15404. */
  15405. packedFloat: boolean;
  15406. /**
  15407. * Creates a new instance BlurPostProcess
  15408. * @param name The name of the effect.
  15409. * @param direction The direction in which to blur the image.
  15410. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15411. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15412. * @param camera The camera to apply the render pass to.
  15413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15414. * @param engine The engine which the post process will be applied. (default: current engine)
  15415. * @param reusable If the post process can be reused on the same frame. (default: false)
  15416. * @param textureType Type of textures used when performing the post process. (default: 0)
  15417. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15418. */
  15419. constructor(name: string,
  15420. /** The direction in which to blur the image. */
  15421. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15422. /**
  15423. * Updates the effect with the current post process compile time values and recompiles the shader.
  15424. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15425. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15426. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15427. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15428. * @param onCompiled Called when the shader has been compiled.
  15429. * @param onError Called if there is an error when compiling a shader.
  15430. */
  15431. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15432. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15433. /**
  15434. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15435. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15436. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15437. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15438. * The gaps between physical kernels are compensated for in the weighting of the samples
  15439. * @param idealKernel Ideal blur kernel.
  15440. * @return Nearest best kernel.
  15441. */
  15442. protected _nearestBestKernel(idealKernel: number): number;
  15443. /**
  15444. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15445. * @param x The point on the Gaussian distribution to sample.
  15446. * @return the value of the Gaussian function at x.
  15447. */
  15448. protected _gaussianWeight(x: number): number;
  15449. /**
  15450. * Generates a string that can be used as a floating point number in GLSL.
  15451. * @param x Value to print.
  15452. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15453. * @return GLSL float string.
  15454. */
  15455. protected _glslFloat(x: number, decimalFigures?: number): string;
  15456. }
  15457. }
  15458. declare module BABYLON {
  15459. /**
  15460. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15461. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15462. * You can then easily use it as a reflectionTexture on a flat surface.
  15463. * In case the surface is not a plane, please consider relying on reflection probes.
  15464. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15465. */
  15466. export class MirrorTexture extends RenderTargetTexture {
  15467. private scene;
  15468. /**
  15469. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15470. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15471. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15472. */
  15473. mirrorPlane: Plane;
  15474. /**
  15475. * Define the blur ratio used to blur the reflection if needed.
  15476. */
  15477. blurRatio: number;
  15478. /**
  15479. * Define the adaptive blur kernel used to blur the reflection if needed.
  15480. * This will autocompute the closest best match for the `blurKernel`
  15481. */
  15482. adaptiveBlurKernel: number;
  15483. /**
  15484. * Define the blur kernel used to blur the reflection if needed.
  15485. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15486. */
  15487. blurKernel: number;
  15488. /**
  15489. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15490. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15491. */
  15492. blurKernelX: number;
  15493. /**
  15494. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15495. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15496. */
  15497. blurKernelY: number;
  15498. private _autoComputeBlurKernel;
  15499. protected _onRatioRescale(): void;
  15500. private _updateGammaSpace;
  15501. private _imageProcessingConfigChangeObserver;
  15502. private _transformMatrix;
  15503. private _mirrorMatrix;
  15504. private _savedViewMatrix;
  15505. private _blurX;
  15506. private _blurY;
  15507. private _adaptiveBlurKernel;
  15508. private _blurKernelX;
  15509. private _blurKernelY;
  15510. private _blurRatio;
  15511. /**
  15512. * Instantiates a Mirror Texture.
  15513. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15514. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15515. * You can then easily use it as a reflectionTexture on a flat surface.
  15516. * In case the surface is not a plane, please consider relying on reflection probes.
  15517. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15518. * @param name
  15519. * @param size
  15520. * @param scene
  15521. * @param generateMipMaps
  15522. * @param type
  15523. * @param samplingMode
  15524. * @param generateDepthBuffer
  15525. */
  15526. constructor(name: string, size: number | {
  15527. width: number;
  15528. height: number;
  15529. } | {
  15530. ratio: number;
  15531. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15532. private _preparePostProcesses;
  15533. /**
  15534. * Clone the mirror texture.
  15535. * @returns the cloned texture
  15536. */
  15537. clone(): MirrorTexture;
  15538. /**
  15539. * Serialize the texture to a JSON representation you could use in Parse later on
  15540. * @returns the serialized JSON representation
  15541. */
  15542. serialize(): any;
  15543. /**
  15544. * Dispose the texture and release its associated resources.
  15545. */
  15546. dispose(): void;
  15547. }
  15548. }
  15549. declare module BABYLON {
  15550. /**
  15551. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15552. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15553. */
  15554. export class Texture extends BaseTexture {
  15555. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15556. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15557. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15558. /** nearest is mag = nearest and min = nearest and mip = linear */
  15559. static readonly NEAREST_SAMPLINGMODE: number;
  15560. /** nearest is mag = nearest and min = nearest and mip = linear */
  15561. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15563. static readonly BILINEAR_SAMPLINGMODE: number;
  15564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15565. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15566. /** Trilinear is mag = linear and min = linear and mip = linear */
  15567. static readonly TRILINEAR_SAMPLINGMODE: number;
  15568. /** Trilinear is mag = linear and min = linear and mip = linear */
  15569. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15570. /** mag = nearest and min = nearest and mip = nearest */
  15571. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15572. /** mag = nearest and min = linear and mip = nearest */
  15573. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15574. /** mag = nearest and min = linear and mip = linear */
  15575. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15576. /** mag = nearest and min = linear and mip = none */
  15577. static readonly NEAREST_LINEAR: number;
  15578. /** mag = nearest and min = nearest and mip = none */
  15579. static readonly NEAREST_NEAREST: number;
  15580. /** mag = linear and min = nearest and mip = nearest */
  15581. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15582. /** mag = linear and min = nearest and mip = linear */
  15583. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15584. /** mag = linear and min = linear and mip = none */
  15585. static readonly LINEAR_LINEAR: number;
  15586. /** mag = linear and min = nearest and mip = none */
  15587. static readonly LINEAR_NEAREST: number;
  15588. /** Explicit coordinates mode */
  15589. static readonly EXPLICIT_MODE: number;
  15590. /** Spherical coordinates mode */
  15591. static readonly SPHERICAL_MODE: number;
  15592. /** Planar coordinates mode */
  15593. static readonly PLANAR_MODE: number;
  15594. /** Cubic coordinates mode */
  15595. static readonly CUBIC_MODE: number;
  15596. /** Projection coordinates mode */
  15597. static readonly PROJECTION_MODE: number;
  15598. /** Inverse Cubic coordinates mode */
  15599. static readonly SKYBOX_MODE: number;
  15600. /** Inverse Cubic coordinates mode */
  15601. static readonly INVCUBIC_MODE: number;
  15602. /** Equirectangular coordinates mode */
  15603. static readonly EQUIRECTANGULAR_MODE: number;
  15604. /** Equirectangular Fixed coordinates mode */
  15605. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15606. /** Equirectangular Fixed Mirrored coordinates mode */
  15607. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15608. /** Texture is not repeating outside of 0..1 UVs */
  15609. static readonly CLAMP_ADDRESSMODE: number;
  15610. /** Texture is repeating outside of 0..1 UVs */
  15611. static readonly WRAP_ADDRESSMODE: number;
  15612. /** Texture is repeating and mirrored */
  15613. static readonly MIRROR_ADDRESSMODE: number;
  15614. /**
  15615. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  15616. */
  15617. static UseSerializedUrlIfAny: boolean;
  15618. /**
  15619. * Define the url of the texture.
  15620. */
  15621. url: Nullable<string>;
  15622. /**
  15623. * Define an offset on the texture to offset the u coordinates of the UVs
  15624. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15625. */
  15626. uOffset: number;
  15627. /**
  15628. * Define an offset on the texture to offset the v coordinates of the UVs
  15629. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15630. */
  15631. vOffset: number;
  15632. /**
  15633. * Define an offset on the texture to scale the u coordinates of the UVs
  15634. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15635. */
  15636. uScale: number;
  15637. /**
  15638. * Define an offset on the texture to scale the v coordinates of the UVs
  15639. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15640. */
  15641. vScale: number;
  15642. /**
  15643. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15644. * @see http://doc.babylonjs.com/how_to/more_materials
  15645. */
  15646. uAng: number;
  15647. /**
  15648. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15649. * @see http://doc.babylonjs.com/how_to/more_materials
  15650. */
  15651. vAng: number;
  15652. /**
  15653. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15654. * @see http://doc.babylonjs.com/how_to/more_materials
  15655. */
  15656. wAng: number;
  15657. /**
  15658. * Defines the center of rotation (U)
  15659. */
  15660. uRotationCenter: number;
  15661. /**
  15662. * Defines the center of rotation (V)
  15663. */
  15664. vRotationCenter: number;
  15665. /**
  15666. * Defines the center of rotation (W)
  15667. */
  15668. wRotationCenter: number;
  15669. /**
  15670. * Are mip maps generated for this texture or not.
  15671. */
  15672. readonly noMipmap: boolean;
  15673. /**
  15674. * List of inspectable custom properties (used by the Inspector)
  15675. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15676. */
  15677. inspectableCustomProperties: Nullable<IInspectable[]>;
  15678. private _noMipmap;
  15679. /** @hidden */ private _invertY: boolean;
  15680. private _rowGenerationMatrix;
  15681. private _cachedTextureMatrix;
  15682. private _projectionModeMatrix;
  15683. private _t0;
  15684. private _t1;
  15685. private _t2;
  15686. private _cachedUOffset;
  15687. private _cachedVOffset;
  15688. private _cachedUScale;
  15689. private _cachedVScale;
  15690. private _cachedUAng;
  15691. private _cachedVAng;
  15692. private _cachedWAng;
  15693. private _cachedProjectionMatrixId;
  15694. private _cachedCoordinatesMode;
  15695. /** @hidden */
  15696. protected _initialSamplingMode: number;
  15697. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15698. private _deleteBuffer;
  15699. protected _format: Nullable<number>;
  15700. private _delayedOnLoad;
  15701. private _delayedOnError;
  15702. /**
  15703. * Observable triggered once the texture has been loaded.
  15704. */
  15705. onLoadObservable: Observable<Texture>;
  15706. protected _isBlocking: boolean;
  15707. /**
  15708. * Is the texture preventing material to render while loading.
  15709. * If false, a default texture will be used instead of the loading one during the preparation step.
  15710. */
  15711. isBlocking: boolean;
  15712. /**
  15713. * Get the current sampling mode associated with the texture.
  15714. */
  15715. readonly samplingMode: number;
  15716. /**
  15717. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15718. */
  15719. readonly invertY: boolean;
  15720. /**
  15721. * Instantiates a new texture.
  15722. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15723. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15724. * @param url define the url of the picture to load as a texture
  15725. * @param scene define the scene or engine the texture will belong to
  15726. * @param noMipmap define if the texture will require mip maps or not
  15727. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15728. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15729. * @param onLoad define a callback triggered when the texture has been loaded
  15730. * @param onError define a callback triggered when an error occurred during the loading session
  15731. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15732. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15733. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15734. */
  15735. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15736. /**
  15737. * Update the url (and optional buffer) of this texture if url was null during construction.
  15738. * @param url the url of the texture
  15739. * @param buffer the buffer of the texture (defaults to null)
  15740. * @param onLoad callback called when the texture is loaded (defaults to null)
  15741. */
  15742. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15743. /**
  15744. * Finish the loading sequence of a texture flagged as delayed load.
  15745. * @hidden
  15746. */
  15747. delayLoad(): void;
  15748. private _prepareRowForTextureGeneration;
  15749. /**
  15750. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15751. * @returns the transform matrix of the texture.
  15752. */
  15753. getTextureMatrix(): Matrix;
  15754. /**
  15755. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15756. * @returns The reflection texture transform
  15757. */
  15758. getReflectionTextureMatrix(): Matrix;
  15759. /**
  15760. * Clones the texture.
  15761. * @returns the cloned texture
  15762. */
  15763. clone(): Texture;
  15764. /**
  15765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15766. * @returns The JSON representation of the texture
  15767. */
  15768. serialize(): any;
  15769. /**
  15770. * Get the current class name of the texture useful for serialization or dynamic coding.
  15771. * @returns "Texture"
  15772. */
  15773. getClassName(): string;
  15774. /**
  15775. * Dispose the texture and release its associated resources.
  15776. */
  15777. dispose(): void;
  15778. /**
  15779. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15780. * @param parsedTexture Define the JSON representation of the texture
  15781. * @param scene Define the scene the parsed texture should be instantiated in
  15782. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15783. * @returns The parsed texture if successful
  15784. */
  15785. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15786. /**
  15787. * Creates a texture from its base 64 representation.
  15788. * @param data Define the base64 payload without the data: prefix
  15789. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15790. * @param scene Define the scene the texture should belong to
  15791. * @param noMipmap Forces the texture to not create mip map information if true
  15792. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15793. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15794. * @param onLoad define a callback triggered when the texture has been loaded
  15795. * @param onError define a callback triggered when an error occurred during the loading session
  15796. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15797. * @returns the created texture
  15798. */
  15799. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15800. /**
  15801. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15802. * @param data Define the base64 payload without the data: prefix
  15803. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15804. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15805. * @param scene Define the scene the texture should belong to
  15806. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15807. * @param noMipmap Forces the texture to not create mip map information if true
  15808. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15809. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15810. * @param onLoad define a callback triggered when the texture has been loaded
  15811. * @param onError define a callback triggered when an error occurred during the loading session
  15812. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15813. * @returns the created texture
  15814. */
  15815. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  15816. }
  15817. }
  15818. declare module BABYLON {
  15819. /**
  15820. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15821. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15822. */
  15823. export class PostProcessManager {
  15824. private _scene;
  15825. private _indexBuffer;
  15826. private _vertexBuffers;
  15827. /**
  15828. * Creates a new instance PostProcess
  15829. * @param scene The scene that the post process is associated with.
  15830. */
  15831. constructor(scene: Scene);
  15832. private _prepareBuffers;
  15833. private _buildIndexBuffer;
  15834. /**
  15835. * Rebuilds the vertex buffers of the manager.
  15836. * @hidden
  15837. */ private _rebuild(): void;
  15838. /**
  15839. * Prepares a frame to be run through a post process.
  15840. * @param sourceTexture The input texture to the post procesess. (default: null)
  15841. * @param postProcesses An array of post processes to be run. (default: null)
  15842. * @returns True if the post processes were able to be run.
  15843. * @hidden
  15844. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15845. /**
  15846. * Manually render a set of post processes to a texture.
  15847. * @param postProcesses An array of post processes to be run.
  15848. * @param targetTexture The target texture to render to.
  15849. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15850. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15851. * @param lodLevel defines which lod of the texture to render to
  15852. */
  15853. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15854. /**
  15855. * Finalize the result of the output of the postprocesses.
  15856. * @param doNotPresent If true the result will not be displayed to the screen.
  15857. * @param targetTexture The target texture to render to.
  15858. * @param faceIndex The index of the face to bind the target texture to.
  15859. * @param postProcesses The array of post processes to render.
  15860. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15861. * @hidden
  15862. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15863. /**
  15864. * Disposes of the post process manager.
  15865. */
  15866. dispose(): void;
  15867. }
  15868. }
  15869. declare module BABYLON {
  15870. /** Interface used by value gradients (color, factor, ...) */
  15871. export interface IValueGradient {
  15872. /**
  15873. * Gets or sets the gradient value (between 0 and 1)
  15874. */
  15875. gradient: number;
  15876. }
  15877. /** Class used to store color4 gradient */
  15878. export class ColorGradient implements IValueGradient {
  15879. /**
  15880. * Gets or sets the gradient value (between 0 and 1)
  15881. */
  15882. gradient: number;
  15883. /**
  15884. * Gets or sets first associated color
  15885. */
  15886. color1: Color4;
  15887. /**
  15888. * Gets or sets second associated color
  15889. */
  15890. color2?: Color4;
  15891. /**
  15892. * Will get a color picked randomly between color1 and color2.
  15893. * If color2 is undefined then color1 will be used
  15894. * @param result defines the target Color4 to store the result in
  15895. */
  15896. getColorToRef(result: Color4): void;
  15897. }
  15898. /** Class used to store color 3 gradient */
  15899. export class Color3Gradient implements IValueGradient {
  15900. /**
  15901. * Gets or sets the gradient value (between 0 and 1)
  15902. */
  15903. gradient: number;
  15904. /**
  15905. * Gets or sets the associated color
  15906. */
  15907. color: Color3;
  15908. }
  15909. /** Class used to store factor gradient */
  15910. export class FactorGradient implements IValueGradient {
  15911. /**
  15912. * Gets or sets the gradient value (between 0 and 1)
  15913. */
  15914. gradient: number;
  15915. /**
  15916. * Gets or sets first associated factor
  15917. */
  15918. factor1: number;
  15919. /**
  15920. * Gets or sets second associated factor
  15921. */
  15922. factor2?: number;
  15923. /**
  15924. * Will get a number picked randomly between factor1 and factor2.
  15925. * If factor2 is undefined then factor1 will be used
  15926. * @returns the picked number
  15927. */
  15928. getFactor(): number;
  15929. }
  15930. /**
  15931. * Helper used to simplify some generic gradient tasks
  15932. */
  15933. export class GradientHelper {
  15934. /**
  15935. * Gets the current gradient from an array of IValueGradient
  15936. * @param ratio defines the current ratio to get
  15937. * @param gradients defines the array of IValueGradient
  15938. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15939. */
  15940. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15941. }
  15942. }
  15943. declare module BABYLON {
  15944. interface AbstractScene {
  15945. /**
  15946. * The list of procedural textures added to the scene
  15947. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15948. */
  15949. proceduralTextures: Array<ProceduralTexture>;
  15950. }
  15951. /**
  15952. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15953. * in a given scene.
  15954. */
  15955. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15956. /**
  15957. * The component name helpfull to identify the component in the list of scene components.
  15958. */
  15959. readonly name: string;
  15960. /**
  15961. * The scene the component belongs to.
  15962. */
  15963. scene: Scene;
  15964. /**
  15965. * Creates a new instance of the component for the given scene
  15966. * @param scene Defines the scene to register the component in
  15967. */
  15968. constructor(scene: Scene);
  15969. /**
  15970. * Registers the component in a given scene
  15971. */
  15972. register(): void;
  15973. /**
  15974. * Rebuilds the elements related to this component in case of
  15975. * context lost for instance.
  15976. */
  15977. rebuild(): void;
  15978. /**
  15979. * Disposes the component and the associated ressources.
  15980. */
  15981. dispose(): void;
  15982. private _beforeClear;
  15983. }
  15984. }
  15985. declare module BABYLON {
  15986. interface Engine {
  15987. /**
  15988. * Creates a new render target cube texture
  15989. * @param size defines the size of the texture
  15990. * @param options defines the options used to create the texture
  15991. * @returns a new render target cube texture stored in an InternalTexture
  15992. */
  15993. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15994. }
  15995. }
  15996. declare module BABYLON {
  15997. /** @hidden */
  15998. export var proceduralVertexShader: {
  15999. name: string;
  16000. shader: string;
  16001. };
  16002. }
  16003. declare module BABYLON {
  16004. /**
  16005. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16006. * This is the base class of any Procedural texture and contains most of the shareable code.
  16007. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16008. */
  16009. export class ProceduralTexture extends Texture {
  16010. isCube: boolean;
  16011. /**
  16012. * Define if the texture is enabled or not (disabled texture will not render)
  16013. */
  16014. isEnabled: boolean;
  16015. /**
  16016. * Define if the texture must be cleared before rendering (default is true)
  16017. */
  16018. autoClear: boolean;
  16019. /**
  16020. * Callback called when the texture is generated
  16021. */
  16022. onGenerated: () => void;
  16023. /**
  16024. * Event raised when the texture is generated
  16025. */
  16026. onGeneratedObservable: Observable<ProceduralTexture>;
  16027. /** @hidden */ private _generateMipMaps: boolean;
  16028. /** @hidden **/ private _effect: Effect;
  16029. /** @hidden */ private _textures: {
  16030. [key: string]: Texture;
  16031. };
  16032. private _size;
  16033. private _currentRefreshId;
  16034. private _refreshRate;
  16035. private _vertexBuffers;
  16036. private _indexBuffer;
  16037. private _uniforms;
  16038. private _samplers;
  16039. private _fragment;
  16040. private _floats;
  16041. private _ints;
  16042. private _floatsArrays;
  16043. private _colors3;
  16044. private _colors4;
  16045. private _vectors2;
  16046. private _vectors3;
  16047. private _matrices;
  16048. private _fallbackTexture;
  16049. private _fallbackTextureUsed;
  16050. private _engine;
  16051. private _cachedDefines;
  16052. private _contentUpdateId;
  16053. private _contentData;
  16054. /**
  16055. * Instantiates a new procedural texture.
  16056. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16057. * This is the base class of any Procedural texture and contains most of the shareable code.
  16058. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16059. * @param name Define the name of the texture
  16060. * @param size Define the size of the texture to create
  16061. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16062. * @param scene Define the scene the texture belongs to
  16063. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16064. * @param generateMipMaps Define if the texture should creates mip maps or not
  16065. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16066. */
  16067. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16068. /**
  16069. * The effect that is created when initializing the post process.
  16070. * @returns The created effect corresponding the the postprocess.
  16071. */
  16072. getEffect(): Effect;
  16073. /**
  16074. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16075. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16076. */
  16077. getContent(): Nullable<ArrayBufferView>;
  16078. private _createIndexBuffer;
  16079. /** @hidden */ private _rebuild(): void;
  16080. /**
  16081. * Resets the texture in order to recreate its associated resources.
  16082. * This can be called in case of context loss
  16083. */
  16084. reset(): void;
  16085. protected _getDefines(): string;
  16086. /**
  16087. * Is the texture ready to be used ? (rendered at least once)
  16088. * @returns true if ready, otherwise, false.
  16089. */
  16090. isReady(): boolean;
  16091. /**
  16092. * Resets the refresh counter of the texture and start bak from scratch.
  16093. * Could be useful to regenerate the texture if it is setup to render only once.
  16094. */
  16095. resetRefreshCounter(): void;
  16096. /**
  16097. * Set the fragment shader to use in order to render the texture.
  16098. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16099. */
  16100. setFragment(fragment: any): void;
  16101. /**
  16102. * Define the refresh rate of the texture or the rendering frequency.
  16103. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16104. */
  16105. refreshRate: number;
  16106. /** @hidden */ private _shouldRender(): boolean;
  16107. /**
  16108. * Get the size the texture is rendering at.
  16109. * @returns the size (texture is always squared)
  16110. */
  16111. getRenderSize(): number;
  16112. /**
  16113. * Resize the texture to new value.
  16114. * @param size Define the new size the texture should have
  16115. * @param generateMipMaps Define whether the new texture should create mip maps
  16116. */
  16117. resize(size: number, generateMipMaps: boolean): void;
  16118. private _checkUniform;
  16119. /**
  16120. * Set a texture in the shader program used to render.
  16121. * @param name Define the name of the uniform samplers as defined in the shader
  16122. * @param texture Define the texture to bind to this sampler
  16123. * @return the texture itself allowing "fluent" like uniform updates
  16124. */
  16125. setTexture(name: string, texture: Texture): ProceduralTexture;
  16126. /**
  16127. * Set a float in the shader.
  16128. * @param name Define the name of the uniform as defined in the shader
  16129. * @param value Define the value to give to the uniform
  16130. * @return the texture itself allowing "fluent" like uniform updates
  16131. */
  16132. setFloat(name: string, value: number): ProceduralTexture;
  16133. /**
  16134. * Set a int in the shader.
  16135. * @param name Define the name of the uniform as defined in the shader
  16136. * @param value Define the value to give to the uniform
  16137. * @return the texture itself allowing "fluent" like uniform updates
  16138. */
  16139. setInt(name: string, value: number): ProceduralTexture;
  16140. /**
  16141. * Set an array of floats in the shader.
  16142. * @param name Define the name of the uniform as defined in the shader
  16143. * @param value Define the value to give to the uniform
  16144. * @return the texture itself allowing "fluent" like uniform updates
  16145. */
  16146. setFloats(name: string, value: number[]): ProceduralTexture;
  16147. /**
  16148. * Set a vec3 in the shader from a Color3.
  16149. * @param name Define the name of the uniform as defined in the shader
  16150. * @param value Define the value to give to the uniform
  16151. * @return the texture itself allowing "fluent" like uniform updates
  16152. */
  16153. setColor3(name: string, value: Color3): ProceduralTexture;
  16154. /**
  16155. * Set a vec4 in the shader from a Color4.
  16156. * @param name Define the name of the uniform as defined in the shader
  16157. * @param value Define the value to give to the uniform
  16158. * @return the texture itself allowing "fluent" like uniform updates
  16159. */
  16160. setColor4(name: string, value: Color4): ProceduralTexture;
  16161. /**
  16162. * Set a vec2 in the shader from a Vector2.
  16163. * @param name Define the name of the uniform as defined in the shader
  16164. * @param value Define the value to give to the uniform
  16165. * @return the texture itself allowing "fluent" like uniform updates
  16166. */
  16167. setVector2(name: string, value: Vector2): ProceduralTexture;
  16168. /**
  16169. * Set a vec3 in the shader from a Vector3.
  16170. * @param name Define the name of the uniform as defined in the shader
  16171. * @param value Define the value to give to the uniform
  16172. * @return the texture itself allowing "fluent" like uniform updates
  16173. */
  16174. setVector3(name: string, value: Vector3): ProceduralTexture;
  16175. /**
  16176. * Set a mat4 in the shader from a MAtrix.
  16177. * @param name Define the name of the uniform as defined in the shader
  16178. * @param value Define the value to give to the uniform
  16179. * @return the texture itself allowing "fluent" like uniform updates
  16180. */
  16181. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16182. /**
  16183. * Render the texture to its associated render target.
  16184. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16185. */
  16186. render(useCameraPostProcess?: boolean): void;
  16187. /**
  16188. * Clone the texture.
  16189. * @returns the cloned texture
  16190. */
  16191. clone(): ProceduralTexture;
  16192. /**
  16193. * Dispose the texture and release its asoociated resources.
  16194. */
  16195. dispose(): void;
  16196. }
  16197. }
  16198. declare module BABYLON {
  16199. /**
  16200. * This represents the base class for particle system in Babylon.
  16201. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16202. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16203. * @example https://doc.babylonjs.com/babylon101/particles
  16204. */
  16205. export class BaseParticleSystem {
  16206. /**
  16207. * Source color is added to the destination color without alpha affecting the result
  16208. */
  16209. static BLENDMODE_ONEONE: number;
  16210. /**
  16211. * Blend current color and particle color using particle’s alpha
  16212. */
  16213. static BLENDMODE_STANDARD: number;
  16214. /**
  16215. * Add current color and particle color multiplied by particle’s alpha
  16216. */
  16217. static BLENDMODE_ADD: number;
  16218. /**
  16219. * Multiply current color with particle color
  16220. */
  16221. static BLENDMODE_MULTIPLY: number;
  16222. /**
  16223. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16224. */
  16225. static BLENDMODE_MULTIPLYADD: number;
  16226. /**
  16227. * List of animations used by the particle system.
  16228. */
  16229. animations: Animation[];
  16230. /**
  16231. * The id of the Particle system.
  16232. */
  16233. id: string;
  16234. /**
  16235. * The friendly name of the Particle system.
  16236. */
  16237. name: string;
  16238. /**
  16239. * The rendering group used by the Particle system to chose when to render.
  16240. */
  16241. renderingGroupId: number;
  16242. /**
  16243. * The emitter represents the Mesh or position we are attaching the particle system to.
  16244. */
  16245. emitter: Nullable<AbstractMesh | Vector3>;
  16246. /**
  16247. * The maximum number of particles to emit per frame
  16248. */
  16249. emitRate: number;
  16250. /**
  16251. * If you want to launch only a few particles at once, that can be done, as well.
  16252. */
  16253. manualEmitCount: number;
  16254. /**
  16255. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16256. */
  16257. updateSpeed: number;
  16258. /**
  16259. * The amount of time the particle system is running (depends of the overall update speed).
  16260. */
  16261. targetStopDuration: number;
  16262. /**
  16263. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16264. */
  16265. disposeOnStop: boolean;
  16266. /**
  16267. * Minimum power of emitting particles.
  16268. */
  16269. minEmitPower: number;
  16270. /**
  16271. * Maximum power of emitting particles.
  16272. */
  16273. maxEmitPower: number;
  16274. /**
  16275. * Minimum life time of emitting particles.
  16276. */
  16277. minLifeTime: number;
  16278. /**
  16279. * Maximum life time of emitting particles.
  16280. */
  16281. maxLifeTime: number;
  16282. /**
  16283. * Minimum Size of emitting particles.
  16284. */
  16285. minSize: number;
  16286. /**
  16287. * Maximum Size of emitting particles.
  16288. */
  16289. maxSize: number;
  16290. /**
  16291. * Minimum scale of emitting particles on X axis.
  16292. */
  16293. minScaleX: number;
  16294. /**
  16295. * Maximum scale of emitting particles on X axis.
  16296. */
  16297. maxScaleX: number;
  16298. /**
  16299. * Minimum scale of emitting particles on Y axis.
  16300. */
  16301. minScaleY: number;
  16302. /**
  16303. * Maximum scale of emitting particles on Y axis.
  16304. */
  16305. maxScaleY: number;
  16306. /**
  16307. * Gets or sets the minimal initial rotation in radians.
  16308. */
  16309. minInitialRotation: number;
  16310. /**
  16311. * Gets or sets the maximal initial rotation in radians.
  16312. */
  16313. maxInitialRotation: number;
  16314. /**
  16315. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16316. */
  16317. minAngularSpeed: number;
  16318. /**
  16319. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16320. */
  16321. maxAngularSpeed: number;
  16322. /**
  16323. * The texture used to render each particle. (this can be a spritesheet)
  16324. */
  16325. particleTexture: Nullable<Texture>;
  16326. /**
  16327. * The layer mask we are rendering the particles through.
  16328. */
  16329. layerMask: number;
  16330. /**
  16331. * This can help using your own shader to render the particle system.
  16332. * The according effect will be created
  16333. */
  16334. customShader: any;
  16335. /**
  16336. * By default particle system starts as soon as they are created. This prevents the
  16337. * automatic start to happen and let you decide when to start emitting particles.
  16338. */
  16339. preventAutoStart: boolean;
  16340. private _noiseTexture;
  16341. /**
  16342. * Gets or sets a texture used to add random noise to particle positions
  16343. */
  16344. noiseTexture: Nullable<ProceduralTexture>;
  16345. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16346. noiseStrength: Vector3;
  16347. /**
  16348. * Callback triggered when the particle animation is ending.
  16349. */
  16350. onAnimationEnd: Nullable<() => void>;
  16351. /**
  16352. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16353. */
  16354. blendMode: number;
  16355. /**
  16356. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16357. * to override the particles.
  16358. */
  16359. forceDepthWrite: boolean;
  16360. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16361. preWarmCycles: number;
  16362. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16363. preWarmStepOffset: number;
  16364. /**
  16365. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16366. */
  16367. spriteCellChangeSpeed: number;
  16368. /**
  16369. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16370. */
  16371. startSpriteCellID: number;
  16372. /**
  16373. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16374. */
  16375. endSpriteCellID: number;
  16376. /**
  16377. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16378. */
  16379. spriteCellWidth: number;
  16380. /**
  16381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16382. */
  16383. spriteCellHeight: number;
  16384. /**
  16385. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16386. */
  16387. spriteRandomStartCell: boolean;
  16388. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16389. translationPivot: Vector2;
  16390. /** @hidden */
  16391. protected _isAnimationSheetEnabled: boolean;
  16392. /**
  16393. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16394. */
  16395. beginAnimationOnStart: boolean;
  16396. /**
  16397. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16398. */
  16399. beginAnimationFrom: number;
  16400. /**
  16401. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16402. */
  16403. beginAnimationTo: number;
  16404. /**
  16405. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16406. */
  16407. beginAnimationLoop: boolean;
  16408. /**
  16409. * Gets or sets a world offset applied to all particles
  16410. */
  16411. worldOffset: Vector3;
  16412. /**
  16413. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16414. */
  16415. isAnimationSheetEnabled: boolean;
  16416. /**
  16417. * Get hosting scene
  16418. * @returns the scene
  16419. */
  16420. getScene(): Scene;
  16421. /**
  16422. * You can use gravity if you want to give an orientation to your particles.
  16423. */
  16424. gravity: Vector3;
  16425. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16426. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16427. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16428. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16429. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16430. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16431. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16432. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16433. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16434. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16435. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16436. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16437. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16438. /**
  16439. * Defines the delay in milliseconds before starting the system (0 by default)
  16440. */
  16441. startDelay: number;
  16442. /**
  16443. * Gets the current list of drag gradients.
  16444. * You must use addDragGradient and removeDragGradient to udpate this list
  16445. * @returns the list of drag gradients
  16446. */
  16447. getDragGradients(): Nullable<Array<FactorGradient>>;
  16448. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16449. limitVelocityDamping: number;
  16450. /**
  16451. * Gets the current list of limit velocity gradients.
  16452. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16453. * @returns the list of limit velocity gradients
  16454. */
  16455. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16456. /**
  16457. * Gets the current list of color gradients.
  16458. * You must use addColorGradient and removeColorGradient to udpate this list
  16459. * @returns the list of color gradients
  16460. */
  16461. getColorGradients(): Nullable<Array<ColorGradient>>;
  16462. /**
  16463. * Gets the current list of size gradients.
  16464. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16465. * @returns the list of size gradients
  16466. */
  16467. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16468. /**
  16469. * Gets the current list of color remap gradients.
  16470. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16471. * @returns the list of color remap gradients
  16472. */
  16473. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16474. /**
  16475. * Gets the current list of alpha remap gradients.
  16476. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16477. * @returns the list of alpha remap gradients
  16478. */
  16479. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of life time gradients.
  16482. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16483. * @returns the list of life time gradients
  16484. */
  16485. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Gets the current list of angular speed gradients.
  16488. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16489. * @returns the list of angular speed gradients
  16490. */
  16491. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16492. /**
  16493. * Gets the current list of velocity gradients.
  16494. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16495. * @returns the list of velocity gradients
  16496. */
  16497. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16498. /**
  16499. * Gets the current list of start size gradients.
  16500. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16501. * @returns the list of start size gradients
  16502. */
  16503. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Gets the current list of emit rate gradients.
  16506. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16507. * @returns the list of emit rate gradients
  16508. */
  16509. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16510. /**
  16511. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16512. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16513. */
  16514. direction1: Vector3;
  16515. /**
  16516. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16517. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16518. */
  16519. direction2: Vector3;
  16520. /**
  16521. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16522. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16523. */
  16524. minEmitBox: Vector3;
  16525. /**
  16526. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16527. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16528. */
  16529. maxEmitBox: Vector3;
  16530. /**
  16531. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16532. */
  16533. color1: Color4;
  16534. /**
  16535. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16536. */
  16537. color2: Color4;
  16538. /**
  16539. * Color the particle will have at the end of its lifetime
  16540. */
  16541. colorDead: Color4;
  16542. /**
  16543. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16544. */
  16545. textureMask: Color4;
  16546. /**
  16547. * The particle emitter type defines the emitter used by the particle system.
  16548. * It can be for example box, sphere, or cone...
  16549. */
  16550. particleEmitterType: IParticleEmitterType;
  16551. /** @hidden */ private _isSubEmitter: boolean;
  16552. /**
  16553. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16554. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16555. */
  16556. billboardMode: number;
  16557. protected _isBillboardBased: boolean;
  16558. /**
  16559. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16560. */
  16561. isBillboardBased: boolean;
  16562. /**
  16563. * The scene the particle system belongs to.
  16564. */
  16565. protected _scene: Scene;
  16566. /**
  16567. * Local cache of defines for image processing.
  16568. */
  16569. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16570. /**
  16571. * Default configuration related to image processing available in the standard Material.
  16572. */
  16573. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16574. /**
  16575. * Gets the image processing configuration used either in this material.
  16576. */
  16577. /**
  16578. * Sets the Default image processing configuration used either in the this material.
  16579. *
  16580. * If sets to null, the scene one is in use.
  16581. */
  16582. imageProcessingConfiguration: ImageProcessingConfiguration;
  16583. /**
  16584. * Attaches a new image processing configuration to the Standard Material.
  16585. * @param configuration
  16586. */
  16587. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16588. /** @hidden */
  16589. protected _reset(): void;
  16590. /** @hidden */
  16591. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16592. /**
  16593. * Instantiates a particle system.
  16594. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16595. * @param name The name of the particle system
  16596. */
  16597. constructor(name: string);
  16598. /**
  16599. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16602. * @returns the emitter
  16603. */
  16604. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16605. /**
  16606. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16607. * @param radius The radius of the hemisphere to emit from
  16608. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16609. * @returns the emitter
  16610. */
  16611. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16612. /**
  16613. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16614. * @param radius The radius of the sphere to emit from
  16615. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16616. * @returns the emitter
  16617. */
  16618. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16619. /**
  16620. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16621. * @param radius The radius of the sphere to emit from
  16622. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16623. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16624. * @returns the emitter
  16625. */
  16626. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16627. /**
  16628. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16629. * @param radius The radius of the emission cylinder
  16630. * @param height The height of the emission cylinder
  16631. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16632. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16633. * @returns the emitter
  16634. */
  16635. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16636. /**
  16637. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16638. * @param radius The radius of the cylinder to emit from
  16639. * @param height The height of the emission cylinder
  16640. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16643. * @returns the emitter
  16644. */
  16645. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16646. /**
  16647. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16648. * @param radius The radius of the cone to emit from
  16649. * @param angle The base angle of the cone
  16650. * @returns the emitter
  16651. */
  16652. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16653. /**
  16654. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16657. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16658. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16659. * @returns the emitter
  16660. */
  16661. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16662. }
  16663. }
  16664. declare module BABYLON {
  16665. /**
  16666. * Type of sub emitter
  16667. */
  16668. export enum SubEmitterType {
  16669. /**
  16670. * Attached to the particle over it's lifetime
  16671. */
  16672. ATTACHED = 0,
  16673. /**
  16674. * Created when the particle dies
  16675. */
  16676. END = 1
  16677. }
  16678. /**
  16679. * Sub emitter class used to emit particles from an existing particle
  16680. */
  16681. export class SubEmitter {
  16682. /**
  16683. * the particle system to be used by the sub emitter
  16684. */
  16685. particleSystem: ParticleSystem;
  16686. /**
  16687. * Type of the submitter (Default: END)
  16688. */
  16689. type: SubEmitterType;
  16690. /**
  16691. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  16692. * Note: This only is supported when using an emitter of type Mesh
  16693. */
  16694. inheritDirection: boolean;
  16695. /**
  16696. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16697. */
  16698. inheritedVelocityAmount: number;
  16699. /**
  16700. * Creates a sub emitter
  16701. * @param particleSystem the particle system to be used by the sub emitter
  16702. */
  16703. constructor(
  16704. /**
  16705. * the particle system to be used by the sub emitter
  16706. */
  16707. particleSystem: ParticleSystem);
  16708. /**
  16709. * Clones the sub emitter
  16710. * @returns the cloned sub emitter
  16711. */
  16712. clone(): SubEmitter;
  16713. /**
  16714. * Serialize current object to a JSON object
  16715. * @returns the serialized object
  16716. */
  16717. serialize(): any;
  16718. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16719. /**
  16720. * Creates a new SubEmitter from a serialized JSON version
  16721. * @param serializationObject defines the JSON object to read from
  16722. * @param scene defines the hosting scene
  16723. * @param rootUrl defines the rootUrl for data loading
  16724. * @returns a new SubEmitter
  16725. */
  16726. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16727. /** Release associated resources */
  16728. dispose(): void;
  16729. }
  16730. }
  16731. declare module BABYLON {
  16732. /** @hidden */
  16733. export var clipPlaneFragmentDeclaration: {
  16734. name: string;
  16735. shader: string;
  16736. };
  16737. }
  16738. declare module BABYLON {
  16739. /** @hidden */
  16740. export var imageProcessingDeclaration: {
  16741. name: string;
  16742. shader: string;
  16743. };
  16744. }
  16745. declare module BABYLON {
  16746. /** @hidden */
  16747. export var imageProcessingFunctions: {
  16748. name: string;
  16749. shader: string;
  16750. };
  16751. }
  16752. declare module BABYLON {
  16753. /** @hidden */
  16754. export var clipPlaneFragment: {
  16755. name: string;
  16756. shader: string;
  16757. };
  16758. }
  16759. declare module BABYLON {
  16760. /** @hidden */
  16761. export var particlesPixelShader: {
  16762. name: string;
  16763. shader: string;
  16764. };
  16765. }
  16766. declare module BABYLON {
  16767. /** @hidden */
  16768. export var clipPlaneVertexDeclaration: {
  16769. name: string;
  16770. shader: string;
  16771. };
  16772. }
  16773. declare module BABYLON {
  16774. /** @hidden */
  16775. export var clipPlaneVertex: {
  16776. name: string;
  16777. shader: string;
  16778. };
  16779. }
  16780. declare module BABYLON {
  16781. /** @hidden */
  16782. export var particlesVertexShader: {
  16783. name: string;
  16784. shader: string;
  16785. };
  16786. }
  16787. declare module BABYLON {
  16788. /**
  16789. * This represents a particle system in Babylon.
  16790. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16792. * @example https://doc.babylonjs.com/babylon101/particles
  16793. */
  16794. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16795. /**
  16796. * Billboard mode will only apply to Y axis
  16797. */
  16798. static readonly BILLBOARDMODE_Y: number;
  16799. /**
  16800. * Billboard mode will apply to all axes
  16801. */
  16802. static readonly BILLBOARDMODE_ALL: number;
  16803. /**
  16804. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16805. */
  16806. static readonly BILLBOARDMODE_STRETCHED: number;
  16807. /**
  16808. * This function can be defined to provide custom update for active particles.
  16809. * This function will be called instead of regular update (age, position, color, etc.).
  16810. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16811. */
  16812. updateFunction: (particles: Particle[]) => void;
  16813. private _emitterWorldMatrix;
  16814. /**
  16815. * This function can be defined to specify initial direction for every new particle.
  16816. * It by default use the emitterType defined function
  16817. */
  16818. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16819. /**
  16820. * This function can be defined to specify initial position for every new particle.
  16821. * It by default use the emitterType defined function
  16822. */
  16823. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16824. /**
  16825. * @hidden
  16826. */ private _inheritedVelocityOffset: Vector3;
  16827. /**
  16828. * An event triggered when the system is disposed
  16829. */
  16830. onDisposeObservable: Observable<ParticleSystem>;
  16831. private _onDisposeObserver;
  16832. /**
  16833. * Sets a callback that will be triggered when the system is disposed
  16834. */
  16835. onDispose: () => void;
  16836. private _particles;
  16837. private _epsilon;
  16838. private _capacity;
  16839. private _stockParticles;
  16840. private _newPartsExcess;
  16841. private _vertexData;
  16842. private _vertexBuffer;
  16843. private _vertexBuffers;
  16844. private _spriteBuffer;
  16845. private _indexBuffer;
  16846. private _effect;
  16847. private _customEffect;
  16848. private _cachedDefines;
  16849. private _scaledColorStep;
  16850. private _colorDiff;
  16851. private _scaledDirection;
  16852. private _scaledGravity;
  16853. private _currentRenderId;
  16854. private _alive;
  16855. private _useInstancing;
  16856. private _started;
  16857. private _stopped;
  16858. private _actualFrame;
  16859. private _scaledUpdateSpeed;
  16860. private _vertexBufferSize;
  16861. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16862. /** @hidden */ private _currentEmitRate1: number;
  16863. /** @hidden */ private _currentEmitRate2: number;
  16864. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16865. /** @hidden */ private _currentStartSize1: number;
  16866. /** @hidden */ private _currentStartSize2: number;
  16867. private readonly _rawTextureWidth;
  16868. private _rampGradientsTexture;
  16869. private _useRampGradients;
  16870. /** Gets or sets a boolean indicating that ramp gradients must be used
  16871. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16872. */
  16873. useRampGradients: boolean;
  16874. /**
  16875. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  16876. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  16877. */
  16878. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16879. private _subEmitters;
  16880. /**
  16881. * @hidden
  16882. * If the particle systems emitter should be disposed when the particle system is disposed
  16883. */ private _disposeEmitterOnDispose: boolean;
  16884. /**
  16885. * The current active Sub-systems, this property is used by the root particle system only.
  16886. */
  16887. activeSubSystems: Array<ParticleSystem>;
  16888. private _rootParticleSystem;
  16889. /**
  16890. * Gets the current list of active particles
  16891. */
  16892. readonly particles: Particle[];
  16893. /**
  16894. * Returns the string "ParticleSystem"
  16895. * @returns a string containing the class name
  16896. */
  16897. getClassName(): string;
  16898. /**
  16899. * Instantiates a particle system.
  16900. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16901. * @param name The name of the particle system
  16902. * @param capacity The max number of particles alive at the same time
  16903. * @param scene The scene the particle system belongs to
  16904. * @param customEffect a custom effect used to change the way particles are rendered by default
  16905. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16906. * @param epsilon Offset used to render the particles
  16907. */
  16908. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16909. private _addFactorGradient;
  16910. private _removeFactorGradient;
  16911. /**
  16912. * Adds a new life time gradient
  16913. * @param gradient defines the gradient to use (between 0 and 1)
  16914. * @param factor defines the life time factor to affect to the specified gradient
  16915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16916. * @returns the current particle system
  16917. */
  16918. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16919. /**
  16920. * Remove a specific life time gradient
  16921. * @param gradient defines the gradient to remove
  16922. * @returns the current particle system
  16923. */
  16924. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16925. /**
  16926. * Adds a new size gradient
  16927. * @param gradient defines the gradient to use (between 0 and 1)
  16928. * @param factor defines the size factor to affect to the specified gradient
  16929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16930. * @returns the current particle system
  16931. */
  16932. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16933. /**
  16934. * Remove a specific size gradient
  16935. * @param gradient defines the gradient to remove
  16936. * @returns the current particle system
  16937. */
  16938. removeSizeGradient(gradient: number): IParticleSystem;
  16939. /**
  16940. * Adds a new color remap gradient
  16941. * @param gradient defines the gradient to use (between 0 and 1)
  16942. * @param min defines the color remap minimal range
  16943. * @param max defines the color remap maximal range
  16944. * @returns the current particle system
  16945. */
  16946. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16947. /**
  16948. * Remove a specific color remap gradient
  16949. * @param gradient defines the gradient to remove
  16950. * @returns the current particle system
  16951. */
  16952. removeColorRemapGradient(gradient: number): IParticleSystem;
  16953. /**
  16954. * Adds a new alpha remap gradient
  16955. * @param gradient defines the gradient to use (between 0 and 1)
  16956. * @param min defines the alpha remap minimal range
  16957. * @param max defines the alpha remap maximal range
  16958. * @returns the current particle system
  16959. */
  16960. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16961. /**
  16962. * Remove a specific alpha remap gradient
  16963. * @param gradient defines the gradient to remove
  16964. * @returns the current particle system
  16965. */
  16966. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16967. /**
  16968. * Adds a new angular speed gradient
  16969. * @param gradient defines the gradient to use (between 0 and 1)
  16970. * @param factor defines the angular speed to affect to the specified gradient
  16971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16972. * @returns the current particle system
  16973. */
  16974. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16975. /**
  16976. * Remove a specific angular speed gradient
  16977. * @param gradient defines the gradient to remove
  16978. * @returns the current particle system
  16979. */
  16980. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16981. /**
  16982. * Adds a new velocity gradient
  16983. * @param gradient defines the gradient to use (between 0 and 1)
  16984. * @param factor defines the velocity to affect to the specified gradient
  16985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16986. * @returns the current particle system
  16987. */
  16988. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16989. /**
  16990. * Remove a specific velocity gradient
  16991. * @param gradient defines the gradient to remove
  16992. * @returns the current particle system
  16993. */
  16994. removeVelocityGradient(gradient: number): IParticleSystem;
  16995. /**
  16996. * Adds a new limit velocity gradient
  16997. * @param gradient defines the gradient to use (between 0 and 1)
  16998. * @param factor defines the limit velocity value to affect to the specified gradient
  16999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17000. * @returns the current particle system
  17001. */
  17002. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17003. /**
  17004. * Remove a specific limit velocity gradient
  17005. * @param gradient defines the gradient to remove
  17006. * @returns the current particle system
  17007. */
  17008. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17009. /**
  17010. * Adds a new drag gradient
  17011. * @param gradient defines the gradient to use (between 0 and 1)
  17012. * @param factor defines the drag value to affect to the specified gradient
  17013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17014. * @returns the current particle system
  17015. */
  17016. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17017. /**
  17018. * Remove a specific drag gradient
  17019. * @param gradient defines the gradient to remove
  17020. * @returns the current particle system
  17021. */
  17022. removeDragGradient(gradient: number): IParticleSystem;
  17023. /**
  17024. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17025. * @param gradient defines the gradient to use (between 0 and 1)
  17026. * @param factor defines the emit rate value to affect to the specified gradient
  17027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17028. * @returns the current particle system
  17029. */
  17030. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17031. /**
  17032. * Remove a specific emit rate gradient
  17033. * @param gradient defines the gradient to remove
  17034. * @returns the current particle system
  17035. */
  17036. removeEmitRateGradient(gradient: number): IParticleSystem;
  17037. /**
  17038. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17039. * @param gradient defines the gradient to use (between 0 and 1)
  17040. * @param factor defines the start size value to affect to the specified gradient
  17041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17042. * @returns the current particle system
  17043. */
  17044. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17045. /**
  17046. * Remove a specific start size gradient
  17047. * @param gradient defines the gradient to remove
  17048. * @returns the current particle system
  17049. */
  17050. removeStartSizeGradient(gradient: number): IParticleSystem;
  17051. private _createRampGradientTexture;
  17052. /**
  17053. * Gets the current list of ramp gradients.
  17054. * You must use addRampGradient and removeRampGradient to udpate this list
  17055. * @returns the list of ramp gradients
  17056. */
  17057. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17058. /**
  17059. * Adds a new ramp gradient used to remap particle colors
  17060. * @param gradient defines the gradient to use (between 0 and 1)
  17061. * @param color defines the color to affect to the specified gradient
  17062. * @returns the current particle system
  17063. */
  17064. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17065. /**
  17066. * Remove a specific ramp gradient
  17067. * @param gradient defines the gradient to remove
  17068. * @returns the current particle system
  17069. */
  17070. removeRampGradient(gradient: number): ParticleSystem;
  17071. /**
  17072. * Adds a new color gradient
  17073. * @param gradient defines the gradient to use (between 0 and 1)
  17074. * @param color1 defines the color to affect to the specified gradient
  17075. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17076. * @returns this particle system
  17077. */
  17078. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17079. /**
  17080. * Remove a specific color gradient
  17081. * @param gradient defines the gradient to remove
  17082. * @returns this particle system
  17083. */
  17084. removeColorGradient(gradient: number): IParticleSystem;
  17085. private _fetchR;
  17086. protected _reset(): void;
  17087. private _resetEffect;
  17088. private _createVertexBuffers;
  17089. private _createIndexBuffer;
  17090. /**
  17091. * Gets the maximum number of particles active at the same time.
  17092. * @returns The max number of active particles.
  17093. */
  17094. getCapacity(): number;
  17095. /**
  17096. * Gets whether there are still active particles in the system.
  17097. * @returns True if it is alive, otherwise false.
  17098. */
  17099. isAlive(): boolean;
  17100. /**
  17101. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17102. * @returns True if it has been started, otherwise false.
  17103. */
  17104. isStarted(): boolean;
  17105. private _prepareSubEmitterInternalArray;
  17106. /**
  17107. * Starts the particle system and begins to emit
  17108. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17109. */
  17110. start(delay?: number): void;
  17111. /**
  17112. * Stops the particle system.
  17113. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17114. */
  17115. stop(stopSubEmitters?: boolean): void;
  17116. /**
  17117. * Remove all active particles
  17118. */
  17119. reset(): void;
  17120. /**
  17121. * @hidden (for internal use only)
  17122. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17123. /**
  17124. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17125. * Its lifetime will start back at 0.
  17126. */
  17127. recycleParticle: (particle: Particle) => void;
  17128. private _stopSubEmitters;
  17129. private _createParticle;
  17130. private _removeFromRoot;
  17131. private _emitFromParticle;
  17132. private _update;
  17133. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17134. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17135. /** @hidden */
  17136. private _getEffect;
  17137. /**
  17138. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17139. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17140. */
  17141. animate(preWarmOnly?: boolean): void;
  17142. private _appendParticleVertices;
  17143. /**
  17144. * Rebuilds the particle system.
  17145. */
  17146. rebuild(): void;
  17147. /**
  17148. * Is this system ready to be used/rendered
  17149. * @return true if the system is ready
  17150. */
  17151. isReady(): boolean;
  17152. private _render;
  17153. /**
  17154. * Renders the particle system in its current state.
  17155. * @returns the current number of particles
  17156. */
  17157. render(): number;
  17158. /**
  17159. * Disposes the particle system and free the associated resources
  17160. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17161. */
  17162. dispose(disposeTexture?: boolean): void;
  17163. /**
  17164. * Clones the particle system.
  17165. * @param name The name of the cloned object
  17166. * @param newEmitter The new emitter to use
  17167. * @returns the cloned particle system
  17168. */
  17169. clone(name: string, newEmitter: any): ParticleSystem;
  17170. /**
  17171. * Serializes the particle system to a JSON object.
  17172. * @returns the JSON object
  17173. */
  17174. serialize(): any;
  17175. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17176. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17177. /**
  17178. * Parses a JSON object to create a particle system.
  17179. * @param parsedParticleSystem The JSON object to parse
  17180. * @param scene The scene to create the particle system in
  17181. * @param rootUrl The root url to use to load external dependencies like texture
  17182. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17183. * @returns the Parsed particle system
  17184. */
  17185. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17186. }
  17187. }
  17188. declare module BABYLON {
  17189. /**
  17190. * A particle represents one of the element emitted by a particle system.
  17191. * This is mainly define by its coordinates, direction, velocity and age.
  17192. */
  17193. export class Particle {
  17194. /**
  17195. * The particle system the particle belongs to.
  17196. */
  17197. particleSystem: ParticleSystem;
  17198. private static _Count;
  17199. /**
  17200. * Unique ID of the particle
  17201. */
  17202. id: number;
  17203. /**
  17204. * The world position of the particle in the scene.
  17205. */
  17206. position: Vector3;
  17207. /**
  17208. * The world direction of the particle in the scene.
  17209. */
  17210. direction: Vector3;
  17211. /**
  17212. * The color of the particle.
  17213. */
  17214. color: Color4;
  17215. /**
  17216. * The color change of the particle per step.
  17217. */
  17218. colorStep: Color4;
  17219. /**
  17220. * Defines how long will the life of the particle be.
  17221. */
  17222. lifeTime: number;
  17223. /**
  17224. * The current age of the particle.
  17225. */
  17226. age: number;
  17227. /**
  17228. * The current size of the particle.
  17229. */
  17230. size: number;
  17231. /**
  17232. * The current scale of the particle.
  17233. */
  17234. scale: Vector2;
  17235. /**
  17236. * The current angle of the particle.
  17237. */
  17238. angle: number;
  17239. /**
  17240. * Defines how fast is the angle changing.
  17241. */
  17242. angularSpeed: number;
  17243. /**
  17244. * Defines the cell index used by the particle to be rendered from a sprite.
  17245. */
  17246. cellIndex: number;
  17247. /**
  17248. * The information required to support color remapping
  17249. */
  17250. remapData: Vector4;
  17251. /** @hidden */ private _randomCellOffset?: number;
  17252. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17253. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17254. /** @hidden */ private _initialStartSpriteCellID: number;
  17255. /** @hidden */ private _initialEndSpriteCellID: number;
  17256. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17257. /** @hidden */ private _currentColor1: Color4;
  17258. /** @hidden */ private _currentColor2: Color4;
  17259. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17260. /** @hidden */ private _currentSize1: number;
  17261. /** @hidden */ private _currentSize2: number;
  17262. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17263. /** @hidden */ private _currentAngularSpeed1: number;
  17264. /** @hidden */ private _currentAngularSpeed2: number;
  17265. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17266. /** @hidden */ private _currentVelocity1: number;
  17267. /** @hidden */ private _currentVelocity2: number;
  17268. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17269. /** @hidden */ private _currentLimitVelocity1: number;
  17270. /** @hidden */ private _currentLimitVelocity2: number;
  17271. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17272. /** @hidden */ private _currentDrag1: number;
  17273. /** @hidden */ private _currentDrag2: number;
  17274. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17275. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17276. /**
  17277. * Creates a new instance Particle
  17278. * @param particleSystem the particle system the particle belongs to
  17279. */
  17280. constructor(
  17281. /**
  17282. * The particle system the particle belongs to.
  17283. */
  17284. particleSystem: ParticleSystem);
  17285. private updateCellInfoFromSystem;
  17286. /**
  17287. * Defines how the sprite cell index is updated for the particle
  17288. */
  17289. updateCellIndex(): void;
  17290. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17291. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17292. /** @hidden */ private _reset(): void;
  17293. /**
  17294. * Copy the properties of particle to another one.
  17295. * @param other the particle to copy the information to.
  17296. */
  17297. copyTo(other: Particle): void;
  17298. }
  17299. }
  17300. declare module BABYLON {
  17301. /**
  17302. * Particle emitter represents a volume emitting particles.
  17303. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17304. */
  17305. export interface IParticleEmitterType {
  17306. /**
  17307. * Called by the particle System when the direction is computed for the created particle.
  17308. * @param worldMatrix is the world matrix of the particle system
  17309. * @param directionToUpdate is the direction vector to update with the result
  17310. * @param particle is the particle we are computed the direction for
  17311. */
  17312. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17313. /**
  17314. * Called by the particle System when the position is computed for the created particle.
  17315. * @param worldMatrix is the world matrix of the particle system
  17316. * @param positionToUpdate is the position vector to update with the result
  17317. * @param particle is the particle we are computed the position for
  17318. */
  17319. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17320. /**
  17321. * Clones the current emitter and returns a copy of it
  17322. * @returns the new emitter
  17323. */
  17324. clone(): IParticleEmitterType;
  17325. /**
  17326. * Called by the GPUParticleSystem to setup the update shader
  17327. * @param effect defines the update shader
  17328. */
  17329. applyToShader(effect: Effect): void;
  17330. /**
  17331. * Returns a string to use to update the GPU particles update shader
  17332. * @returns the effect defines string
  17333. */
  17334. getEffectDefines(): string;
  17335. /**
  17336. * Returns a string representing the class name
  17337. * @returns a string containing the class name
  17338. */
  17339. getClassName(): string;
  17340. /**
  17341. * Serializes the particle system to a JSON object.
  17342. * @returns the JSON object
  17343. */
  17344. serialize(): any;
  17345. /**
  17346. * Parse properties from a JSON object
  17347. * @param serializationObject defines the JSON object
  17348. */
  17349. parse(serializationObject: any): void;
  17350. }
  17351. }
  17352. declare module BABYLON {
  17353. /**
  17354. * Particle emitter emitting particles from the inside of a box.
  17355. * It emits the particles randomly between 2 given directions.
  17356. */
  17357. export class BoxParticleEmitter implements IParticleEmitterType {
  17358. /**
  17359. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17360. */
  17361. direction1: Vector3;
  17362. /**
  17363. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17364. */
  17365. direction2: Vector3;
  17366. /**
  17367. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17368. */
  17369. minEmitBox: Vector3;
  17370. /**
  17371. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17372. */
  17373. maxEmitBox: Vector3;
  17374. /**
  17375. * Creates a new instance BoxParticleEmitter
  17376. */
  17377. constructor();
  17378. /**
  17379. * Called by the particle System when the direction is computed for the created particle.
  17380. * @param worldMatrix is the world matrix of the particle system
  17381. * @param directionToUpdate is the direction vector to update with the result
  17382. * @param particle is the particle we are computed the direction for
  17383. */
  17384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17385. /**
  17386. * Called by the particle System when the position is computed for the created particle.
  17387. * @param worldMatrix is the world matrix of the particle system
  17388. * @param positionToUpdate is the position vector to update with the result
  17389. * @param particle is the particle we are computed the position for
  17390. */
  17391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17392. /**
  17393. * Clones the current emitter and returns a copy of it
  17394. * @returns the new emitter
  17395. */
  17396. clone(): BoxParticleEmitter;
  17397. /**
  17398. * Called by the GPUParticleSystem to setup the update shader
  17399. * @param effect defines the update shader
  17400. */
  17401. applyToShader(effect: Effect): void;
  17402. /**
  17403. * Returns a string to use to update the GPU particles update shader
  17404. * @returns a string containng the defines string
  17405. */
  17406. getEffectDefines(): string;
  17407. /**
  17408. * Returns the string "BoxParticleEmitter"
  17409. * @returns a string containing the class name
  17410. */
  17411. getClassName(): string;
  17412. /**
  17413. * Serializes the particle system to a JSON object.
  17414. * @returns the JSON object
  17415. */
  17416. serialize(): any;
  17417. /**
  17418. * Parse properties from a JSON object
  17419. * @param serializationObject defines the JSON object
  17420. */
  17421. parse(serializationObject: any): void;
  17422. }
  17423. }
  17424. declare module BABYLON {
  17425. /**
  17426. * Particle emitter emitting particles from the inside of a cone.
  17427. * It emits the particles alongside the cone volume from the base to the particle.
  17428. * The emission direction might be randomized.
  17429. */
  17430. export class ConeParticleEmitter implements IParticleEmitterType {
  17431. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17432. directionRandomizer: number;
  17433. private _radius;
  17434. private _angle;
  17435. private _height;
  17436. /**
  17437. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17438. */
  17439. radiusRange: number;
  17440. /**
  17441. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17442. */
  17443. heightRange: number;
  17444. /**
  17445. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17446. */
  17447. emitFromSpawnPointOnly: boolean;
  17448. /**
  17449. * Gets or sets the radius of the emission cone
  17450. */
  17451. radius: number;
  17452. /**
  17453. * Gets or sets the angle of the emission cone
  17454. */
  17455. angle: number;
  17456. private _buildHeight;
  17457. /**
  17458. * Creates a new instance ConeParticleEmitter
  17459. * @param radius the radius of the emission cone (1 by default)
  17460. * @param angle the cone base angle (PI by default)
  17461. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17462. */
  17463. constructor(radius?: number, angle?: number,
  17464. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17465. directionRandomizer?: number);
  17466. /**
  17467. * Called by the particle System when the direction is computed for the created particle.
  17468. * @param worldMatrix is the world matrix of the particle system
  17469. * @param directionToUpdate is the direction vector to update with the result
  17470. * @param particle is the particle we are computed the direction for
  17471. */
  17472. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17473. /**
  17474. * Called by the particle System when the position is computed for the created particle.
  17475. * @param worldMatrix is the world matrix of the particle system
  17476. * @param positionToUpdate is the position vector to update with the result
  17477. * @param particle is the particle we are computed the position for
  17478. */
  17479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17480. /**
  17481. * Clones the current emitter and returns a copy of it
  17482. * @returns the new emitter
  17483. */
  17484. clone(): ConeParticleEmitter;
  17485. /**
  17486. * Called by the GPUParticleSystem to setup the update shader
  17487. * @param effect defines the update shader
  17488. */
  17489. applyToShader(effect: Effect): void;
  17490. /**
  17491. * Returns a string to use to update the GPU particles update shader
  17492. * @returns a string containng the defines string
  17493. */
  17494. getEffectDefines(): string;
  17495. /**
  17496. * Returns the string "ConeParticleEmitter"
  17497. * @returns a string containing the class name
  17498. */
  17499. getClassName(): string;
  17500. /**
  17501. * Serializes the particle system to a JSON object.
  17502. * @returns the JSON object
  17503. */
  17504. serialize(): any;
  17505. /**
  17506. * Parse properties from a JSON object
  17507. * @param serializationObject defines the JSON object
  17508. */
  17509. parse(serializationObject: any): void;
  17510. }
  17511. }
  17512. declare module BABYLON {
  17513. /**
  17514. * Particle emitter emitting particles from the inside of a cylinder.
  17515. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17516. */
  17517. export class CylinderParticleEmitter implements IParticleEmitterType {
  17518. /**
  17519. * The radius of the emission cylinder.
  17520. */
  17521. radius: number;
  17522. /**
  17523. * The height of the emission cylinder.
  17524. */
  17525. height: number;
  17526. /**
  17527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17528. */
  17529. radiusRange: number;
  17530. /**
  17531. * How much to randomize the particle direction [0-1].
  17532. */
  17533. directionRandomizer: number;
  17534. /**
  17535. * Creates a new instance CylinderParticleEmitter
  17536. * @param radius the radius of the emission cylinder (1 by default)
  17537. * @param height the height of the emission cylinder (1 by default)
  17538. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17539. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17540. */
  17541. constructor(
  17542. /**
  17543. * The radius of the emission cylinder.
  17544. */
  17545. radius?: number,
  17546. /**
  17547. * The height of the emission cylinder.
  17548. */
  17549. height?: number,
  17550. /**
  17551. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17552. */
  17553. radiusRange?: number,
  17554. /**
  17555. * How much to randomize the particle direction [0-1].
  17556. */
  17557. directionRandomizer?: number);
  17558. /**
  17559. * Called by the particle System when the direction is computed for the created particle.
  17560. * @param worldMatrix is the world matrix of the particle system
  17561. * @param directionToUpdate is the direction vector to update with the result
  17562. * @param particle is the particle we are computed the direction for
  17563. */
  17564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17565. /**
  17566. * Called by the particle System when the position is computed for the created particle.
  17567. * @param worldMatrix is the world matrix of the particle system
  17568. * @param positionToUpdate is the position vector to update with the result
  17569. * @param particle is the particle we are computed the position for
  17570. */
  17571. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17572. /**
  17573. * Clones the current emitter and returns a copy of it
  17574. * @returns the new emitter
  17575. */
  17576. clone(): CylinderParticleEmitter;
  17577. /**
  17578. * Called by the GPUParticleSystem to setup the update shader
  17579. * @param effect defines the update shader
  17580. */
  17581. applyToShader(effect: Effect): void;
  17582. /**
  17583. * Returns a string to use to update the GPU particles update shader
  17584. * @returns a string containng the defines string
  17585. */
  17586. getEffectDefines(): string;
  17587. /**
  17588. * Returns the string "CylinderParticleEmitter"
  17589. * @returns a string containing the class name
  17590. */
  17591. getClassName(): string;
  17592. /**
  17593. * Serializes the particle system to a JSON object.
  17594. * @returns the JSON object
  17595. */
  17596. serialize(): any;
  17597. /**
  17598. * Parse properties from a JSON object
  17599. * @param serializationObject defines the JSON object
  17600. */
  17601. parse(serializationObject: any): void;
  17602. }
  17603. /**
  17604. * Particle emitter emitting particles from the inside of a cylinder.
  17605. * It emits the particles randomly between two vectors.
  17606. */
  17607. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17608. /**
  17609. * The min limit of the emission direction.
  17610. */
  17611. direction1: Vector3;
  17612. /**
  17613. * The max limit of the emission direction.
  17614. */
  17615. direction2: Vector3;
  17616. /**
  17617. * Creates a new instance CylinderDirectedParticleEmitter
  17618. * @param radius the radius of the emission cylinder (1 by default)
  17619. * @param height the height of the emission cylinder (1 by default)
  17620. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17621. * @param direction1 the min limit of the emission direction (up vector by default)
  17622. * @param direction2 the max limit of the emission direction (up vector by default)
  17623. */
  17624. constructor(radius?: number, height?: number, radiusRange?: number,
  17625. /**
  17626. * The min limit of the emission direction.
  17627. */
  17628. direction1?: Vector3,
  17629. /**
  17630. * The max limit of the emission direction.
  17631. */
  17632. direction2?: Vector3);
  17633. /**
  17634. * Called by the particle System when the direction is computed for the created particle.
  17635. * @param worldMatrix is the world matrix of the particle system
  17636. * @param directionToUpdate is the direction vector to update with the result
  17637. * @param particle is the particle we are computed the direction for
  17638. */
  17639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17640. /**
  17641. * Clones the current emitter and returns a copy of it
  17642. * @returns the new emitter
  17643. */
  17644. clone(): CylinderDirectedParticleEmitter;
  17645. /**
  17646. * Called by the GPUParticleSystem to setup the update shader
  17647. * @param effect defines the update shader
  17648. */
  17649. applyToShader(effect: Effect): void;
  17650. /**
  17651. * Returns a string to use to update the GPU particles update shader
  17652. * @returns a string containng the defines string
  17653. */
  17654. getEffectDefines(): string;
  17655. /**
  17656. * Returns the string "CylinderDirectedParticleEmitter"
  17657. * @returns a string containing the class name
  17658. */
  17659. getClassName(): string;
  17660. /**
  17661. * Serializes the particle system to a JSON object.
  17662. * @returns the JSON object
  17663. */
  17664. serialize(): any;
  17665. /**
  17666. * Parse properties from a JSON object
  17667. * @param serializationObject defines the JSON object
  17668. */
  17669. parse(serializationObject: any): void;
  17670. }
  17671. }
  17672. declare module BABYLON {
  17673. /**
  17674. * Particle emitter emitting particles from the inside of a hemisphere.
  17675. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17676. */
  17677. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17678. /**
  17679. * The radius of the emission hemisphere.
  17680. */
  17681. radius: number;
  17682. /**
  17683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17684. */
  17685. radiusRange: number;
  17686. /**
  17687. * How much to randomize the particle direction [0-1].
  17688. */
  17689. directionRandomizer: number;
  17690. /**
  17691. * Creates a new instance HemisphericParticleEmitter
  17692. * @param radius the radius of the emission hemisphere (1 by default)
  17693. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17694. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17695. */
  17696. constructor(
  17697. /**
  17698. * The radius of the emission hemisphere.
  17699. */
  17700. radius?: number,
  17701. /**
  17702. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17703. */
  17704. radiusRange?: number,
  17705. /**
  17706. * How much to randomize the particle direction [0-1].
  17707. */
  17708. directionRandomizer?: number);
  17709. /**
  17710. * Called by the particle System when the direction is computed for the created particle.
  17711. * @param worldMatrix is the world matrix of the particle system
  17712. * @param directionToUpdate is the direction vector to update with the result
  17713. * @param particle is the particle we are computed the direction for
  17714. */
  17715. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17716. /**
  17717. * Called by the particle System when the position is computed for the created particle.
  17718. * @param worldMatrix is the world matrix of the particle system
  17719. * @param positionToUpdate is the position vector to update with the result
  17720. * @param particle is the particle we are computed the position for
  17721. */
  17722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17723. /**
  17724. * Clones the current emitter and returns a copy of it
  17725. * @returns the new emitter
  17726. */
  17727. clone(): HemisphericParticleEmitter;
  17728. /**
  17729. * Called by the GPUParticleSystem to setup the update shader
  17730. * @param effect defines the update shader
  17731. */
  17732. applyToShader(effect: Effect): void;
  17733. /**
  17734. * Returns a string to use to update the GPU particles update shader
  17735. * @returns a string containng the defines string
  17736. */
  17737. getEffectDefines(): string;
  17738. /**
  17739. * Returns the string "HemisphericParticleEmitter"
  17740. * @returns a string containing the class name
  17741. */
  17742. getClassName(): string;
  17743. /**
  17744. * Serializes the particle system to a JSON object.
  17745. * @returns the JSON object
  17746. */
  17747. serialize(): any;
  17748. /**
  17749. * Parse properties from a JSON object
  17750. * @param serializationObject defines the JSON object
  17751. */
  17752. parse(serializationObject: any): void;
  17753. }
  17754. }
  17755. declare module BABYLON {
  17756. /**
  17757. * Particle emitter emitting particles from a point.
  17758. * It emits the particles randomly between 2 given directions.
  17759. */
  17760. export class PointParticleEmitter implements IParticleEmitterType {
  17761. /**
  17762. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17763. */
  17764. direction1: Vector3;
  17765. /**
  17766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17767. */
  17768. direction2: Vector3;
  17769. /**
  17770. * Creates a new instance PointParticleEmitter
  17771. */
  17772. constructor();
  17773. /**
  17774. * Called by the particle System when the direction is computed for the created particle.
  17775. * @param worldMatrix is the world matrix of the particle system
  17776. * @param directionToUpdate is the direction vector to update with the result
  17777. * @param particle is the particle we are computed the direction for
  17778. */
  17779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17780. /**
  17781. * Called by the particle System when the position is computed for the created particle.
  17782. * @param worldMatrix is the world matrix of the particle system
  17783. * @param positionToUpdate is the position vector to update with the result
  17784. * @param particle is the particle we are computed the position for
  17785. */
  17786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17787. /**
  17788. * Clones the current emitter and returns a copy of it
  17789. * @returns the new emitter
  17790. */
  17791. clone(): PointParticleEmitter;
  17792. /**
  17793. * Called by the GPUParticleSystem to setup the update shader
  17794. * @param effect defines the update shader
  17795. */
  17796. applyToShader(effect: Effect): void;
  17797. /**
  17798. * Returns a string to use to update the GPU particles update shader
  17799. * @returns a string containng the defines string
  17800. */
  17801. getEffectDefines(): string;
  17802. /**
  17803. * Returns the string "PointParticleEmitter"
  17804. * @returns a string containing the class name
  17805. */
  17806. getClassName(): string;
  17807. /**
  17808. * Serializes the particle system to a JSON object.
  17809. * @returns the JSON object
  17810. */
  17811. serialize(): any;
  17812. /**
  17813. * Parse properties from a JSON object
  17814. * @param serializationObject defines the JSON object
  17815. */
  17816. parse(serializationObject: any): void;
  17817. }
  17818. }
  17819. declare module BABYLON {
  17820. /**
  17821. * Particle emitter emitting particles from the inside of a sphere.
  17822. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17823. */
  17824. export class SphereParticleEmitter implements IParticleEmitterType {
  17825. /**
  17826. * The radius of the emission sphere.
  17827. */
  17828. radius: number;
  17829. /**
  17830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17831. */
  17832. radiusRange: number;
  17833. /**
  17834. * How much to randomize the particle direction [0-1].
  17835. */
  17836. directionRandomizer: number;
  17837. /**
  17838. * Creates a new instance SphereParticleEmitter
  17839. * @param radius the radius of the emission sphere (1 by default)
  17840. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17841. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17842. */
  17843. constructor(
  17844. /**
  17845. * The radius of the emission sphere.
  17846. */
  17847. radius?: number,
  17848. /**
  17849. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17850. */
  17851. radiusRange?: number,
  17852. /**
  17853. * How much to randomize the particle direction [0-1].
  17854. */
  17855. directionRandomizer?: number);
  17856. /**
  17857. * Called by the particle System when the direction is computed for the created particle.
  17858. * @param worldMatrix is the world matrix of the particle system
  17859. * @param directionToUpdate is the direction vector to update with the result
  17860. * @param particle is the particle we are computed the direction for
  17861. */
  17862. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17863. /**
  17864. * Called by the particle System when the position is computed for the created particle.
  17865. * @param worldMatrix is the world matrix of the particle system
  17866. * @param positionToUpdate is the position vector to update with the result
  17867. * @param particle is the particle we are computed the position for
  17868. */
  17869. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17870. /**
  17871. * Clones the current emitter and returns a copy of it
  17872. * @returns the new emitter
  17873. */
  17874. clone(): SphereParticleEmitter;
  17875. /**
  17876. * Called by the GPUParticleSystem to setup the update shader
  17877. * @param effect defines the update shader
  17878. */
  17879. applyToShader(effect: Effect): void;
  17880. /**
  17881. * Returns a string to use to update the GPU particles update shader
  17882. * @returns a string containng the defines string
  17883. */
  17884. getEffectDefines(): string;
  17885. /**
  17886. * Returns the string "SphereParticleEmitter"
  17887. * @returns a string containing the class name
  17888. */
  17889. getClassName(): string;
  17890. /**
  17891. * Serializes the particle system to a JSON object.
  17892. * @returns the JSON object
  17893. */
  17894. serialize(): any;
  17895. /**
  17896. * Parse properties from a JSON object
  17897. * @param serializationObject defines the JSON object
  17898. */
  17899. parse(serializationObject: any): void;
  17900. }
  17901. /**
  17902. * Particle emitter emitting particles from the inside of a sphere.
  17903. * It emits the particles randomly between two vectors.
  17904. */
  17905. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17906. /**
  17907. * The min limit of the emission direction.
  17908. */
  17909. direction1: Vector3;
  17910. /**
  17911. * The max limit of the emission direction.
  17912. */
  17913. direction2: Vector3;
  17914. /**
  17915. * Creates a new instance SphereDirectedParticleEmitter
  17916. * @param radius the radius of the emission sphere (1 by default)
  17917. * @param direction1 the min limit of the emission direction (up vector by default)
  17918. * @param direction2 the max limit of the emission direction (up vector by default)
  17919. */
  17920. constructor(radius?: number,
  17921. /**
  17922. * The min limit of the emission direction.
  17923. */
  17924. direction1?: Vector3,
  17925. /**
  17926. * The max limit of the emission direction.
  17927. */
  17928. direction2?: Vector3);
  17929. /**
  17930. * Called by the particle System when the direction is computed for the created particle.
  17931. * @param worldMatrix is the world matrix of the particle system
  17932. * @param directionToUpdate is the direction vector to update with the result
  17933. * @param particle is the particle we are computed the direction for
  17934. */
  17935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17936. /**
  17937. * Clones the current emitter and returns a copy of it
  17938. * @returns the new emitter
  17939. */
  17940. clone(): SphereDirectedParticleEmitter;
  17941. /**
  17942. * Called by the GPUParticleSystem to setup the update shader
  17943. * @param effect defines the update shader
  17944. */
  17945. applyToShader(effect: Effect): void;
  17946. /**
  17947. * Returns a string to use to update the GPU particles update shader
  17948. * @returns a string containng the defines string
  17949. */
  17950. getEffectDefines(): string;
  17951. /**
  17952. * Returns the string "SphereDirectedParticleEmitter"
  17953. * @returns a string containing the class name
  17954. */
  17955. getClassName(): string;
  17956. /**
  17957. * Serializes the particle system to a JSON object.
  17958. * @returns the JSON object
  17959. */
  17960. serialize(): any;
  17961. /**
  17962. * Parse properties from a JSON object
  17963. * @param serializationObject defines the JSON object
  17964. */
  17965. parse(serializationObject: any): void;
  17966. }
  17967. }
  17968. declare module BABYLON {
  17969. /**
  17970. * Interface representing a particle system in Babylon.js.
  17971. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17972. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17973. */
  17974. export interface IParticleSystem {
  17975. /**
  17976. * List of animations used by the particle system.
  17977. */
  17978. animations: Animation[];
  17979. /**
  17980. * The id of the Particle system.
  17981. */
  17982. id: string;
  17983. /**
  17984. * The name of the Particle system.
  17985. */
  17986. name: string;
  17987. /**
  17988. * The emitter represents the Mesh or position we are attaching the particle system to.
  17989. */
  17990. emitter: Nullable<AbstractMesh | Vector3>;
  17991. /**
  17992. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17993. */
  17994. isBillboardBased: boolean;
  17995. /**
  17996. * The rendering group used by the Particle system to chose when to render.
  17997. */
  17998. renderingGroupId: number;
  17999. /**
  18000. * The layer mask we are rendering the particles through.
  18001. */
  18002. layerMask: number;
  18003. /**
  18004. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18005. */
  18006. updateSpeed: number;
  18007. /**
  18008. * The amount of time the particle system is running (depends of the overall update speed).
  18009. */
  18010. targetStopDuration: number;
  18011. /**
  18012. * The texture used to render each particle. (this can be a spritesheet)
  18013. */
  18014. particleTexture: Nullable<Texture>;
  18015. /**
  18016. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18017. */
  18018. blendMode: number;
  18019. /**
  18020. * Minimum life time of emitting particles.
  18021. */
  18022. minLifeTime: number;
  18023. /**
  18024. * Maximum life time of emitting particles.
  18025. */
  18026. maxLifeTime: number;
  18027. /**
  18028. * Minimum Size of emitting particles.
  18029. */
  18030. minSize: number;
  18031. /**
  18032. * Maximum Size of emitting particles.
  18033. */
  18034. maxSize: number;
  18035. /**
  18036. * Minimum scale of emitting particles on X axis.
  18037. */
  18038. minScaleX: number;
  18039. /**
  18040. * Maximum scale of emitting particles on X axis.
  18041. */
  18042. maxScaleX: number;
  18043. /**
  18044. * Minimum scale of emitting particles on Y axis.
  18045. */
  18046. minScaleY: number;
  18047. /**
  18048. * Maximum scale of emitting particles on Y axis.
  18049. */
  18050. maxScaleY: number;
  18051. /**
  18052. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18053. */
  18054. color1: Color4;
  18055. /**
  18056. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18057. */
  18058. color2: Color4;
  18059. /**
  18060. * Color the particle will have at the end of its lifetime.
  18061. */
  18062. colorDead: Color4;
  18063. /**
  18064. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18065. */
  18066. emitRate: number;
  18067. /**
  18068. * You can use gravity if you want to give an orientation to your particles.
  18069. */
  18070. gravity: Vector3;
  18071. /**
  18072. * Minimum power of emitting particles.
  18073. */
  18074. minEmitPower: number;
  18075. /**
  18076. * Maximum power of emitting particles.
  18077. */
  18078. maxEmitPower: number;
  18079. /**
  18080. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18081. */
  18082. minAngularSpeed: number;
  18083. /**
  18084. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18085. */
  18086. maxAngularSpeed: number;
  18087. /**
  18088. * Gets or sets the minimal initial rotation in radians.
  18089. */
  18090. minInitialRotation: number;
  18091. /**
  18092. * Gets or sets the maximal initial rotation in radians.
  18093. */
  18094. maxInitialRotation: number;
  18095. /**
  18096. * The particle emitter type defines the emitter used by the particle system.
  18097. * It can be for example box, sphere, or cone...
  18098. */
  18099. particleEmitterType: Nullable<IParticleEmitterType>;
  18100. /**
  18101. * Defines the delay in milliseconds before starting the system (0 by default)
  18102. */
  18103. startDelay: number;
  18104. /**
  18105. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18106. */
  18107. preWarmCycles: number;
  18108. /**
  18109. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18110. */
  18111. preWarmStepOffset: number;
  18112. /**
  18113. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18114. */
  18115. spriteCellChangeSpeed: number;
  18116. /**
  18117. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18118. */
  18119. startSpriteCellID: number;
  18120. /**
  18121. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18122. */
  18123. endSpriteCellID: number;
  18124. /**
  18125. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18126. */
  18127. spriteCellWidth: number;
  18128. /**
  18129. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18130. */
  18131. spriteCellHeight: number;
  18132. /**
  18133. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18134. */
  18135. spriteRandomStartCell: boolean;
  18136. /**
  18137. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18138. */
  18139. isAnimationSheetEnabled: boolean;
  18140. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18141. translationPivot: Vector2;
  18142. /**
  18143. * Gets or sets a texture used to add random noise to particle positions
  18144. */
  18145. noiseTexture: Nullable<BaseTexture>;
  18146. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18147. noiseStrength: Vector3;
  18148. /**
  18149. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18150. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18151. */
  18152. billboardMode: number;
  18153. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18154. limitVelocityDamping: number;
  18155. /**
  18156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18157. */
  18158. beginAnimationOnStart: boolean;
  18159. /**
  18160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18161. */
  18162. beginAnimationFrom: number;
  18163. /**
  18164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18165. */
  18166. beginAnimationTo: number;
  18167. /**
  18168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18169. */
  18170. beginAnimationLoop: boolean;
  18171. /**
  18172. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18173. */
  18174. disposeOnStop: boolean;
  18175. /**
  18176. * Gets the maximum number of particles active at the same time.
  18177. * @returns The max number of active particles.
  18178. */
  18179. getCapacity(): number;
  18180. /**
  18181. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18182. * @returns True if it has been started, otherwise false.
  18183. */
  18184. isStarted(): boolean;
  18185. /**
  18186. * Animates the particle system for this frame.
  18187. */
  18188. animate(): void;
  18189. /**
  18190. * Renders the particle system in its current state.
  18191. * @returns the current number of particles
  18192. */
  18193. render(): number;
  18194. /**
  18195. * Dispose the particle system and frees its associated resources.
  18196. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18197. */
  18198. dispose(disposeTexture?: boolean): void;
  18199. /**
  18200. * Clones the particle system.
  18201. * @param name The name of the cloned object
  18202. * @param newEmitter The new emitter to use
  18203. * @returns the cloned particle system
  18204. */
  18205. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18206. /**
  18207. * Serializes the particle system to a JSON object.
  18208. * @returns the JSON object
  18209. */
  18210. serialize(): any;
  18211. /**
  18212. * Rebuild the particle system
  18213. */
  18214. rebuild(): void;
  18215. /**
  18216. * Starts the particle system and begins to emit
  18217. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18218. */
  18219. start(delay?: number): void;
  18220. /**
  18221. * Stops the particle system.
  18222. */
  18223. stop(): void;
  18224. /**
  18225. * Remove all active particles
  18226. */
  18227. reset(): void;
  18228. /**
  18229. * Is this system ready to be used/rendered
  18230. * @return true if the system is ready
  18231. */
  18232. isReady(): boolean;
  18233. /**
  18234. * Adds a new color gradient
  18235. * @param gradient defines the gradient to use (between 0 and 1)
  18236. * @param color1 defines the color to affect to the specified gradient
  18237. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18238. * @returns the current particle system
  18239. */
  18240. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18241. /**
  18242. * Remove a specific color gradient
  18243. * @param gradient defines the gradient to remove
  18244. * @returns the current particle system
  18245. */
  18246. removeColorGradient(gradient: number): IParticleSystem;
  18247. /**
  18248. * Adds a new size gradient
  18249. * @param gradient defines the gradient to use (between 0 and 1)
  18250. * @param factor defines the size factor to affect to the specified gradient
  18251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18252. * @returns the current particle system
  18253. */
  18254. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18255. /**
  18256. * Remove a specific size gradient
  18257. * @param gradient defines the gradient to remove
  18258. * @returns the current particle system
  18259. */
  18260. removeSizeGradient(gradient: number): IParticleSystem;
  18261. /**
  18262. * Gets the current list of color gradients.
  18263. * You must use addColorGradient and removeColorGradient to udpate this list
  18264. * @returns the list of color gradients
  18265. */
  18266. getColorGradients(): Nullable<Array<ColorGradient>>;
  18267. /**
  18268. * Gets the current list of size gradients.
  18269. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18270. * @returns the list of size gradients
  18271. */
  18272. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18273. /**
  18274. * Gets the current list of angular speed gradients.
  18275. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18276. * @returns the list of angular speed gradients
  18277. */
  18278. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18279. /**
  18280. * Adds a new angular speed gradient
  18281. * @param gradient defines the gradient to use (between 0 and 1)
  18282. * @param factor defines the angular speed to affect to the specified gradient
  18283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18284. * @returns the current particle system
  18285. */
  18286. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18287. /**
  18288. * Remove a specific angular speed gradient
  18289. * @param gradient defines the gradient to remove
  18290. * @returns the current particle system
  18291. */
  18292. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18293. /**
  18294. * Gets the current list of velocity gradients.
  18295. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18296. * @returns the list of velocity gradients
  18297. */
  18298. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18299. /**
  18300. * Adds a new velocity gradient
  18301. * @param gradient defines the gradient to use (between 0 and 1)
  18302. * @param factor defines the velocity to affect to the specified gradient
  18303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18304. * @returns the current particle system
  18305. */
  18306. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18307. /**
  18308. * Remove a specific velocity gradient
  18309. * @param gradient defines the gradient to remove
  18310. * @returns the current particle system
  18311. */
  18312. removeVelocityGradient(gradient: number): IParticleSystem;
  18313. /**
  18314. * Gets the current list of limit velocity gradients.
  18315. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18316. * @returns the list of limit velocity gradients
  18317. */
  18318. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18319. /**
  18320. * Adds a new limit velocity gradient
  18321. * @param gradient defines the gradient to use (between 0 and 1)
  18322. * @param factor defines the limit velocity to affect to the specified gradient
  18323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18324. * @returns the current particle system
  18325. */
  18326. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18327. /**
  18328. * Remove a specific limit velocity gradient
  18329. * @param gradient defines the gradient to remove
  18330. * @returns the current particle system
  18331. */
  18332. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18333. /**
  18334. * Adds a new drag gradient
  18335. * @param gradient defines the gradient to use (between 0 and 1)
  18336. * @param factor defines the drag to affect to the specified gradient
  18337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18338. * @returns the current particle system
  18339. */
  18340. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18341. /**
  18342. * Remove a specific drag gradient
  18343. * @param gradient defines the gradient to remove
  18344. * @returns the current particle system
  18345. */
  18346. removeDragGradient(gradient: number): IParticleSystem;
  18347. /**
  18348. * Gets the current list of drag gradients.
  18349. * You must use addDragGradient and removeDragGradient to udpate this list
  18350. * @returns the list of drag gradients
  18351. */
  18352. getDragGradients(): Nullable<Array<FactorGradient>>;
  18353. /**
  18354. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18355. * @param gradient defines the gradient to use (between 0 and 1)
  18356. * @param factor defines the emit rate to affect to the specified gradient
  18357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18358. * @returns the current particle system
  18359. */
  18360. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18361. /**
  18362. * Remove a specific emit rate gradient
  18363. * @param gradient defines the gradient to remove
  18364. * @returns the current particle system
  18365. */
  18366. removeEmitRateGradient(gradient: number): IParticleSystem;
  18367. /**
  18368. * Gets the current list of emit rate gradients.
  18369. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18370. * @returns the list of emit rate gradients
  18371. */
  18372. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18373. /**
  18374. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18375. * @param gradient defines the gradient to use (between 0 and 1)
  18376. * @param factor defines the start size to affect to the specified gradient
  18377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18378. * @returns the current particle system
  18379. */
  18380. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18381. /**
  18382. * Remove a specific start size gradient
  18383. * @param gradient defines the gradient to remove
  18384. * @returns the current particle system
  18385. */
  18386. removeStartSizeGradient(gradient: number): IParticleSystem;
  18387. /**
  18388. * Gets the current list of start size gradients.
  18389. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18390. * @returns the list of start size gradients
  18391. */
  18392. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18393. /**
  18394. * Adds a new life time gradient
  18395. * @param gradient defines the gradient to use (between 0 and 1)
  18396. * @param factor defines the life time factor to affect to the specified gradient
  18397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18398. * @returns the current particle system
  18399. */
  18400. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18401. /**
  18402. * Remove a specific life time gradient
  18403. * @param gradient defines the gradient to remove
  18404. * @returns the current particle system
  18405. */
  18406. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18407. /**
  18408. * Gets the current list of life time gradients.
  18409. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18410. * @returns the list of life time gradients
  18411. */
  18412. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18413. /**
  18414. * Gets the current list of color gradients.
  18415. * You must use addColorGradient and removeColorGradient to udpate this list
  18416. * @returns the list of color gradients
  18417. */
  18418. getColorGradients(): Nullable<Array<ColorGradient>>;
  18419. /**
  18420. * Adds a new ramp gradient used to remap particle colors
  18421. * @param gradient defines the gradient to use (between 0 and 1)
  18422. * @param color defines the color to affect to the specified gradient
  18423. * @returns the current particle system
  18424. */
  18425. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18426. /**
  18427. * Gets the current list of ramp gradients.
  18428. * You must use addRampGradient and removeRampGradient to udpate this list
  18429. * @returns the list of ramp gradients
  18430. */
  18431. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18432. /** Gets or sets a boolean indicating that ramp gradients must be used
  18433. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18434. */
  18435. useRampGradients: boolean;
  18436. /**
  18437. * Adds a new color remap gradient
  18438. * @param gradient defines the gradient to use (between 0 and 1)
  18439. * @param min defines the color remap minimal range
  18440. * @param max defines the color remap maximal range
  18441. * @returns the current particle system
  18442. */
  18443. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18444. /**
  18445. * Gets the current list of color remap gradients.
  18446. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18447. * @returns the list of color remap gradients
  18448. */
  18449. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18450. /**
  18451. * Adds a new alpha remap gradient
  18452. * @param gradient defines the gradient to use (between 0 and 1)
  18453. * @param min defines the alpha remap minimal range
  18454. * @param max defines the alpha remap maximal range
  18455. * @returns the current particle system
  18456. */
  18457. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18458. /**
  18459. * Gets the current list of alpha remap gradients.
  18460. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18461. * @returns the list of alpha remap gradients
  18462. */
  18463. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18464. /**
  18465. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18468. * @returns the emitter
  18469. */
  18470. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18471. /**
  18472. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18473. * @param radius The radius of the hemisphere to emit from
  18474. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18475. * @returns the emitter
  18476. */
  18477. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18478. /**
  18479. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18480. * @param radius The radius of the sphere to emit from
  18481. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18482. * @returns the emitter
  18483. */
  18484. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18485. /**
  18486. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18487. * @param radius The radius of the sphere to emit from
  18488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18490. * @returns the emitter
  18491. */
  18492. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18493. /**
  18494. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18495. * @param radius The radius of the emission cylinder
  18496. * @param height The height of the emission cylinder
  18497. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18498. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18499. * @returns the emitter
  18500. */
  18501. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18502. /**
  18503. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18504. * @param radius The radius of the cylinder to emit from
  18505. * @param height The height of the emission cylinder
  18506. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18509. * @returns the emitter
  18510. */
  18511. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18512. /**
  18513. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18514. * @param radius The radius of the cone to emit from
  18515. * @param angle The base angle of the cone
  18516. * @returns the emitter
  18517. */
  18518. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18519. /**
  18520. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18523. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18524. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18525. * @returns the emitter
  18526. */
  18527. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18528. /**
  18529. * Get hosting scene
  18530. * @returns the scene
  18531. */
  18532. getScene(): Scene;
  18533. }
  18534. }
  18535. declare module BABYLON {
  18536. /**
  18537. * Creates an instance based on a source mesh.
  18538. */
  18539. export class InstancedMesh extends AbstractMesh {
  18540. private _sourceMesh;
  18541. private _currentLOD;
  18542. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18543. constructor(name: string, source: Mesh);
  18544. /**
  18545. * Returns the string "InstancedMesh".
  18546. */
  18547. getClassName(): string;
  18548. /** Gets the list of lights affecting that mesh */
  18549. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18550. /**
  18551. * If the source mesh receives shadows
  18552. */
  18553. readonly receiveShadows: boolean;
  18554. /**
  18555. * The material of the source mesh
  18556. */
  18557. readonly material: Nullable<Material>;
  18558. /**
  18559. * Visibility of the source mesh
  18560. */
  18561. readonly visibility: number;
  18562. /**
  18563. * Skeleton of the source mesh
  18564. */
  18565. readonly skeleton: Nullable<Skeleton>;
  18566. /**
  18567. * Rendering ground id of the source mesh
  18568. */
  18569. renderingGroupId: number;
  18570. /**
  18571. * Returns the total number of vertices (integer).
  18572. */
  18573. getTotalVertices(): number;
  18574. /**
  18575. * Returns a positive integer : the total number of indices in this mesh geometry.
  18576. * @returns the numner of indices or zero if the mesh has no geometry.
  18577. */
  18578. getTotalIndices(): number;
  18579. /**
  18580. * The source mesh of the instance
  18581. */
  18582. readonly sourceMesh: Mesh;
  18583. /**
  18584. * Is this node ready to be used/rendered
  18585. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18586. * @return {boolean} is it ready
  18587. */
  18588. isReady(completeCheck?: boolean): boolean;
  18589. /**
  18590. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18591. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18592. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  18593. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18594. */
  18595. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18596. /**
  18597. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18598. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18599. * The `data` are either a numeric array either a Float32Array.
  18600. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18601. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  18602. * Note that a new underlying VertexBuffer object is created each call.
  18603. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18604. *
  18605. * Possible `kind` values :
  18606. * - VertexBuffer.PositionKind
  18607. * - VertexBuffer.UVKind
  18608. * - VertexBuffer.UV2Kind
  18609. * - VertexBuffer.UV3Kind
  18610. * - VertexBuffer.UV4Kind
  18611. * - VertexBuffer.UV5Kind
  18612. * - VertexBuffer.UV6Kind
  18613. * - VertexBuffer.ColorKind
  18614. * - VertexBuffer.MatricesIndicesKind
  18615. * - VertexBuffer.MatricesIndicesExtraKind
  18616. * - VertexBuffer.MatricesWeightsKind
  18617. * - VertexBuffer.MatricesWeightsExtraKind
  18618. *
  18619. * Returns the Mesh.
  18620. */
  18621. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18622. /**
  18623. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18624. * If the mesh has no geometry, it is simply returned as it is.
  18625. * The `data` are either a numeric array either a Float32Array.
  18626. * No new underlying VertexBuffer object is created.
  18627. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18628. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18629. *
  18630. * Possible `kind` values :
  18631. * - VertexBuffer.PositionKind
  18632. * - VertexBuffer.UVKind
  18633. * - VertexBuffer.UV2Kind
  18634. * - VertexBuffer.UV3Kind
  18635. * - VertexBuffer.UV4Kind
  18636. * - VertexBuffer.UV5Kind
  18637. * - VertexBuffer.UV6Kind
  18638. * - VertexBuffer.ColorKind
  18639. * - VertexBuffer.MatricesIndicesKind
  18640. * - VertexBuffer.MatricesIndicesExtraKind
  18641. * - VertexBuffer.MatricesWeightsKind
  18642. * - VertexBuffer.MatricesWeightsExtraKind
  18643. *
  18644. * Returns the Mesh.
  18645. */
  18646. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18647. /**
  18648. * Sets the mesh indices.
  18649. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18650. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18651. * This method creates a new index buffer each call.
  18652. * Returns the Mesh.
  18653. */
  18654. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18655. /**
  18656. * Boolean : True if the mesh owns the requested kind of data.
  18657. */
  18658. isVerticesDataPresent(kind: string): boolean;
  18659. /**
  18660. * Returns an array of indices (IndicesArray).
  18661. */
  18662. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18663. /**
  18664. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18665. * This means the mesh underlying bounding box and sphere are recomputed.
  18666. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18667. * @returns the current mesh
  18668. */
  18669. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18670. /** @hidden */ private _preActivate(): InstancedMesh;
  18671. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18672. /** @hidden */ private _postActivate(): void;
  18673. getWorldMatrix(): Matrix;
  18674. readonly isAnInstance: boolean;
  18675. /**
  18676. * Returns the current associated LOD AbstractMesh.
  18677. */
  18678. getLOD(camera: Camera): AbstractMesh;
  18679. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18680. /** @hidden */ private _generatePointsArray(): boolean;
  18681. /**
  18682. * Creates a new InstancedMesh from the current mesh.
  18683. * - name (string) : the cloned mesh name
  18684. * - newParent (optional Node) : the optional Node to parent the clone to.
  18685. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18686. *
  18687. * Returns the clone.
  18688. */
  18689. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18690. /**
  18691. * Disposes the InstancedMesh.
  18692. * Returns nothing.
  18693. */
  18694. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18695. }
  18696. }
  18697. declare module BABYLON {
  18698. /**
  18699. * Defines the options associated with the creation of a shader material.
  18700. */
  18701. export interface IShaderMaterialOptions {
  18702. /**
  18703. * Does the material work in alpha blend mode
  18704. */
  18705. needAlphaBlending: boolean;
  18706. /**
  18707. * Does the material work in alpha test mode
  18708. */
  18709. needAlphaTesting: boolean;
  18710. /**
  18711. * The list of attribute names used in the shader
  18712. */
  18713. attributes: string[];
  18714. /**
  18715. * The list of unifrom names used in the shader
  18716. */
  18717. uniforms: string[];
  18718. /**
  18719. * The list of UBO names used in the shader
  18720. */
  18721. uniformBuffers: string[];
  18722. /**
  18723. * The list of sampler names used in the shader
  18724. */
  18725. samplers: string[];
  18726. /**
  18727. * The list of defines used in the shader
  18728. */
  18729. defines: string[];
  18730. }
  18731. /**
  18732. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18733. *
  18734. * This returned material effects how the mesh will look based on the code in the shaders.
  18735. *
  18736. * @see http://doc.babylonjs.com/how_to/shader_material
  18737. */
  18738. export class ShaderMaterial extends Material {
  18739. private _shaderPath;
  18740. private _options;
  18741. private _textures;
  18742. private _textureArrays;
  18743. private _floats;
  18744. private _ints;
  18745. private _floatsArrays;
  18746. private _colors3;
  18747. private _colors3Arrays;
  18748. private _colors4;
  18749. private _colors4Arrays;
  18750. private _vectors2;
  18751. private _vectors3;
  18752. private _vectors4;
  18753. private _matrices;
  18754. private _matrices3x3;
  18755. private _matrices2x2;
  18756. private _vectors2Arrays;
  18757. private _vectors3Arrays;
  18758. private _vectors4Arrays;
  18759. private _cachedWorldViewMatrix;
  18760. private _cachedWorldViewProjectionMatrix;
  18761. private _renderId;
  18762. /**
  18763. * Instantiate a new shader material.
  18764. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18765. * This returned material effects how the mesh will look based on the code in the shaders.
  18766. * @see http://doc.babylonjs.com/how_to/shader_material
  18767. * @param name Define the name of the material in the scene
  18768. * @param scene Define the scene the material belongs to
  18769. * @param shaderPath Defines the route to the shader code in one of three ways:
  18770. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18771. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18772. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18773. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18774. * @param options Define the options used to create the shader
  18775. */
  18776. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18777. /**
  18778. * Gets the options used to compile the shader.
  18779. * They can be modified to trigger a new compilation
  18780. */
  18781. readonly options: IShaderMaterialOptions;
  18782. /**
  18783. * Gets the current class name of the material e.g. "ShaderMaterial"
  18784. * Mainly use in serialization.
  18785. * @returns the class name
  18786. */
  18787. getClassName(): string;
  18788. /**
  18789. * Specifies if the material will require alpha blending
  18790. * @returns a boolean specifying if alpha blending is needed
  18791. */
  18792. needAlphaBlending(): boolean;
  18793. /**
  18794. * Specifies if this material should be rendered in alpha test mode
  18795. * @returns a boolean specifying if an alpha test is needed.
  18796. */
  18797. needAlphaTesting(): boolean;
  18798. private _checkUniform;
  18799. /**
  18800. * Set a texture in the shader.
  18801. * @param name Define the name of the uniform samplers as defined in the shader
  18802. * @param texture Define the texture to bind to this sampler
  18803. * @return the material itself allowing "fluent" like uniform updates
  18804. */
  18805. setTexture(name: string, texture: Texture): ShaderMaterial;
  18806. /**
  18807. * Set a texture array in the shader.
  18808. * @param name Define the name of the uniform sampler array as defined in the shader
  18809. * @param textures Define the list of textures to bind to this sampler
  18810. * @return the material itself allowing "fluent" like uniform updates
  18811. */
  18812. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18813. /**
  18814. * Set a float in the shader.
  18815. * @param name Define the name of the uniform as defined in the shader
  18816. * @param value Define the value to give to the uniform
  18817. * @return the material itself allowing "fluent" like uniform updates
  18818. */
  18819. setFloat(name: string, value: number): ShaderMaterial;
  18820. /**
  18821. * Set a int in the shader.
  18822. * @param name Define the name of the uniform as defined in the shader
  18823. * @param value Define the value to give to the uniform
  18824. * @return the material itself allowing "fluent" like uniform updates
  18825. */
  18826. setInt(name: string, value: number): ShaderMaterial;
  18827. /**
  18828. * Set an array of floats in the shader.
  18829. * @param name Define the name of the uniform as defined in the shader
  18830. * @param value Define the value to give to the uniform
  18831. * @return the material itself allowing "fluent" like uniform updates
  18832. */
  18833. setFloats(name: string, value: number[]): ShaderMaterial;
  18834. /**
  18835. * Set a vec3 in the shader from a Color3.
  18836. * @param name Define the name of the uniform as defined in the shader
  18837. * @param value Define the value to give to the uniform
  18838. * @return the material itself allowing "fluent" like uniform updates
  18839. */
  18840. setColor3(name: string, value: Color3): ShaderMaterial;
  18841. /**
  18842. * Set a vec3 array in the shader from a Color3 array.
  18843. * @param name Define the name of the uniform as defined in the shader
  18844. * @param value Define the value to give to the uniform
  18845. * @return the material itself allowing "fluent" like uniform updates
  18846. */
  18847. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18848. /**
  18849. * Set a vec4 in the shader from a Color4.
  18850. * @param name Define the name of the uniform as defined in the shader
  18851. * @param value Define the value to give to the uniform
  18852. * @return the material itself allowing "fluent" like uniform updates
  18853. */
  18854. setColor4(name: string, value: Color4): ShaderMaterial;
  18855. /**
  18856. * Set a vec4 array in the shader from a Color4 array.
  18857. * @param name Define the name of the uniform as defined in the shader
  18858. * @param value Define the value to give to the uniform
  18859. * @return the material itself allowing "fluent" like uniform updates
  18860. */
  18861. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18862. /**
  18863. * Set a vec2 in the shader from a Vector2.
  18864. * @param name Define the name of the uniform as defined in the shader
  18865. * @param value Define the value to give to the uniform
  18866. * @return the material itself allowing "fluent" like uniform updates
  18867. */
  18868. setVector2(name: string, value: Vector2): ShaderMaterial;
  18869. /**
  18870. * Set a vec3 in the shader from a Vector3.
  18871. * @param name Define the name of the uniform as defined in the shader
  18872. * @param value Define the value to give to the uniform
  18873. * @return the material itself allowing "fluent" like uniform updates
  18874. */
  18875. setVector3(name: string, value: Vector3): ShaderMaterial;
  18876. /**
  18877. * Set a vec4 in the shader from a Vector4.
  18878. * @param name Define the name of the uniform as defined in the shader
  18879. * @param value Define the value to give to the uniform
  18880. * @return the material itself allowing "fluent" like uniform updates
  18881. */
  18882. setVector4(name: string, value: Vector4): ShaderMaterial;
  18883. /**
  18884. * Set a mat4 in the shader from a Matrix.
  18885. * @param name Define the name of the uniform as defined in the shader
  18886. * @param value Define the value to give to the uniform
  18887. * @return the material itself allowing "fluent" like uniform updates
  18888. */
  18889. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18890. /**
  18891. * Set a mat3 in the shader from a Float32Array.
  18892. * @param name Define the name of the uniform as defined in the shader
  18893. * @param value Define the value to give to the uniform
  18894. * @return the material itself allowing "fluent" like uniform updates
  18895. */
  18896. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18897. /**
  18898. * Set a mat2 in the shader from a Float32Array.
  18899. * @param name Define the name of the uniform as defined in the shader
  18900. * @param value Define the value to give to the uniform
  18901. * @return the material itself allowing "fluent" like uniform updates
  18902. */
  18903. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18904. /**
  18905. * Set a vec2 array in the shader from a number array.
  18906. * @param name Define the name of the uniform as defined in the shader
  18907. * @param value Define the value to give to the uniform
  18908. * @return the material itself allowing "fluent" like uniform updates
  18909. */
  18910. setArray2(name: string, value: number[]): ShaderMaterial;
  18911. /**
  18912. * Set a vec3 array in the shader from a number array.
  18913. * @param name Define the name of the uniform as defined in the shader
  18914. * @param value Define the value to give to the uniform
  18915. * @return the material itself allowing "fluent" like uniform updates
  18916. */
  18917. setArray3(name: string, value: number[]): ShaderMaterial;
  18918. /**
  18919. * Set a vec4 array in the shader from a number array.
  18920. * @param name Define the name of the uniform as defined in the shader
  18921. * @param value Define the value to give to the uniform
  18922. * @return the material itself allowing "fluent" like uniform updates
  18923. */
  18924. setArray4(name: string, value: number[]): ShaderMaterial;
  18925. private _checkCache;
  18926. /**
  18927. * Specifies that the submesh is ready to be used
  18928. * @param mesh defines the mesh to check
  18929. * @param subMesh defines which submesh to check
  18930. * @param useInstances specifies that instances should be used
  18931. * @returns a boolean indicating that the submesh is ready or not
  18932. */
  18933. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18934. /**
  18935. * Checks if the material is ready to render the requested mesh
  18936. * @param mesh Define the mesh to render
  18937. * @param useInstances Define whether or not the material is used with instances
  18938. * @returns true if ready, otherwise false
  18939. */
  18940. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18941. /**
  18942. * Binds the world matrix to the material
  18943. * @param world defines the world transformation matrix
  18944. */
  18945. bindOnlyWorldMatrix(world: Matrix): void;
  18946. /**
  18947. * Binds the material to the mesh
  18948. * @param world defines the world transformation matrix
  18949. * @param mesh defines the mesh to bind the material to
  18950. */
  18951. bind(world: Matrix, mesh?: Mesh): void;
  18952. /**
  18953. * Gets the active textures from the material
  18954. * @returns an array of textures
  18955. */
  18956. getActiveTextures(): BaseTexture[];
  18957. /**
  18958. * Specifies if the material uses a texture
  18959. * @param texture defines the texture to check against the material
  18960. * @returns a boolean specifying if the material uses the texture
  18961. */
  18962. hasTexture(texture: BaseTexture): boolean;
  18963. /**
  18964. * Makes a duplicate of the material, and gives it a new name
  18965. * @param name defines the new name for the duplicated material
  18966. * @returns the cloned material
  18967. */
  18968. clone(name: string): ShaderMaterial;
  18969. /**
  18970. * Disposes the material
  18971. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18972. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18973. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18974. */
  18975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18976. /**
  18977. * Serializes this material in a JSON representation
  18978. * @returns the serialized material object
  18979. */
  18980. serialize(): any;
  18981. /**
  18982. * Creates a shader material from parsed shader material data
  18983. * @param source defines the JSON represnetation of the material
  18984. * @param scene defines the hosting scene
  18985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18986. * @returns a new material
  18987. */
  18988. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18989. }
  18990. }
  18991. declare module BABYLON {
  18992. /** @hidden */
  18993. export var colorPixelShader: {
  18994. name: string;
  18995. shader: string;
  18996. };
  18997. }
  18998. declare module BABYLON {
  18999. /** @hidden */
  19000. export var colorVertexShader: {
  19001. name: string;
  19002. shader: string;
  19003. };
  19004. }
  19005. declare module BABYLON {
  19006. /**
  19007. * Line mesh
  19008. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19009. */
  19010. export class LinesMesh extends Mesh {
  19011. /**
  19012. * If vertex color should be applied to the mesh
  19013. */
  19014. readonly useVertexColor?: boolean | undefined;
  19015. /**
  19016. * If vertex alpha should be applied to the mesh
  19017. */
  19018. readonly useVertexAlpha?: boolean | undefined;
  19019. /**
  19020. * Color of the line (Default: White)
  19021. */
  19022. color: Color3;
  19023. /**
  19024. * Alpha of the line (Default: 1)
  19025. */
  19026. alpha: number;
  19027. /**
  19028. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19029. * This margin is expressed in world space coordinates, so its value may vary.
  19030. * Default value is 0.1
  19031. */
  19032. intersectionThreshold: number;
  19033. private _colorShader;
  19034. private color4;
  19035. /**
  19036. * Creates a new LinesMesh
  19037. * @param name defines the name
  19038. * @param scene defines the hosting scene
  19039. * @param parent defines the parent mesh if any
  19040. * @param source defines the optional source LinesMesh used to clone data from
  19041. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19042. * When false, achieved by calling a clone(), also passing False.
  19043. * This will make creation of children, recursive.
  19044. * @param useVertexColor defines if this LinesMesh supports vertex color
  19045. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19046. */
  19047. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19048. /**
  19049. * If vertex color should be applied to the mesh
  19050. */
  19051. useVertexColor?: boolean | undefined,
  19052. /**
  19053. * If vertex alpha should be applied to the mesh
  19054. */
  19055. useVertexAlpha?: boolean | undefined);
  19056. private _addClipPlaneDefine;
  19057. private _removeClipPlaneDefine;
  19058. isReady(): boolean;
  19059. /**
  19060. * Returns the string "LineMesh"
  19061. */
  19062. getClassName(): string;
  19063. /**
  19064. * @hidden
  19065. */
  19066. /**
  19067. * @hidden
  19068. */
  19069. material: Material;
  19070. /**
  19071. * @hidden
  19072. */
  19073. readonly checkCollisions: boolean;
  19074. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19075. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19076. /**
  19077. * Disposes of the line mesh
  19078. * @param doNotRecurse If children should be disposed
  19079. */
  19080. dispose(doNotRecurse?: boolean): void;
  19081. /**
  19082. * Returns a new LineMesh object cloned from the current one.
  19083. */
  19084. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19085. /**
  19086. * Creates a new InstancedLinesMesh object from the mesh model.
  19087. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19088. * @param name defines the name of the new instance
  19089. * @returns a new InstancedLinesMesh
  19090. */
  19091. createInstance(name: string): InstancedLinesMesh;
  19092. }
  19093. /**
  19094. * Creates an instance based on a source LinesMesh
  19095. */
  19096. export class InstancedLinesMesh extends InstancedMesh {
  19097. /**
  19098. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19099. * This margin is expressed in world space coordinates, so its value may vary.
  19100. * Initilized with the intersectionThreshold value of the source LinesMesh
  19101. */
  19102. intersectionThreshold: number;
  19103. constructor(name: string, source: LinesMesh);
  19104. /**
  19105. * Returns the string "InstancedLinesMesh".
  19106. */
  19107. getClassName(): string;
  19108. }
  19109. }
  19110. declare module BABYLON {
  19111. /** @hidden */
  19112. export var linePixelShader: {
  19113. name: string;
  19114. shader: string;
  19115. };
  19116. }
  19117. declare module BABYLON {
  19118. /** @hidden */
  19119. export var lineVertexShader: {
  19120. name: string;
  19121. shader: string;
  19122. };
  19123. }
  19124. declare module BABYLON {
  19125. interface AbstractMesh {
  19126. /**
  19127. * Gets the edgesRenderer associated with the mesh
  19128. */
  19129. edgesRenderer: Nullable<EdgesRenderer>;
  19130. }
  19131. interface LinesMesh {
  19132. /**
  19133. * Enables the edge rendering mode on the mesh.
  19134. * This mode makes the mesh edges visible
  19135. * @param epsilon defines the maximal distance between two angles to detect a face
  19136. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19137. * @returns the currentAbstractMesh
  19138. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19139. */
  19140. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19141. }
  19142. interface InstancedLinesMesh {
  19143. /**
  19144. * Enables the edge rendering mode on the mesh.
  19145. * This mode makes the mesh edges visible
  19146. * @param epsilon defines the maximal distance between two angles to detect a face
  19147. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19148. * @returns the current InstancedLinesMesh
  19149. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19150. */
  19151. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19152. }
  19153. /**
  19154. * Defines the minimum contract an Edges renderer should follow.
  19155. */
  19156. export interface IEdgesRenderer extends IDisposable {
  19157. /**
  19158. * Gets or sets a boolean indicating if the edgesRenderer is active
  19159. */
  19160. isEnabled: boolean;
  19161. /**
  19162. * Renders the edges of the attached mesh,
  19163. */
  19164. render(): void;
  19165. /**
  19166. * Checks wether or not the edges renderer is ready to render.
  19167. * @return true if ready, otherwise false.
  19168. */
  19169. isReady(): boolean;
  19170. }
  19171. /**
  19172. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19173. */
  19174. export class EdgesRenderer implements IEdgesRenderer {
  19175. /**
  19176. * Define the size of the edges with an orthographic camera
  19177. */
  19178. edgesWidthScalerForOrthographic: number;
  19179. /**
  19180. * Define the size of the edges with a perspective camera
  19181. */
  19182. edgesWidthScalerForPerspective: number;
  19183. protected _source: AbstractMesh;
  19184. protected _linesPositions: number[];
  19185. protected _linesNormals: number[];
  19186. protected _linesIndices: number[];
  19187. protected _epsilon: number;
  19188. protected _indicesCount: number;
  19189. protected _lineShader: ShaderMaterial;
  19190. protected _ib: DataBuffer;
  19191. protected _buffers: {
  19192. [key: string]: Nullable<VertexBuffer>;
  19193. };
  19194. protected _checkVerticesInsteadOfIndices: boolean;
  19195. private _meshRebuildObserver;
  19196. private _meshDisposeObserver;
  19197. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19198. isEnabled: boolean;
  19199. /**
  19200. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19201. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19202. * @param source Mesh used to create edges
  19203. * @param epsilon sum of angles in adjacency to check for edge
  19204. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19205. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19206. */
  19207. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19208. protected _prepareRessources(): void;
  19209. /** @hidden */ private _rebuild(): void;
  19210. /**
  19211. * Releases the required resources for the edges renderer
  19212. */
  19213. dispose(): void;
  19214. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19215. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19216. /**
  19217. * Checks if the pair of p0 and p1 is en edge
  19218. * @param faceIndex
  19219. * @param edge
  19220. * @param faceNormals
  19221. * @param p0
  19222. * @param p1
  19223. * @private
  19224. */
  19225. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19226. /**
  19227. * push line into the position, normal and index buffer
  19228. * @protected
  19229. */
  19230. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19231. /**
  19232. * Generates lines edges from adjacencjes
  19233. * @private
  19234. */ private _generateEdgesLines(): void;
  19235. /**
  19236. * Checks wether or not the edges renderer is ready to render.
  19237. * @return true if ready, otherwise false.
  19238. */
  19239. isReady(): boolean;
  19240. /**
  19241. * Renders the edges of the attached mesh,
  19242. */
  19243. render(): void;
  19244. }
  19245. /**
  19246. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19247. */
  19248. export class LineEdgesRenderer extends EdgesRenderer {
  19249. /**
  19250. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19251. * @param source LineMesh used to generate edges
  19252. * @param epsilon not important (specified angle for edge detection)
  19253. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19254. */
  19255. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19256. /**
  19257. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19258. */ private _generateEdgesLines(): void;
  19259. }
  19260. }
  19261. declare module BABYLON {
  19262. /**
  19263. * This represents the object necessary to create a rendering group.
  19264. * This is exclusively used and created by the rendering manager.
  19265. * To modify the behavior, you use the available helpers in your scene or meshes.
  19266. * @hidden
  19267. */
  19268. export class RenderingGroup {
  19269. index: number;
  19270. private static _zeroVector;
  19271. private _scene;
  19272. private _opaqueSubMeshes;
  19273. private _transparentSubMeshes;
  19274. private _alphaTestSubMeshes;
  19275. private _depthOnlySubMeshes;
  19276. private _particleSystems;
  19277. private _spriteManagers;
  19278. private _opaqueSortCompareFn;
  19279. private _alphaTestSortCompareFn;
  19280. private _transparentSortCompareFn;
  19281. private _renderOpaque;
  19282. private _renderAlphaTest;
  19283. private _renderTransparent;
  19284. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19285. onBeforeTransparentRendering: () => void;
  19286. /**
  19287. * Set the opaque sort comparison function.
  19288. * If null the sub meshes will be render in the order they were created
  19289. */
  19290. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19291. /**
  19292. * Set the alpha test sort comparison function.
  19293. * If null the sub meshes will be render in the order they were created
  19294. */
  19295. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19296. /**
  19297. * Set the transparent sort comparison function.
  19298. * If null the sub meshes will be render in the order they were created
  19299. */
  19300. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19301. /**
  19302. * Creates a new rendering group.
  19303. * @param index The rendering group index
  19304. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19305. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19306. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19307. */
  19308. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19309. /**
  19310. * Render all the sub meshes contained in the group.
  19311. * @param customRenderFunction Used to override the default render behaviour of the group.
  19312. * @returns true if rendered some submeshes.
  19313. */
  19314. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19315. /**
  19316. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19317. * @param subMeshes The submeshes to render
  19318. */
  19319. private renderOpaqueSorted;
  19320. /**
  19321. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19322. * @param subMeshes The submeshes to render
  19323. */
  19324. private renderAlphaTestSorted;
  19325. /**
  19326. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19327. * @param subMeshes The submeshes to render
  19328. */
  19329. private renderTransparentSorted;
  19330. /**
  19331. * Renders the submeshes in a specified order.
  19332. * @param subMeshes The submeshes to sort before render
  19333. * @param sortCompareFn The comparison function use to sort
  19334. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19335. * @param transparent Specifies to activate blending if true
  19336. */
  19337. private static renderSorted;
  19338. /**
  19339. * Renders the submeshes in the order they were dispatched (no sort applied).
  19340. * @param subMeshes The submeshes to render
  19341. */
  19342. private static renderUnsorted;
  19343. /**
  19344. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19345. * are rendered back to front if in the same alpha index.
  19346. *
  19347. * @param a The first submesh
  19348. * @param b The second submesh
  19349. * @returns The result of the comparison
  19350. */
  19351. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19352. /**
  19353. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19354. * are rendered back to front.
  19355. *
  19356. * @param a The first submesh
  19357. * @param b The second submesh
  19358. * @returns The result of the comparison
  19359. */
  19360. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19361. /**
  19362. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19363. * are rendered front to back (prevent overdraw).
  19364. *
  19365. * @param a The first submesh
  19366. * @param b The second submesh
  19367. * @returns The result of the comparison
  19368. */
  19369. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19370. /**
  19371. * Resets the different lists of submeshes to prepare a new frame.
  19372. */
  19373. prepare(): void;
  19374. dispose(): void;
  19375. /**
  19376. * Inserts the submesh in its correct queue depending on its material.
  19377. * @param subMesh The submesh to dispatch
  19378. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19379. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19380. */
  19381. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19382. dispatchSprites(spriteManager: ISpriteManager): void;
  19383. dispatchParticles(particleSystem: IParticleSystem): void;
  19384. private _renderParticles;
  19385. private _renderSprites;
  19386. }
  19387. }
  19388. declare module BABYLON {
  19389. /**
  19390. * Interface describing the different options available in the rendering manager
  19391. * regarding Auto Clear between groups.
  19392. */
  19393. export interface IRenderingManagerAutoClearSetup {
  19394. /**
  19395. * Defines whether or not autoclear is enable.
  19396. */
  19397. autoClear: boolean;
  19398. /**
  19399. * Defines whether or not to autoclear the depth buffer.
  19400. */
  19401. depth: boolean;
  19402. /**
  19403. * Defines whether or not to autoclear the stencil buffer.
  19404. */
  19405. stencil: boolean;
  19406. }
  19407. /**
  19408. * This class is used by the onRenderingGroupObservable
  19409. */
  19410. export class RenderingGroupInfo {
  19411. /**
  19412. * The Scene that being rendered
  19413. */
  19414. scene: Scene;
  19415. /**
  19416. * The camera currently used for the rendering pass
  19417. */
  19418. camera: Nullable<Camera>;
  19419. /**
  19420. * The ID of the renderingGroup being processed
  19421. */
  19422. renderingGroupId: number;
  19423. }
  19424. /**
  19425. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19426. * It is enable to manage the different groups as well as the different necessary sort functions.
  19427. * This should not be used directly aside of the few static configurations
  19428. */
  19429. export class RenderingManager {
  19430. /**
  19431. * The max id used for rendering groups (not included)
  19432. */
  19433. static MAX_RENDERINGGROUPS: number;
  19434. /**
  19435. * The min id used for rendering groups (included)
  19436. */
  19437. static MIN_RENDERINGGROUPS: number;
  19438. /**
  19439. * Used to globally prevent autoclearing scenes.
  19440. */
  19441. static AUTOCLEAR: boolean;
  19442. /**
  19443. * @hidden
  19444. */ private _useSceneAutoClearSetup: boolean;
  19445. private _scene;
  19446. private _renderingGroups;
  19447. private _depthStencilBufferAlreadyCleaned;
  19448. private _autoClearDepthStencil;
  19449. private _customOpaqueSortCompareFn;
  19450. private _customAlphaTestSortCompareFn;
  19451. private _customTransparentSortCompareFn;
  19452. private _renderingGroupInfo;
  19453. /**
  19454. * Instantiates a new rendering group for a particular scene
  19455. * @param scene Defines the scene the groups belongs to
  19456. */
  19457. constructor(scene: Scene);
  19458. private _clearDepthStencilBuffer;
  19459. /**
  19460. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19461. * @hidden
  19462. */
  19463. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19464. /**
  19465. * Resets the different information of the group to prepare a new frame
  19466. * @hidden
  19467. */
  19468. reset(): void;
  19469. /**
  19470. * Dispose and release the group and its associated resources.
  19471. * @hidden
  19472. */
  19473. dispose(): void;
  19474. /**
  19475. * Clear the info related to rendering groups preventing retention points during dispose.
  19476. */
  19477. freeRenderingGroups(): void;
  19478. private _prepareRenderingGroup;
  19479. /**
  19480. * Add a sprite manager to the rendering manager in order to render it this frame.
  19481. * @param spriteManager Define the sprite manager to render
  19482. */
  19483. dispatchSprites(spriteManager: ISpriteManager): void;
  19484. /**
  19485. * Add a particle system to the rendering manager in order to render it this frame.
  19486. * @param particleSystem Define the particle system to render
  19487. */
  19488. dispatchParticles(particleSystem: IParticleSystem): void;
  19489. /**
  19490. * Add a submesh to the manager in order to render it this frame
  19491. * @param subMesh The submesh to dispatch
  19492. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19493. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19494. */
  19495. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19496. /**
  19497. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19498. * This allowed control for front to back rendering or reversly depending of the special needs.
  19499. *
  19500. * @param renderingGroupId The rendering group id corresponding to its index
  19501. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19502. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19503. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19504. */
  19505. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  19506. /**
  19507. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19508. *
  19509. * @param renderingGroupId The rendering group id corresponding to its index
  19510. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19511. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19512. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19513. */
  19514. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19515. /**
  19516. * Gets the current auto clear configuration for one rendering group of the rendering
  19517. * manager.
  19518. * @param index the rendering group index to get the information for
  19519. * @returns The auto clear setup for the requested rendering group
  19520. */
  19521. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19522. }
  19523. }
  19524. declare module BABYLON {
  19525. /**
  19526. * This Helps creating a texture that will be created from a camera in your scene.
  19527. * It is basically a dynamic texture that could be used to create special effects for instance.
  19528. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19529. */
  19530. export class RenderTargetTexture extends Texture {
  19531. isCube: boolean;
  19532. /**
  19533. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19534. */
  19535. static readonly REFRESHRATE_RENDER_ONCE: number;
  19536. /**
  19537. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19538. */
  19539. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19540. /**
  19541. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19542. * the central point of your effect and can save a lot of performances.
  19543. */
  19544. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19545. /**
  19546. * Use this predicate to dynamically define the list of mesh you want to render.
  19547. * If set, the renderList property will be overwritten.
  19548. */
  19549. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19550. private _renderList;
  19551. /**
  19552. * Use this list to define the list of mesh you want to render.
  19553. */
  19554. renderList: Nullable<Array<AbstractMesh>>;
  19555. private _hookArray;
  19556. /**
  19557. * Define if particles should be rendered in your texture.
  19558. */
  19559. renderParticles: boolean;
  19560. /**
  19561. * Define if sprites should be rendered in your texture.
  19562. */
  19563. renderSprites: boolean;
  19564. /**
  19565. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19566. */
  19567. coordinatesMode: number;
  19568. /**
  19569. * Define the camera used to render the texture.
  19570. */
  19571. activeCamera: Nullable<Camera>;
  19572. /**
  19573. * Override the render function of the texture with your own one.
  19574. */
  19575. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19576. /**
  19577. * Define if camera post processes should be use while rendering the texture.
  19578. */
  19579. useCameraPostProcesses: boolean;
  19580. /**
  19581. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19582. */
  19583. ignoreCameraViewport: boolean;
  19584. private _postProcessManager;
  19585. private _postProcesses;
  19586. private _resizeObserver;
  19587. /**
  19588. * An event triggered when the texture is unbind.
  19589. */
  19590. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19591. /**
  19592. * An event triggered when the texture is unbind.
  19593. */
  19594. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19595. private _onAfterUnbindObserver;
  19596. /**
  19597. * Set a after unbind callback in the texture.
  19598. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19599. */
  19600. onAfterUnbind: () => void;
  19601. /**
  19602. * An event triggered before rendering the texture
  19603. */
  19604. onBeforeRenderObservable: Observable<number>;
  19605. private _onBeforeRenderObserver;
  19606. /**
  19607. * Set a before render callback in the texture.
  19608. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19609. */
  19610. onBeforeRender: (faceIndex: number) => void;
  19611. /**
  19612. * An event triggered after rendering the texture
  19613. */
  19614. onAfterRenderObservable: Observable<number>;
  19615. private _onAfterRenderObserver;
  19616. /**
  19617. * Set a after render callback in the texture.
  19618. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19619. */
  19620. onAfterRender: (faceIndex: number) => void;
  19621. /**
  19622. * An event triggered after the texture clear
  19623. */
  19624. onClearObservable: Observable<Engine>;
  19625. private _onClearObserver;
  19626. /**
  19627. * Set a clear callback in the texture.
  19628. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19629. */
  19630. onClear: (Engine: Engine) => void;
  19631. /**
  19632. * An event triggered when the texture is resized.
  19633. */
  19634. onResizeObservable: Observable<RenderTargetTexture>;
  19635. /**
  19636. * Define the clear color of the Render Target if it should be different from the scene.
  19637. */
  19638. clearColor: Color4;
  19639. protected _size: number | {
  19640. width: number;
  19641. height: number;
  19642. };
  19643. protected _initialSizeParameter: number | {
  19644. width: number;
  19645. height: number;
  19646. } | {
  19647. ratio: number;
  19648. };
  19649. protected _sizeRatio: Nullable<number>;
  19650. /** @hidden */ private _generateMipMaps: boolean;
  19651. protected _renderingManager: RenderingManager;
  19652. /** @hidden */ private _waitingRenderList: string[];
  19653. protected _doNotChangeAspectRatio: boolean;
  19654. protected _currentRefreshId: number;
  19655. protected _refreshRate: number;
  19656. protected _textureMatrix: Matrix;
  19657. protected _samples: number;
  19658. protected _renderTargetOptions: RenderTargetCreationOptions;
  19659. /**
  19660. * Gets render target creation options that were used.
  19661. */
  19662. readonly renderTargetOptions: RenderTargetCreationOptions;
  19663. protected _engine: Engine;
  19664. protected _onRatioRescale(): void;
  19665. /**
  19666. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19667. * It must define where the camera used to render the texture is set
  19668. */
  19669. boundingBoxPosition: Vector3;
  19670. private _boundingBoxSize;
  19671. /**
  19672. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19673. * When defined, the cubemap will switch to local mode
  19674. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19675. * @example https://www.babylonjs-playground.com/#RNASML
  19676. */
  19677. boundingBoxSize: Vector3;
  19678. /**
  19679. * In case the RTT has been created with a depth texture, get the associated
  19680. * depth texture.
  19681. * Otherwise, return null.
  19682. */
  19683. depthStencilTexture: Nullable<InternalTexture>;
  19684. /**
  19685. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19686. * or used a shadow, depth texture...
  19687. * @param name The friendly name of the texture
  19688. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  19689. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19690. * @param generateMipMaps True if mip maps need to be generated after render.
  19691. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19692. * @param type The type of the buffer in the RTT (int, half float, float...)
  19693. * @param isCube True if a cube texture needs to be created
  19694. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19695. * @param generateDepthBuffer True to generate a depth buffer
  19696. * @param generateStencilBuffer True to generate a stencil buffer
  19697. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19698. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19699. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19700. */
  19701. constructor(name: string, size: number | {
  19702. width: number;
  19703. height: number;
  19704. } | {
  19705. ratio: number;
  19706. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19707. /**
  19708. * Creates a depth stencil texture.
  19709. * This is only available in WebGL 2 or with the depth texture extension available.
  19710. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19711. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19712. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19713. */
  19714. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19715. private _processSizeParameter;
  19716. /**
  19717. * Define the number of samples to use in case of MSAA.
  19718. * It defaults to one meaning no MSAA has been enabled.
  19719. */
  19720. samples: number;
  19721. /**
  19722. * Resets the refresh counter of the texture and start bak from scratch.
  19723. * Could be useful to regenerate the texture if it is setup to render only once.
  19724. */
  19725. resetRefreshCounter(): void;
  19726. /**
  19727. * Define the refresh rate of the texture or the rendering frequency.
  19728. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19729. */
  19730. refreshRate: number;
  19731. /**
  19732. * Adds a post process to the render target rendering passes.
  19733. * @param postProcess define the post process to add
  19734. */
  19735. addPostProcess(postProcess: PostProcess): void;
  19736. /**
  19737. * Clear all the post processes attached to the render target
  19738. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19739. */
  19740. clearPostProcesses(dispose?: boolean): void;
  19741. /**
  19742. * Remove one of the post process from the list of attached post processes to the texture
  19743. * @param postProcess define the post process to remove from the list
  19744. */
  19745. removePostProcess(postProcess: PostProcess): void;
  19746. /** @hidden */ private _shouldRender(): boolean;
  19747. /**
  19748. * Gets the actual render size of the texture.
  19749. * @returns the width of the render size
  19750. */
  19751. getRenderSize(): number;
  19752. /**
  19753. * Gets the actual render width of the texture.
  19754. * @returns the width of the render size
  19755. */
  19756. getRenderWidth(): number;
  19757. /**
  19758. * Gets the actual render height of the texture.
  19759. * @returns the height of the render size
  19760. */
  19761. getRenderHeight(): number;
  19762. /**
  19763. * Get if the texture can be rescaled or not.
  19764. */
  19765. readonly canRescale: boolean;
  19766. /**
  19767. * Resize the texture using a ratio.
  19768. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19769. */
  19770. scale(ratio: number): void;
  19771. /**
  19772. * Get the texture reflection matrix used to rotate/transform the reflection.
  19773. * @returns the reflection matrix
  19774. */
  19775. getReflectionTextureMatrix(): Matrix;
  19776. /**
  19777. * Resize the texture to a new desired size.
  19778. * Be carrefull as it will recreate all the data in the new texture.
  19779. * @param size Define the new size. It can be:
  19780. * - a number for squared texture,
  19781. * - an object containing { width: number, height: number }
  19782. * - or an object containing a ratio { ratio: number }
  19783. */
  19784. resize(size: number | {
  19785. width: number;
  19786. height: number;
  19787. } | {
  19788. ratio: number;
  19789. }): void;
  19790. /**
  19791. * Renders all the objects from the render list into the texture.
  19792. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19793. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19794. */
  19795. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19796. private _bestReflectionRenderTargetDimension;
  19797. /**
  19798. * @hidden
  19799. * @param faceIndex face index to bind to if this is a cubetexture
  19800. */ private _bindFrameBuffer(faceIndex?: number): void;
  19801. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19802. private renderToTarget;
  19803. /**
  19804. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19805. * This allowed control for front to back rendering or reversly depending of the special needs.
  19806. *
  19807. * @param renderingGroupId The rendering group id corresponding to its index
  19808. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19809. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19810. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19811. */
  19812. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  19813. /**
  19814. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19815. *
  19816. * @param renderingGroupId The rendering group id corresponding to its index
  19817. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19818. */
  19819. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19820. /**
  19821. * Clones the texture.
  19822. * @returns the cloned texture
  19823. */
  19824. clone(): RenderTargetTexture;
  19825. /**
  19826. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19827. * @returns The JSON representation of the texture
  19828. */
  19829. serialize(): any;
  19830. /**
  19831. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19832. */
  19833. disposeFramebufferObjects(): void;
  19834. /**
  19835. * Dispose the texture and release its associated resources.
  19836. */
  19837. dispose(): void;
  19838. /** @hidden */ private _rebuild(): void;
  19839. /**
  19840. * Clear the info related to rendering groups preventing retention point in material dispose.
  19841. */
  19842. freeRenderingGroups(): void;
  19843. /**
  19844. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19845. * @returns the view count
  19846. */
  19847. getViewCount(): number;
  19848. }
  19849. }
  19850. declare module BABYLON {
  19851. /**
  19852. * Base class for the main features of a material in Babylon.js
  19853. */
  19854. export class Material implements IAnimatable {
  19855. /**
  19856. * Returns the triangle fill mode
  19857. */
  19858. static readonly TriangleFillMode: number;
  19859. /**
  19860. * Returns the wireframe mode
  19861. */
  19862. static readonly WireFrameFillMode: number;
  19863. /**
  19864. * Returns the point fill mode
  19865. */
  19866. static readonly PointFillMode: number;
  19867. /**
  19868. * Returns the point list draw mode
  19869. */
  19870. static readonly PointListDrawMode: number;
  19871. /**
  19872. * Returns the line list draw mode
  19873. */
  19874. static readonly LineListDrawMode: number;
  19875. /**
  19876. * Returns the line loop draw mode
  19877. */
  19878. static readonly LineLoopDrawMode: number;
  19879. /**
  19880. * Returns the line strip draw mode
  19881. */
  19882. static readonly LineStripDrawMode: number;
  19883. /**
  19884. * Returns the triangle strip draw mode
  19885. */
  19886. static readonly TriangleStripDrawMode: number;
  19887. /**
  19888. * Returns the triangle fan draw mode
  19889. */
  19890. static readonly TriangleFanDrawMode: number;
  19891. /**
  19892. * Stores the clock-wise side orientation
  19893. */
  19894. static readonly ClockWiseSideOrientation: number;
  19895. /**
  19896. * Stores the counter clock-wise side orientation
  19897. */
  19898. static readonly CounterClockWiseSideOrientation: number;
  19899. /**
  19900. * The dirty texture flag value
  19901. */
  19902. static readonly TextureDirtyFlag: number;
  19903. /**
  19904. * The dirty light flag value
  19905. */
  19906. static readonly LightDirtyFlag: number;
  19907. /**
  19908. * The dirty fresnel flag value
  19909. */
  19910. static readonly FresnelDirtyFlag: number;
  19911. /**
  19912. * The dirty attribute flag value
  19913. */
  19914. static readonly AttributesDirtyFlag: number;
  19915. /**
  19916. * The dirty misc flag value
  19917. */
  19918. static readonly MiscDirtyFlag: number;
  19919. /**
  19920. * The all dirty flag value
  19921. */
  19922. static readonly AllDirtyFlag: number;
  19923. /**
  19924. * The ID of the material
  19925. */
  19926. id: string;
  19927. /**
  19928. * Gets or sets the unique id of the material
  19929. */
  19930. uniqueId: number;
  19931. /**
  19932. * The name of the material
  19933. */
  19934. name: string;
  19935. /**
  19936. * Gets or sets user defined metadata
  19937. */
  19938. metadata: any;
  19939. /**
  19940. * For internal use only. Please do not use.
  19941. */
  19942. reservedDataStore: any;
  19943. /**
  19944. * Specifies if the ready state should be checked on each call
  19945. */
  19946. checkReadyOnEveryCall: boolean;
  19947. /**
  19948. * Specifies if the ready state should be checked once
  19949. */
  19950. checkReadyOnlyOnce: boolean;
  19951. /**
  19952. * The state of the material
  19953. */
  19954. state: string;
  19955. /**
  19956. * The alpha value of the material
  19957. */
  19958. protected _alpha: number;
  19959. /**
  19960. * List of inspectable custom properties (used by the Inspector)
  19961. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19962. */
  19963. inspectableCustomProperties: IInspectable[];
  19964. /**
  19965. * Sets the alpha value of the material
  19966. */
  19967. /**
  19968. * Gets the alpha value of the material
  19969. */
  19970. alpha: number;
  19971. /**
  19972. * Specifies if back face culling is enabled
  19973. */
  19974. protected _backFaceCulling: boolean;
  19975. /**
  19976. * Sets the back-face culling state
  19977. */
  19978. /**
  19979. * Gets the back-face culling state
  19980. */
  19981. backFaceCulling: boolean;
  19982. /**
  19983. * Stores the value for side orientation
  19984. */
  19985. sideOrientation: number;
  19986. /**
  19987. * Callback triggered when the material is compiled
  19988. */
  19989. onCompiled: Nullable<(effect: Effect) => void>;
  19990. /**
  19991. * Callback triggered when an error occurs
  19992. */
  19993. onError: Nullable<(effect: Effect, errors: string) => void>;
  19994. /**
  19995. * Callback triggered to get the render target textures
  19996. */
  19997. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19998. /**
  19999. * Gets a boolean indicating that current material needs to register RTT
  20000. */
  20001. readonly hasRenderTargetTextures: boolean;
  20002. /**
  20003. * Specifies if the material should be serialized
  20004. */
  20005. doNotSerialize: boolean;
  20006. /**
  20007. * @hidden
  20008. */ private _storeEffectOnSubMeshes: boolean;
  20009. /**
  20010. * Stores the animations for the material
  20011. */
  20012. animations: Nullable<Array<Animation>>;
  20013. /**
  20014. * An event triggered when the material is disposed
  20015. */
  20016. onDisposeObservable: Observable<Material>;
  20017. /**
  20018. * An observer which watches for dispose events
  20019. */
  20020. private _onDisposeObserver;
  20021. private _onUnBindObservable;
  20022. /**
  20023. * Called during a dispose event
  20024. */
  20025. onDispose: () => void;
  20026. private _onBindObservable;
  20027. /**
  20028. * An event triggered when the material is bound
  20029. */
  20030. readonly onBindObservable: Observable<AbstractMesh>;
  20031. /**
  20032. * An observer which watches for bind events
  20033. */
  20034. private _onBindObserver;
  20035. /**
  20036. * Called during a bind event
  20037. */
  20038. onBind: (Mesh: AbstractMesh) => void;
  20039. /**
  20040. * An event triggered when the material is unbound
  20041. */
  20042. readonly onUnBindObservable: Observable<Material>;
  20043. /**
  20044. * Stores the value of the alpha mode
  20045. */
  20046. private _alphaMode;
  20047. /**
  20048. * Sets the value of the alpha mode.
  20049. *
  20050. * | Value | Type | Description |
  20051. * | --- | --- | --- |
  20052. * | 0 | ALPHA_DISABLE | |
  20053. * | 1 | ALPHA_ADD | |
  20054. * | 2 | ALPHA_COMBINE | |
  20055. * | 3 | ALPHA_SUBTRACT | |
  20056. * | 4 | ALPHA_MULTIPLY | |
  20057. * | 5 | ALPHA_MAXIMIZED | |
  20058. * | 6 | ALPHA_ONEONE | |
  20059. * | 7 | ALPHA_PREMULTIPLIED | |
  20060. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20061. * | 9 | ALPHA_INTERPOLATE | |
  20062. * | 10 | ALPHA_SCREENMODE | |
  20063. *
  20064. */
  20065. /**
  20066. * Gets the value of the alpha mode
  20067. */
  20068. alphaMode: number;
  20069. /**
  20070. * Stores the state of the need depth pre-pass value
  20071. */
  20072. private _needDepthPrePass;
  20073. /**
  20074. * Sets the need depth pre-pass value
  20075. */
  20076. /**
  20077. * Gets the depth pre-pass value
  20078. */
  20079. needDepthPrePass: boolean;
  20080. /**
  20081. * Specifies if depth writing should be disabled
  20082. */
  20083. disableDepthWrite: boolean;
  20084. /**
  20085. * Specifies if depth writing should be forced
  20086. */
  20087. forceDepthWrite: boolean;
  20088. /**
  20089. * Specifies if there should be a separate pass for culling
  20090. */
  20091. separateCullingPass: boolean;
  20092. /**
  20093. * Stores the state specifing if fog should be enabled
  20094. */
  20095. private _fogEnabled;
  20096. /**
  20097. * Sets the state for enabling fog
  20098. */
  20099. /**
  20100. * Gets the value of the fog enabled state
  20101. */
  20102. fogEnabled: boolean;
  20103. /**
  20104. * Stores the size of points
  20105. */
  20106. pointSize: number;
  20107. /**
  20108. * Stores the z offset value
  20109. */
  20110. zOffset: number;
  20111. /**
  20112. * Gets a value specifying if wireframe mode is enabled
  20113. */
  20114. /**
  20115. * Sets the state of wireframe mode
  20116. */
  20117. wireframe: boolean;
  20118. /**
  20119. * Gets the value specifying if point clouds are enabled
  20120. */
  20121. /**
  20122. * Sets the state of point cloud mode
  20123. */
  20124. pointsCloud: boolean;
  20125. /**
  20126. * Gets the material fill mode
  20127. */
  20128. /**
  20129. * Sets the material fill mode
  20130. */
  20131. fillMode: number;
  20132. /**
  20133. * @hidden
  20134. * Stores the effects for the material
  20135. */ private _effect: Nullable<Effect>;
  20136. /**
  20137. * @hidden
  20138. * Specifies if the material was previously ready
  20139. */ private _wasPreviouslyReady: boolean;
  20140. /**
  20141. * Specifies if uniform buffers should be used
  20142. */
  20143. private _useUBO;
  20144. /**
  20145. * Stores a reference to the scene
  20146. */
  20147. private _scene;
  20148. /**
  20149. * Stores the fill mode state
  20150. */
  20151. private _fillMode;
  20152. /**
  20153. * Specifies if the depth write state should be cached
  20154. */
  20155. private _cachedDepthWriteState;
  20156. /**
  20157. * Stores the uniform buffer
  20158. */
  20159. protected _uniformBuffer: UniformBuffer;
  20160. /** @hidden */ private _indexInSceneMaterialArray: number;
  20161. /** @hidden */
  20162. meshMap: Nullable<{
  20163. [id: string]: AbstractMesh | undefined;
  20164. }>;
  20165. /**
  20166. * Creates a material instance
  20167. * @param name defines the name of the material
  20168. * @param scene defines the scene to reference
  20169. * @param doNotAdd specifies if the material should be added to the scene
  20170. */
  20171. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20172. /**
  20173. * Returns a string representation of the current material
  20174. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20175. * @returns a string with material information
  20176. */
  20177. toString(fullDetails?: boolean): string;
  20178. /**
  20179. * Gets the class name of the material
  20180. * @returns a string with the class name of the material
  20181. */
  20182. getClassName(): string;
  20183. /**
  20184. * Specifies if updates for the material been locked
  20185. */
  20186. readonly isFrozen: boolean;
  20187. /**
  20188. * Locks updates for the material
  20189. */
  20190. freeze(): void;
  20191. /**
  20192. * Unlocks updates for the material
  20193. */
  20194. unfreeze(): void;
  20195. /**
  20196. * Specifies if the material is ready to be used
  20197. * @param mesh defines the mesh to check
  20198. * @param useInstances specifies if instances should be used
  20199. * @returns a boolean indicating if the material is ready to be used
  20200. */
  20201. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20202. /**
  20203. * Specifies that the submesh is ready to be used
  20204. * @param mesh defines the mesh to check
  20205. * @param subMesh defines which submesh to check
  20206. * @param useInstances specifies that instances should be used
  20207. * @returns a boolean indicating that the submesh is ready or not
  20208. */
  20209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20210. /**
  20211. * Returns the material effect
  20212. * @returns the effect associated with the material
  20213. */
  20214. getEffect(): Nullable<Effect>;
  20215. /**
  20216. * Returns the current scene
  20217. * @returns a Scene
  20218. */
  20219. getScene(): Scene;
  20220. /**
  20221. * Specifies if the material will require alpha blending
  20222. * @returns a boolean specifying if alpha blending is needed
  20223. */
  20224. needAlphaBlending(): boolean;
  20225. /**
  20226. * Specifies if the mesh will require alpha blending
  20227. * @param mesh defines the mesh to check
  20228. * @returns a boolean specifying if alpha blending is needed for the mesh
  20229. */
  20230. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20231. /**
  20232. * Specifies if this material should be rendered in alpha test mode
  20233. * @returns a boolean specifying if an alpha test is needed.
  20234. */
  20235. needAlphaTesting(): boolean;
  20236. /**
  20237. * Gets the texture used for the alpha test
  20238. * @returns the texture to use for alpha testing
  20239. */
  20240. getAlphaTestTexture(): Nullable<BaseTexture>;
  20241. /**
  20242. * Marks the material to indicate that it needs to be re-calculated
  20243. */
  20244. markDirty(): void;
  20245. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20246. /**
  20247. * Binds the material to the mesh
  20248. * @param world defines the world transformation matrix
  20249. * @param mesh defines the mesh to bind the material to
  20250. */
  20251. bind(world: Matrix, mesh?: Mesh): void;
  20252. /**
  20253. * Binds the submesh to the material
  20254. * @param world defines the world transformation matrix
  20255. * @param mesh defines the mesh containing the submesh
  20256. * @param subMesh defines the submesh to bind the material to
  20257. */
  20258. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20259. /**
  20260. * Binds the world matrix to the material
  20261. * @param world defines the world transformation matrix
  20262. */
  20263. bindOnlyWorldMatrix(world: Matrix): void;
  20264. /**
  20265. * Binds the scene's uniform buffer to the effect.
  20266. * @param effect defines the effect to bind to the scene uniform buffer
  20267. * @param sceneUbo defines the uniform buffer storing scene data
  20268. */
  20269. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20270. /**
  20271. * Binds the view matrix to the effect
  20272. * @param effect defines the effect to bind the view matrix to
  20273. */
  20274. bindView(effect: Effect): void;
  20275. /**
  20276. * Binds the view projection matrix to the effect
  20277. * @param effect defines the effect to bind the view projection matrix to
  20278. */
  20279. bindViewProjection(effect: Effect): void;
  20280. /**
  20281. * Specifies if material alpha testing should be turned on for the mesh
  20282. * @param mesh defines the mesh to check
  20283. */
  20284. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20285. /**
  20286. * Processes to execute after binding the material to a mesh
  20287. * @param mesh defines the rendered mesh
  20288. */
  20289. protected _afterBind(mesh?: Mesh): void;
  20290. /**
  20291. * Unbinds the material from the mesh
  20292. */
  20293. unbind(): void;
  20294. /**
  20295. * Gets the active textures from the material
  20296. * @returns an array of textures
  20297. */
  20298. getActiveTextures(): BaseTexture[];
  20299. /**
  20300. * Specifies if the material uses a texture
  20301. * @param texture defines the texture to check against the material
  20302. * @returns a boolean specifying if the material uses the texture
  20303. */
  20304. hasTexture(texture: BaseTexture): boolean;
  20305. /**
  20306. * Makes a duplicate of the material, and gives it a new name
  20307. * @param name defines the new name for the duplicated material
  20308. * @returns the cloned material
  20309. */
  20310. clone(name: string): Nullable<Material>;
  20311. /**
  20312. * Gets the meshes bound to the material
  20313. * @returns an array of meshes bound to the material
  20314. */
  20315. getBindedMeshes(): AbstractMesh[];
  20316. /**
  20317. * Force shader compilation
  20318. * @param mesh defines the mesh associated with this material
  20319. * @param onCompiled defines a function to execute once the material is compiled
  20320. * @param options defines the options to configure the compilation
  20321. */
  20322. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20323. clipPlane: boolean;
  20324. }>): void;
  20325. /**
  20326. * Force shader compilation
  20327. * @param mesh defines the mesh that will use this material
  20328. * @param options defines additional options for compiling the shaders
  20329. * @returns a promise that resolves when the compilation completes
  20330. */
  20331. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20332. clipPlane: boolean;
  20333. }>): Promise<void>;
  20334. private static readonly _AllDirtyCallBack;
  20335. private static readonly _ImageProcessingDirtyCallBack;
  20336. private static readonly _TextureDirtyCallBack;
  20337. private static readonly _FresnelDirtyCallBack;
  20338. private static readonly _MiscDirtyCallBack;
  20339. private static readonly _LightsDirtyCallBack;
  20340. private static readonly _AttributeDirtyCallBack;
  20341. private static _FresnelAndMiscDirtyCallBack;
  20342. private static _TextureAndMiscDirtyCallBack;
  20343. private static readonly _DirtyCallbackArray;
  20344. private static readonly _RunDirtyCallBacks;
  20345. /**
  20346. * Marks a define in the material to indicate that it needs to be re-computed
  20347. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20348. */
  20349. markAsDirty(flag: number): void;
  20350. /**
  20351. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20352. * @param func defines a function which checks material defines against the submeshes
  20353. */
  20354. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20355. /**
  20356. * Indicates that we need to re-calculated for all submeshes
  20357. */
  20358. protected _markAllSubMeshesAsAllDirty(): void;
  20359. /**
  20360. * Indicates that image processing needs to be re-calculated for all submeshes
  20361. */
  20362. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20363. /**
  20364. * Indicates that textures need to be re-calculated for all submeshes
  20365. */
  20366. protected _markAllSubMeshesAsTexturesDirty(): void;
  20367. /**
  20368. * Indicates that fresnel needs to be re-calculated for all submeshes
  20369. */
  20370. protected _markAllSubMeshesAsFresnelDirty(): void;
  20371. /**
  20372. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20373. */
  20374. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20375. /**
  20376. * Indicates that lights need to be re-calculated for all submeshes
  20377. */
  20378. protected _markAllSubMeshesAsLightsDirty(): void;
  20379. /**
  20380. * Indicates that attributes need to be re-calculated for all submeshes
  20381. */
  20382. protected _markAllSubMeshesAsAttributesDirty(): void;
  20383. /**
  20384. * Indicates that misc needs to be re-calculated for all submeshes
  20385. */
  20386. protected _markAllSubMeshesAsMiscDirty(): void;
  20387. /**
  20388. * Indicates that textures and misc need to be re-calculated for all submeshes
  20389. */
  20390. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20391. /**
  20392. * Disposes the material
  20393. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20394. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20395. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20396. */
  20397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20398. /** @hidden */
  20399. private releaseVertexArrayObject;
  20400. /**
  20401. * Serializes this material
  20402. * @returns the serialized material object
  20403. */
  20404. serialize(): any;
  20405. /**
  20406. * Creates a material from parsed material data
  20407. * @param parsedMaterial defines parsed material data
  20408. * @param scene defines the hosting scene
  20409. * @param rootUrl defines the root URL to use to load textures
  20410. * @returns a new material
  20411. */
  20412. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20413. }
  20414. }
  20415. declare module BABYLON {
  20416. /**
  20417. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20418. * separate meshes. This can be use to improve performances.
  20419. * @see http://doc.babylonjs.com/how_to/multi_materials
  20420. */
  20421. export class MultiMaterial extends Material {
  20422. private _subMaterials;
  20423. /**
  20424. * Gets or Sets the list of Materials used within the multi material.
  20425. * They need to be ordered according to the submeshes order in the associated mesh
  20426. */
  20427. subMaterials: Nullable<Material>[];
  20428. /**
  20429. * Function used to align with Node.getChildren()
  20430. * @returns the list of Materials used within the multi material
  20431. */
  20432. getChildren(): Nullable<Material>[];
  20433. /**
  20434. * Instantiates a new Multi Material
  20435. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20436. * separate meshes. This can be use to improve performances.
  20437. * @see http://doc.babylonjs.com/how_to/multi_materials
  20438. * @param name Define the name in the scene
  20439. * @param scene Define the scene the material belongs to
  20440. */
  20441. constructor(name: string, scene: Scene);
  20442. private _hookArray;
  20443. /**
  20444. * Get one of the submaterial by its index in the submaterials array
  20445. * @param index The index to look the sub material at
  20446. * @returns The Material if the index has been defined
  20447. */
  20448. getSubMaterial(index: number): Nullable<Material>;
  20449. /**
  20450. * Get the list of active textures for the whole sub materials list.
  20451. * @returns All the textures that will be used during the rendering
  20452. */
  20453. getActiveTextures(): BaseTexture[];
  20454. /**
  20455. * Gets the current class name of the material e.g. "MultiMaterial"
  20456. * Mainly use in serialization.
  20457. * @returns the class name
  20458. */
  20459. getClassName(): string;
  20460. /**
  20461. * Checks if the material is ready to render the requested sub mesh
  20462. * @param mesh Define the mesh the submesh belongs to
  20463. * @param subMesh Define the sub mesh to look readyness for
  20464. * @param useInstances Define whether or not the material is used with instances
  20465. * @returns true if ready, otherwise false
  20466. */
  20467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20468. /**
  20469. * Clones the current material and its related sub materials
  20470. * @param name Define the name of the newly cloned material
  20471. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20472. * @returns the cloned material
  20473. */
  20474. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20475. /**
  20476. * Serializes the materials into a JSON representation.
  20477. * @returns the JSON representation
  20478. */
  20479. serialize(): any;
  20480. /**
  20481. * Dispose the material and release its associated resources
  20482. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  20483. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  20484. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  20485. */
  20486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20487. /**
  20488. * Creates a MultiMaterial from parsed MultiMaterial data.
  20489. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20490. * @param scene defines the hosting scene
  20491. * @returns a new MultiMaterial
  20492. */
  20493. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20494. }
  20495. }
  20496. declare module BABYLON {
  20497. /**
  20498. * Base class for submeshes
  20499. */
  20500. export class BaseSubMesh {
  20501. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20502. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20503. /**
  20504. * Gets associated effect
  20505. */
  20506. readonly effect: Nullable<Effect>;
  20507. /**
  20508. * Sets associated effect (effect used to render this submesh)
  20509. * @param effect defines the effect to associate with
  20510. * @param defines defines the set of defines used to compile this effect
  20511. */
  20512. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20513. }
  20514. /**
  20515. * Defines a subdivision inside a mesh
  20516. */
  20517. export class SubMesh extends BaseSubMesh implements ICullable {
  20518. /** the material index to use */
  20519. materialIndex: number;
  20520. /** vertex index start */
  20521. verticesStart: number;
  20522. /** vertices count */
  20523. verticesCount: number;
  20524. /** index start */
  20525. indexStart: number;
  20526. /** indices count */
  20527. indexCount: number;
  20528. /** @hidden */ private _linesIndexCount: number;
  20529. private _mesh;
  20530. private _renderingMesh;
  20531. private _boundingInfo;
  20532. private _linesIndexBuffer;
  20533. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20534. /** @hidden */ private _trianglePlanes: Plane[];
  20535. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20536. /** @hidden */ private _renderId: number;
  20537. /** @hidden */ private _alphaIndex: number;
  20538. /** @hidden */ private _distanceToCamera: number;
  20539. /** @hidden */ private _id: number;
  20540. private _currentMaterial;
  20541. /**
  20542. * Add a new submesh to a mesh
  20543. * @param materialIndex defines the material index to use
  20544. * @param verticesStart defines vertex index start
  20545. * @param verticesCount defines vertices count
  20546. * @param indexStart defines index start
  20547. * @param indexCount defines indices count
  20548. * @param mesh defines the parent mesh
  20549. * @param renderingMesh defines an optional rendering mesh
  20550. * @param createBoundingBox defines if bounding box should be created for this submesh
  20551. * @returns the new submesh
  20552. */
  20553. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20554. /**
  20555. * Creates a new submesh
  20556. * @param materialIndex defines the material index to use
  20557. * @param verticesStart defines vertex index start
  20558. * @param verticesCount defines vertices count
  20559. * @param indexStart defines index start
  20560. * @param indexCount defines indices count
  20561. * @param mesh defines the parent mesh
  20562. * @param renderingMesh defines an optional rendering mesh
  20563. * @param createBoundingBox defines if bounding box should be created for this submesh
  20564. */
  20565. constructor(
  20566. /** the material index to use */
  20567. materialIndex: number,
  20568. /** vertex index start */
  20569. verticesStart: number,
  20570. /** vertices count */
  20571. verticesCount: number,
  20572. /** index start */
  20573. indexStart: number,
  20574. /** indices count */
  20575. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20576. /**
  20577. * Returns true if this submesh covers the entire parent mesh
  20578. * @ignorenaming
  20579. */
  20580. readonly IsGlobal: boolean;
  20581. /**
  20582. * Returns the submesh BoudingInfo object
  20583. * @returns current bounding info (or mesh's one if the submesh is global)
  20584. */
  20585. getBoundingInfo(): BoundingInfo;
  20586. /**
  20587. * Sets the submesh BoundingInfo
  20588. * @param boundingInfo defines the new bounding info to use
  20589. * @returns the SubMesh
  20590. */
  20591. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20592. /**
  20593. * Returns the mesh of the current submesh
  20594. * @return the parent mesh
  20595. */
  20596. getMesh(): AbstractMesh;
  20597. /**
  20598. * Returns the rendering mesh of the submesh
  20599. * @returns the rendering mesh (could be different from parent mesh)
  20600. */
  20601. getRenderingMesh(): Mesh;
  20602. /**
  20603. * Returns the submesh material
  20604. * @returns null or the current material
  20605. */
  20606. getMaterial(): Nullable<Material>;
  20607. /**
  20608. * Sets a new updated BoundingInfo object to the submesh
  20609. * @param data defines an optional position array to use to determine the bounding info
  20610. * @returns the SubMesh
  20611. */
  20612. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20613. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20614. /**
  20615. * Updates the submesh BoundingInfo
  20616. * @param world defines the world matrix to use to update the bounding info
  20617. * @returns the submesh
  20618. */
  20619. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20620. /**
  20621. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20622. * @param frustumPlanes defines the frustum planes
  20623. * @returns true if the submesh is intersecting with the frustum
  20624. */
  20625. isInFrustum(frustumPlanes: Plane[]): boolean;
  20626. /**
  20627. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20628. * @param frustumPlanes defines the frustum planes
  20629. * @returns true if the submesh is inside the frustum
  20630. */
  20631. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20632. /**
  20633. * Renders the submesh
  20634. * @param enableAlphaMode defines if alpha needs to be used
  20635. * @returns the submesh
  20636. */
  20637. render(enableAlphaMode: boolean): SubMesh;
  20638. /**
  20639. * @hidden
  20640. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20641. /**
  20642. * Checks if the submesh intersects with a ray
  20643. * @param ray defines the ray to test
  20644. * @returns true is the passed ray intersects the submesh bounding box
  20645. */
  20646. canIntersects(ray: Ray): boolean;
  20647. /**
  20648. * Intersects current submesh with a ray
  20649. * @param ray defines the ray to test
  20650. * @param positions defines mesh's positions array
  20651. * @param indices defines mesh's indices array
  20652. * @param fastCheck defines if only bounding info should be used
  20653. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20654. * @returns intersection info or null if no intersection
  20655. */
  20656. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20657. /** @hidden */
  20658. private _intersectLines;
  20659. /** @hidden */
  20660. private _intersectUnIndexedLines;
  20661. /** @hidden */
  20662. private _intersectTriangles;
  20663. /** @hidden */
  20664. private _intersectUnIndexedTriangles;
  20665. /** @hidden */ private _rebuild(): void;
  20666. /**
  20667. * Creates a new submesh from the passed mesh
  20668. * @param newMesh defines the new hosting mesh
  20669. * @param newRenderingMesh defines an optional rendering mesh
  20670. * @returns the new submesh
  20671. */
  20672. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20673. /**
  20674. * Release associated resources
  20675. */
  20676. dispose(): void;
  20677. /**
  20678. * Gets the class name
  20679. * @returns the string "SubMesh".
  20680. */
  20681. getClassName(): string;
  20682. /**
  20683. * Creates a new submesh from indices data
  20684. * @param materialIndex the index of the main mesh material
  20685. * @param startIndex the index where to start the copy in the mesh indices array
  20686. * @param indexCount the number of indices to copy then from the startIndex
  20687. * @param mesh the main mesh to create the submesh from
  20688. * @param renderingMesh the optional rendering mesh
  20689. * @returns a new submesh
  20690. */
  20691. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20692. }
  20693. }
  20694. declare module BABYLON {
  20695. /**
  20696. * Class used to represent data loading progression
  20697. */
  20698. export class SceneLoaderFlags {
  20699. private static _ForceFullSceneLoadingForIncremental;
  20700. private static _ShowLoadingScreen;
  20701. private static _CleanBoneMatrixWeights;
  20702. private static _loggingLevel;
  20703. /**
  20704. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20705. */
  20706. static ForceFullSceneLoadingForIncremental: boolean;
  20707. /**
  20708. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20709. */
  20710. static ShowLoadingScreen: boolean;
  20711. /**
  20712. * Defines the current logging level (while loading the scene)
  20713. * @ignorenaming
  20714. */
  20715. static loggingLevel: number;
  20716. /**
  20717. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20718. */
  20719. static CleanBoneMatrixWeights: boolean;
  20720. }
  20721. }
  20722. declare module BABYLON {
  20723. /**
  20724. * Class used to store geometry data (vertex buffers + index buffer)
  20725. */
  20726. export class Geometry implements IGetSetVerticesData {
  20727. /**
  20728. * Gets or sets the ID of the geometry
  20729. */
  20730. id: string;
  20731. /**
  20732. * Gets or sets the unique ID of the geometry
  20733. */
  20734. uniqueId: number;
  20735. /**
  20736. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20737. */
  20738. delayLoadState: number;
  20739. /**
  20740. * Gets the file containing the data to load when running in delay load state
  20741. */
  20742. delayLoadingFile: Nullable<string>;
  20743. /**
  20744. * Callback called when the geometry is updated
  20745. */
  20746. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20747. private _scene;
  20748. private _engine;
  20749. private _meshes;
  20750. private _totalVertices;
  20751. /** @hidden */ private _indices: IndicesArray;
  20752. /** @hidden */ private _vertexBuffers: {
  20753. [key: string]: VertexBuffer;
  20754. };
  20755. private _isDisposed;
  20756. private _extend;
  20757. private _boundingBias;
  20758. /** @hidden */ private _delayInfo: Array<string>;
  20759. private _indexBuffer;
  20760. private _indexBufferIsUpdatable;
  20761. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20762. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20763. /** @hidden */ private _softwareSkinningFrameId: number;
  20764. private _vertexArrayObjects;
  20765. private _updatable;
  20766. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20767. /**
  20768. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  20769. */
  20770. /**
  20771. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  20772. */
  20773. boundingBias: Vector2;
  20774. /**
  20775. * Static function used to attach a new empty geometry to a mesh
  20776. * @param mesh defines the mesh to attach the geometry to
  20777. * @returns the new Geometry
  20778. */
  20779. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20780. /**
  20781. * Creates a new geometry
  20782. * @param id defines the unique ID
  20783. * @param scene defines the hosting scene
  20784. * @param vertexData defines the VertexData used to get geometry data
  20785. * @param updatable defines if geometry must be updatable (false by default)
  20786. * @param mesh defines the mesh that will be associated with the geometry
  20787. */
  20788. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20789. /**
  20790. * Gets the current extend of the geometry
  20791. */
  20792. readonly extend: {
  20793. minimum: Vector3;
  20794. maximum: Vector3;
  20795. };
  20796. /**
  20797. * Gets the hosting scene
  20798. * @returns the hosting Scene
  20799. */
  20800. getScene(): Scene;
  20801. /**
  20802. * Gets the hosting engine
  20803. * @returns the hosting Engine
  20804. */
  20805. getEngine(): Engine;
  20806. /**
  20807. * Defines if the geometry is ready to use
  20808. * @returns true if the geometry is ready to be used
  20809. */
  20810. isReady(): boolean;
  20811. /**
  20812. * Gets a value indicating that the geometry should not be serialized
  20813. */
  20814. readonly doNotSerialize: boolean;
  20815. /** @hidden */ private _rebuild(): void;
  20816. /**
  20817. * Affects all geometry data in one call
  20818. * @param vertexData defines the geometry data
  20819. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20820. */
  20821. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20822. /**
  20823. * Set specific vertex data
  20824. * @param kind defines the data kind (Position, normal, etc...)
  20825. * @param data defines the vertex data to use
  20826. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20827. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20828. */
  20829. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20830. /**
  20831. * Removes a specific vertex data
  20832. * @param kind defines the data kind (Position, normal, etc...)
  20833. */
  20834. removeVerticesData(kind: string): void;
  20835. /**
  20836. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20837. * @param buffer defines the vertex buffer to use
  20838. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20839. */
  20840. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20841. /**
  20842. * Update a specific vertex buffer
  20843. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20844. * It will do nothing if the buffer is not updatable
  20845. * @param kind defines the data kind (Position, normal, etc...)
  20846. * @param data defines the data to use
  20847. * @param offset defines the offset in the target buffer where to store the data
  20848. * @param useBytes set to true if the offset is in bytes
  20849. */
  20850. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20851. /**
  20852. * Update a specific vertex buffer
  20853. * This function will create a new buffer if the current one is not updatable
  20854. * @param kind defines the data kind (Position, normal, etc...)
  20855. * @param data defines the data to use
  20856. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20857. */
  20858. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20859. private _updateBoundingInfo;
  20860. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20861. /**
  20862. * Gets total number of vertices
  20863. * @returns the total number of vertices
  20864. */
  20865. getTotalVertices(): number;
  20866. /**
  20867. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20868. * @param kind defines the data kind (Position, normal, etc...)
  20869. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20870. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20871. * @returns a float array containing vertex data
  20872. */
  20873. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20874. /**
  20875. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20876. * @param kind defines the data kind (Position, normal, etc...)
  20877. * @returns true if the vertex buffer with the specified kind is updatable
  20878. */
  20879. isVertexBufferUpdatable(kind: string): boolean;
  20880. /**
  20881. * Gets a specific vertex buffer
  20882. * @param kind defines the data kind (Position, normal, etc...)
  20883. * @returns a VertexBuffer
  20884. */
  20885. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20886. /**
  20887. * Returns all vertex buffers
  20888. * @return an object holding all vertex buffers indexed by kind
  20889. */
  20890. getVertexBuffers(): Nullable<{
  20891. [key: string]: VertexBuffer;
  20892. }>;
  20893. /**
  20894. * Gets a boolean indicating if specific vertex buffer is present
  20895. * @param kind defines the data kind (Position, normal, etc...)
  20896. * @returns true if data is present
  20897. */
  20898. isVerticesDataPresent(kind: string): boolean;
  20899. /**
  20900. * Gets a list of all attached data kinds (Position, normal, etc...)
  20901. * @returns a list of string containing all kinds
  20902. */
  20903. getVerticesDataKinds(): string[];
  20904. /**
  20905. * Update index buffer
  20906. * @param indices defines the indices to store in the index buffer
  20907. * @param offset defines the offset in the target buffer where to store the data
  20908. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20909. */
  20910. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20911. /**
  20912. * Creates a new index buffer
  20913. * @param indices defines the indices to store in the index buffer
  20914. * @param totalVertices defines the total number of vertices (could be null)
  20915. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20916. */
  20917. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20918. /**
  20919. * Return the total number of indices
  20920. * @returns the total number of indices
  20921. */
  20922. getTotalIndices(): number;
  20923. /**
  20924. * Gets the index buffer array
  20925. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20926. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20927. * @returns the index buffer array
  20928. */
  20929. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20930. /**
  20931. * Gets the index buffer
  20932. * @return the index buffer
  20933. */
  20934. getIndexBuffer(): Nullable<DataBuffer>;
  20935. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20936. /**
  20937. * Release the associated resources for a specific mesh
  20938. * @param mesh defines the source mesh
  20939. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20940. */
  20941. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20942. /**
  20943. * Apply current geometry to a given mesh
  20944. * @param mesh defines the mesh to apply geometry to
  20945. */
  20946. applyToMesh(mesh: Mesh): void;
  20947. private _updateExtend;
  20948. private _applyToMesh;
  20949. private notifyUpdate;
  20950. /**
  20951. * Load the geometry if it was flagged as delay loaded
  20952. * @param scene defines the hosting scene
  20953. * @param onLoaded defines a callback called when the geometry is loaded
  20954. */
  20955. load(scene: Scene, onLoaded?: () => void): void;
  20956. private _queueLoad;
  20957. /**
  20958. * Invert the geometry to move from a right handed system to a left handed one.
  20959. */
  20960. toLeftHanded(): void;
  20961. /** @hidden */ private _resetPointsArrayCache(): void;
  20962. /** @hidden */ private _generatePointsArray(): boolean;
  20963. /**
  20964. * Gets a value indicating if the geometry is disposed
  20965. * @returns true if the geometry was disposed
  20966. */
  20967. isDisposed(): boolean;
  20968. private _disposeVertexArrayObjects;
  20969. /**
  20970. * Free all associated resources
  20971. */
  20972. dispose(): void;
  20973. /**
  20974. * Clone the current geometry into a new geometry
  20975. * @param id defines the unique ID of the new geometry
  20976. * @returns a new geometry object
  20977. */
  20978. copy(id: string): Geometry;
  20979. /**
  20980. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20981. * @return a JSON representation of the current geometry data (without the vertices data)
  20982. */
  20983. serialize(): any;
  20984. private toNumberArray;
  20985. /**
  20986. * Serialize all vertices data into a JSON oject
  20987. * @returns a JSON representation of the current geometry data
  20988. */
  20989. serializeVerticeData(): any;
  20990. /**
  20991. * Extracts a clone of a mesh geometry
  20992. * @param mesh defines the source mesh
  20993. * @param id defines the unique ID of the new geometry object
  20994. * @returns the new geometry object
  20995. */
  20996. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20997. /**
  20998. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20999. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21000. * Be aware Math.random() could cause collisions, but:
  21001. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21002. * @returns a string containing a new GUID
  21003. */
  21004. static RandomId(): string;
  21005. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21006. private static _CleanMatricesWeights;
  21007. /**
  21008. * Create a new geometry from persisted data (Using .babylon file format)
  21009. * @param parsedVertexData defines the persisted data
  21010. * @param scene defines the hosting scene
  21011. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21012. * @returns the new geometry object
  21013. */
  21014. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21015. }
  21016. }
  21017. declare module BABYLON {
  21018. /**
  21019. * Define an interface for all classes that will get and set the data on vertices
  21020. */
  21021. export interface IGetSetVerticesData {
  21022. /**
  21023. * Gets a boolean indicating if specific vertex data is present
  21024. * @param kind defines the vertex data kind to use
  21025. * @returns true is data kind is present
  21026. */
  21027. isVerticesDataPresent(kind: string): boolean;
  21028. /**
  21029. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21030. * @param kind defines the data kind (Position, normal, etc...)
  21031. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21032. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21033. * @returns a float array containing vertex data
  21034. */
  21035. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21036. /**
  21037. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21038. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21039. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21040. * @returns the indices array or an empty array if the mesh has no geometry
  21041. */
  21042. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21043. /**
  21044. * Set specific vertex data
  21045. * @param kind defines the data kind (Position, normal, etc...)
  21046. * @param data defines the vertex data to use
  21047. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21048. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21049. */
  21050. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21051. /**
  21052. * Update a specific associated vertex buffer
  21053. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21054. * - VertexBuffer.PositionKind
  21055. * - VertexBuffer.UVKind
  21056. * - VertexBuffer.UV2Kind
  21057. * - VertexBuffer.UV3Kind
  21058. * - VertexBuffer.UV4Kind
  21059. * - VertexBuffer.UV5Kind
  21060. * - VertexBuffer.UV6Kind
  21061. * - VertexBuffer.ColorKind
  21062. * - VertexBuffer.MatricesIndicesKind
  21063. * - VertexBuffer.MatricesIndicesExtraKind
  21064. * - VertexBuffer.MatricesWeightsKind
  21065. * - VertexBuffer.MatricesWeightsExtraKind
  21066. * @param data defines the data source
  21067. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21068. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21069. */
  21070. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21071. /**
  21072. * Creates a new index buffer
  21073. * @param indices defines the indices to store in the index buffer
  21074. * @param totalVertices defines the total number of vertices (could be null)
  21075. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21076. */
  21077. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21078. }
  21079. /**
  21080. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21081. */
  21082. export class VertexData {
  21083. /**
  21084. * Mesh side orientation : usually the external or front surface
  21085. */
  21086. static readonly FRONTSIDE: number;
  21087. /**
  21088. * Mesh side orientation : usually the internal or back surface
  21089. */
  21090. static readonly BACKSIDE: number;
  21091. /**
  21092. * Mesh side orientation : both internal and external or front and back surfaces
  21093. */
  21094. static readonly DOUBLESIDE: number;
  21095. /**
  21096. * Mesh side orientation : by default, `FRONTSIDE`
  21097. */
  21098. static readonly DEFAULTSIDE: number;
  21099. /**
  21100. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21101. */
  21102. positions: Nullable<FloatArray>;
  21103. /**
  21104. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21105. */
  21106. normals: Nullable<FloatArray>;
  21107. /**
  21108. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21109. */
  21110. tangents: Nullable<FloatArray>;
  21111. /**
  21112. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21113. */
  21114. uvs: Nullable<FloatArray>;
  21115. /**
  21116. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21117. */
  21118. uvs2: Nullable<FloatArray>;
  21119. /**
  21120. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21121. */
  21122. uvs3: Nullable<FloatArray>;
  21123. /**
  21124. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21125. */
  21126. uvs4: Nullable<FloatArray>;
  21127. /**
  21128. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21129. */
  21130. uvs5: Nullable<FloatArray>;
  21131. /**
  21132. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21133. */
  21134. uvs6: Nullable<FloatArray>;
  21135. /**
  21136. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21137. */
  21138. colors: Nullable<FloatArray>;
  21139. /**
  21140. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21141. */
  21142. matricesIndices: Nullable<FloatArray>;
  21143. /**
  21144. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21145. */
  21146. matricesWeights: Nullable<FloatArray>;
  21147. /**
  21148. * An array extending the number of possible indices
  21149. */
  21150. matricesIndicesExtra: Nullable<FloatArray>;
  21151. /**
  21152. * An array extending the number of possible weights when the number of indices is extended
  21153. */
  21154. matricesWeightsExtra: Nullable<FloatArray>;
  21155. /**
  21156. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21157. */
  21158. indices: Nullable<IndicesArray>;
  21159. /**
  21160. * Uses the passed data array to set the set the values for the specified kind of data
  21161. * @param data a linear array of floating numbers
  21162. * @param kind the type of data that is being set, eg positions, colors etc
  21163. */
  21164. set(data: FloatArray, kind: string): void;
  21165. /**
  21166. * Associates the vertexData to the passed Mesh.
  21167. * Sets it as updatable or not (default `false`)
  21168. * @param mesh the mesh the vertexData is applied to
  21169. * @param updatable when used and having the value true allows new data to update the vertexData
  21170. * @returns the VertexData
  21171. */
  21172. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21173. /**
  21174. * Associates the vertexData to the passed Geometry.
  21175. * Sets it as updatable or not (default `false`)
  21176. * @param geometry the geometry the vertexData is applied to
  21177. * @param updatable when used and having the value true allows new data to update the vertexData
  21178. * @returns VertexData
  21179. */
  21180. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21181. /**
  21182. * Updates the associated mesh
  21183. * @param mesh the mesh to be updated
  21184. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21185. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21186. * @returns VertexData
  21187. */
  21188. updateMesh(mesh: Mesh): VertexData;
  21189. /**
  21190. * Updates the associated geometry
  21191. * @param geometry the geometry to be updated
  21192. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21193. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21194. * @returns VertexData.
  21195. */
  21196. updateGeometry(geometry: Geometry): VertexData;
  21197. private _applyTo;
  21198. private _update;
  21199. /**
  21200. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21201. * @param matrix the transforming matrix
  21202. * @returns the VertexData
  21203. */
  21204. transform(matrix: Matrix): VertexData;
  21205. /**
  21206. * Merges the passed VertexData into the current one
  21207. * @param other the VertexData to be merged into the current one
  21208. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21209. * @returns the modified VertexData
  21210. */
  21211. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21212. private _mergeElement;
  21213. private _validate;
  21214. /**
  21215. * Serializes the VertexData
  21216. * @returns a serialized object
  21217. */
  21218. serialize(): any;
  21219. /**
  21220. * Extracts the vertexData from a mesh
  21221. * @param mesh the mesh from which to extract the VertexData
  21222. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21223. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21224. * @returns the object VertexData associated to the passed mesh
  21225. */
  21226. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21227. /**
  21228. * Extracts the vertexData from the geometry
  21229. * @param geometry the geometry from which to extract the VertexData
  21230. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21231. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21232. * @returns the object VertexData associated to the passed mesh
  21233. */
  21234. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21235. private static _ExtractFrom;
  21236. /**
  21237. * Creates the VertexData for a Ribbon
  21238. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21239. * * pathArray array of paths, each of which an array of successive Vector3
  21240. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21241. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21242. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  21243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21244. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21245. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21246. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21247. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21248. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21249. * @returns the VertexData of the ribbon
  21250. */
  21251. static CreateRibbon(options: {
  21252. pathArray: Vector3[][];
  21253. closeArray?: boolean;
  21254. closePath?: boolean;
  21255. offset?: number;
  21256. sideOrientation?: number;
  21257. frontUVs?: Vector4;
  21258. backUVs?: Vector4;
  21259. invertUV?: boolean;
  21260. uvs?: Vector2[];
  21261. colors?: Color4[];
  21262. }): VertexData;
  21263. /**
  21264. * Creates the VertexData for a box
  21265. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21266. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21267. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21268. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21269. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21270. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21271. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21273. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21274. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21275. * @returns the VertexData of the box
  21276. */
  21277. static CreateBox(options: {
  21278. size?: number;
  21279. width?: number;
  21280. height?: number;
  21281. depth?: number;
  21282. faceUV?: Vector4[];
  21283. faceColors?: Color4[];
  21284. sideOrientation?: number;
  21285. frontUVs?: Vector4;
  21286. backUVs?: Vector4;
  21287. }): VertexData;
  21288. /**
  21289. * Creates the VertexData for a tiled box
  21290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21291. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21292. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21293. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21295. * @returns the VertexData of the box
  21296. */
  21297. static CreateTiledBox(options: {
  21298. pattern?: number;
  21299. width?: number;
  21300. height?: number;
  21301. depth?: number;
  21302. tileSize?: number;
  21303. tileWidth?: number;
  21304. tileHeight?: number;
  21305. alignHorizontal?: number;
  21306. alignVertical?: number;
  21307. faceUV?: Vector4[];
  21308. faceColors?: Color4[];
  21309. sideOrientation?: number;
  21310. }): VertexData;
  21311. /**
  21312. * Creates the VertexData for a tiled plane
  21313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21314. * * pattern a limited pattern arrangement depending on the number
  21315. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21316. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21317. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21318. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21319. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21320. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21321. * @returns the VertexData of the tiled plane
  21322. */
  21323. static CreateTiledPlane(options: {
  21324. pattern?: number;
  21325. tileSize?: number;
  21326. tileWidth?: number;
  21327. tileHeight?: number;
  21328. size?: number;
  21329. width?: number;
  21330. height?: number;
  21331. alignHorizontal?: number;
  21332. alignVertical?: number;
  21333. sideOrientation?: number;
  21334. frontUVs?: Vector4;
  21335. backUVs?: Vector4;
  21336. }): VertexData;
  21337. /**
  21338. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21339. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21340. * * segments sets the number of horizontal strips optional, default 32
  21341. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21342. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21343. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21344. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21345. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  21346. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  21347. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21348. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21349. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21350. * @returns the VertexData of the ellipsoid
  21351. */
  21352. static CreateSphere(options: {
  21353. segments?: number;
  21354. diameter?: number;
  21355. diameterX?: number;
  21356. diameterY?: number;
  21357. diameterZ?: number;
  21358. arc?: number;
  21359. slice?: number;
  21360. sideOrientation?: number;
  21361. frontUVs?: Vector4;
  21362. backUVs?: Vector4;
  21363. }): VertexData;
  21364. /**
  21365. * Creates the VertexData for a cylinder, cone or prism
  21366. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21367. * * height sets the height (y direction) of the cylinder, optional, default 2
  21368. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21369. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21370. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21371. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21372. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21373. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  21374. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21375. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21376. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21377. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21379. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21380. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21381. * @returns the VertexData of the cylinder, cone or prism
  21382. */
  21383. static CreateCylinder(options: {
  21384. height?: number;
  21385. diameterTop?: number;
  21386. diameterBottom?: number;
  21387. diameter?: number;
  21388. tessellation?: number;
  21389. subdivisions?: number;
  21390. arc?: number;
  21391. faceColors?: Color4[];
  21392. faceUV?: Vector4[];
  21393. hasRings?: boolean;
  21394. enclose?: boolean;
  21395. sideOrientation?: number;
  21396. frontUVs?: Vector4;
  21397. backUVs?: Vector4;
  21398. }): VertexData;
  21399. /**
  21400. * Creates the VertexData for a torus
  21401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21402. * * diameter the diameter of the torus, optional default 1
  21403. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21404. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21406. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21407. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21408. * @returns the VertexData of the torus
  21409. */
  21410. static CreateTorus(options: {
  21411. diameter?: number;
  21412. thickness?: number;
  21413. tessellation?: number;
  21414. sideOrientation?: number;
  21415. frontUVs?: Vector4;
  21416. backUVs?: Vector4;
  21417. }): VertexData;
  21418. /**
  21419. * Creates the VertexData of the LineSystem
  21420. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21421. * - lines an array of lines, each line being an array of successive Vector3
  21422. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21423. * @returns the VertexData of the LineSystem
  21424. */
  21425. static CreateLineSystem(options: {
  21426. lines: Vector3[][];
  21427. colors?: Nullable<Color4[][]>;
  21428. }): VertexData;
  21429. /**
  21430. * Create the VertexData for a DashedLines
  21431. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21432. * - points an array successive Vector3
  21433. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21434. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21435. * - dashNb the intended total number of dashes, optional, default 200
  21436. * @returns the VertexData for the DashedLines
  21437. */
  21438. static CreateDashedLines(options: {
  21439. points: Vector3[];
  21440. dashSize?: number;
  21441. gapSize?: number;
  21442. dashNb?: number;
  21443. }): VertexData;
  21444. /**
  21445. * Creates the VertexData for a Ground
  21446. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21447. * - width the width (x direction) of the ground, optional, default 1
  21448. * - height the height (z direction) of the ground, optional, default 1
  21449. * - subdivisions the number of subdivisions per side, optional, default 1
  21450. * @returns the VertexData of the Ground
  21451. */
  21452. static CreateGround(options: {
  21453. width?: number;
  21454. height?: number;
  21455. subdivisions?: number;
  21456. subdivisionsX?: number;
  21457. subdivisionsY?: number;
  21458. }): VertexData;
  21459. /**
  21460. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21461. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21462. * * xmin the ground minimum X coordinate, optional, default -1
  21463. * * zmin the ground minimum Z coordinate, optional, default -1
  21464. * * xmax the ground maximum X coordinate, optional, default 1
  21465. * * zmax the ground maximum Z coordinate, optional, default 1
  21466. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  21467. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  21468. * @returns the VertexData of the TiledGround
  21469. */
  21470. static CreateTiledGround(options: {
  21471. xmin: number;
  21472. zmin: number;
  21473. xmax: number;
  21474. zmax: number;
  21475. subdivisions?: {
  21476. w: number;
  21477. h: number;
  21478. };
  21479. precision?: {
  21480. w: number;
  21481. h: number;
  21482. };
  21483. }): VertexData;
  21484. /**
  21485. * Creates the VertexData of the Ground designed from a heightmap
  21486. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21487. * * width the width (x direction) of the ground
  21488. * * height the height (z direction) of the ground
  21489. * * subdivisions the number of subdivisions per side
  21490. * * minHeight the minimum altitude on the ground, optional, default 0
  21491. * * maxHeight the maximum altitude on the ground, optional default 1
  21492. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21493. * * buffer the array holding the image color data
  21494. * * bufferWidth the width of image
  21495. * * bufferHeight the height of image
  21496. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21497. * @returns the VertexData of the Ground designed from a heightmap
  21498. */
  21499. static CreateGroundFromHeightMap(options: {
  21500. width: number;
  21501. height: number;
  21502. subdivisions: number;
  21503. minHeight: number;
  21504. maxHeight: number;
  21505. colorFilter: Color3;
  21506. buffer: Uint8Array;
  21507. bufferWidth: number;
  21508. bufferHeight: number;
  21509. alphaFilter: number;
  21510. }): VertexData;
  21511. /**
  21512. * Creates the VertexData for a Plane
  21513. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21514. * * size sets the width and height of the plane to the value of size, optional default 1
  21515. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21516. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21518. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21519. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21520. * @returns the VertexData of the box
  21521. */
  21522. static CreatePlane(options: {
  21523. size?: number;
  21524. width?: number;
  21525. height?: number;
  21526. sideOrientation?: number;
  21527. frontUVs?: Vector4;
  21528. backUVs?: Vector4;
  21529. }): VertexData;
  21530. /**
  21531. * Creates the VertexData of the Disc or regular Polygon
  21532. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21533. * * radius the radius of the disc, optional default 0.5
  21534. * * tessellation the number of polygon sides, optional, default 64
  21535. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  21536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21537. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21538. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21539. * @returns the VertexData of the box
  21540. */
  21541. static CreateDisc(options: {
  21542. radius?: number;
  21543. tessellation?: number;
  21544. arc?: number;
  21545. sideOrientation?: number;
  21546. frontUVs?: Vector4;
  21547. backUVs?: Vector4;
  21548. }): VertexData;
  21549. /**
  21550. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21551. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21552. * @param polygon a mesh built from polygonTriangulation.build()
  21553. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21554. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21555. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21556. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21557. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21558. * @returns the VertexData of the Polygon
  21559. */
  21560. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21561. /**
  21562. * Creates the VertexData of the IcoSphere
  21563. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21564. * * radius the radius of the IcoSphere, optional default 1
  21565. * * radiusX allows stretching in the x direction, optional, default radius
  21566. * * radiusY allows stretching in the y direction, optional, default radius
  21567. * * radiusZ allows stretching in the z direction, optional, default radius
  21568. * * flat when true creates a flat shaded mesh, optional, default true
  21569. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21570. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21571. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21572. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21573. * @returns the VertexData of the IcoSphere
  21574. */
  21575. static CreateIcoSphere(options: {
  21576. radius?: number;
  21577. radiusX?: number;
  21578. radiusY?: number;
  21579. radiusZ?: number;
  21580. flat?: boolean;
  21581. subdivisions?: number;
  21582. sideOrientation?: number;
  21583. frontUVs?: Vector4;
  21584. backUVs?: Vector4;
  21585. }): VertexData;
  21586. /**
  21587. * Creates the VertexData for a Polyhedron
  21588. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21589. * * type provided types are:
  21590. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21591. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  21592. * * size the size of the IcoSphere, optional default 1
  21593. * * sizeX allows stretching in the x direction, optional, default size
  21594. * * sizeY allows stretching in the y direction, optional, default size
  21595. * * sizeZ allows stretching in the z direction, optional, default size
  21596. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  21597. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21598. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21599. * * flat when true creates a flat shaded mesh, optional, default true
  21600. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21601. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21602. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21603. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21604. * @returns the VertexData of the Polyhedron
  21605. */
  21606. static CreatePolyhedron(options: {
  21607. type?: number;
  21608. size?: number;
  21609. sizeX?: number;
  21610. sizeY?: number;
  21611. sizeZ?: number;
  21612. custom?: any;
  21613. faceUV?: Vector4[];
  21614. faceColors?: Color4[];
  21615. flat?: boolean;
  21616. sideOrientation?: number;
  21617. frontUVs?: Vector4;
  21618. backUVs?: Vector4;
  21619. }): VertexData;
  21620. /**
  21621. * Creates the VertexData for a TorusKnot
  21622. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21623. * * radius the radius of the torus knot, optional, default 2
  21624. * * tube the thickness of the tube, optional, default 0.5
  21625. * * radialSegments the number of sides on each tube segments, optional, default 32
  21626. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21627. * * p the number of windings around the z axis, optional, default 2
  21628. * * q the number of windings around the x axis, optional, default 3
  21629. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21630. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21631. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21632. * @returns the VertexData of the Torus Knot
  21633. */
  21634. static CreateTorusKnot(options: {
  21635. radius?: number;
  21636. tube?: number;
  21637. radialSegments?: number;
  21638. tubularSegments?: number;
  21639. p?: number;
  21640. q?: number;
  21641. sideOrientation?: number;
  21642. frontUVs?: Vector4;
  21643. backUVs?: Vector4;
  21644. }): VertexData;
  21645. /**
  21646. * Compute normals for given positions and indices
  21647. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21648. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21649. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21650. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21651. * * facetNormals : optional array of facet normals (vector3)
  21652. * * facetPositions : optional array of facet positions (vector3)
  21653. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21654. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21655. * * bInfo : optional bounding info, required for facetPartitioning computation
  21656. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21657. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21658. * * useRightHandedSystem: optional boolean to for right handed system computation
  21659. * * depthSort : optional boolean to enable the facet depth sort computation
  21660. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21661. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21662. */
  21663. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21664. facetNormals?: any;
  21665. facetPositions?: any;
  21666. facetPartitioning?: any;
  21667. ratio?: number;
  21668. bInfo?: any;
  21669. bbSize?: Vector3;
  21670. subDiv?: any;
  21671. useRightHandedSystem?: boolean;
  21672. depthSort?: boolean;
  21673. distanceTo?: Vector3;
  21674. depthSortedFacets?: any;
  21675. }): void;
  21676. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21677. /**
  21678. * Applies VertexData created from the imported parameters to the geometry
  21679. * @param parsedVertexData the parsed data from an imported file
  21680. * @param geometry the geometry to apply the VertexData to
  21681. */
  21682. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21683. }
  21684. }
  21685. declare module BABYLON {
  21686. /**
  21687. * Defines a target to use with MorphTargetManager
  21688. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21689. */
  21690. export class MorphTarget implements IAnimatable {
  21691. /** defines the name of the target */
  21692. name: string;
  21693. /**
  21694. * Gets or sets the list of animations
  21695. */
  21696. animations: Animation[];
  21697. private _scene;
  21698. private _positions;
  21699. private _normals;
  21700. private _tangents;
  21701. private _uvs;
  21702. private _influence;
  21703. /**
  21704. * Observable raised when the influence changes
  21705. */
  21706. onInfluenceChanged: Observable<boolean>;
  21707. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21708. /**
  21709. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21710. */
  21711. influence: number;
  21712. /**
  21713. * Gets or sets the id of the morph Target
  21714. */
  21715. id: string;
  21716. private _animationPropertiesOverride;
  21717. /**
  21718. * Gets or sets the animation properties override
  21719. */
  21720. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21721. /**
  21722. * Creates a new MorphTarget
  21723. * @param name defines the name of the target
  21724. * @param influence defines the influence to use
  21725. * @param scene defines the scene the morphtarget belongs to
  21726. */
  21727. constructor(
  21728. /** defines the name of the target */
  21729. name: string, influence?: number, scene?: Nullable<Scene>);
  21730. /**
  21731. * Gets a boolean defining if the target contains position data
  21732. */
  21733. readonly hasPositions: boolean;
  21734. /**
  21735. * Gets a boolean defining if the target contains normal data
  21736. */
  21737. readonly hasNormals: boolean;
  21738. /**
  21739. * Gets a boolean defining if the target contains tangent data
  21740. */
  21741. readonly hasTangents: boolean;
  21742. /**
  21743. * Gets a boolean defining if the target contains texture coordinates data
  21744. */
  21745. readonly hasUVs: boolean;
  21746. /**
  21747. * Affects position data to this target
  21748. * @param data defines the position data to use
  21749. */
  21750. setPositions(data: Nullable<FloatArray>): void;
  21751. /**
  21752. * Gets the position data stored in this target
  21753. * @returns a FloatArray containing the position data (or null if not present)
  21754. */
  21755. getPositions(): Nullable<FloatArray>;
  21756. /**
  21757. * Affects normal data to this target
  21758. * @param data defines the normal data to use
  21759. */
  21760. setNormals(data: Nullable<FloatArray>): void;
  21761. /**
  21762. * Gets the normal data stored in this target
  21763. * @returns a FloatArray containing the normal data (or null if not present)
  21764. */
  21765. getNormals(): Nullable<FloatArray>;
  21766. /**
  21767. * Affects tangent data to this target
  21768. * @param data defines the tangent data to use
  21769. */
  21770. setTangents(data: Nullable<FloatArray>): void;
  21771. /**
  21772. * Gets the tangent data stored in this target
  21773. * @returns a FloatArray containing the tangent data (or null if not present)
  21774. */
  21775. getTangents(): Nullable<FloatArray>;
  21776. /**
  21777. * Affects texture coordinates data to this target
  21778. * @param data defines the texture coordinates data to use
  21779. */
  21780. setUVs(data: Nullable<FloatArray>): void;
  21781. /**
  21782. * Gets the texture coordinates data stored in this target
  21783. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21784. */
  21785. getUVs(): Nullable<FloatArray>;
  21786. /**
  21787. * Serializes the current target into a Serialization object
  21788. * @returns the serialized object
  21789. */
  21790. serialize(): any;
  21791. /**
  21792. * Returns the string "MorphTarget"
  21793. * @returns "MorphTarget"
  21794. */
  21795. getClassName(): string;
  21796. /**
  21797. * Creates a new target from serialized data
  21798. * @param serializationObject defines the serialized data to use
  21799. * @returns a new MorphTarget
  21800. */
  21801. static Parse(serializationObject: any): MorphTarget;
  21802. /**
  21803. * Creates a MorphTarget from mesh data
  21804. * @param mesh defines the source mesh
  21805. * @param name defines the name to use for the new target
  21806. * @param influence defines the influence to attach to the target
  21807. * @returns a new MorphTarget
  21808. */
  21809. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21810. }
  21811. }
  21812. declare module BABYLON {
  21813. /**
  21814. * This class is used to deform meshes using morphing between different targets
  21815. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21816. */
  21817. export class MorphTargetManager {
  21818. private _targets;
  21819. private _targetInfluenceChangedObservers;
  21820. private _targetDataLayoutChangedObservers;
  21821. private _activeTargets;
  21822. private _scene;
  21823. private _influences;
  21824. private _supportsNormals;
  21825. private _supportsTangents;
  21826. private _supportsUVs;
  21827. private _vertexCount;
  21828. private _uniqueId;
  21829. private _tempInfluences;
  21830. /**
  21831. * Gets or sets a boolean indicating if normals must be morphed
  21832. */
  21833. enableNormalMorphing: boolean;
  21834. /**
  21835. * Gets or sets a boolean indicating if tangents must be morphed
  21836. */
  21837. enableTangentMorphing: boolean;
  21838. /**
  21839. * Gets or sets a boolean indicating if UV must be morphed
  21840. */
  21841. enableUVMorphing: boolean;
  21842. /**
  21843. * Creates a new MorphTargetManager
  21844. * @param scene defines the current scene
  21845. */
  21846. constructor(scene?: Nullable<Scene>);
  21847. /**
  21848. * Gets the unique ID of this manager
  21849. */
  21850. readonly uniqueId: number;
  21851. /**
  21852. * Gets the number of vertices handled by this manager
  21853. */
  21854. readonly vertexCount: number;
  21855. /**
  21856. * Gets a boolean indicating if this manager supports morphing of normals
  21857. */
  21858. readonly supportsNormals: boolean;
  21859. /**
  21860. * Gets a boolean indicating if this manager supports morphing of tangents
  21861. */
  21862. readonly supportsTangents: boolean;
  21863. /**
  21864. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21865. */
  21866. readonly supportsUVs: boolean;
  21867. /**
  21868. * Gets the number of targets stored in this manager
  21869. */
  21870. readonly numTargets: number;
  21871. /**
  21872. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21873. */
  21874. readonly numInfluencers: number;
  21875. /**
  21876. * Gets the list of influences (one per target)
  21877. */
  21878. readonly influences: Float32Array;
  21879. /**
  21880. * Gets the active target at specified index. An active target is a target with an influence > 0
  21881. * @param index defines the index to check
  21882. * @returns the requested target
  21883. */
  21884. getActiveTarget(index: number): MorphTarget;
  21885. /**
  21886. * Gets the target at specified index
  21887. * @param index defines the index to check
  21888. * @returns the requested target
  21889. */
  21890. getTarget(index: number): MorphTarget;
  21891. /**
  21892. * Add a new target to this manager
  21893. * @param target defines the target to add
  21894. */
  21895. addTarget(target: MorphTarget): void;
  21896. /**
  21897. * Removes a target from the manager
  21898. * @param target defines the target to remove
  21899. */
  21900. removeTarget(target: MorphTarget): void;
  21901. /**
  21902. * Serializes the current manager into a Serialization object
  21903. * @returns the serialized object
  21904. */
  21905. serialize(): any;
  21906. private _syncActiveTargets;
  21907. /**
  21908. * Syncrhonize the targets with all the meshes using this morph target manager
  21909. */
  21910. synchronize(): void;
  21911. /**
  21912. * Creates a new MorphTargetManager from serialized data
  21913. * @param serializationObject defines the serialized data
  21914. * @param scene defines the hosting scene
  21915. * @returns the new MorphTargetManager
  21916. */
  21917. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21918. }
  21919. }
  21920. declare module BABYLON {
  21921. /**
  21922. * Class used to represent a specific level of detail of a mesh
  21923. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21924. */
  21925. export class MeshLODLevel {
  21926. /** Defines the distance where this level should start being displayed */
  21927. distance: number;
  21928. /** Defines the mesh to use to render this level */
  21929. mesh: Nullable<Mesh>;
  21930. /**
  21931. * Creates a new LOD level
  21932. * @param distance defines the distance where this level should star being displayed
  21933. * @param mesh defines the mesh to use to render this level
  21934. */
  21935. constructor(
  21936. /** Defines the distance where this level should start being displayed */
  21937. distance: number,
  21938. /** Defines the mesh to use to render this level */
  21939. mesh: Nullable<Mesh>);
  21940. }
  21941. }
  21942. declare module BABYLON {
  21943. /**
  21944. * Mesh representing the gorund
  21945. */
  21946. export class GroundMesh extends Mesh {
  21947. /** If octree should be generated */
  21948. generateOctree: boolean;
  21949. private _heightQuads;
  21950. /** @hidden */ private _subdivisionsX: number;
  21951. /** @hidden */ private _subdivisionsY: number;
  21952. /** @hidden */ private _width: number;
  21953. /** @hidden */ private _height: number;
  21954. /** @hidden */ private _minX: number;
  21955. /** @hidden */ private _maxX: number;
  21956. /** @hidden */ private _minZ: number;
  21957. /** @hidden */ private _maxZ: number;
  21958. constructor(name: string, scene: Scene);
  21959. /**
  21960. * "GroundMesh"
  21961. * @returns "GroundMesh"
  21962. */
  21963. getClassName(): string;
  21964. /**
  21965. * The minimum of x and y subdivisions
  21966. */
  21967. readonly subdivisions: number;
  21968. /**
  21969. * X subdivisions
  21970. */
  21971. readonly subdivisionsX: number;
  21972. /**
  21973. * Y subdivisions
  21974. */
  21975. readonly subdivisionsY: number;
  21976. /**
  21977. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21978. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21979. * @param chunksCount the number of subdivisions for x and y
  21980. * @param octreeBlocksSize (Default: 32)
  21981. */
  21982. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21983. /**
  21984. * Returns a height (y) value in the Worl system :
  21985. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21986. * @param x x coordinate
  21987. * @param z z coordinate
  21988. * @returns the ground y position if (x, z) are outside the ground surface.
  21989. */
  21990. getHeightAtCoordinates(x: number, z: number): number;
  21991. /**
  21992. * Returns a normalized vector (Vector3) orthogonal to the ground
  21993. * at the ground coordinates (x, z) expressed in the World system.
  21994. * @param x x coordinate
  21995. * @param z z coordinate
  21996. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21997. */
  21998. getNormalAtCoordinates(x: number, z: number): Vector3;
  21999. /**
  22000. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22001. * at the ground coordinates (x, z) expressed in the World system.
  22002. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22003. * @param x x coordinate
  22004. * @param z z coordinate
  22005. * @param ref vector to store the result
  22006. * @returns the GroundMesh.
  22007. */
  22008. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22009. /**
  22010. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22011. * if the ground has been updated.
  22012. * This can be used in the render loop.
  22013. * @returns the GroundMesh.
  22014. */
  22015. updateCoordinateHeights(): GroundMesh;
  22016. private _getFacetAt;
  22017. private _initHeightQuads;
  22018. private _computeHeightQuads;
  22019. /**
  22020. * Serializes this ground mesh
  22021. * @param serializationObject object to write serialization to
  22022. */
  22023. serialize(serializationObject: any): void;
  22024. /**
  22025. * Parses a serialized ground mesh
  22026. * @param parsedMesh the serialized mesh
  22027. * @param scene the scene to create the ground mesh in
  22028. * @returns the created ground mesh
  22029. */
  22030. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22031. }
  22032. }
  22033. declare module BABYLON {
  22034. /**
  22035. * Interface for Physics-Joint data
  22036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22037. */
  22038. export interface PhysicsJointData {
  22039. /**
  22040. * The main pivot of the joint
  22041. */
  22042. mainPivot?: Vector3;
  22043. /**
  22044. * The connected pivot of the joint
  22045. */
  22046. connectedPivot?: Vector3;
  22047. /**
  22048. * The main axis of the joint
  22049. */
  22050. mainAxis?: Vector3;
  22051. /**
  22052. * The connected axis of the joint
  22053. */
  22054. connectedAxis?: Vector3;
  22055. /**
  22056. * The collision of the joint
  22057. */
  22058. collision?: boolean;
  22059. /**
  22060. * Native Oimo/Cannon/Energy data
  22061. */
  22062. nativeParams?: any;
  22063. }
  22064. /**
  22065. * This is a holder class for the physics joint created by the physics plugin
  22066. * It holds a set of functions to control the underlying joint
  22067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22068. */
  22069. export class PhysicsJoint {
  22070. /**
  22071. * The type of the physics joint
  22072. */
  22073. type: number;
  22074. /**
  22075. * The data for the physics joint
  22076. */
  22077. jointData: PhysicsJointData;
  22078. private _physicsJoint;
  22079. protected _physicsPlugin: IPhysicsEnginePlugin;
  22080. /**
  22081. * Initializes the physics joint
  22082. * @param type The type of the physics joint
  22083. * @param jointData The data for the physics joint
  22084. */
  22085. constructor(
  22086. /**
  22087. * The type of the physics joint
  22088. */
  22089. type: number,
  22090. /**
  22091. * The data for the physics joint
  22092. */
  22093. jointData: PhysicsJointData);
  22094. /**
  22095. * Gets the physics joint
  22096. */
  22097. /**
  22098. * Sets the physics joint
  22099. */
  22100. physicsJoint: any;
  22101. /**
  22102. * Sets the physics plugin
  22103. */
  22104. physicsPlugin: IPhysicsEnginePlugin;
  22105. /**
  22106. * Execute a function that is physics-plugin specific.
  22107. * @param {Function} func the function that will be executed.
  22108. * It accepts two parameters: the physics world and the physics joint
  22109. */
  22110. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22111. /**
  22112. * Distance-Joint type
  22113. */
  22114. static DistanceJoint: number;
  22115. /**
  22116. * Hinge-Joint type
  22117. */
  22118. static HingeJoint: number;
  22119. /**
  22120. * Ball-and-Socket joint type
  22121. */
  22122. static BallAndSocketJoint: number;
  22123. /**
  22124. * Wheel-Joint type
  22125. */
  22126. static WheelJoint: number;
  22127. /**
  22128. * Slider-Joint type
  22129. */
  22130. static SliderJoint: number;
  22131. /**
  22132. * Prismatic-Joint type
  22133. */
  22134. static PrismaticJoint: number;
  22135. /**
  22136. * Universal-Joint type
  22137. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22138. */
  22139. static UniversalJoint: number;
  22140. /**
  22141. * Hinge-Joint 2 type
  22142. */
  22143. static Hinge2Joint: number;
  22144. /**
  22145. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22146. */
  22147. static PointToPointJoint: number;
  22148. /**
  22149. * Spring-Joint type
  22150. */
  22151. static SpringJoint: number;
  22152. /**
  22153. * Lock-Joint type
  22154. */
  22155. static LockJoint: number;
  22156. }
  22157. /**
  22158. * A class representing a physics distance joint
  22159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22160. */
  22161. export class DistanceJoint extends PhysicsJoint {
  22162. /**
  22163. *
  22164. * @param jointData The data for the Distance-Joint
  22165. */
  22166. constructor(jointData: DistanceJointData);
  22167. /**
  22168. * Update the predefined distance.
  22169. * @param maxDistance The maximum preferred distance
  22170. * @param minDistance The minimum preferred distance
  22171. */
  22172. updateDistance(maxDistance: number, minDistance?: number): void;
  22173. }
  22174. /**
  22175. * Represents a Motor-Enabled Joint
  22176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22177. */
  22178. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22179. /**
  22180. * Initializes the Motor-Enabled Joint
  22181. * @param type The type of the joint
  22182. * @param jointData The physica joint data for the joint
  22183. */
  22184. constructor(type: number, jointData: PhysicsJointData);
  22185. /**
  22186. * Set the motor values.
  22187. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22188. * @param force the force to apply
  22189. * @param maxForce max force for this motor.
  22190. */
  22191. setMotor(force?: number, maxForce?: number): void;
  22192. /**
  22193. * Set the motor's limits.
  22194. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22195. * @param upperLimit The upper limit of the motor
  22196. * @param lowerLimit The lower limit of the motor
  22197. */
  22198. setLimit(upperLimit: number, lowerLimit?: number): void;
  22199. }
  22200. /**
  22201. * This class represents a single physics Hinge-Joint
  22202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22203. */
  22204. export class HingeJoint extends MotorEnabledJoint {
  22205. /**
  22206. * Initializes the Hinge-Joint
  22207. * @param jointData The joint data for the Hinge-Joint
  22208. */
  22209. constructor(jointData: PhysicsJointData);
  22210. /**
  22211. * Set the motor values.
  22212. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22213. * @param {number} force the force to apply
  22214. * @param {number} maxForce max force for this motor.
  22215. */
  22216. setMotor(force?: number, maxForce?: number): void;
  22217. /**
  22218. * Set the motor's limits.
  22219. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22220. * @param upperLimit The upper limit of the motor
  22221. * @param lowerLimit The lower limit of the motor
  22222. */
  22223. setLimit(upperLimit: number, lowerLimit?: number): void;
  22224. }
  22225. /**
  22226. * This class represents a dual hinge physics joint (same as wheel joint)
  22227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22228. */
  22229. export class Hinge2Joint extends MotorEnabledJoint {
  22230. /**
  22231. * Initializes the Hinge2-Joint
  22232. * @param jointData The joint data for the Hinge2-Joint
  22233. */
  22234. constructor(jointData: PhysicsJointData);
  22235. /**
  22236. * Set the motor values.
  22237. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22238. * @param {number} targetSpeed the speed the motor is to reach
  22239. * @param {number} maxForce max force for this motor.
  22240. * @param {motorIndex} the motor's index, 0 or 1.
  22241. */
  22242. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22243. /**
  22244. * Set the motor limits.
  22245. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22246. * @param {number} upperLimit the upper limit
  22247. * @param {number} lowerLimit lower limit
  22248. * @param {motorIndex} the motor's index, 0 or 1.
  22249. */
  22250. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22251. }
  22252. /**
  22253. * Interface for a motor enabled joint
  22254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22255. */
  22256. export interface IMotorEnabledJoint {
  22257. /**
  22258. * Physics joint
  22259. */
  22260. physicsJoint: any;
  22261. /**
  22262. * Sets the motor of the motor-enabled joint
  22263. * @param force The force of the motor
  22264. * @param maxForce The maximum force of the motor
  22265. * @param motorIndex The index of the motor
  22266. */
  22267. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22268. /**
  22269. * Sets the limit of the motor
  22270. * @param upperLimit The upper limit of the motor
  22271. * @param lowerLimit The lower limit of the motor
  22272. * @param motorIndex The index of the motor
  22273. */
  22274. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22275. }
  22276. /**
  22277. * Joint data for a Distance-Joint
  22278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22279. */
  22280. export interface DistanceJointData extends PhysicsJointData {
  22281. /**
  22282. * Max distance the 2 joint objects can be apart
  22283. */
  22284. maxDistance: number;
  22285. }
  22286. /**
  22287. * Joint data from a spring joint
  22288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22289. */
  22290. export interface SpringJointData extends PhysicsJointData {
  22291. /**
  22292. * Length of the spring
  22293. */
  22294. length: number;
  22295. /**
  22296. * Stiffness of the spring
  22297. */
  22298. stiffness: number;
  22299. /**
  22300. * Damping of the spring
  22301. */
  22302. damping: number;
  22303. /** this callback will be called when applying the force to the impostors. */
  22304. forceApplicationCallback: () => void;
  22305. }
  22306. }
  22307. declare module BABYLON {
  22308. /**
  22309. * Holds the data for the raycast result
  22310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22311. */
  22312. export class PhysicsRaycastResult {
  22313. private _hasHit;
  22314. private _hitDistance;
  22315. private _hitNormalWorld;
  22316. private _hitPointWorld;
  22317. private _rayFromWorld;
  22318. private _rayToWorld;
  22319. /**
  22320. * Gets if there was a hit
  22321. */
  22322. readonly hasHit: boolean;
  22323. /**
  22324. * Gets the distance from the hit
  22325. */
  22326. readonly hitDistance: number;
  22327. /**
  22328. * Gets the hit normal/direction in the world
  22329. */
  22330. readonly hitNormalWorld: Vector3;
  22331. /**
  22332. * Gets the hit point in the world
  22333. */
  22334. readonly hitPointWorld: Vector3;
  22335. /**
  22336. * Gets the ray "start point" of the ray in the world
  22337. */
  22338. readonly rayFromWorld: Vector3;
  22339. /**
  22340. * Gets the ray "end point" of the ray in the world
  22341. */
  22342. readonly rayToWorld: Vector3;
  22343. /**
  22344. * Sets the hit data (normal & point in world space)
  22345. * @param hitNormalWorld defines the normal in world space
  22346. * @param hitPointWorld defines the point in world space
  22347. */
  22348. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22349. /**
  22350. * Sets the distance from the start point to the hit point
  22351. * @param distance
  22352. */
  22353. setHitDistance(distance: number): void;
  22354. /**
  22355. * Calculates the distance manually
  22356. */
  22357. calculateHitDistance(): void;
  22358. /**
  22359. * Resets all the values to default
  22360. * @param from The from point on world space
  22361. * @param to The to point on world space
  22362. */
  22363. reset(from?: Vector3, to?: Vector3): void;
  22364. }
  22365. /**
  22366. * Interface for the size containing width and height
  22367. */
  22368. interface IXYZ {
  22369. /**
  22370. * X
  22371. */
  22372. x: number;
  22373. /**
  22374. * Y
  22375. */
  22376. y: number;
  22377. /**
  22378. * Z
  22379. */
  22380. z: number;
  22381. }
  22382. }
  22383. declare module BABYLON {
  22384. /**
  22385. * Interface used to describe a physics joint
  22386. */
  22387. export interface PhysicsImpostorJoint {
  22388. /** Defines the main impostor to which the joint is linked */
  22389. mainImpostor: PhysicsImpostor;
  22390. /** Defines the impostor that is connected to the main impostor using this joint */
  22391. connectedImpostor: PhysicsImpostor;
  22392. /** Defines the joint itself */
  22393. joint: PhysicsJoint;
  22394. }
  22395. /** @hidden */
  22396. export interface IPhysicsEnginePlugin {
  22397. world: any;
  22398. name: string;
  22399. setGravity(gravity: Vector3): void;
  22400. setTimeStep(timeStep: number): void;
  22401. getTimeStep(): number;
  22402. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22404. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22405. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22406. removePhysicsBody(impostor: PhysicsImpostor): void;
  22407. generateJoint(joint: PhysicsImpostorJoint): void;
  22408. removeJoint(joint: PhysicsImpostorJoint): void;
  22409. isSupported(): boolean;
  22410. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22411. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22412. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22413. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22414. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22415. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22416. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22417. getBodyMass(impostor: PhysicsImpostor): number;
  22418. getBodyFriction(impostor: PhysicsImpostor): number;
  22419. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22420. getBodyRestitution(impostor: PhysicsImpostor): number;
  22421. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22422. getBodyPressure?(impostor: PhysicsImpostor): number;
  22423. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22424. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22425. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22426. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22427. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22428. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22429. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22430. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22431. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22432. sleepBody(impostor: PhysicsImpostor): void;
  22433. wakeUpBody(impostor: PhysicsImpostor): void;
  22434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22435. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22436. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22437. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22438. getRadius(impostor: PhysicsImpostor): number;
  22439. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22441. dispose(): void;
  22442. }
  22443. /**
  22444. * Interface used to define a physics engine
  22445. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22446. */
  22447. export interface IPhysicsEngine {
  22448. /**
  22449. * Gets the gravity vector used by the simulation
  22450. */
  22451. gravity: Vector3;
  22452. /**
  22453. * Sets the gravity vector used by the simulation
  22454. * @param gravity defines the gravity vector to use
  22455. */
  22456. setGravity(gravity: Vector3): void;
  22457. /**
  22458. * Set the time step of the physics engine.
  22459. * Default is 1/60.
  22460. * To slow it down, enter 1/600 for example.
  22461. * To speed it up, 1/30
  22462. * @param newTimeStep the new timestep to apply to this world.
  22463. */
  22464. setTimeStep(newTimeStep: number): void;
  22465. /**
  22466. * Get the time step of the physics engine.
  22467. * @returns the current time step
  22468. */
  22469. getTimeStep(): number;
  22470. /**
  22471. * Release all resources
  22472. */
  22473. dispose(): void;
  22474. /**
  22475. * Gets the name of the current physics plugin
  22476. * @returns the name of the plugin
  22477. */
  22478. getPhysicsPluginName(): string;
  22479. /**
  22480. * Adding a new impostor for the impostor tracking.
  22481. * This will be done by the impostor itself.
  22482. * @param impostor the impostor to add
  22483. */
  22484. addImpostor(impostor: PhysicsImpostor): void;
  22485. /**
  22486. * Remove an impostor from the engine.
  22487. * This impostor and its mesh will not longer be updated by the physics engine.
  22488. * @param impostor the impostor to remove
  22489. */
  22490. removeImpostor(impostor: PhysicsImpostor): void;
  22491. /**
  22492. * Add a joint to the physics engine
  22493. * @param mainImpostor defines the main impostor to which the joint is added.
  22494. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22495. * @param joint defines the joint that will connect both impostors.
  22496. */
  22497. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22498. /**
  22499. * Removes a joint from the simulation
  22500. * @param mainImpostor defines the impostor used with the joint
  22501. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22502. * @param joint defines the joint to remove
  22503. */
  22504. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22505. /**
  22506. * Gets the current plugin used to run the simulation
  22507. * @returns current plugin
  22508. */
  22509. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22510. /**
  22511. * Gets the list of physic impostors
  22512. * @returns an array of PhysicsImpostor
  22513. */
  22514. getImpostors(): Array<PhysicsImpostor>;
  22515. /**
  22516. * Gets the impostor for a physics enabled object
  22517. * @param object defines the object impersonated by the impostor
  22518. * @returns the PhysicsImpostor or null if not found
  22519. */
  22520. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22521. /**
  22522. * Gets the impostor for a physics body object
  22523. * @param body defines physics body used by the impostor
  22524. * @returns the PhysicsImpostor or null if not found
  22525. */
  22526. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22527. /**
  22528. * Does a raycast in the physics world
  22529. * @param from when should the ray start?
  22530. * @param to when should the ray end?
  22531. * @returns PhysicsRaycastResult
  22532. */
  22533. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22534. /**
  22535. * Called by the scene. No need to call it.
  22536. * @param delta defines the timespam between frames
  22537. */ private _step(delta: number): void;
  22538. }
  22539. }
  22540. declare module BABYLON {
  22541. /**
  22542. * The interface for the physics imposter parameters
  22543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22544. */
  22545. export interface PhysicsImpostorParameters {
  22546. /**
  22547. * The mass of the physics imposter
  22548. */
  22549. mass: number;
  22550. /**
  22551. * The friction of the physics imposter
  22552. */
  22553. friction?: number;
  22554. /**
  22555. * The coefficient of restitution of the physics imposter
  22556. */
  22557. restitution?: number;
  22558. /**
  22559. * The native options of the physics imposter
  22560. */
  22561. nativeOptions?: any;
  22562. /**
  22563. * Specifies if the parent should be ignored
  22564. */
  22565. ignoreParent?: boolean;
  22566. /**
  22567. * Specifies if bi-directional transformations should be disabled
  22568. */
  22569. disableBidirectionalTransformation?: boolean;
  22570. /**
  22571. * The pressure inside the physics imposter, soft object only
  22572. */
  22573. pressure?: number;
  22574. /**
  22575. * The stiffness the physics imposter, soft object only
  22576. */
  22577. stiffness?: number;
  22578. /**
  22579. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22580. */
  22581. velocityIterations?: number;
  22582. /**
  22583. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22584. */
  22585. positionIterations?: number;
  22586. /**
  22587. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22588. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22589. * Add to fix multiple points
  22590. */
  22591. fixedPoints?: number;
  22592. /**
  22593. * The collision margin around a soft object
  22594. */
  22595. margin?: number;
  22596. /**
  22597. * The collision margin around a soft object
  22598. */
  22599. damping?: number;
  22600. /**
  22601. * The path for a rope based on an extrusion
  22602. */
  22603. path?: any;
  22604. /**
  22605. * The shape of an extrusion used for a rope based on an extrusion
  22606. */
  22607. shape?: any;
  22608. }
  22609. /**
  22610. * Interface for a physics-enabled object
  22611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22612. */
  22613. export interface IPhysicsEnabledObject {
  22614. /**
  22615. * The position of the physics-enabled object
  22616. */
  22617. position: Vector3;
  22618. /**
  22619. * The rotation of the physics-enabled object
  22620. */
  22621. rotationQuaternion: Nullable<Quaternion>;
  22622. /**
  22623. * The scale of the physics-enabled object
  22624. */
  22625. scaling: Vector3;
  22626. /**
  22627. * The rotation of the physics-enabled object
  22628. */
  22629. rotation?: Vector3;
  22630. /**
  22631. * The parent of the physics-enabled object
  22632. */
  22633. parent?: any;
  22634. /**
  22635. * The bounding info of the physics-enabled object
  22636. * @returns The bounding info of the physics-enabled object
  22637. */
  22638. getBoundingInfo(): BoundingInfo;
  22639. /**
  22640. * Computes the world matrix
  22641. * @param force Specifies if the world matrix should be computed by force
  22642. * @returns A world matrix
  22643. */
  22644. computeWorldMatrix(force: boolean): Matrix;
  22645. /**
  22646. * Gets the world matrix
  22647. * @returns A world matrix
  22648. */
  22649. getWorldMatrix?(): Matrix;
  22650. /**
  22651. * Gets the child meshes
  22652. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22653. * @returns An array of abstract meshes
  22654. */
  22655. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22656. /**
  22657. * Gets the vertex data
  22658. * @param kind The type of vertex data
  22659. * @returns A nullable array of numbers, or a float32 array
  22660. */
  22661. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22662. /**
  22663. * Gets the indices from the mesh
  22664. * @returns A nullable array of index arrays
  22665. */
  22666. getIndices?(): Nullable<IndicesArray>;
  22667. /**
  22668. * Gets the scene from the mesh
  22669. * @returns the indices array or null
  22670. */
  22671. getScene?(): Scene;
  22672. /**
  22673. * Gets the absolute position from the mesh
  22674. * @returns the absolute position
  22675. */
  22676. getAbsolutePosition(): Vector3;
  22677. /**
  22678. * Gets the absolute pivot point from the mesh
  22679. * @returns the absolute pivot point
  22680. */
  22681. getAbsolutePivotPoint(): Vector3;
  22682. /**
  22683. * Rotates the mesh
  22684. * @param axis The axis of rotation
  22685. * @param amount The amount of rotation
  22686. * @param space The space of the rotation
  22687. * @returns The rotation transform node
  22688. */
  22689. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22690. /**
  22691. * Translates the mesh
  22692. * @param axis The axis of translation
  22693. * @param distance The distance of translation
  22694. * @param space The space of the translation
  22695. * @returns The transform node
  22696. */
  22697. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22698. /**
  22699. * Sets the absolute position of the mesh
  22700. * @param absolutePosition The absolute position of the mesh
  22701. * @returns The transform node
  22702. */
  22703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22704. /**
  22705. * Gets the class name of the mesh
  22706. * @returns The class name
  22707. */
  22708. getClassName(): string;
  22709. }
  22710. /**
  22711. * Represents a physics imposter
  22712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22713. */
  22714. export class PhysicsImpostor {
  22715. /**
  22716. * The physics-enabled object used as the physics imposter
  22717. */
  22718. object: IPhysicsEnabledObject;
  22719. /**
  22720. * The type of the physics imposter
  22721. */
  22722. type: number;
  22723. private _options;
  22724. private _scene?;
  22725. /**
  22726. * The default object size of the imposter
  22727. */
  22728. static DEFAULT_OBJECT_SIZE: Vector3;
  22729. /**
  22730. * The identity quaternion of the imposter
  22731. */
  22732. static IDENTITY_QUATERNION: Quaternion;
  22733. /** @hidden */ private _pluginData: any;
  22734. private _physicsEngine;
  22735. private _physicsBody;
  22736. private _bodyUpdateRequired;
  22737. private _onBeforePhysicsStepCallbacks;
  22738. private _onAfterPhysicsStepCallbacks;
  22739. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22740. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22741. otherImpostors: Array<PhysicsImpostor>;
  22742. }>;
  22743. private _deltaPosition;
  22744. private _deltaRotation;
  22745. private _deltaRotationConjugated;
  22746. /** @hidden */ private _isFromLine: boolean;
  22747. private _parent;
  22748. private _isDisposed;
  22749. private static _tmpVecs;
  22750. private static _tmpQuat;
  22751. /**
  22752. * Specifies if the physics imposter is disposed
  22753. */
  22754. readonly isDisposed: boolean;
  22755. /**
  22756. * Gets the mass of the physics imposter
  22757. */
  22758. mass: number;
  22759. /**
  22760. * Gets the coefficient of friction
  22761. */
  22762. /**
  22763. * Sets the coefficient of friction
  22764. */
  22765. friction: number;
  22766. /**
  22767. * Gets the coefficient of restitution
  22768. */
  22769. /**
  22770. * Sets the coefficient of restitution
  22771. */
  22772. restitution: number;
  22773. /**
  22774. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22775. */
  22776. /**
  22777. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22778. */
  22779. pressure: number;
  22780. /**
  22781. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22782. */
  22783. /**
  22784. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22785. */
  22786. stiffness: number;
  22787. /**
  22788. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22789. */
  22790. /**
  22791. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22792. */
  22793. velocityIterations: number;
  22794. /**
  22795. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22796. */
  22797. /**
  22798. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22799. */
  22800. positionIterations: number;
  22801. /**
  22802. * The unique id of the physics imposter
  22803. * set by the physics engine when adding this impostor to the array
  22804. */
  22805. uniqueId: number;
  22806. /**
  22807. * @hidden
  22808. */
  22809. soft: boolean;
  22810. /**
  22811. * @hidden
  22812. */
  22813. segments: number;
  22814. private _joints;
  22815. /**
  22816. * Initializes the physics imposter
  22817. * @param object The physics-enabled object used as the physics imposter
  22818. * @param type The type of the physics imposter
  22819. * @param _options The options for the physics imposter
  22820. * @param _scene The Babylon scene
  22821. */
  22822. constructor(
  22823. /**
  22824. * The physics-enabled object used as the physics imposter
  22825. */
  22826. object: IPhysicsEnabledObject,
  22827. /**
  22828. * The type of the physics imposter
  22829. */
  22830. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22831. /**
  22832. * This function will completly initialize this impostor.
  22833. * It will create a new body - but only if this mesh has no parent.
  22834. * If it has, this impostor will not be used other than to define the impostor
  22835. * of the child mesh.
  22836. * @hidden
  22837. */ private _init(): void;
  22838. private _getPhysicsParent;
  22839. /**
  22840. * Should a new body be generated.
  22841. * @returns boolean specifying if body initialization is required
  22842. */
  22843. isBodyInitRequired(): boolean;
  22844. /**
  22845. * Sets the updated scaling
  22846. * @param updated Specifies if the scaling is updated
  22847. */
  22848. setScalingUpdated(): void;
  22849. /**
  22850. * Force a regeneration of this or the parent's impostor's body.
  22851. * Use under cautious - This will remove all joints already implemented.
  22852. */
  22853. forceUpdate(): void;
  22854. /**
  22855. * Gets the body that holds this impostor. Either its own, or its parent.
  22856. */
  22857. /**
  22858. * Set the physics body. Used mainly by the physics engine/plugin
  22859. */
  22860. physicsBody: any;
  22861. /**
  22862. * Get the parent of the physics imposter
  22863. * @returns Physics imposter or null
  22864. */
  22865. /**
  22866. * Sets the parent of the physics imposter
  22867. */
  22868. parent: Nullable<PhysicsImpostor>;
  22869. /**
  22870. * Resets the update flags
  22871. */
  22872. resetUpdateFlags(): void;
  22873. /**
  22874. * Gets the object extend size
  22875. * @returns the object extend size
  22876. */
  22877. getObjectExtendSize(): Vector3;
  22878. /**
  22879. * Gets the object center
  22880. * @returns The object center
  22881. */
  22882. getObjectCenter(): Vector3;
  22883. /**
  22884. * Get a specific parametes from the options parameter
  22885. * @param paramName The object parameter name
  22886. * @returns The object parameter
  22887. */
  22888. getParam(paramName: string): any;
  22889. /**
  22890. * Sets a specific parameter in the options given to the physics plugin
  22891. * @param paramName The parameter name
  22892. * @param value The value of the parameter
  22893. */
  22894. setParam(paramName: string, value: number): void;
  22895. /**
  22896. * Specifically change the body's mass option. Won't recreate the physics body object
  22897. * @param mass The mass of the physics imposter
  22898. */
  22899. setMass(mass: number): void;
  22900. /**
  22901. * Gets the linear velocity
  22902. * @returns linear velocity or null
  22903. */
  22904. getLinearVelocity(): Nullable<Vector3>;
  22905. /**
  22906. * Sets the linear velocity
  22907. * @param velocity linear velocity or null
  22908. */
  22909. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22910. /**
  22911. * Gets the angular velocity
  22912. * @returns angular velocity or null
  22913. */
  22914. getAngularVelocity(): Nullable<Vector3>;
  22915. /**
  22916. * Sets the angular velocity
  22917. * @param velocity The velocity or null
  22918. */
  22919. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22920. /**
  22921. * Execute a function with the physics plugin native code
  22922. * Provide a function the will have two variables - the world object and the physics body object
  22923. * @param func The function to execute with the physics plugin native code
  22924. */
  22925. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22926. /**
  22927. * Register a function that will be executed before the physics world is stepping forward
  22928. * @param func The function to execute before the physics world is stepped forward
  22929. */
  22930. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22931. /**
  22932. * Unregister a function that will be executed before the physics world is stepping forward
  22933. * @param func The function to execute before the physics world is stepped forward
  22934. */
  22935. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22936. /**
  22937. * Register a function that will be executed after the physics step
  22938. * @param func The function to execute after physics step
  22939. */
  22940. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22941. /**
  22942. * Unregisters a function that will be executed after the physics step
  22943. * @param func The function to execute after physics step
  22944. */
  22945. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22946. /**
  22947. * register a function that will be executed when this impostor collides against a different body
  22948. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22949. * @param func Callback that is executed on collision
  22950. */
  22951. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22952. /**
  22953. * Unregisters the physics imposter on contact
  22954. * @param collideAgainst The physics object to collide against
  22955. * @param func Callback to execute on collision
  22956. */
  22957. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22958. private _tmpQuat;
  22959. private _tmpQuat2;
  22960. /**
  22961. * Get the parent rotation
  22962. * @returns The parent rotation
  22963. */
  22964. getParentsRotation(): Quaternion;
  22965. /**
  22966. * this function is executed by the physics engine.
  22967. */
  22968. beforeStep: () => void;
  22969. /**
  22970. * this function is executed by the physics engine
  22971. */
  22972. afterStep: () => void;
  22973. /**
  22974. * Legacy collision detection event support
  22975. */
  22976. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22977. /**
  22978. * event and body object due to cannon's event-based architecture.
  22979. */
  22980. onCollide: (e: {
  22981. body: any;
  22982. }) => void;
  22983. /**
  22984. * Apply a force
  22985. * @param force The force to apply
  22986. * @param contactPoint The contact point for the force
  22987. * @returns The physics imposter
  22988. */
  22989. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22990. /**
  22991. * Apply an impulse
  22992. * @param force The impulse force
  22993. * @param contactPoint The contact point for the impulse force
  22994. * @returns The physics imposter
  22995. */
  22996. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22997. /**
  22998. * A help function to create a joint
  22999. * @param otherImpostor A physics imposter used to create a joint
  23000. * @param jointType The type of joint
  23001. * @param jointData The data for the joint
  23002. * @returns The physics imposter
  23003. */
  23004. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23005. /**
  23006. * Add a joint to this impostor with a different impostor
  23007. * @param otherImpostor A physics imposter used to add a joint
  23008. * @param joint The joint to add
  23009. * @returns The physics imposter
  23010. */
  23011. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23012. /**
  23013. * Add an anchor to a cloth impostor
  23014. * @param otherImpostor rigid impostor to anchor to
  23015. * @param width ratio across width from 0 to 1
  23016. * @param height ratio up height from 0 to 1
  23017. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23018. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23019. * @returns impostor the soft imposter
  23020. */
  23021. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23022. /**
  23023. * Add a hook to a rope impostor
  23024. * @param otherImpostor rigid impostor to anchor to
  23025. * @param length ratio across rope from 0 to 1
  23026. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23027. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23028. * @returns impostor the rope imposter
  23029. */
  23030. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23031. /**
  23032. * Will keep this body still, in a sleep mode.
  23033. * @returns the physics imposter
  23034. */
  23035. sleep(): PhysicsImpostor;
  23036. /**
  23037. * Wake the body up.
  23038. * @returns The physics imposter
  23039. */
  23040. wakeUp(): PhysicsImpostor;
  23041. /**
  23042. * Clones the physics imposter
  23043. * @param newObject The physics imposter clones to this physics-enabled object
  23044. * @returns A nullable physics imposter
  23045. */
  23046. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23047. /**
  23048. * Disposes the physics imposter
  23049. */
  23050. dispose(): void;
  23051. /**
  23052. * Sets the delta position
  23053. * @param position The delta position amount
  23054. */
  23055. setDeltaPosition(position: Vector3): void;
  23056. /**
  23057. * Sets the delta rotation
  23058. * @param rotation The delta rotation amount
  23059. */
  23060. setDeltaRotation(rotation: Quaternion): void;
  23061. /**
  23062. * Gets the box size of the physics imposter and stores the result in the input parameter
  23063. * @param result Stores the box size
  23064. * @returns The physics imposter
  23065. */
  23066. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23067. /**
  23068. * Gets the radius of the physics imposter
  23069. * @returns Radius of the physics imposter
  23070. */
  23071. getRadius(): number;
  23072. /**
  23073. * Sync a bone with this impostor
  23074. * @param bone The bone to sync to the impostor.
  23075. * @param boneMesh The mesh that the bone is influencing.
  23076. * @param jointPivot The pivot of the joint / bone in local space.
  23077. * @param distToJoint Optional distance from the impostor to the joint.
  23078. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23079. */
  23080. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23081. /**
  23082. * Sync impostor to a bone
  23083. * @param bone The bone that the impostor will be synced to.
  23084. * @param boneMesh The mesh that the bone is influencing.
  23085. * @param jointPivot The pivot of the joint / bone in local space.
  23086. * @param distToJoint Optional distance from the impostor to the joint.
  23087. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23088. * @param boneAxis Optional vector3 axis the bone is aligned with
  23089. */
  23090. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23091. /**
  23092. * No-Imposter type
  23093. */
  23094. static NoImpostor: number;
  23095. /**
  23096. * Sphere-Imposter type
  23097. */
  23098. static SphereImpostor: number;
  23099. /**
  23100. * Box-Imposter type
  23101. */
  23102. static BoxImpostor: number;
  23103. /**
  23104. * Plane-Imposter type
  23105. */
  23106. static PlaneImpostor: number;
  23107. /**
  23108. * Mesh-imposter type
  23109. */
  23110. static MeshImpostor: number;
  23111. /**
  23112. * Capsule-Impostor type (Ammo.js plugin only)
  23113. */
  23114. static CapsuleImpostor: number;
  23115. /**
  23116. * Cylinder-Imposter type
  23117. */
  23118. static CylinderImpostor: number;
  23119. /**
  23120. * Particle-Imposter type
  23121. */
  23122. static ParticleImpostor: number;
  23123. /**
  23124. * Heightmap-Imposter type
  23125. */
  23126. static HeightmapImpostor: number;
  23127. /**
  23128. * ConvexHull-Impostor type (Ammo.js plugin only)
  23129. */
  23130. static ConvexHullImpostor: number;
  23131. /**
  23132. * Rope-Imposter type
  23133. */
  23134. static RopeImpostor: number;
  23135. /**
  23136. * Cloth-Imposter type
  23137. */
  23138. static ClothImpostor: number;
  23139. /**
  23140. * Softbody-Imposter type
  23141. */
  23142. static SoftbodyImpostor: number;
  23143. }
  23144. }
  23145. declare module BABYLON {
  23146. /**
  23147. * @hidden
  23148. **/
  23149. export class _CreationDataStorage {
  23150. closePath?: boolean;
  23151. closeArray?: boolean;
  23152. idx: number[];
  23153. dashSize: number;
  23154. gapSize: number;
  23155. path3D: Path3D;
  23156. pathArray: Vector3[][];
  23157. arc: number;
  23158. radius: number;
  23159. cap: number;
  23160. tessellation: number;
  23161. }
  23162. /**
  23163. * @hidden
  23164. **/ private class _InstanceDataStorage {
  23165. visibleInstances: any;
  23166. batchCache: _InstancesBatch;
  23167. instancesBufferSize: number;
  23168. instancesBuffer: Nullable<Buffer>;
  23169. instancesData: Float32Array;
  23170. overridenInstanceCount: number;
  23171. isFrozen: boolean;
  23172. previousBatch: Nullable<_InstancesBatch>;
  23173. hardwareInstancedRendering: boolean;
  23174. sideOrientation: number;
  23175. }
  23176. /**
  23177. * @hidden
  23178. **/
  23179. export class _InstancesBatch {
  23180. mustReturn: boolean;
  23181. visibleInstances: Nullable<InstancedMesh[]>[];
  23182. renderSelf: boolean[];
  23183. hardwareInstancedRendering: boolean[];
  23184. }
  23185. /**
  23186. * Class used to represent renderable models
  23187. */
  23188. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23189. /**
  23190. * Mesh side orientation : usually the external or front surface
  23191. */
  23192. static readonly FRONTSIDE: number;
  23193. /**
  23194. * Mesh side orientation : usually the internal or back surface
  23195. */
  23196. static readonly BACKSIDE: number;
  23197. /**
  23198. * Mesh side orientation : both internal and external or front and back surfaces
  23199. */
  23200. static readonly DOUBLESIDE: number;
  23201. /**
  23202. * Mesh side orientation : by default, `FRONTSIDE`
  23203. */
  23204. static readonly DEFAULTSIDE: number;
  23205. /**
  23206. * Mesh cap setting : no cap
  23207. */
  23208. static readonly NO_CAP: number;
  23209. /**
  23210. * Mesh cap setting : one cap at the beginning of the mesh
  23211. */
  23212. static readonly CAP_START: number;
  23213. /**
  23214. * Mesh cap setting : one cap at the end of the mesh
  23215. */
  23216. static readonly CAP_END: number;
  23217. /**
  23218. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23219. */
  23220. static readonly CAP_ALL: number;
  23221. /**
  23222. * Mesh pattern setting : no flip or rotate
  23223. */
  23224. static readonly NO_FLIP: number;
  23225. /**
  23226. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23227. */
  23228. static readonly FLIP_TILE: number;
  23229. /**
  23230. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23231. */
  23232. static readonly ROTATE_TILE: number;
  23233. /**
  23234. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23235. */
  23236. static readonly FLIP_ROW: number;
  23237. /**
  23238. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23239. */
  23240. static readonly ROTATE_ROW: number;
  23241. /**
  23242. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23243. */
  23244. static readonly FLIP_N_ROTATE_TILE: number;
  23245. /**
  23246. * Mesh pattern setting : rotate pattern and rotate
  23247. */
  23248. static readonly FLIP_N_ROTATE_ROW: number;
  23249. /**
  23250. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23251. */
  23252. static readonly CENTER: number;
  23253. /**
  23254. * Mesh tile positioning : part tiles on left
  23255. */
  23256. static readonly LEFT: number;
  23257. /**
  23258. * Mesh tile positioning : part tiles on right
  23259. */
  23260. static readonly RIGHT: number;
  23261. /**
  23262. * Mesh tile positioning : part tiles on top
  23263. */
  23264. static readonly TOP: number;
  23265. /**
  23266. * Mesh tile positioning : part tiles on bottom
  23267. */
  23268. static readonly BOTTOM: number;
  23269. /**
  23270. * Gets the default side orientation.
  23271. * @param orientation the orientation to value to attempt to get
  23272. * @returns the default orientation
  23273. * @hidden
  23274. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23275. private _internalMeshDataInfo;
  23276. /**
  23277. * An event triggered before rendering the mesh
  23278. */
  23279. readonly onBeforeRenderObservable: Observable<Mesh>;
  23280. /**
  23281. * An event triggered before binding the mesh
  23282. */
  23283. readonly onBeforeBindObservable: Observable<Mesh>;
  23284. /**
  23285. * An event triggered after rendering the mesh
  23286. */
  23287. readonly onAfterRenderObservable: Observable<Mesh>;
  23288. /**
  23289. * An event triggered before drawing the mesh
  23290. */
  23291. readonly onBeforeDrawObservable: Observable<Mesh>;
  23292. private _onBeforeDrawObserver;
  23293. /**
  23294. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23295. */
  23296. onBeforeDraw: () => void;
  23297. readonly hasInstances: boolean;
  23298. /**
  23299. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23300. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23301. */
  23302. delayLoadState: number;
  23303. /**
  23304. * Gets the list of instances created from this mesh
  23305. * it is not supposed to be modified manually.
  23306. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23307. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23308. */
  23309. instances: InstancedMesh[];
  23310. /**
  23311. * Gets the file containing delay loading data for this mesh
  23312. */
  23313. delayLoadingFile: string;
  23314. /** @hidden */ private _binaryInfo: any;
  23315. /**
  23316. * User defined function used to change how LOD level selection is done
  23317. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23318. */
  23319. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23320. /**
  23321. * Gets or sets the morph target manager
  23322. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23323. */
  23324. morphTargetManager: Nullable<MorphTargetManager>;
  23325. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23326. /** @hidden */ private _geometry: Nullable<Geometry>;
  23327. /** @hidden */ private _delayInfo: Array<string>;
  23328. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23329. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23330. private _effectiveMaterial;
  23331. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23332. /** @hidden */ private _originalBuilderSideOrientation: number;
  23333. /**
  23334. * Use this property to change the original side orientation defined at construction time
  23335. */
  23336. overrideMaterialSideOrientation: Nullable<number>;
  23337. /**
  23338. * Gets the source mesh (the one used to clone this one from)
  23339. */
  23340. readonly source: Nullable<Mesh>;
  23341. /**
  23342. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23343. */
  23344. isUnIndexed: boolean;
  23345. /**
  23346. * @constructor
  23347. * @param name The value used by scene.getMeshByName() to do a lookup.
  23348. * @param scene The scene to add this mesh to.
  23349. * @param parent The parent of this mesh, if it has one
  23350. * @param source An optional Mesh from which geometry is shared, cloned.
  23351. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23352. * When false, achieved by calling a clone(), also passing False.
  23353. * This will make creation of children, recursive.
  23354. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23355. */
  23356. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23357. instantiateHierarychy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23358. /**
  23359. * Gets the class name
  23360. * @returns the string "Mesh".
  23361. */
  23362. getClassName(): string;
  23363. /** @hidden */ protected readonly _isMesh: boolean;
  23364. /**
  23365. * Returns a description of this mesh
  23366. * @param fullDetails define if full details about this mesh must be used
  23367. * @returns a descriptive string representing this mesh
  23368. */
  23369. toString(fullDetails?: boolean): string;
  23370. /** @hidden */ private _unBindEffect(): void;
  23371. /**
  23372. * Gets a boolean indicating if this mesh has LOD
  23373. */
  23374. readonly hasLODLevels: boolean;
  23375. /**
  23376. * Gets the list of MeshLODLevel associated with the current mesh
  23377. * @returns an array of MeshLODLevel
  23378. */
  23379. getLODLevels(): MeshLODLevel[];
  23380. private _sortLODLevels;
  23381. /**
  23382. * Add a mesh as LOD level triggered at the given distance.
  23383. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23384. * @param distance The distance from the center of the object to show this level
  23385. * @param mesh The mesh to be added as LOD level (can be null)
  23386. * @return This mesh (for chaining)
  23387. */
  23388. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23389. /**
  23390. * Returns the LOD level mesh at the passed distance or null if not found.
  23391. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23392. * @param distance The distance from the center of the object to show this level
  23393. * @returns a Mesh or `null`
  23394. */
  23395. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23396. /**
  23397. * Remove a mesh from the LOD array
  23398. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23399. * @param mesh defines the mesh to be removed
  23400. * @return This mesh (for chaining)
  23401. */
  23402. removeLODLevel(mesh: Mesh): Mesh;
  23403. /**
  23404. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23405. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23406. * @param camera defines the camera to use to compute distance
  23407. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23408. * @return This mesh (for chaining)
  23409. */
  23410. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23411. /**
  23412. * Gets the mesh internal Geometry object
  23413. */
  23414. readonly geometry: Nullable<Geometry>;
  23415. /**
  23416. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23417. * @returns the total number of vertices
  23418. */
  23419. getTotalVertices(): number;
  23420. /**
  23421. * Returns the content of an associated vertex buffer
  23422. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23423. * - VertexBuffer.PositionKind
  23424. * - VertexBuffer.UVKind
  23425. * - VertexBuffer.UV2Kind
  23426. * - VertexBuffer.UV3Kind
  23427. * - VertexBuffer.UV4Kind
  23428. * - VertexBuffer.UV5Kind
  23429. * - VertexBuffer.UV6Kind
  23430. * - VertexBuffer.ColorKind
  23431. * - VertexBuffer.MatricesIndicesKind
  23432. * - VertexBuffer.MatricesIndicesExtraKind
  23433. * - VertexBuffer.MatricesWeightsKind
  23434. * - VertexBuffer.MatricesWeightsExtraKind
  23435. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  23436. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23437. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23438. */
  23439. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23440. /**
  23441. * Returns the mesh VertexBuffer object from the requested `kind`
  23442. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23443. * - VertexBuffer.PositionKind
  23444. * - VertexBuffer.NormalKind
  23445. * - VertexBuffer.UVKind
  23446. * - VertexBuffer.UV2Kind
  23447. * - VertexBuffer.UV3Kind
  23448. * - VertexBuffer.UV4Kind
  23449. * - VertexBuffer.UV5Kind
  23450. * - VertexBuffer.UV6Kind
  23451. * - VertexBuffer.ColorKind
  23452. * - VertexBuffer.MatricesIndicesKind
  23453. * - VertexBuffer.MatricesIndicesExtraKind
  23454. * - VertexBuffer.MatricesWeightsKind
  23455. * - VertexBuffer.MatricesWeightsExtraKind
  23456. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23457. */
  23458. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23459. /**
  23460. * Tests if a specific vertex buffer is associated with this mesh
  23461. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23462. * - VertexBuffer.PositionKind
  23463. * - VertexBuffer.NormalKind
  23464. * - VertexBuffer.UVKind
  23465. * - VertexBuffer.UV2Kind
  23466. * - VertexBuffer.UV3Kind
  23467. * - VertexBuffer.UV4Kind
  23468. * - VertexBuffer.UV5Kind
  23469. * - VertexBuffer.UV6Kind
  23470. * - VertexBuffer.ColorKind
  23471. * - VertexBuffer.MatricesIndicesKind
  23472. * - VertexBuffer.MatricesIndicesExtraKind
  23473. * - VertexBuffer.MatricesWeightsKind
  23474. * - VertexBuffer.MatricesWeightsExtraKind
  23475. * @returns a boolean
  23476. */
  23477. isVerticesDataPresent(kind: string): boolean;
  23478. /**
  23479. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23480. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23481. * - VertexBuffer.PositionKind
  23482. * - VertexBuffer.UVKind
  23483. * - VertexBuffer.UV2Kind
  23484. * - VertexBuffer.UV3Kind
  23485. * - VertexBuffer.UV4Kind
  23486. * - VertexBuffer.UV5Kind
  23487. * - VertexBuffer.UV6Kind
  23488. * - VertexBuffer.ColorKind
  23489. * - VertexBuffer.MatricesIndicesKind
  23490. * - VertexBuffer.MatricesIndicesExtraKind
  23491. * - VertexBuffer.MatricesWeightsKind
  23492. * - VertexBuffer.MatricesWeightsExtraKind
  23493. * @returns a boolean
  23494. */
  23495. isVertexBufferUpdatable(kind: string): boolean;
  23496. /**
  23497. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23498. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23499. * - VertexBuffer.PositionKind
  23500. * - VertexBuffer.NormalKind
  23501. * - VertexBuffer.UVKind
  23502. * - VertexBuffer.UV2Kind
  23503. * - VertexBuffer.UV3Kind
  23504. * - VertexBuffer.UV4Kind
  23505. * - VertexBuffer.UV5Kind
  23506. * - VertexBuffer.UV6Kind
  23507. * - VertexBuffer.ColorKind
  23508. * - VertexBuffer.MatricesIndicesKind
  23509. * - VertexBuffer.MatricesIndicesExtraKind
  23510. * - VertexBuffer.MatricesWeightsKind
  23511. * - VertexBuffer.MatricesWeightsExtraKind
  23512. * @returns an array of strings
  23513. */
  23514. getVerticesDataKinds(): string[];
  23515. /**
  23516. * Returns a positive integer : the total number of indices in this mesh geometry.
  23517. * @returns the numner of indices or zero if the mesh has no geometry.
  23518. */
  23519. getTotalIndices(): number;
  23520. /**
  23521. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23522. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  23523. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23524. * @returns the indices array or an empty array if the mesh has no geometry
  23525. */
  23526. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23527. readonly isBlocked: boolean;
  23528. /**
  23529. * Determine if the current mesh is ready to be rendered
  23530. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23531. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23532. * @returns true if all associated assets are ready (material, textures, shaders)
  23533. */
  23534. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23535. /**
  23536. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  23537. */
  23538. readonly areNormalsFrozen: boolean;
  23539. /**
  23540. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  23541. * @returns the current mesh
  23542. */
  23543. freezeNormals(): Mesh;
  23544. /**
  23545. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  23546. * @returns the current mesh
  23547. */
  23548. unfreezeNormals(): Mesh;
  23549. /**
  23550. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23551. */
  23552. overridenInstanceCount: number;
  23553. /** @hidden */ private _preActivate(): Mesh;
  23554. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23555. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23556. /**
  23557. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23558. * This means the mesh underlying bounding box and sphere are recomputed.
  23559. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23560. * @returns the current mesh
  23561. */
  23562. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23563. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23564. /**
  23565. * This function will subdivide the mesh into multiple submeshes
  23566. * @param count defines the expected number of submeshes
  23567. */
  23568. subdivide(count: number): void;
  23569. /**
  23570. * Copy a FloatArray into a specific associated vertex buffer
  23571. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23572. * - VertexBuffer.PositionKind
  23573. * - VertexBuffer.UVKind
  23574. * - VertexBuffer.UV2Kind
  23575. * - VertexBuffer.UV3Kind
  23576. * - VertexBuffer.UV4Kind
  23577. * - VertexBuffer.UV5Kind
  23578. * - VertexBuffer.UV6Kind
  23579. * - VertexBuffer.ColorKind
  23580. * - VertexBuffer.MatricesIndicesKind
  23581. * - VertexBuffer.MatricesIndicesExtraKind
  23582. * - VertexBuffer.MatricesWeightsKind
  23583. * - VertexBuffer.MatricesWeightsExtraKind
  23584. * @param data defines the data source
  23585. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23586. * @param stride defines the data stride size (can be null)
  23587. * @returns the current mesh
  23588. */
  23589. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23590. /**
  23591. * Flags an associated vertex buffer as updatable
  23592. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23593. * - VertexBuffer.PositionKind
  23594. * - VertexBuffer.UVKind
  23595. * - VertexBuffer.UV2Kind
  23596. * - VertexBuffer.UV3Kind
  23597. * - VertexBuffer.UV4Kind
  23598. * - VertexBuffer.UV5Kind
  23599. * - VertexBuffer.UV6Kind
  23600. * - VertexBuffer.ColorKind
  23601. * - VertexBuffer.MatricesIndicesKind
  23602. * - VertexBuffer.MatricesIndicesExtraKind
  23603. * - VertexBuffer.MatricesWeightsKind
  23604. * - VertexBuffer.MatricesWeightsExtraKind
  23605. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23606. */
  23607. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23608. /**
  23609. * Sets the mesh global Vertex Buffer
  23610. * @param buffer defines the buffer to use
  23611. * @returns the current mesh
  23612. */
  23613. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23614. /**
  23615. * Update a specific associated vertex buffer
  23616. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23617. * - VertexBuffer.PositionKind
  23618. * - VertexBuffer.UVKind
  23619. * - VertexBuffer.UV2Kind
  23620. * - VertexBuffer.UV3Kind
  23621. * - VertexBuffer.UV4Kind
  23622. * - VertexBuffer.UV5Kind
  23623. * - VertexBuffer.UV6Kind
  23624. * - VertexBuffer.ColorKind
  23625. * - VertexBuffer.MatricesIndicesKind
  23626. * - VertexBuffer.MatricesIndicesExtraKind
  23627. * - VertexBuffer.MatricesWeightsKind
  23628. * - VertexBuffer.MatricesWeightsExtraKind
  23629. * @param data defines the data source
  23630. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23631. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  23632. * @returns the current mesh
  23633. */
  23634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23635. /**
  23636. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23637. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23638. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23639. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23640. * @returns the current mesh
  23641. */
  23642. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23643. /**
  23644. * Creates a un-shared specific occurence of the geometry for the mesh.
  23645. * @returns the current mesh
  23646. */
  23647. makeGeometryUnique(): Mesh;
  23648. /**
  23649. * Set the index buffer of this mesh
  23650. * @param indices defines the source data
  23651. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23652. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23653. * @returns the current mesh
  23654. */
  23655. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23656. /**
  23657. * Update the current index buffer
  23658. * @param indices defines the source data
  23659. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23660. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  23661. * @returns the current mesh
  23662. */
  23663. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23664. /**
  23665. * Invert the geometry to move from a right handed system to a left handed one.
  23666. * @returns the current mesh
  23667. */
  23668. toLeftHanded(): Mesh;
  23669. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23670. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23671. /**
  23672. * Registers for this mesh a javascript function called just before the rendering process
  23673. * @param func defines the function to call before rendering this mesh
  23674. * @returns the current mesh
  23675. */
  23676. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23677. /**
  23678. * Disposes a previously registered javascript function called before the rendering
  23679. * @param func defines the function to remove
  23680. * @returns the current mesh
  23681. */
  23682. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23683. /**
  23684. * Registers for this mesh a javascript function called just after the rendering is complete
  23685. * @param func defines the function to call after rendering this mesh
  23686. * @returns the current mesh
  23687. */
  23688. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23689. /**
  23690. * Disposes a previously registered javascript function called after the rendering.
  23691. * @param func defines the function to remove
  23692. * @returns the current mesh
  23693. */
  23694. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23695. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23696. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23697. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23698. /** @hidden */ private _rebuild(): void;
  23699. /** @hidden */ private _freeze(): void;
  23700. /** @hidden */ private _unFreeze(): void;
  23701. /**
  23702. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  23703. * @param subMesh defines the subMesh to render
  23704. * @param enableAlphaMode defines if alpha mode can be changed
  23705. * @returns the current mesh
  23706. */
  23707. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23708. private _onBeforeDraw;
  23709. /**
  23710. * Renormalize the mesh and patch it up if there are no weights
  23711. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23712. * However in the case of zero weights then we set just a single influence to 1.
  23713. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23714. */
  23715. cleanMatrixWeights(): void;
  23716. private normalizeSkinFourWeights;
  23717. private normalizeSkinWeightsAndExtra;
  23718. /**
  23719. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23720. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23721. * the user know there was an issue with importing the mesh
  23722. * @returns a validation object with skinned, valid and report string
  23723. */
  23724. validateSkinning(): {
  23725. skinned: boolean;
  23726. valid: boolean;
  23727. report: string;
  23728. };
  23729. /** @hidden */ private _checkDelayState(): Mesh;
  23730. private _queueLoad;
  23731. /**
  23732. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23733. * A mesh is in the frustum if its bounding box intersects the frustum
  23734. * @param frustumPlanes defines the frustum to test
  23735. * @returns true if the mesh is in the frustum planes
  23736. */
  23737. isInFrustum(frustumPlanes: Plane[]): boolean;
  23738. /**
  23739. * Sets the mesh material by the material or multiMaterial `id` property
  23740. * @param id is a string identifying the material or the multiMaterial
  23741. * @returns the current mesh
  23742. */
  23743. setMaterialByID(id: string): Mesh;
  23744. /**
  23745. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23746. * @returns an array of IAnimatable
  23747. */
  23748. getAnimatables(): IAnimatable[];
  23749. /**
  23750. * Modifies the mesh geometry according to the passed transformation matrix.
  23751. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23752. * The mesh normals are modified using the same transformation.
  23753. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23754. * @param transform defines the transform matrix to use
  23755. * @see http://doc.babylonjs.com/resources/baking_transformations
  23756. * @returns the current mesh
  23757. */
  23758. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23759. /**
  23760. * Modifies the mesh geometry according to its own current World Matrix.
  23761. * The mesh World Matrix is then reset.
  23762. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23763. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23764. * @see http://doc.babylonjs.com/resources/baking_transformations
  23765. * @returns the current mesh
  23766. */
  23767. bakeCurrentTransformIntoVertices(): Mesh;
  23768. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23769. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23770. /** @hidden */ private _generatePointsArray(): boolean;
  23771. /**
  23772. * Returns a new Mesh object generated from the current mesh properties.
  23773. * This method must not get confused with createInstance()
  23774. * @param name is a string, the name given to the new mesh
  23775. * @param newParent can be any Node object (default `null`)
  23776. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23777. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23778. * @returns a new mesh
  23779. */
  23780. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23781. /**
  23782. * Releases resources associated with this mesh.
  23783. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23784. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23785. */
  23786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23787. /**
  23788. * Modifies the mesh geometry according to a displacement map.
  23789. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  23790. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23791. * @param url is a string, the URL from the image file is to be downloaded.
  23792. * @param minHeight is the lower limit of the displacement.
  23793. * @param maxHeight is the upper limit of the displacement.
  23794. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  23795. * @param uvOffset is an optional vector2 used to offset UV.
  23796. * @param uvScale is an optional vector2 used to scale UV.
  23797. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  23798. * @returns the Mesh.
  23799. */
  23800. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23801. /**
  23802. * Modifies the mesh geometry according to a displacementMap buffer.
  23803. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  23804. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23805. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23806. * @param heightMapWidth is the width of the buffer image.
  23807. * @param heightMapHeight is the height of the buffer image.
  23808. * @param minHeight is the lower limit of the displacement.
  23809. * @param maxHeight is the upper limit of the displacement.
  23810. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  23811. * @param uvOffset is an optional vector2 used to offset UV.
  23812. * @param uvScale is an optional vector2 used to scale UV.
  23813. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  23814. * @returns the Mesh.
  23815. */
  23816. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23817. /**
  23818. * Modify the mesh to get a flat shading rendering.
  23819. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23820. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23821. * @returns current mesh
  23822. */
  23823. convertToFlatShadedMesh(): Mesh;
  23824. /**
  23825. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23826. * In other words, more vertices, no more indices and a single bigger VBO.
  23827. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23828. * @returns current mesh
  23829. */
  23830. convertToUnIndexedMesh(): Mesh;
  23831. /**
  23832. * Inverses facet orientations.
  23833. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23834. * @param flipNormals will also inverts the normals
  23835. * @returns current mesh
  23836. */
  23837. flipFaces(flipNormals?: boolean): Mesh;
  23838. /**
  23839. * Increase the number of facets and hence vertices in a mesh
  23840. * Vertex normals are interpolated from existing vertex normals
  23841. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23842. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23843. */
  23844. increaseVertices(numberPerEdge: number): void;
  23845. /**
  23846. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23847. * This will undo any application of covertToFlatShadedMesh
  23848. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23849. */
  23850. forceSharedVertices(): void;
  23851. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23852. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23853. /**
  23854. * Creates a new InstancedMesh object from the mesh model.
  23855. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23856. * @param name defines the name of the new instance
  23857. * @returns a new InstancedMesh
  23858. */
  23859. createInstance(name: string): InstancedMesh;
  23860. /**
  23861. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23862. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23863. * @returns the current mesh
  23864. */
  23865. synchronizeInstances(): Mesh;
  23866. /**
  23867. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23868. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23869. * This should be used together with the simplification to avoid disappearing triangles.
  23870. * @param successCallback an optional success callback to be called after the optimization finished.
  23871. * @returns the current mesh
  23872. */
  23873. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23874. /**
  23875. * Serialize current mesh
  23876. * @param serializationObject defines the object which will receive the serialization data
  23877. */
  23878. serialize(serializationObject: any): void;
  23879. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23880. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23881. /**
  23882. * Returns a new Mesh object parsed from the source provided.
  23883. * @param parsedMesh is the source
  23884. * @param scene defines the hosting scene
  23885. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23886. * @returns a new Mesh
  23887. */
  23888. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23889. /**
  23890. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23891. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23892. * @param name defines the name of the mesh to create
  23893. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23894. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23895. * @param closePath creates a seam between the first and the last points of each path of the path array
  23896. * @param offset is taken in account only if the `pathArray` is containing a single path
  23897. * @param scene defines the hosting scene
  23898. * @param updatable defines if the mesh must be flagged as updatable
  23899. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23900. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  23901. * @returns a new Mesh
  23902. */
  23903. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23904. /**
  23905. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23906. * @param name defines the name of the mesh to create
  23907. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23908. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  23909. * @param scene defines the hosting scene
  23910. * @param updatable defines if the mesh must be flagged as updatable
  23911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23912. * @returns a new Mesh
  23913. */
  23914. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23915. /**
  23916. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23917. * @param name defines the name of the mesh to create
  23918. * @param size sets the size (float) of each box side (default 1)
  23919. * @param scene defines the hosting scene
  23920. * @param updatable defines if the mesh must be flagged as updatable
  23921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23922. * @returns a new Mesh
  23923. */
  23924. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23925. /**
  23926. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23927. * @param name defines the name of the mesh to create
  23928. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23929. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23930. * @param scene defines the hosting scene
  23931. * @param updatable defines if the mesh must be flagged as updatable
  23932. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23933. * @returns a new Mesh
  23934. */
  23935. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23936. /**
  23937. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23938. * @param name defines the name of the mesh to create
  23939. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23940. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23941. * @param scene defines the hosting scene
  23942. * @returns a new Mesh
  23943. */
  23944. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23945. /**
  23946. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23947. * @param name defines the name of the mesh to create
  23948. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23949. * @param diameterTop set the top cap diameter (floats, default 1)
  23950. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23951. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23952. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23953. * @param scene defines the hosting scene
  23954. * @param updatable defines if the mesh must be flagged as updatable
  23955. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23956. * @returns a new Mesh
  23957. */
  23958. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23959. /**
  23960. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23961. * @param name defines the name of the mesh to create
  23962. * @param diameter sets the diameter size (float) of the torus (default 1)
  23963. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23964. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23965. * @param scene defines the hosting scene
  23966. * @param updatable defines if the mesh must be flagged as updatable
  23967. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23968. * @returns a new Mesh
  23969. */
  23970. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23971. /**
  23972. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23973. * @param name defines the name of the mesh to create
  23974. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23975. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23976. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23977. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23978. * @param p the number of windings on X axis (positive integers, default 2)
  23979. * @param q the number of windings on Y axis (positive integers, default 3)
  23980. * @param scene defines the hosting scene
  23981. * @param updatable defines if the mesh must be flagged as updatable
  23982. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23983. * @returns a new Mesh
  23984. */
  23985. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23986. /**
  23987. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23988. * @param name defines the name of the mesh to create
  23989. * @param points is an array successive Vector3
  23990. * @param scene defines the hosting scene
  23991. * @param updatable defines if the mesh must be flagged as updatable
  23992. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  23993. * @returns a new Mesh
  23994. */
  23995. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23996. /**
  23997. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23998. * @param name defines the name of the mesh to create
  23999. * @param points is an array successive Vector3
  24000. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24001. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24002. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24003. * @param scene defines the hosting scene
  24004. * @param updatable defines if the mesh must be flagged as updatable
  24005. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24006. * @returns a new Mesh
  24007. */
  24008. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24009. /**
  24010. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24011. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24012. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  24013. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24014. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24015. * Remember you can only change the shape positions, not their number when updating a polygon.
  24016. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24017. * @param name defines the name of the mesh to create
  24018. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24019. * @param scene defines the hosting scene
  24020. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24021. * @param updatable defines if the mesh must be flagged as updatable
  24022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24023. * @param earcutInjection can be used to inject your own earcut reference
  24024. * @returns a new Mesh
  24025. */
  24026. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24027. /**
  24028. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24029. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24030. * @param name defines the name of the mesh to create
  24031. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24032. * @param depth defines the height of extrusion
  24033. * @param scene defines the hosting scene
  24034. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24035. * @param updatable defines if the mesh must be flagged as updatable
  24036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24037. * @param earcutInjection can be used to inject your own earcut reference
  24038. * @returns a new Mesh
  24039. */
  24040. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24041. /**
  24042. * Creates an extruded shape mesh.
  24043. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24044. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24045. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24046. * @param name defines the name of the mesh to create
  24047. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24048. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24049. * @param scale is the value to scale the shape
  24050. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  24051. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24052. * @param scene defines the hosting scene
  24053. * @param updatable defines if the mesh must be flagged as updatable
  24054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24055. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24056. * @returns a new Mesh
  24057. */
  24058. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24059. /**
  24060. * Creates an custom extruded shape mesh.
  24061. * The custom extrusion is a parametric shape.
  24062. * It has no predefined shape. Its final shape will depend on the input parameters.
  24063. * Please consider using the same method from the MeshBuilder class instead
  24064. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24065. * @param name defines the name of the mesh to create
  24066. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24067. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24068. * @param scaleFunction is a custom Javascript function called on each path point
  24069. * @param rotationFunction is a custom Javascript function called on each path point
  24070. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24071. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24072. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24073. * @param scene defines the hosting scene
  24074. * @param updatable defines if the mesh must be flagged as updatable
  24075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24076. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  24077. * @returns a new Mesh
  24078. */
  24079. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24080. /**
  24081. * Creates lathe mesh.
  24082. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24083. * Please consider using the same method from the MeshBuilder class instead
  24084. * @param name defines the name of the mesh to create
  24085. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  24086. * @param radius is the radius value of the lathe
  24087. * @param tessellation is the side number of the lathe.
  24088. * @param scene defines the hosting scene
  24089. * @param updatable defines if the mesh must be flagged as updatable
  24090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24091. * @returns a new Mesh
  24092. */
  24093. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24094. /**
  24095. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24096. * @param name defines the name of the mesh to create
  24097. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24098. * @param scene defines the hosting scene
  24099. * @param updatable defines if the mesh must be flagged as updatable
  24100. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24101. * @returns a new Mesh
  24102. */
  24103. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24104. /**
  24105. * Creates a ground mesh.
  24106. * Please consider using the same method from the MeshBuilder class instead
  24107. * @param name defines the name of the mesh to create
  24108. * @param width set the width of the ground
  24109. * @param height set the height of the ground
  24110. * @param subdivisions sets the number of subdivisions per side
  24111. * @param scene defines the hosting scene
  24112. * @param updatable defines if the mesh must be flagged as updatable
  24113. * @returns a new Mesh
  24114. */
  24115. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24116. /**
  24117. * Creates a tiled ground mesh.
  24118. * Please consider using the same method from the MeshBuilder class instead
  24119. * @param name defines the name of the mesh to create
  24120. * @param xmin set the ground minimum X coordinate
  24121. * @param zmin set the ground minimum Y coordinate
  24122. * @param xmax set the ground maximum X coordinate
  24123. * @param zmax set the ground maximum Z coordinate
  24124. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  24125. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  24126. * @param scene defines the hosting scene
  24127. * @param updatable defines if the mesh must be flagged as updatable
  24128. * @returns a new Mesh
  24129. */
  24130. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24131. w: number;
  24132. h: number;
  24133. }, precision: {
  24134. w: number;
  24135. h: number;
  24136. }, scene: Scene, updatable?: boolean): Mesh;
  24137. /**
  24138. * Creates a ground mesh from a height map.
  24139. * Please consider using the same method from the MeshBuilder class instead
  24140. * @see http://doc.babylonjs.com/babylon101/height_map
  24141. * @param name defines the name of the mesh to create
  24142. * @param url sets the URL of the height map image resource
  24143. * @param width set the ground width size
  24144. * @param height set the ground height size
  24145. * @param subdivisions sets the number of subdivision per side
  24146. * @param minHeight is the minimum altitude on the ground
  24147. * @param maxHeight is the maximum altitude on the ground
  24148. * @param scene defines the hosting scene
  24149. * @param updatable defines if the mesh must be flagged as updatable
  24150. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24151. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24152. * @returns a new Mesh
  24153. */
  24154. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  24155. /**
  24156. * Creates a tube mesh.
  24157. * The tube is a parametric shape.
  24158. * It has no predefined shape. Its final shape will depend on the input parameters.
  24159. * Please consider using the same method from the MeshBuilder class instead
  24160. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24161. * @param name defines the name of the mesh to create
  24162. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24163. * @param radius sets the tube radius size
  24164. * @param tessellation is the number of sides on the tubular surface
  24165. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  24166. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24167. * @param scene defines the hosting scene
  24168. * @param updatable defines if the mesh must be flagged as updatable
  24169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24170. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  24171. * @returns a new Mesh
  24172. */
  24173. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24174. (i: number, distance: number): number;
  24175. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24176. /**
  24177. * Creates a polyhedron mesh.
  24178. * Please consider using the same method from the MeshBuilder class instead.
  24179. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  24180. * * The parameter `size` (positive float, default 1) sets the polygon size
  24181. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24182. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  24183. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  24184. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  24185. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24186. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  24187. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24190. * @param name defines the name of the mesh to create
  24191. * @param options defines the options used to create the mesh
  24192. * @param scene defines the hosting scene
  24193. * @returns a new Mesh
  24194. */
  24195. static CreatePolyhedron(name: string, options: {
  24196. type?: number;
  24197. size?: number;
  24198. sizeX?: number;
  24199. sizeY?: number;
  24200. sizeZ?: number;
  24201. custom?: any;
  24202. faceUV?: Vector4[];
  24203. faceColors?: Color4[];
  24204. updatable?: boolean;
  24205. sideOrientation?: number;
  24206. }, scene: Scene): Mesh;
  24207. /**
  24208. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24209. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24210. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  24211. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24212. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  24213. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24216. * @param name defines the name of the mesh
  24217. * @param options defines the options used to create the mesh
  24218. * @param scene defines the hosting scene
  24219. * @returns a new Mesh
  24220. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24221. */
  24222. static CreateIcoSphere(name: string, options: {
  24223. radius?: number;
  24224. flat?: boolean;
  24225. subdivisions?: number;
  24226. sideOrientation?: number;
  24227. updatable?: boolean;
  24228. }, scene: Scene): Mesh;
  24229. /**
  24230. * Creates a decal mesh.
  24231. * Please consider using the same method from the MeshBuilder class instead.
  24232. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24233. * @param name defines the name of the mesh
  24234. * @param sourceMesh defines the mesh receiving the decal
  24235. * @param position sets the position of the decal in world coordinates
  24236. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24237. * @param size sets the decal scaling
  24238. * @param angle sets the angle to rotate the decal
  24239. * @returns a new Mesh
  24240. */
  24241. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24242. /**
  24243. * Prepare internal position array for software CPU skinning
  24244. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24245. */
  24246. setPositionsForCPUSkinning(): Float32Array;
  24247. /**
  24248. * Prepare internal normal array for software CPU skinning
  24249. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24250. */
  24251. setNormalsForCPUSkinning(): Float32Array;
  24252. /**
  24253. * Updates the vertex buffer by applying transformation from the bones
  24254. * @param skeleton defines the skeleton to apply to current mesh
  24255. * @returns the current mesh
  24256. */
  24257. applySkeleton(skeleton: Skeleton): Mesh;
  24258. /**
  24259. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  24260. * @param meshes defines the list of meshes to scan
  24261. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24262. */
  24263. static MinMax(meshes: AbstractMesh[]): {
  24264. min: Vector3;
  24265. max: Vector3;
  24266. };
  24267. /**
  24268. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24269. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24270. * @returns a vector3
  24271. */
  24272. static Center(meshesOrMinMaxVector: {
  24273. min: Vector3;
  24274. max: Vector3;
  24275. } | AbstractMesh[]): Vector3;
  24276. /**
  24277. * Merge the array of meshes into a single mesh for performance reasons.
  24278. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24279. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24280. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24281. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24282. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24283. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24284. * @returns a new mesh
  24285. */
  24286. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24287. /** @hidden */
  24288. addInstance(instance: InstancedMesh): void;
  24289. /** @hidden */
  24290. removeInstance(instance: InstancedMesh): void;
  24291. }
  24292. }
  24293. declare module BABYLON {
  24294. /**
  24295. * This is the base class of all the camera used in the application.
  24296. * @see http://doc.babylonjs.com/features/cameras
  24297. */
  24298. export class Camera extends Node {
  24299. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24300. /**
  24301. * This is the default projection mode used by the cameras.
  24302. * It helps recreating a feeling of perspective and better appreciate depth.
  24303. * This is the best way to simulate real life cameras.
  24304. */
  24305. static readonly PERSPECTIVE_CAMERA: number;
  24306. /**
  24307. * This helps creating camera with an orthographic mode.
  24308. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  24309. */
  24310. static readonly ORTHOGRAPHIC_CAMERA: number;
  24311. /**
  24312. * This is the default FOV mode for perspective cameras.
  24313. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24314. */
  24315. static readonly FOVMODE_VERTICAL_FIXED: number;
  24316. /**
  24317. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24318. */
  24319. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24320. /**
  24321. * This specifies ther is no need for a camera rig.
  24322. * Basically only one eye is rendered corresponding to the camera.
  24323. */
  24324. static readonly RIG_MODE_NONE: number;
  24325. /**
  24326. * Simulates a camera Rig with one blue eye and one red eye.
  24327. * This can be use with 3d blue and red glasses.
  24328. */
  24329. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24330. /**
  24331. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24332. */
  24333. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24334. /**
  24335. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24336. */
  24337. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24338. /**
  24339. * Defines that both eyes of the camera will be rendered over under each other.
  24340. */
  24341. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24342. /**
  24343. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24344. */
  24345. static readonly RIG_MODE_VR: number;
  24346. /**
  24347. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24348. */
  24349. static readonly RIG_MODE_WEBVR: number;
  24350. /**
  24351. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24352. */
  24353. static readonly RIG_MODE_CUSTOM: number;
  24354. /**
  24355. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24356. */
  24357. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24358. /**
  24359. * Define the input manager associated with the camera.
  24360. */
  24361. inputs: CameraInputsManager<Camera>;
  24362. /** @hidden */ private _position: Vector3;
  24363. /**
  24364. * Define the current local position of the camera in the scene
  24365. */
  24366. position: Vector3;
  24367. /**
  24368. * The vector the camera should consider as up.
  24369. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24370. */
  24371. upVector: Vector3;
  24372. /**
  24373. * Define the current limit on the left side for an orthographic camera
  24374. * In scene unit
  24375. */
  24376. orthoLeft: Nullable<number>;
  24377. /**
  24378. * Define the current limit on the right side for an orthographic camera
  24379. * In scene unit
  24380. */
  24381. orthoRight: Nullable<number>;
  24382. /**
  24383. * Define the current limit on the bottom side for an orthographic camera
  24384. * In scene unit
  24385. */
  24386. orthoBottom: Nullable<number>;
  24387. /**
  24388. * Define the current limit on the top side for an orthographic camera
  24389. * In scene unit
  24390. */
  24391. orthoTop: Nullable<number>;
  24392. /**
  24393. * Field Of View is set in Radians. (default is 0.8)
  24394. */
  24395. fov: number;
  24396. /**
  24397. * Define the minimum distance the camera can see from.
  24398. * This is important to note that the depth buffer are not infinite and the closer it starts
  24399. * the more your scene might encounter depth fighting issue.
  24400. */
  24401. minZ: number;
  24402. /**
  24403. * Define the maximum distance the camera can see to.
  24404. * This is important to note that the depth buffer are not infinite and the further it end
  24405. * the more your scene might encounter depth fighting issue.
  24406. */
  24407. maxZ: number;
  24408. /**
  24409. * Define the default inertia of the camera.
  24410. * This helps giving a smooth feeling to the camera movement.
  24411. */
  24412. inertia: number;
  24413. /**
  24414. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24415. */
  24416. mode: number;
  24417. /**
  24418. * Define wether the camera is intermediate.
  24419. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24420. */
  24421. isIntermediate: boolean;
  24422. /**
  24423. * Define the viewport of the camera.
  24424. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24425. */
  24426. viewport: Viewport;
  24427. /**
  24428. * Restricts the camera to viewing objects with the same layerMask.
  24429. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24430. */
  24431. layerMask: number;
  24432. /**
  24433. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24434. */
  24435. fovMode: number;
  24436. /**
  24437. * Rig mode of the camera.
  24438. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24439. * This is normally controlled byt the camera themselves as internal use.
  24440. */
  24441. cameraRigMode: number;
  24442. /**
  24443. * Defines the distance between both "eyes" in case of a RIG
  24444. */
  24445. interaxialDistance: number;
  24446. /**
  24447. * Defines if stereoscopic rendering is done side by side or over under.
  24448. */
  24449. isStereoscopicSideBySide: boolean;
  24450. /**
  24451. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  24452. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24453. * else in the scene. (Eg. security camera)
  24454. *
  24455. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24456. */
  24457. customRenderTargets: RenderTargetTexture[];
  24458. /**
  24459. * When set, the camera will render to this render target instead of the default canvas
  24460. *
  24461. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24462. */
  24463. outputRenderTarget: Nullable<RenderTargetTexture>;
  24464. /**
  24465. * Observable triggered when the camera view matrix has changed.
  24466. */
  24467. onViewMatrixChangedObservable: Observable<Camera>;
  24468. /**
  24469. * Observable triggered when the camera Projection matrix has changed.
  24470. */
  24471. onProjectionMatrixChangedObservable: Observable<Camera>;
  24472. /**
  24473. * Observable triggered when the inputs have been processed.
  24474. */
  24475. onAfterCheckInputsObservable: Observable<Camera>;
  24476. /**
  24477. * Observable triggered when reset has been called and applied to the camera.
  24478. */
  24479. onRestoreStateObservable: Observable<Camera>;
  24480. /** @hidden */ private _cameraRigParams: any;
  24481. /** @hidden */ private _rigCameras: Camera[];
  24482. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24483. protected _webvrViewMatrix: Matrix;
  24484. /** @hidden */ private _skipRendering: boolean;
  24485. /** @hidden */ private _projectionMatrix: Matrix;
  24486. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24487. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24488. protected _globalPosition: Vector3;
  24489. /** @hidden */ private _computedViewMatrix: Matrix;
  24490. private _doNotComputeProjectionMatrix;
  24491. private _transformMatrix;
  24492. private _frustumPlanes;
  24493. private _refreshFrustumPlanes;
  24494. private _storedFov;
  24495. private _stateStored;
  24496. /**
  24497. * Instantiates a new camera object.
  24498. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24499. * @see http://doc.babylonjs.com/features/cameras
  24500. * @param name Defines the name of the camera in the scene
  24501. * @param position Defines the position of the camera
  24502. * @param scene Defines the scene the camera belongs too
  24503. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24504. */
  24505. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24506. /**
  24507. * Store current camera state (fov, position, etc..)
  24508. * @returns the camera
  24509. */
  24510. storeState(): Camera;
  24511. /**
  24512. * Restores the camera state values if it has been stored. You must call storeState() first
  24513. */
  24514. protected _restoreStateValues(): boolean;
  24515. /**
  24516. * Restored camera state. You must call storeState() first.
  24517. * @returns true if restored and false otherwise
  24518. */
  24519. restoreState(): boolean;
  24520. /**
  24521. * Gets the class name of the camera.
  24522. * @returns the class name
  24523. */
  24524. getClassName(): string;
  24525. /** @hidden */ protected readonly _isCamera: boolean;
  24526. /**
  24527. * Gets a string representation of the camera useful for debug purpose.
  24528. * @param fullDetails Defines that a more verboe level of logging is required
  24529. * @returns the string representation
  24530. */
  24531. toString(fullDetails?: boolean): string;
  24532. /**
  24533. * Gets the current world space position of the camera.
  24534. */
  24535. readonly globalPosition: Vector3;
  24536. /**
  24537. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24538. * @returns the active meshe list
  24539. */
  24540. getActiveMeshes(): SmartArray<AbstractMesh>;
  24541. /**
  24542. * Check wether a mesh is part of the current active mesh list of the camera
  24543. * @param mesh Defines the mesh to check
  24544. * @returns true if active, false otherwise
  24545. */
  24546. isActiveMesh(mesh: Mesh): boolean;
  24547. /**
  24548. * Is this camera ready to be used/rendered
  24549. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24550. * @return true if the camera is ready
  24551. */
  24552. isReady(completeCheck?: boolean): boolean;
  24553. /** @hidden */ private _initCache(): void;
  24554. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24555. /** @hidden */ private _isSynchronized(): boolean;
  24556. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24557. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24558. /**
  24559. * Attach the input controls to a specific dom element to get the input from.
  24560. * @param element Defines the element the controls should be listened from
  24561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24562. */
  24563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24564. /**
  24565. * Detach the current controls from the specified dom element.
  24566. * @param element Defines the element to stop listening the inputs from
  24567. */
  24568. detachControl(element: HTMLElement): void;
  24569. /**
  24570. * Update the camera state according to the different inputs gathered during the frame.
  24571. */
  24572. update(): void;
  24573. /** @hidden */ private _checkInputs(): void;
  24574. /** @hidden */
  24575. readonly rigCameras: Camera[];
  24576. /**
  24577. * Gets the post process used by the rig cameras
  24578. */
  24579. readonly rigPostProcess: Nullable<PostProcess>;
  24580. /**
  24581. * Internal, gets the first post proces.
  24582. * @returns the first post process to be run on this camera.
  24583. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24584. private _cascadePostProcessesToRigCams;
  24585. /**
  24586. * Attach a post process to the camera.
  24587. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24588. * @param postProcess The post process to attach to the camera
  24589. * @param insertAt The position of the post process in case several of them are in use in the scene
  24590. * @returns the position the post process has been inserted at
  24591. */
  24592. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24593. /**
  24594. * Detach a post process to the camera.
  24595. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24596. * @param postProcess The post process to detach from the camera
  24597. */
  24598. detachPostProcess(postProcess: PostProcess): void;
  24599. /**
  24600. * Gets the current world matrix of the camera
  24601. */
  24602. getWorldMatrix(): Matrix;
  24603. /** @hidden */ private _getViewMatrix(): Matrix;
  24604. /**
  24605. * Gets the current view matrix of the camera.
  24606. * @param force forces the camera to recompute the matrix without looking at the cached state
  24607. * @returns the view matrix
  24608. */
  24609. getViewMatrix(force?: boolean): Matrix;
  24610. /**
  24611. * Freeze the projection matrix.
  24612. * It will prevent the cache check of the camera projection compute and can speed up perf
  24613. * if no parameter of the camera are meant to change
  24614. * @param projection Defines manually a projection if necessary
  24615. */
  24616. freezeProjectionMatrix(projection?: Matrix): void;
  24617. /**
  24618. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24619. */
  24620. unfreezeProjectionMatrix(): void;
  24621. /**
  24622. * Gets the current projection matrix of the camera.
  24623. * @param force forces the camera to recompute the matrix without looking at the cached state
  24624. * @returns the projection matrix
  24625. */
  24626. getProjectionMatrix(force?: boolean): Matrix;
  24627. /**
  24628. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24629. * @returns a Matrix
  24630. */
  24631. getTransformationMatrix(): Matrix;
  24632. private _updateFrustumPlanes;
  24633. /**
  24634. * Checks if a cullable object (mesh...) is in the camera frustum
  24635. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24636. * @param target The object to check
  24637. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24638. * @returns true if the object is in frustum otherwise false
  24639. */
  24640. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24641. /**
  24642. * Checks if a cullable object (mesh...) is in the camera frustum
  24643. * Unlike isInFrustum this cheks the full bounding box
  24644. * @param target The object to check
  24645. * @returns true if the object is in frustum otherwise false
  24646. */
  24647. isCompletelyInFrustum(target: ICullable): boolean;
  24648. /**
  24649. * Gets a ray in the forward direction from the camera.
  24650. * @param length Defines the length of the ray to create
  24651. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24652. * @param origin Defines the start point of the ray which defaults to the camera position
  24653. * @returns the forward ray
  24654. */
  24655. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24656. /**
  24657. * Releases resources associated with this node.
  24658. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24659. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24660. */
  24661. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24662. /** @hidden */ private _isLeftCamera: boolean;
  24663. /**
  24664. * Gets the left camera of a rig setup in case of Rigged Camera
  24665. */
  24666. readonly isLeftCamera: boolean;
  24667. /** @hidden */ private _isRightCamera: boolean;
  24668. /**
  24669. * Gets the right camera of a rig setup in case of Rigged Camera
  24670. */
  24671. readonly isRightCamera: boolean;
  24672. /**
  24673. * Gets the left camera of a rig setup in case of Rigged Camera
  24674. */
  24675. readonly leftCamera: Nullable<FreeCamera>;
  24676. /**
  24677. * Gets the right camera of a rig setup in case of Rigged Camera
  24678. */
  24679. readonly rightCamera: Nullable<FreeCamera>;
  24680. /**
  24681. * Gets the left camera target of a rig setup in case of Rigged Camera
  24682. * @returns the target position
  24683. */
  24684. getLeftTarget(): Nullable<Vector3>;
  24685. /**
  24686. * Gets the right camera target of a rig setup in case of Rigged Camera
  24687. * @returns the target position
  24688. */
  24689. getRightTarget(): Nullable<Vector3>;
  24690. /**
  24691. * @hidden
  24692. */
  24693. setCameraRigMode(mode: number, rigParams: any): void;
  24694. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24695. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24696. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24697. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24698. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24699. protected _updateCameraRotationMatrix(): void;
  24700. protected _updateWebVRCameraRotationMatrix(): void;
  24701. /**
  24702. * This function MUST be overwritten by the different WebVR cameras available.
  24703. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24704. * @hidden
  24705. */ private _getWebVRProjectionMatrix(): Matrix;
  24706. /**
  24707. * This function MUST be overwritten by the different WebVR cameras available.
  24708. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24709. * @hidden
  24710. */ private _getWebVRViewMatrix(): Matrix;
  24711. /** @hidden */
  24712. setCameraRigParameter(name: string, value: any): void;
  24713. /**
  24714. * needs to be overridden by children so sub has required properties to be copied
  24715. * @hidden
  24716. */
  24717. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24718. /**
  24719. * May need to be overridden by children
  24720. * @hidden
  24721. */ private _updateRigCameras(): void;
  24722. /** @hidden */ private _setupInputs(): void;
  24723. /**
  24724. * Serialiaze the camera setup to a json represention
  24725. * @returns the JSON representation
  24726. */
  24727. serialize(): any;
  24728. /**
  24729. * Clones the current camera.
  24730. * @param name The cloned camera name
  24731. * @returns the cloned camera
  24732. */
  24733. clone(name: string): Camera;
  24734. /**
  24735. * Gets the direction of the camera relative to a given local axis.
  24736. * @param localAxis Defines the reference axis to provide a relative direction.
  24737. * @return the direction
  24738. */
  24739. getDirection(localAxis: Vector3): Vector3;
  24740. /**
  24741. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24742. * @param localAxis Defines the reference axis to provide a relative direction.
  24743. * @param result Defines the vector to store the result in
  24744. */
  24745. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24746. /**
  24747. * Gets a camera constructor for a given camera type
  24748. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24749. * @param name The name of the camera the result will be able to instantiate
  24750. * @param scene The scene the result will construct the camera in
  24751. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24752. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24753. * @returns a factory method to construc the camera
  24754. */
  24755. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24756. /**
  24757. * Compute the world matrix of the camera.
  24758. * @returns the camera workd matrix
  24759. */
  24760. computeWorldMatrix(): Matrix;
  24761. /**
  24762. * Parse a JSON and creates the camera from the parsed information
  24763. * @param parsedCamera The JSON to parse
  24764. * @param scene The scene to instantiate the camera in
  24765. * @returns the newly constructed camera
  24766. */
  24767. static Parse(parsedCamera: any, scene: Scene): Camera;
  24768. }
  24769. }
  24770. declare module BABYLON {
  24771. /**
  24772. * Class containing static functions to help procedurally build meshes
  24773. */
  24774. export class DiscBuilder {
  24775. /**
  24776. * Creates a plane polygonal mesh. By default, this is a disc
  24777. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24778. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24779. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  24780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24783. * @param name defines the name of the mesh
  24784. * @param options defines the options used to create the mesh
  24785. * @param scene defines the hosting scene
  24786. * @returns the plane polygonal mesh
  24787. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24788. */
  24789. static CreateDisc(name: string, options: {
  24790. radius?: number;
  24791. tessellation?: number;
  24792. arc?: number;
  24793. updatable?: boolean;
  24794. sideOrientation?: number;
  24795. frontUVs?: Vector4;
  24796. backUVs?: Vector4;
  24797. }, scene?: Nullable<Scene>): Mesh;
  24798. }
  24799. }
  24800. declare module BABYLON {
  24801. /**
  24802. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24803. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  24804. * The SPS is also a particle system. It provides some methods to manage the particles.
  24805. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24806. *
  24807. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24808. */
  24809. export class SolidParticleSystem implements IDisposable {
  24810. /**
  24811. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24812. * Example : var p = SPS.particles[i];
  24813. */
  24814. particles: SolidParticle[];
  24815. /**
  24816. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24817. */
  24818. nbParticles: number;
  24819. /**
  24820. * If the particles must ever face the camera (default false). Useful for planar particles.
  24821. */
  24822. billboard: boolean;
  24823. /**
  24824. * Recompute normals when adding a shape
  24825. */
  24826. recomputeNormals: boolean;
  24827. /**
  24828. * This a counter ofr your own usage. It's not set by any SPS functions.
  24829. */
  24830. counter: number;
  24831. /**
  24832. * The SPS name. This name is also given to the underlying mesh.
  24833. */
  24834. name: string;
  24835. /**
  24836. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24837. */
  24838. mesh: Mesh;
  24839. /**
  24840. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24841. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24842. */
  24843. vars: any;
  24844. /**
  24845. * This array is populated when the SPS is set as 'pickable'.
  24846. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24847. * Each element of this array is an object `{idx: int, faceId: int}`.
  24848. * `idx` is the picked particle index in the `SPS.particles` array
  24849. * `faceId` is the picked face index counted within this particle.
  24850. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24851. */
  24852. pickedParticles: {
  24853. idx: number;
  24854. faceId: number;
  24855. }[];
  24856. /**
  24857. * This array is populated when `enableDepthSort` is set to true.
  24858. * Each element of this array is an instance of the class DepthSortedParticle.
  24859. */
  24860. depthSortedParticles: DepthSortedParticle[];
  24861. /**
  24862. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24863. * @hidden
  24864. */ private _bSphereOnly: boolean;
  24865. /**
  24866. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24867. * @hidden
  24868. */ private _bSphereRadiusFactor: number;
  24869. private _scene;
  24870. private _positions;
  24871. private _indices;
  24872. private _normals;
  24873. private _colors;
  24874. private _uvs;
  24875. private _indices32;
  24876. private _positions32;
  24877. private _normals32;
  24878. private _fixedNormal32;
  24879. private _colors32;
  24880. private _uvs32;
  24881. private _index;
  24882. private _updatable;
  24883. private _pickable;
  24884. private _isVisibilityBoxLocked;
  24885. private _alwaysVisible;
  24886. private _depthSort;
  24887. private _shapeCounter;
  24888. private _copy;
  24889. private _color;
  24890. private _computeParticleColor;
  24891. private _computeParticleTexture;
  24892. private _computeParticleRotation;
  24893. private _computeParticleVertex;
  24894. private _computeBoundingBox;
  24895. private _depthSortParticles;
  24896. private _camera;
  24897. private _mustUnrotateFixedNormals;
  24898. private _particlesIntersect;
  24899. private _needs32Bits;
  24900. /**
  24901. * Creates a SPS (Solid Particle System) object.
  24902. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24903. * @param scene (Scene) is the scene in which the SPS is added.
  24904. * @param options defines the options of the sps e.g.
  24905. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24906. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24907. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24908. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24909. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24910. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24911. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24912. */
  24913. constructor(name: string, scene: Scene, options?: {
  24914. updatable?: boolean;
  24915. isPickable?: boolean;
  24916. enableDepthSort?: boolean;
  24917. particleIntersection?: boolean;
  24918. boundingSphereOnly?: boolean;
  24919. bSphereRadiusFactor?: number;
  24920. });
  24921. /**
  24922. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24923. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24924. * @returns the created mesh
  24925. */
  24926. buildMesh(): Mesh;
  24927. /**
  24928. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24929. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24930. * Thus the particles generated from `digest()` have their property `position` set yet.
  24931. * @param mesh ( Mesh ) is the mesh to be digested
  24932. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  24933. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24934. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24935. * @returns the current SPS
  24936. */
  24937. digest(mesh: Mesh, options?: {
  24938. facetNb?: number;
  24939. number?: number;
  24940. delta?: number;
  24941. }): SolidParticleSystem;
  24942. private _unrotateFixedNormals;
  24943. private _resetCopy;
  24944. private _meshBuilder;
  24945. private _posToShape;
  24946. private _uvsToShapeUV;
  24947. private _addParticle;
  24948. /**
  24949. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24950. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24951. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24952. * @param nb (positive integer) the number of particles to be created from this model
  24953. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24954. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24955. * @returns the number of shapes in the system
  24956. */
  24957. addShape(mesh: Mesh, nb: number, options?: {
  24958. positionFunction?: any;
  24959. vertexFunction?: any;
  24960. }): number;
  24961. private _rebuildParticle;
  24962. /**
  24963. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24964. * @returns the SPS.
  24965. */
  24966. rebuildMesh(): SolidParticleSystem;
  24967. /**
  24968. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24969. * This method calls `updateParticle()` for each particle of the SPS.
  24970. * For an animated SPS, it is usually called within the render loop.
  24971. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24972. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24973. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24974. * @returns the SPS.
  24975. */
  24976. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24977. /**
  24978. * Disposes the SPS.
  24979. */
  24980. dispose(): void;
  24981. /**
  24982. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24983. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24984. * @returns the SPS.
  24985. */
  24986. refreshVisibleSize(): SolidParticleSystem;
  24987. /**
  24988. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24989. * @param size the size (float) of the visibility box
  24990. * note : this doesn't lock the SPS mesh bounding box.
  24991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24992. */
  24993. setVisibilityBox(size: number): void;
  24994. /**
  24995. * Gets whether the SPS as always visible or not
  24996. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24997. */
  24998. /**
  24999. * Sets the SPS as always visible or not
  25000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25001. */
  25002. isAlwaysVisible: boolean;
  25003. /**
  25004. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25005. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25006. */
  25007. /**
  25008. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25009. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25010. */
  25011. isVisibilityBoxLocked: boolean;
  25012. /**
  25013. * Tells to `setParticles()` to compute the particle rotations or not.
  25014. * Default value : true. The SPS is faster when it's set to false.
  25015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25016. */
  25017. /**
  25018. * Gets if `setParticles()` computes the particle rotations or not.
  25019. * Default value : true. The SPS is faster when it's set to false.
  25020. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25021. */
  25022. computeParticleRotation: boolean;
  25023. /**
  25024. * Tells to `setParticles()` to compute the particle colors or not.
  25025. * Default value : true. The SPS is faster when it's set to false.
  25026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25027. */
  25028. /**
  25029. * Gets if `setParticles()` computes the particle colors or not.
  25030. * Default value : true. The SPS is faster when it's set to false.
  25031. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25032. */
  25033. computeParticleColor: boolean;
  25034. /**
  25035. * Gets if `setParticles()` computes the particle textures or not.
  25036. * Default value : true. The SPS is faster when it's set to false.
  25037. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25038. */
  25039. computeParticleTexture: boolean;
  25040. /**
  25041. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25042. * Default value : false. The SPS is faster when it's set to false.
  25043. * Note : the particle custom vertex positions aren't stored values.
  25044. */
  25045. /**
  25046. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25047. * Default value : false. The SPS is faster when it's set to false.
  25048. * Note : the particle custom vertex positions aren't stored values.
  25049. */
  25050. computeParticleVertex: boolean;
  25051. /**
  25052. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25053. */
  25054. /**
  25055. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25056. */
  25057. computeBoundingBox: boolean;
  25058. /**
  25059. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25061. * Default : `true`
  25062. */
  25063. /**
  25064. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25065. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25066. * Default : `true`
  25067. */
  25068. depthSortParticles: boolean;
  25069. /**
  25070. * This function does nothing. It may be overwritten to set all the particle first values.
  25071. * The SPS doesn't call this function, you may have to call it by your own.
  25072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25073. */
  25074. initParticles(): void;
  25075. /**
  25076. * This function does nothing. It may be overwritten to recycle a particle.
  25077. * The SPS doesn't call this function, you may have to call it by your own.
  25078. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25079. * @param particle The particle to recycle
  25080. * @returns the recycled particle
  25081. */
  25082. recycleParticle(particle: SolidParticle): SolidParticle;
  25083. /**
  25084. * Updates a particle : this function should be overwritten by the user.
  25085. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25087. * @example : just set a particle position or velocity and recycle conditions
  25088. * @param particle The particle to update
  25089. * @returns the updated particle
  25090. */
  25091. updateParticle(particle: SolidParticle): SolidParticle;
  25092. /**
  25093. * Updates a vertex of a particle : it can be overwritten by the user.
  25094. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25095. * @param particle the current particle
  25096. * @param vertex the current index of the current particle
  25097. * @param pt the index of the current vertex in the particle shape
  25098. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25099. * @example : just set a vertex particle position
  25100. * @returns the updated vertex
  25101. */
  25102. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25103. /**
  25104. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25105. * This does nothing and may be overwritten by the user.
  25106. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25107. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25108. * @param update the boolean update value actually passed to setParticles()
  25109. */
  25110. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25111. /**
  25112. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25113. * This will be passed three parameters.
  25114. * This does nothing and may be overwritten by the user.
  25115. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25116. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25117. * @param update the boolean update value actually passed to setParticles()
  25118. */
  25119. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25120. }
  25121. }
  25122. declare module BABYLON {
  25123. /**
  25124. * Represents one particle of a solid particle system.
  25125. */
  25126. export class SolidParticle {
  25127. /**
  25128. * particle global index
  25129. */
  25130. idx: number;
  25131. /**
  25132. * The color of the particle
  25133. */
  25134. color: Nullable<Color4>;
  25135. /**
  25136. * The world space position of the particle.
  25137. */
  25138. position: Vector3;
  25139. /**
  25140. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25141. */
  25142. rotation: Vector3;
  25143. /**
  25144. * The world space rotation quaternion of the particle.
  25145. */
  25146. rotationQuaternion: Nullable<Quaternion>;
  25147. /**
  25148. * The scaling of the particle.
  25149. */
  25150. scaling: Vector3;
  25151. /**
  25152. * The uvs of the particle.
  25153. */
  25154. uvs: Vector4;
  25155. /**
  25156. * The current speed of the particle.
  25157. */
  25158. velocity: Vector3;
  25159. /**
  25160. * The pivot point in the particle local space.
  25161. */
  25162. pivot: Vector3;
  25163. /**
  25164. * Must the particle be translated from its pivot point in its local space ?
  25165. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25166. * Default : false
  25167. */
  25168. translateFromPivot: boolean;
  25169. /**
  25170. * Is the particle active or not ?
  25171. */
  25172. alive: boolean;
  25173. /**
  25174. * Is the particle visible or not ?
  25175. */
  25176. isVisible: boolean;
  25177. /**
  25178. * Index of this particle in the global "positions" array (Internal use)
  25179. * @hidden
  25180. */ private _pos: number;
  25181. /**
  25182. * @hidden Index of this particle in the global "indices" array (Internal use)
  25183. */ private _ind: number;
  25184. /**
  25185. * @hidden ModelShape of this particle (Internal use)
  25186. */ private _model: ModelShape;
  25187. /**
  25188. * ModelShape id of this particle
  25189. */
  25190. shapeId: number;
  25191. /**
  25192. * Index of the particle in its shape id
  25193. */
  25194. idxInShape: number;
  25195. /**
  25196. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25197. */ private _modelBoundingInfo: BoundingInfo;
  25198. /**
  25199. * @hidden Particle BoundingInfo object (Internal use)
  25200. */ private _boundingInfo: BoundingInfo;
  25201. /**
  25202. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25203. */ private _sps: SolidParticleSystem;
  25204. /**
  25205. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25206. */ private _stillInvisible: boolean;
  25207. /**
  25208. * @hidden Last computed particle rotation matrix
  25209. */ private _rotationMatrix: number[];
  25210. /**
  25211. * Parent particle Id, if any.
  25212. * Default null.
  25213. */
  25214. parentId: Nullable<number>;
  25215. /**
  25216. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25217. * The possible values are :
  25218. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25219. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25220. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25221. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25222. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25223. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25224. * */
  25225. cullingStrategy: number;
  25226. /**
  25227. * @hidden Internal global position in the SPS.
  25228. */ private _globalPosition: Vector3;
  25229. /**
  25230. * Creates a Solid Particle object.
  25231. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25232. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25233. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25234. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25235. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25236. * @param shapeId (integer) is the model shape identifier in the SPS.
  25237. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25238. * @param sps defines the sps it is associated to
  25239. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25240. */
  25241. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25242. /**
  25243. * Legacy support, changed scale to scaling
  25244. */
  25245. /**
  25246. * Legacy support, changed scale to scaling
  25247. */
  25248. scale: Vector3;
  25249. /**
  25250. * Legacy support, changed quaternion to rotationQuaternion
  25251. */
  25252. /**
  25253. * Legacy support, changed quaternion to rotationQuaternion
  25254. */
  25255. quaternion: Nullable<Quaternion>;
  25256. /**
  25257. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25258. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25259. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25260. * @returns true if it intersects
  25261. */
  25262. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25263. /**
  25264. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25265. * A particle is in the frustum if its bounding box intersects the frustum
  25266. * @param frustumPlanes defines the frustum to test
  25267. * @returns true if the particle is in the frustum planes
  25268. */
  25269. isInFrustum(frustumPlanes: Plane[]): boolean;
  25270. /**
  25271. * get the rotation matrix of the particle
  25272. * @hidden
  25273. */
  25274. getRotationMatrix(m: Matrix): void;
  25275. }
  25276. /**
  25277. * Represents the shape of the model used by one particle of a solid particle system.
  25278. * SPS internal tool, don't use it manually.
  25279. */
  25280. export class ModelShape {
  25281. /**
  25282. * The shape id
  25283. * @hidden
  25284. */
  25285. shapeID: number;
  25286. /**
  25287. * flat array of model positions (internal use)
  25288. * @hidden
  25289. */ private _shape: Vector3[];
  25290. /**
  25291. * flat array of model UVs (internal use)
  25292. * @hidden
  25293. */ private _shapeUV: number[];
  25294. /**
  25295. * length of the shape in the model indices array (internal use)
  25296. * @hidden
  25297. */ private _indicesLength: number;
  25298. /**
  25299. * Custom position function (internal use)
  25300. * @hidden
  25301. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25302. /**
  25303. * Custom vertex function (internal use)
  25304. * @hidden
  25305. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25306. /**
  25307. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  25308. * SPS internal tool, don't use it manually.
  25309. * @hidden
  25310. */
  25311. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25312. }
  25313. /**
  25314. * Represents a Depth Sorted Particle in the solid particle system.
  25315. */
  25316. export class DepthSortedParticle {
  25317. /**
  25318. * Index of the particle in the "indices" array
  25319. */
  25320. ind: number;
  25321. /**
  25322. * Length of the particle shape in the "indices" array
  25323. */
  25324. indicesLength: number;
  25325. /**
  25326. * Squared distance from the particle to the camera
  25327. */
  25328. sqDistance: number;
  25329. }
  25330. }
  25331. declare module BABYLON {
  25332. /**
  25333. * @hidden
  25334. */
  25335. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25336. }
  25337. }
  25338. declare module BABYLON {
  25339. /** @hidden */ private class _FacetDataStorage {
  25340. facetPositions: Vector3[];
  25341. facetNormals: Vector3[];
  25342. facetPartitioning: number[][];
  25343. facetNb: number;
  25344. partitioningSubdivisions: number;
  25345. partitioningBBoxRatio: number;
  25346. facetDataEnabled: boolean;
  25347. facetParameters: any;
  25348. bbSize: Vector3;
  25349. subDiv: {
  25350. max: number;
  25351. X: number;
  25352. Y: number;
  25353. Z: number;
  25354. };
  25355. facetDepthSort: boolean;
  25356. facetDepthSortEnabled: boolean;
  25357. depthSortedIndices: IndicesArray;
  25358. depthSortedFacets: {
  25359. ind: number;
  25360. sqDistance: number;
  25361. }[];
  25362. facetDepthSortFunction: (f1: {
  25363. ind: number;
  25364. sqDistance: number;
  25365. }, f2: {
  25366. ind: number;
  25367. sqDistance: number;
  25368. }) => number;
  25369. facetDepthSortFrom: Vector3;
  25370. facetDepthSortOrigin: Vector3;
  25371. invertedMatrix: Matrix;
  25372. }
  25373. /**
  25374. * @hidden
  25375. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  25376. }
  25377. /**
  25378. * Class used to store all common mesh properties
  25379. */
  25380. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25381. /** No occlusion */
  25382. static OCCLUSION_TYPE_NONE: number;
  25383. /** Occlusion set to optimisitic */
  25384. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25385. /** Occlusion set to strict */
  25386. static OCCLUSION_TYPE_STRICT: number;
  25387. /** Use an accurante occlusion algorithm */
  25388. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25389. /** Use a conservative occlusion algorithm */
  25390. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25391. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25392. * Test order :
  25393. * Is the bounding sphere outside the frustum ?
  25394. * If not, are the bounding box vertices outside the frustum ?
  25395. * It not, then the cullable object is in the frustum.
  25396. */
  25397. static readonly CULLINGSTRATEGY_STANDARD: number;
  25398. /** Culling strategy : Bounding Sphere Only.
  25399. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25400. * It's also less accurate than the standard because some not visible objects can still be selected.
  25401. * Test : is the bounding sphere outside the frustum ?
  25402. * If not, then the cullable object is in the frustum.
  25403. */
  25404. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25405. /** Culling strategy : Optimistic Inclusion.
  25406. * This in an inclusion test first, then the standard exclusion test.
  25407. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25408. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  25409. * Anyway, it's as accurate as the standard strategy.
  25410. * Test :
  25411. * Is the cullable object bounding sphere center in the frustum ?
  25412. * If not, apply the default culling strategy.
  25413. */
  25414. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25415. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25416. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25417. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25418. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  25419. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25420. * Test :
  25421. * Is the cullable object bounding sphere center in the frustum ?
  25422. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25423. */
  25424. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25425. /**
  25426. * No billboard
  25427. */
  25428. static readonly BILLBOARDMODE_NONE: number;
  25429. /** Billboard on X axis */
  25430. static readonly BILLBOARDMODE_X: number;
  25431. /** Billboard on Y axis */
  25432. static readonly BILLBOARDMODE_Y: number;
  25433. /** Billboard on Z axis */
  25434. static readonly BILLBOARDMODE_Z: number;
  25435. /** Billboard on all axes */
  25436. static readonly BILLBOARDMODE_ALL: number;
  25437. /** Billboard on using position instead of orientation */
  25438. static readonly BILLBOARDMODE_USE_POSITION: number;
  25439. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25440. /**
  25441. * The culling strategy to use to check whether the mesh must be rendered or not.
  25442. * This value can be changed at any time and will be used on the next render mesh selection.
  25443. * The possible values are :
  25444. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25445. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25446. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25447. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25448. * Please read each static variable documentation to get details about the culling process.
  25449. * */
  25450. cullingStrategy: number;
  25451. /**
  25452. * Gets the number of facets in the mesh
  25453. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25454. */
  25455. readonly facetNb: number;
  25456. /**
  25457. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25459. */
  25460. partitioningSubdivisions: number;
  25461. /**
  25462. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25463. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25465. */
  25466. partitioningBBoxRatio: number;
  25467. /**
  25468. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25469. * Works only for updatable meshes.
  25470. * Doesn't work with multi-materials
  25471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25472. */
  25473. mustDepthSortFacets: boolean;
  25474. /**
  25475. * The location (Vector3) where the facet depth sort must be computed from.
  25476. * By default, the active camera position.
  25477. * Used only when facet depth sort is enabled
  25478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25479. */
  25480. facetDepthSortFrom: Vector3;
  25481. /**
  25482. * gets a boolean indicating if facetData is enabled
  25483. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25484. */
  25485. readonly isFacetDataEnabled: boolean;
  25486. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25487. /**
  25488. * An event triggered when this mesh collides with another one
  25489. */
  25490. onCollideObservable: Observable<AbstractMesh>;
  25491. /** Set a function to call when this mesh collides with another one */
  25492. onCollide: () => void;
  25493. /**
  25494. * An event triggered when the collision's position changes
  25495. */
  25496. onCollisionPositionChangeObservable: Observable<Vector3>;
  25497. /** Set a function to call when the collision's position changes */
  25498. onCollisionPositionChange: () => void;
  25499. /**
  25500. * An event triggered when material is changed
  25501. */
  25502. onMaterialChangedObservable: Observable<AbstractMesh>;
  25503. /**
  25504. * Gets or sets the orientation for POV movement & rotation
  25505. */
  25506. definedFacingForward: boolean;
  25507. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25508. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25509. /**
  25510. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25511. */
  25512. /**
  25513. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25514. */
  25515. visibility: number;
  25516. /** Gets or sets the alpha index used to sort transparent meshes
  25517. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25518. */
  25519. alphaIndex: number;
  25520. /**
  25521. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25522. */
  25523. isVisible: boolean;
  25524. /**
  25525. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25526. */
  25527. isPickable: boolean;
  25528. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25529. showSubMeshesBoundingBox: boolean;
  25530. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25531. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25532. */
  25533. isBlocker: boolean;
  25534. /**
  25535. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25536. */
  25537. enablePointerMoveEvents: boolean;
  25538. /**
  25539. * Specifies the rendering group id for this mesh (0 by default)
  25540. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25541. */
  25542. renderingGroupId: number;
  25543. private _material;
  25544. /** Gets or sets current material */
  25545. material: Nullable<Material>;
  25546. /**
  25547. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25548. * @see http://doc.babylonjs.com/babylon101/shadows
  25549. */
  25550. receiveShadows: boolean;
  25551. /** Defines color to use when rendering outline */
  25552. outlineColor: Color3;
  25553. /** Define width to use when rendering outline */
  25554. outlineWidth: number;
  25555. /** Defines color to use when rendering overlay */
  25556. overlayColor: Color3;
  25557. /** Defines alpha to use when rendering overlay */
  25558. overlayAlpha: number;
  25559. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25560. hasVertexAlpha: boolean;
  25561. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  25562. useVertexColors: boolean;
  25563. /**
  25564. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25565. */
  25566. computeBonesUsingShaders: boolean;
  25567. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25568. numBoneInfluencers: number;
  25569. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25570. applyFog: boolean;
  25571. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25572. useOctreeForRenderingSelection: boolean;
  25573. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25574. useOctreeForPicking: boolean;
  25575. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25576. useOctreeForCollisions: boolean;
  25577. /**
  25578. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25579. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25580. */
  25581. layerMask: number;
  25582. /**
  25583. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25584. */
  25585. alwaysSelectAsActiveMesh: boolean;
  25586. /**
  25587. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25588. */
  25589. doNotSyncBoundingInfo: boolean;
  25590. /**
  25591. * Gets or sets the current action manager
  25592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25593. */
  25594. actionManager: Nullable<AbstractActionManager>;
  25595. private _meshCollisionData;
  25596. /**
  25597. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25598. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25599. */
  25600. ellipsoid: Vector3;
  25601. /**
  25602. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25603. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25604. */
  25605. ellipsoidOffset: Vector3;
  25606. /**
  25607. * Gets or sets a collision mask used to mask collisions (default is -1).
  25608. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25609. */
  25610. collisionMask: number;
  25611. /**
  25612. * Gets or sets the current collision group mask (-1 by default).
  25613. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25614. */
  25615. collisionGroup: number;
  25616. /**
  25617. * Defines edge width used when edgesRenderer is enabled
  25618. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25619. */
  25620. edgesWidth: number;
  25621. /**
  25622. * Defines edge color used when edgesRenderer is enabled
  25623. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25624. */
  25625. edgesColor: Color4;
  25626. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25627. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25628. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25629. /** @hidden */ private _renderId: number;
  25630. /**
  25631. * Gets or sets the list of subMeshes
  25632. * @see http://doc.babylonjs.com/how_to/multi_materials
  25633. */
  25634. subMeshes: SubMesh[];
  25635. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25636. /** @hidden */ private _unIndexed: boolean;
  25637. /** @hidden */ private _lightSources: Light[];
  25638. /** Gets the list of lights affecting that mesh */
  25639. readonly lightSources: Light[];
  25640. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25641. /** @hidden */ private _waitingData: {
  25642. lods: Nullable<any>;
  25643. actions: Nullable<any>;
  25644. freezeWorldMatrix: Nullable<boolean>;
  25645. };
  25646. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25647. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25648. /**
  25649. * Gets or sets a skeleton to apply skining transformations
  25650. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25651. */
  25652. skeleton: Nullable<Skeleton>;
  25653. /**
  25654. * An event triggered when the mesh is rebuilt.
  25655. */
  25656. onRebuildObservable: Observable<AbstractMesh>;
  25657. /**
  25658. * The current camera unifom buffer.
  25659. * @hidden Internal use only.
  25660. */ private _uniformBuffer: UniformBuffer;
  25661. /**
  25662. * Creates a new AbstractMesh
  25663. * @param name defines the name of the mesh
  25664. * @param scene defines the hosting scene
  25665. */
  25666. constructor(name: string, scene?: Nullable<Scene>);
  25667. protected _buildUniformLayout(): void;
  25668. /**
  25669. * Transfer the mesh values to its UBO.
  25670. * @param world The world matrix associated with the mesh
  25671. */
  25672. transferToEffect(world: Matrix): void;
  25673. /**
  25674. * Gets the mesh uniform buffer.
  25675. * @return the uniform buffer of the mesh.
  25676. */
  25677. getMeshUniformBuffer(): UniformBuffer;
  25678. /**
  25679. * Returns the string "AbstractMesh"
  25680. * @returns "AbstractMesh"
  25681. */
  25682. getClassName(): string;
  25683. /**
  25684. * Gets a string representation of the current mesh
  25685. * @param fullDetails defines a boolean indicating if full details must be included
  25686. * @returns a string representation of the current mesh
  25687. */
  25688. toString(fullDetails?: boolean): string;
  25689. /**
  25690. * @hidden
  25691. */
  25692. protected _getEffectiveParent(): Nullable<Node>;
  25693. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25694. /** @hidden */ private _rebuild(): void;
  25695. /** @hidden */ private _resyncLightSources(): void;
  25696. /** @hidden */ private _resyncLighSource(light: Light): void;
  25697. /** @hidden */ private _unBindEffect(): void;
  25698. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25699. private _markSubMeshesAsDirty;
  25700. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25701. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25702. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25703. /**
  25704. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25705. */
  25706. scaling: Vector3;
  25707. /**
  25708. * Returns true if the mesh is blocked. Implemented by child classes
  25709. */
  25710. readonly isBlocked: boolean;
  25711. /**
  25712. * Returns the mesh itself by default. Implemented by child classes
  25713. * @param camera defines the camera to use to pick the right LOD level
  25714. * @returns the currentAbstractMesh
  25715. */
  25716. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25717. /**
  25718. * Returns 0 by default. Implemented by child classes
  25719. * @returns an integer
  25720. */
  25721. getTotalVertices(): number;
  25722. /**
  25723. * Returns a positive integer : the total number of indices in this mesh geometry.
  25724. * @returns the numner of indices or zero if the mesh has no geometry.
  25725. */
  25726. getTotalIndices(): number;
  25727. /**
  25728. * Returns null by default. Implemented by child classes
  25729. * @returns null
  25730. */
  25731. getIndices(): Nullable<IndicesArray>;
  25732. /**
  25733. * Returns the array of the requested vertex data kind. Implemented by child classes
  25734. * @param kind defines the vertex data kind to use
  25735. * @returns null
  25736. */
  25737. getVerticesData(kind: string): Nullable<FloatArray>;
  25738. /**
  25739. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25740. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25741. * Note that a new underlying VertexBuffer object is created each call.
  25742. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25743. * @param kind defines vertex data kind:
  25744. * * VertexBuffer.PositionKind
  25745. * * VertexBuffer.UVKind
  25746. * * VertexBuffer.UV2Kind
  25747. * * VertexBuffer.UV3Kind
  25748. * * VertexBuffer.UV4Kind
  25749. * * VertexBuffer.UV5Kind
  25750. * * VertexBuffer.UV6Kind
  25751. * * VertexBuffer.ColorKind
  25752. * * VertexBuffer.MatricesIndicesKind
  25753. * * VertexBuffer.MatricesIndicesExtraKind
  25754. * * VertexBuffer.MatricesWeightsKind
  25755. * * VertexBuffer.MatricesWeightsExtraKind
  25756. * @param data defines the data source
  25757. * @param updatable defines if the data must be flagged as updatable (or static)
  25758. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  25759. * @returns the current mesh
  25760. */
  25761. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25762. /**
  25763. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25764. * If the mesh has no geometry, it is simply returned as it is.
  25765. * @param kind defines vertex data kind:
  25766. * * VertexBuffer.PositionKind
  25767. * * VertexBuffer.UVKind
  25768. * * VertexBuffer.UV2Kind
  25769. * * VertexBuffer.UV3Kind
  25770. * * VertexBuffer.UV4Kind
  25771. * * VertexBuffer.UV5Kind
  25772. * * VertexBuffer.UV6Kind
  25773. * * VertexBuffer.ColorKind
  25774. * * VertexBuffer.MatricesIndicesKind
  25775. * * VertexBuffer.MatricesIndicesExtraKind
  25776. * * VertexBuffer.MatricesWeightsKind
  25777. * * VertexBuffer.MatricesWeightsExtraKind
  25778. * @param data defines the data source
  25779. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  25780. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25781. * @returns the current mesh
  25782. */
  25783. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25784. /**
  25785. * Sets the mesh indices,
  25786. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25787. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25788. * @param totalVertices Defines the total number of vertices
  25789. * @returns the current mesh
  25790. */
  25791. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25792. /**
  25793. * Gets a boolean indicating if specific vertex data is present
  25794. * @param kind defines the vertex data kind to use
  25795. * @returns true is data kind is present
  25796. */
  25797. isVerticesDataPresent(kind: string): boolean;
  25798. /**
  25799. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25800. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25801. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25802. * @returns a BoundingInfo
  25803. */
  25804. getBoundingInfo(): BoundingInfo;
  25805. /**
  25806. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25807. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25808. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25809. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25810. * @returns the current mesh
  25811. */
  25812. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25813. /**
  25814. * Overwrite the current bounding info
  25815. * @param boundingInfo defines the new bounding info
  25816. * @returns the current mesh
  25817. */
  25818. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25819. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25820. readonly useBones: boolean;
  25821. /** @hidden */ private _preActivate(): void;
  25822. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25823. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25824. /** @hidden */ private _postActivate(): void;
  25825. /** @hidden */ private _freeze(): void;
  25826. /** @hidden */ private _unFreeze(): void;
  25827. /**
  25828. * Gets the current world matrix
  25829. * @returns a Matrix
  25830. */
  25831. getWorldMatrix(): Matrix;
  25832. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25833. /**
  25834. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25835. */
  25836. readonly isAnInstance: boolean;
  25837. /**
  25838. * Gets a boolean indicating if this mesh has instances
  25839. */
  25840. readonly hasInstances: boolean;
  25841. /**
  25842. * Perform relative position change from the point of view of behind the front of the mesh.
  25843. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25844. * Supports definition of mesh facing forward or backward
  25845. * @param amountRight defines the distance on the right axis
  25846. * @param amountUp defines the distance on the up axis
  25847. * @param amountForward defines the distance on the forward axis
  25848. * @returns the current mesh
  25849. */
  25850. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25851. /**
  25852. * Calculate relative position change from the point of view of behind the front of the mesh.
  25853. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25854. * Supports definition of mesh facing forward or backward
  25855. * @param amountRight defines the distance on the right axis
  25856. * @param amountUp defines the distance on the up axis
  25857. * @param amountForward defines the distance on the forward axis
  25858. * @returns the new displacement vector
  25859. */
  25860. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25861. /**
  25862. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25863. * Supports definition of mesh facing forward or backward
  25864. * @param flipBack defines the flip
  25865. * @param twirlClockwise defines the twirl
  25866. * @param tiltRight defines the tilt
  25867. * @returns the current mesh
  25868. */
  25869. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25870. /**
  25871. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25872. * Supports definition of mesh facing forward or backward.
  25873. * @param flipBack defines the flip
  25874. * @param twirlClockwise defines the twirl
  25875. * @param tiltRight defines the tilt
  25876. * @returns the new rotation vector
  25877. */
  25878. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25879. /**
  25880. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25881. * This means the mesh underlying bounding box and sphere are recomputed.
  25882. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25883. * @returns the current mesh
  25884. */
  25885. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25886. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25887. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25888. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25889. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25890. /** @hidden */
  25891. protected _afterComputeWorldMatrix(): void;
  25892. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25893. /**
  25894. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25895. * A mesh is in the frustum if its bounding box intersects the frustum
  25896. * @param frustumPlanes defines the frustum to test
  25897. * @returns true if the mesh is in the frustum planes
  25898. */
  25899. isInFrustum(frustumPlanes: Plane[]): boolean;
  25900. /**
  25901. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25902. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25903. * @param frustumPlanes defines the frustum to test
  25904. * @returns true if the mesh is completely in the frustum planes
  25905. */
  25906. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25907. /**
  25908. * True if the mesh intersects another mesh or a SolidParticle object
  25909. * @param mesh defines a target mesh or SolidParticle to test
  25910. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  25911. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25912. * @returns true if there is an intersection
  25913. */
  25914. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25915. /**
  25916. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25917. * @param point defines the point to test
  25918. * @returns true if there is an intersection
  25919. */
  25920. intersectsPoint(point: Vector3): boolean;
  25921. /**
  25922. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25924. */
  25925. checkCollisions: boolean;
  25926. /**
  25927. * Gets Collider object used to compute collisions (not physics)
  25928. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25929. */
  25930. readonly collider: Nullable<Collider>;
  25931. /**
  25932. * Move the mesh using collision engine
  25933. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25934. * @param displacement defines the requested displacement vector
  25935. * @returns the current mesh
  25936. */
  25937. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25938. private _onCollisionPositionChange;
  25939. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25940. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25941. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25942. /** @hidden */ private _generatePointsArray(): boolean;
  25943. /**
  25944. * Checks if the passed Ray intersects with the mesh
  25945. * @param ray defines the ray to use
  25946. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25947. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25948. * @returns the picking info
  25949. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25950. */
  25951. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25952. /**
  25953. * Clones the current mesh
  25954. * @param name defines the mesh name
  25955. * @param newParent defines the new mesh parent
  25956. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25957. * @returns the new mesh
  25958. */
  25959. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25960. /**
  25961. * Disposes all the submeshes of the current meshnp
  25962. * @returns the current mesh
  25963. */
  25964. releaseSubMeshes(): AbstractMesh;
  25965. /**
  25966. * Releases resources associated with this abstract mesh.
  25967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25969. */
  25970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25971. /**
  25972. * Adds the passed mesh as a child to the current mesh
  25973. * @param mesh defines the child mesh
  25974. * @returns the current mesh
  25975. */
  25976. addChild(mesh: AbstractMesh): AbstractMesh;
  25977. /**
  25978. * Removes the passed mesh from the current mesh children list
  25979. * @param mesh defines the child mesh
  25980. * @returns the current mesh
  25981. */
  25982. removeChild(mesh: AbstractMesh): AbstractMesh;
  25983. /** @hidden */
  25984. private _initFacetData;
  25985. /**
  25986. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25987. * This method can be called within the render loop.
  25988. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  25989. * @returns the current mesh
  25990. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25991. */
  25992. updateFacetData(): AbstractMesh;
  25993. /**
  25994. * Returns the facetLocalNormals array.
  25995. * The normals are expressed in the mesh local spac
  25996. * @returns an array of Vector3
  25997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25998. */
  25999. getFacetLocalNormals(): Vector3[];
  26000. /**
  26001. * Returns the facetLocalPositions array.
  26002. * The facet positions are expressed in the mesh local space
  26003. * @returns an array of Vector3
  26004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26005. */
  26006. getFacetLocalPositions(): Vector3[];
  26007. /**
  26008. * Returns the facetLocalPartioning array
  26009. * @returns an array of array of numbers
  26010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26011. */
  26012. getFacetLocalPartitioning(): number[][];
  26013. /**
  26014. * Returns the i-th facet position in the world system.
  26015. * This method allocates a new Vector3 per call
  26016. * @param i defines the facet index
  26017. * @returns a new Vector3
  26018. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26019. */
  26020. getFacetPosition(i: number): Vector3;
  26021. /**
  26022. * Sets the reference Vector3 with the i-th facet position in the world system
  26023. * @param i defines the facet index
  26024. * @param ref defines the target vector
  26025. * @returns the current mesh
  26026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26027. */
  26028. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26029. /**
  26030. * Returns the i-th facet normal in the world system.
  26031. * This method allocates a new Vector3 per call
  26032. * @param i defines the facet index
  26033. * @returns a new Vector3
  26034. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26035. */
  26036. getFacetNormal(i: number): Vector3;
  26037. /**
  26038. * Sets the reference Vector3 with the i-th facet normal in the world system
  26039. * @param i defines the facet index
  26040. * @param ref defines the target vector
  26041. * @returns the current mesh
  26042. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26043. */
  26044. getFacetNormalToRef(i: number, ref: Vector3): this;
  26045. /**
  26046. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  26047. * @param x defines x coordinate
  26048. * @param y defines y coordinate
  26049. * @param z defines z coordinate
  26050. * @returns the array of facet indexes
  26051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26052. */
  26053. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26054. /**
  26055. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26056. * @param projected sets as the (x,y,z) world projection on the facet
  26057. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  26058. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  26059. * @param x defines x coordinate
  26060. * @param y defines y coordinate
  26061. * @param z defines z coordinate
  26062. * @returns the face index if found (or null instead)
  26063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26064. */
  26065. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26066. /**
  26067. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26068. * @param projected sets as the (x,y,z) local projection on the facet
  26069. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  26070. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  26071. * @param x defines x coordinate
  26072. * @param y defines y coordinate
  26073. * @param z defines z coordinate
  26074. * @returns the face index if found (or null instead)
  26075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26076. */
  26077. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26078. /**
  26079. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26080. * @returns the parameters
  26081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26082. */
  26083. getFacetDataParameters(): any;
  26084. /**
  26085. * Disables the feature FacetData and frees the related memory
  26086. * @returns the current mesh
  26087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26088. */
  26089. disableFacetData(): AbstractMesh;
  26090. /**
  26091. * Updates the AbstractMesh indices array
  26092. * @param indices defines the data source
  26093. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26094. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  26095. * @returns the current mesh
  26096. */
  26097. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26098. /**
  26099. * Creates new normals data for the mesh
  26100. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26101. * @returns the current mesh
  26102. */
  26103. createNormals(updatable: boolean): AbstractMesh;
  26104. /**
  26105. * Align the mesh with a normal
  26106. * @param normal defines the normal to use
  26107. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26108. * @returns the current mesh
  26109. */
  26110. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26111. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26112. /**
  26113. * Disables the mesh edge rendering mode
  26114. * @returns the currentAbstractMesh
  26115. */
  26116. disableEdgesRendering(): AbstractMesh;
  26117. /**
  26118. * Enables the edge rendering mode on the mesh.
  26119. * This mode makes the mesh edges visible
  26120. * @param epsilon defines the maximal distance between two angles to detect a face
  26121. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26122. * @returns the currentAbstractMesh
  26123. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26124. */
  26125. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26126. }
  26127. }
  26128. declare module BABYLON {
  26129. /**
  26130. * Interface used to define ActionEvent
  26131. */
  26132. export interface IActionEvent {
  26133. /** The mesh or sprite that triggered the action */
  26134. source: any;
  26135. /** The X mouse cursor position at the time of the event */
  26136. pointerX: number;
  26137. /** The Y mouse cursor position at the time of the event */
  26138. pointerY: number;
  26139. /** The mesh that is currently pointed at (can be null) */
  26140. meshUnderPointer: Nullable<AbstractMesh>;
  26141. /** the original (browser) event that triggered the ActionEvent */
  26142. sourceEvent?: any;
  26143. /** additional data for the event */
  26144. additionalData?: any;
  26145. }
  26146. /**
  26147. * ActionEvent is the event being sent when an action is triggered.
  26148. */
  26149. export class ActionEvent implements IActionEvent {
  26150. /** The mesh or sprite that triggered the action */
  26151. source: any;
  26152. /** The X mouse cursor position at the time of the event */
  26153. pointerX: number;
  26154. /** The Y mouse cursor position at the time of the event */
  26155. pointerY: number;
  26156. /** The mesh that is currently pointed at (can be null) */
  26157. meshUnderPointer: Nullable<AbstractMesh>;
  26158. /** the original (browser) event that triggered the ActionEvent */
  26159. sourceEvent?: any;
  26160. /** additional data for the event */
  26161. additionalData?: any;
  26162. /**
  26163. * Creates a new ActionEvent
  26164. * @param source The mesh or sprite that triggered the action
  26165. * @param pointerX The X mouse cursor position at the time of the event
  26166. * @param pointerY The Y mouse cursor position at the time of the event
  26167. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26168. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26169. * @param additionalData additional data for the event
  26170. */
  26171. constructor(
  26172. /** The mesh or sprite that triggered the action */
  26173. source: any,
  26174. /** The X mouse cursor position at the time of the event */
  26175. pointerX: number,
  26176. /** The Y mouse cursor position at the time of the event */
  26177. pointerY: number,
  26178. /** The mesh that is currently pointed at (can be null) */
  26179. meshUnderPointer: Nullable<AbstractMesh>,
  26180. /** the original (browser) event that triggered the ActionEvent */
  26181. sourceEvent?: any,
  26182. /** additional data for the event */
  26183. additionalData?: any);
  26184. /**
  26185. * Helper function to auto-create an ActionEvent from a source mesh.
  26186. * @param source The source mesh that triggered the event
  26187. * @param evt The original (browser) event
  26188. * @param additionalData additional data for the event
  26189. * @returns the new ActionEvent
  26190. */
  26191. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26192. /**
  26193. * Helper function to auto-create an ActionEvent from a source sprite
  26194. * @param source The source sprite that triggered the event
  26195. * @param scene Scene associated with the sprite
  26196. * @param evt The original (browser) event
  26197. * @param additionalData additional data for the event
  26198. * @returns the new ActionEvent
  26199. */
  26200. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26201. /**
  26202. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26203. * @param scene the scene where the event occurred
  26204. * @param evt The original (browser) event
  26205. * @returns the new ActionEvent
  26206. */
  26207. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26208. /**
  26209. * Helper function to auto-create an ActionEvent from a primitive
  26210. * @param prim defines the target primitive
  26211. * @param pointerPos defines the pointer position
  26212. * @param evt The original (browser) event
  26213. * @param additionalData additional data for the event
  26214. * @returns the new ActionEvent
  26215. */
  26216. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26217. }
  26218. }
  26219. declare module BABYLON {
  26220. /**
  26221. * Abstract class used to decouple action Manager from scene and meshes.
  26222. * Do not instantiate.
  26223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26224. */
  26225. export abstract class AbstractActionManager implements IDisposable {
  26226. /** Gets the list of active triggers */
  26227. static Triggers: {
  26228. [key: string]: number;
  26229. };
  26230. /** Gets the cursor to use when hovering items */
  26231. hoverCursor: string;
  26232. /** Gets the list of actions */
  26233. actions: IAction[];
  26234. /**
  26235. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26236. */
  26237. isRecursive: boolean;
  26238. /**
  26239. * Releases all associated resources
  26240. */
  26241. abstract dispose(): void;
  26242. /**
  26243. * Does this action manager has pointer triggers
  26244. */
  26245. abstract readonly hasPointerTriggers: boolean;
  26246. /**
  26247. * Does this action manager has pick triggers
  26248. */
  26249. abstract readonly hasPickTriggers: boolean;
  26250. /**
  26251. * Process a specific trigger
  26252. * @param trigger defines the trigger to process
  26253. * @param evt defines the event details to be processed
  26254. */
  26255. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26256. /**
  26257. * Does this action manager handles actions of any of the given triggers
  26258. * @param triggers defines the triggers to be tested
  26259. * @return a boolean indicating whether one (or more) of the triggers is handled
  26260. */
  26261. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26262. /**
  26263. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26264. * speed.
  26265. * @param triggerA defines the trigger to be tested
  26266. * @param triggerB defines the trigger to be tested
  26267. * @return a boolean indicating whether one (or more) of the triggers is handled
  26268. */
  26269. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26270. /**
  26271. * Does this action manager handles actions of a given trigger
  26272. * @param trigger defines the trigger to be tested
  26273. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26274. * @return whether the trigger is handled
  26275. */
  26276. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26277. /**
  26278. * Serialize this manager to a JSON object
  26279. * @param name defines the property name to store this manager
  26280. * @returns a JSON representation of this manager
  26281. */
  26282. abstract serialize(name: string): any;
  26283. /**
  26284. * Registers an action to this action manager
  26285. * @param action defines the action to be registered
  26286. * @return the action amended (prepared) after registration
  26287. */
  26288. abstract registerAction(action: IAction): Nullable<IAction>;
  26289. /**
  26290. * Unregisters an action to this action manager
  26291. * @param action defines the action to be unregistered
  26292. * @return a boolean indicating whether the action has been unregistered
  26293. */
  26294. abstract unregisterAction(action: IAction): Boolean;
  26295. /**
  26296. * Does exist one action manager with at least one trigger
  26297. **/
  26298. static readonly HasTriggers: boolean;
  26299. /**
  26300. * Does exist one action manager with at least one pick trigger
  26301. **/
  26302. static readonly HasPickTriggers: boolean;
  26303. /**
  26304. * Does exist one action manager that handles actions of a given trigger
  26305. * @param trigger defines the trigger to be tested
  26306. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26307. **/
  26308. static HasSpecificTrigger(trigger: number): boolean;
  26309. }
  26310. }
  26311. declare module BABYLON {
  26312. /**
  26313. * Defines how a node can be built from a string name.
  26314. */
  26315. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26316. /**
  26317. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26318. */
  26319. export class Node implements IBehaviorAware<Node> {
  26320. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26321. private static _NodeConstructors;
  26322. /**
  26323. * Add a new node constructor
  26324. * @param type defines the type name of the node to construct
  26325. * @param constructorFunc defines the constructor function
  26326. */
  26327. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26328. /**
  26329. * Returns a node constructor based on type name
  26330. * @param type defines the type name
  26331. * @param name defines the new node name
  26332. * @param scene defines the hosting scene
  26333. * @param options defines optional options to transmit to constructors
  26334. * @returns the new constructor or null
  26335. */
  26336. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26337. /**
  26338. * Gets or sets the name of the node
  26339. */
  26340. name: string;
  26341. /**
  26342. * Gets or sets the id of the node
  26343. */
  26344. id: string;
  26345. /**
  26346. * Gets or sets the unique id of the node
  26347. */
  26348. uniqueId: number;
  26349. /**
  26350. * Gets or sets a string used to store user defined state for the node
  26351. */
  26352. state: string;
  26353. /**
  26354. * Gets or sets an object used to store user defined information for the node
  26355. */
  26356. metadata: any;
  26357. /**
  26358. * For internal use only. Please do not use.
  26359. */
  26360. reservedDataStore: any;
  26361. /**
  26362. * List of inspectable custom properties (used by the Inspector)
  26363. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26364. */
  26365. inspectableCustomProperties: IInspectable[];
  26366. /**
  26367. * Gets or sets a boolean used to define if the node must be serialized
  26368. */
  26369. doNotSerialize: boolean;
  26370. /** @hidden */ private _isDisposed: boolean;
  26371. /**
  26372. * Gets a list of Animations associated with the node
  26373. */
  26374. animations: Animation[];
  26375. protected _ranges: {
  26376. [name: string]: Nullable<AnimationRange>;
  26377. };
  26378. /**
  26379. * Callback raised when the node is ready to be used
  26380. */
  26381. onReady: Nullable<(node: Node) => void>;
  26382. private _isEnabled;
  26383. private _isParentEnabled;
  26384. private _isReady;
  26385. /** @hidden */ private _currentRenderId: number;
  26386. private _parentUpdateId;
  26387. /** @hidden */ private _childUpdateId: number;
  26388. /** @hidden */ private _waitingParentId: Nullable<string>;
  26389. /** @hidden */ private _scene: Scene;
  26390. /** @hidden */ private _cache: any;
  26391. private _parentNode;
  26392. private _children;
  26393. /** @hidden */ private _worldMatrix: Matrix;
  26394. /** @hidden */ private _worldMatrixDeterminant: number;
  26395. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26396. /** @hidden */
  26397. private _sceneRootNodesIndex;
  26398. /**
  26399. * Gets a boolean indicating if the node has been disposed
  26400. * @returns true if the node was disposed
  26401. */
  26402. isDisposed(): boolean;
  26403. /**
  26404. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26405. * @see https://doc.babylonjs.com/how_to/parenting
  26406. */
  26407. parent: Nullable<Node>;
  26408. private addToSceneRootNodes;
  26409. private removeFromSceneRootNodes;
  26410. private _animationPropertiesOverride;
  26411. /**
  26412. * Gets or sets the animation properties override
  26413. */
  26414. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26415. /**
  26416. * Gets a string idenfifying the name of the class
  26417. * @returns "Node" string
  26418. */
  26419. getClassName(): string;
  26420. /** @hidden */ protected readonly _isNode: boolean;
  26421. /**
  26422. * An event triggered when the mesh is disposed
  26423. */
  26424. onDisposeObservable: Observable<Node>;
  26425. private _onDisposeObserver;
  26426. /**
  26427. * Sets a callback that will be raised when the node will be disposed
  26428. */
  26429. onDispose: () => void;
  26430. /**
  26431. * Creates a new Node
  26432. * @param name the name and id to be given to this node
  26433. * @param scene the scene this node will be added to
  26434. * @param addToRootNodes the node will be added to scene.rootNodes
  26435. */
  26436. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26437. /**
  26438. * Gets the scene of the node
  26439. * @returns a scene
  26440. */
  26441. getScene(): Scene;
  26442. /**
  26443. * Gets the engine of the node
  26444. * @returns a Engine
  26445. */
  26446. getEngine(): Engine;
  26447. private _behaviors;
  26448. /**
  26449. * Attach a behavior to the node
  26450. * @see http://doc.babylonjs.com/features/behaviour
  26451. * @param behavior defines the behavior to attach
  26452. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26453. * @returns the current Node
  26454. */
  26455. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26456. /**
  26457. * Remove an attached behavior
  26458. * @see http://doc.babylonjs.com/features/behaviour
  26459. * @param behavior defines the behavior to attach
  26460. * @returns the current Node
  26461. */
  26462. removeBehavior(behavior: Behavior<Node>): Node;
  26463. /**
  26464. * Gets the list of attached behaviors
  26465. * @see http://doc.babylonjs.com/features/behaviour
  26466. */
  26467. readonly behaviors: Behavior<Node>[];
  26468. /**
  26469. * Gets an attached behavior by name
  26470. * @param name defines the name of the behavior to look for
  26471. * @see http://doc.babylonjs.com/features/behaviour
  26472. * @returns null if behavior was not found else the requested behavior
  26473. */
  26474. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26475. /**
  26476. * Returns the latest update of the World matrix
  26477. * @returns a Matrix
  26478. */
  26479. getWorldMatrix(): Matrix;
  26480. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26481. /**
  26482. * Returns directly the latest state of the mesh World matrix.
  26483. * A Matrix is returned.
  26484. */
  26485. readonly worldMatrixFromCache: Matrix;
  26486. /** @hidden */ private _initCache(): void;
  26487. /** @hidden */
  26488. updateCache(force?: boolean): void;
  26489. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26490. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26491. /** @hidden */ private _isSynchronized(): boolean;
  26492. /** @hidden */ private _markSyncedWithParent(): void;
  26493. /** @hidden */
  26494. isSynchronizedWithParent(): boolean;
  26495. /** @hidden */
  26496. isSynchronized(): boolean;
  26497. /**
  26498. * Is this node ready to be used/rendered
  26499. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26500. * @return true if the node is ready
  26501. */
  26502. isReady(completeCheck?: boolean): boolean;
  26503. /**
  26504. * Is this node enabled?
  26505. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  26506. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  26507. * @return whether this node (and its parent) is enabled
  26508. */
  26509. isEnabled(checkAncestors?: boolean): boolean;
  26510. /** @hidden */
  26511. protected _syncParentEnabledState(): void;
  26512. /**
  26513. * Set the enabled state of this node
  26514. * @param value defines the new enabled state
  26515. */
  26516. setEnabled(value: boolean): void;
  26517. /**
  26518. * Is this node a descendant of the given node?
  26519. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26520. * @param ancestor defines the parent node to inspect
  26521. * @returns a boolean indicating if this node is a descendant of the given node
  26522. */
  26523. isDescendantOf(ancestor: Node): boolean;
  26524. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26525. /**
  26526. * Will return all nodes that have this node as ascendant
  26527. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  26528. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26529. * @return all children nodes of all types
  26530. */
  26531. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26532. /**
  26533. * Get all child-meshes of this node
  26534. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  26535. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26536. * @returns an array of AbstractMesh
  26537. */
  26538. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26539. /**
  26540. * Get all direct children of this node
  26541. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26542. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  26543. * @returns an array of Node
  26544. */
  26545. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26546. /** @hidden */ private _setReady(state: boolean): void;
  26547. /**
  26548. * Get an animation by name
  26549. * @param name defines the name of the animation to look for
  26550. * @returns null if not found else the requested animation
  26551. */
  26552. getAnimationByName(name: string): Nullable<Animation>;
  26553. /**
  26554. * Creates an animation range for this node
  26555. * @param name defines the name of the range
  26556. * @param from defines the starting key
  26557. * @param to defines the end key
  26558. */
  26559. createAnimationRange(name: string, from: number, to: number): void;
  26560. /**
  26561. * Delete a specific animation range
  26562. * @param name defines the name of the range to delete
  26563. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26564. */
  26565. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26566. /**
  26567. * Get an animation range by name
  26568. * @param name defines the name of the animation range to look for
  26569. * @returns null if not found else the requested animation range
  26570. */
  26571. getAnimationRange(name: string): Nullable<AnimationRange>;
  26572. /**
  26573. * Gets the list of all animation ranges defined on this node
  26574. * @returns an array
  26575. */
  26576. getAnimationRanges(): Nullable<AnimationRange>[];
  26577. /**
  26578. * Will start the animation sequence
  26579. * @param name defines the range frames for animation sequence
  26580. * @param loop defines if the animation should loop (false by default)
  26581. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26582. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26583. * @returns the object created for this animation. If range does not exist, it will return null
  26584. */
  26585. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26586. /**
  26587. * Serialize animation ranges into a JSON compatible object
  26588. * @returns serialization object
  26589. */
  26590. serializeAnimationRanges(): any;
  26591. /**
  26592. * Computes the world matrix of the node
  26593. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26594. * @returns the world matrix
  26595. */
  26596. computeWorldMatrix(force?: boolean): Matrix;
  26597. /**
  26598. * Releases resources associated with this node.
  26599. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26600. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26601. */
  26602. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26603. /**
  26604. * Parse animation range data from a serialization object and store them into a given node
  26605. * @param node defines where to store the animation ranges
  26606. * @param parsedNode defines the serialization object to read data from
  26607. * @param scene defines the hosting scene
  26608. */
  26609. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26610. /**
  26611. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26612. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26613. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  26614. * @returns the new bounding vectors
  26615. */
  26616. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26617. min: Vector3;
  26618. max: Vector3;
  26619. };
  26620. }
  26621. }
  26622. declare module BABYLON {
  26623. /**
  26624. * @hidden
  26625. */
  26626. export class _IAnimationState {
  26627. key: number;
  26628. repeatCount: number;
  26629. workValue?: any;
  26630. loopMode?: number;
  26631. offsetValue?: any;
  26632. highLimitValue?: any;
  26633. }
  26634. /**
  26635. * Class used to store any kind of animation
  26636. */
  26637. export class Animation {
  26638. /**Name of the animation */
  26639. name: string;
  26640. /**Property to animate */
  26641. targetProperty: string;
  26642. /**The frames per second of the animation */
  26643. framePerSecond: number;
  26644. /**The data type of the animation */
  26645. dataType: number;
  26646. /**The loop mode of the animation */
  26647. loopMode?: number | undefined;
  26648. /**Specifies if blending should be enabled */
  26649. enableBlending?: boolean | undefined;
  26650. /**
  26651. * Use matrix interpolation instead of using direct key value when animating matrices
  26652. */
  26653. static AllowMatricesInterpolation: boolean;
  26654. /**
  26655. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26656. */
  26657. static AllowMatrixDecomposeForInterpolation: boolean;
  26658. /**
  26659. * Stores the key frames of the animation
  26660. */
  26661. private _keys;
  26662. /**
  26663. * Stores the easing function of the animation
  26664. */
  26665. private _easingFunction;
  26666. /**
  26667. * @hidden Internal use only
  26668. */ private _runtimeAnimations: RuntimeAnimation[];
  26669. /**
  26670. * The set of event that will be linked to this animation
  26671. */
  26672. private _events;
  26673. /**
  26674. * Stores an array of target property paths
  26675. */
  26676. targetPropertyPath: string[];
  26677. /**
  26678. * Stores the blending speed of the animation
  26679. */
  26680. blendingSpeed: number;
  26681. /**
  26682. * Stores the animation ranges for the animation
  26683. */
  26684. private _ranges;
  26685. /**
  26686. * @hidden Internal use
  26687. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26688. /**
  26689. * Sets up an animation
  26690. * @param property The property to animate
  26691. * @param animationType The animation type to apply
  26692. * @param framePerSecond The frames per second of the animation
  26693. * @param easingFunction The easing function used in the animation
  26694. * @returns The created animation
  26695. */
  26696. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26697. /**
  26698. * Create and start an animation on a node
  26699. * @param name defines the name of the global animation that will be run on all nodes
  26700. * @param node defines the root node where the animation will take place
  26701. * @param targetProperty defines property to animate
  26702. * @param framePerSecond defines the number of frame per second yo use
  26703. * @param totalFrame defines the number of frames in total
  26704. * @param from defines the initial value
  26705. * @param to defines the final value
  26706. * @param loopMode defines which loop mode you want to use (off by default)
  26707. * @param easingFunction defines the easing function to use (linear by default)
  26708. * @param onAnimationEnd defines the callback to call when animation end
  26709. * @returns the animatable created for this animation
  26710. */
  26711. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26712. /**
  26713. * Create and start an animation on a node and its descendants
  26714. * @param name defines the name of the global animation that will be run on all nodes
  26715. * @param node defines the root node where the animation will take place
  26716. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  26717. * @param targetProperty defines property to animate
  26718. * @param framePerSecond defines the number of frame per second to use
  26719. * @param totalFrame defines the number of frames in total
  26720. * @param from defines the initial value
  26721. * @param to defines the final value
  26722. * @param loopMode defines which loop mode you want to use (off by default)
  26723. * @param easingFunction defines the easing function to use (linear by default)
  26724. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26725. * @returns the list of animatables created for all nodes
  26726. * @example https://www.babylonjs-playground.com/#MH0VLI
  26727. */
  26728. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  26729. /**
  26730. * Creates a new animation, merges it with the existing animations and starts it
  26731. * @param name Name of the animation
  26732. * @param node Node which contains the scene that begins the animations
  26733. * @param targetProperty Specifies which property to animate
  26734. * @param framePerSecond The frames per second of the animation
  26735. * @param totalFrame The total number of frames
  26736. * @param from The frame at the beginning of the animation
  26737. * @param to The frame at the end of the animation
  26738. * @param loopMode Specifies the loop mode of the animation
  26739. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26740. * @param onAnimationEnd Callback to run once the animation is complete
  26741. * @returns Nullable animation
  26742. */
  26743. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26744. /**
  26745. * Transition property of an host to the target Value
  26746. * @param property The property to transition
  26747. * @param targetValue The target Value of the property
  26748. * @param host The object where the property to animate belongs
  26749. * @param scene Scene used to run the animation
  26750. * @param frameRate Framerate (in frame/s) to use
  26751. * @param transition The transition type we want to use
  26752. * @param duration The duration of the animation, in milliseconds
  26753. * @param onAnimationEnd Callback trigger at the end of the animation
  26754. * @returns Nullable animation
  26755. */
  26756. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26757. /**
  26758. * Return the array of runtime animations currently using this animation
  26759. */
  26760. readonly runtimeAnimations: RuntimeAnimation[];
  26761. /**
  26762. * Specifies if any of the runtime animations are currently running
  26763. */
  26764. readonly hasRunningRuntimeAnimations: boolean;
  26765. /**
  26766. * Initializes the animation
  26767. * @param name Name of the animation
  26768. * @param targetProperty Property to animate
  26769. * @param framePerSecond The frames per second of the animation
  26770. * @param dataType The data type of the animation
  26771. * @param loopMode The loop mode of the animation
  26772. * @param enableBlending Specifies if blending should be enabled
  26773. */
  26774. constructor(
  26775. /**Name of the animation */
  26776. name: string,
  26777. /**Property to animate */
  26778. targetProperty: string,
  26779. /**The frames per second of the animation */
  26780. framePerSecond: number,
  26781. /**The data type of the animation */
  26782. dataType: number,
  26783. /**The loop mode of the animation */
  26784. loopMode?: number | undefined,
  26785. /**Specifies if blending should be enabled */
  26786. enableBlending?: boolean | undefined);
  26787. /**
  26788. * Converts the animation to a string
  26789. * @param fullDetails support for multiple levels of logging within scene loading
  26790. * @returns String form of the animation
  26791. */
  26792. toString(fullDetails?: boolean): string;
  26793. /**
  26794. * Add an event to this animation
  26795. * @param event Event to add
  26796. */
  26797. addEvent(event: AnimationEvent): void;
  26798. /**
  26799. * Remove all events found at the given frame
  26800. * @param frame The frame to remove events from
  26801. */
  26802. removeEvents(frame: number): void;
  26803. /**
  26804. * Retrieves all the events from the animation
  26805. * @returns Events from the animation
  26806. */
  26807. getEvents(): AnimationEvent[];
  26808. /**
  26809. * Creates an animation range
  26810. * @param name Name of the animation range
  26811. * @param from Starting frame of the animation range
  26812. * @param to Ending frame of the animation
  26813. */
  26814. createRange(name: string, from: number, to: number): void;
  26815. /**
  26816. * Deletes an animation range by name
  26817. * @param name Name of the animation range to delete
  26818. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26819. */
  26820. deleteRange(name: string, deleteFrames?: boolean): void;
  26821. /**
  26822. * Gets the animation range by name, or null if not defined
  26823. * @param name Name of the animation range
  26824. * @returns Nullable animation range
  26825. */
  26826. getRange(name: string): Nullable<AnimationRange>;
  26827. /**
  26828. * Gets the key frames from the animation
  26829. * @returns The key frames of the animation
  26830. */
  26831. getKeys(): Array<IAnimationKey>;
  26832. /**
  26833. * Gets the highest frame rate of the animation
  26834. * @returns Highest frame rate of the animation
  26835. */
  26836. getHighestFrame(): number;
  26837. /**
  26838. * Gets the easing function of the animation
  26839. * @returns Easing function of the animation
  26840. */
  26841. getEasingFunction(): IEasingFunction;
  26842. /**
  26843. * Sets the easing function of the animation
  26844. * @param easingFunction A custom mathematical formula for animation
  26845. */
  26846. setEasingFunction(easingFunction: EasingFunction): void;
  26847. /**
  26848. * Interpolates a scalar linearly
  26849. * @param startValue Start value of the animation curve
  26850. * @param endValue End value of the animation curve
  26851. * @param gradient Scalar amount to interpolate
  26852. * @returns Interpolated scalar value
  26853. */
  26854. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26855. /**
  26856. * Interpolates a scalar cubically
  26857. * @param startValue Start value of the animation curve
  26858. * @param outTangent End tangent of the animation
  26859. * @param endValue End value of the animation curve
  26860. * @param inTangent Start tangent of the animation curve
  26861. * @param gradient Scalar amount to interpolate
  26862. * @returns Interpolated scalar value
  26863. */
  26864. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26865. /**
  26866. * Interpolates a quaternion using a spherical linear interpolation
  26867. * @param startValue Start value of the animation curve
  26868. * @param endValue End value of the animation curve
  26869. * @param gradient Scalar amount to interpolate
  26870. * @returns Interpolated quaternion value
  26871. */
  26872. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26873. /**
  26874. * Interpolates a quaternion cubically
  26875. * @param startValue Start value of the animation curve
  26876. * @param outTangent End tangent of the animation curve
  26877. * @param endValue End value of the animation curve
  26878. * @param inTangent Start tangent of the animation curve
  26879. * @param gradient Scalar amount to interpolate
  26880. * @returns Interpolated quaternion value
  26881. */
  26882. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26883. /**
  26884. * Interpolates a Vector3 linearl
  26885. * @param startValue Start value of the animation curve
  26886. * @param endValue End value of the animation curve
  26887. * @param gradient Scalar amount to interpolate
  26888. * @returns Interpolated scalar value
  26889. */
  26890. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26891. /**
  26892. * Interpolates a Vector3 cubically
  26893. * @param startValue Start value of the animation curve
  26894. * @param outTangent End tangent of the animation
  26895. * @param endValue End value of the animation curve
  26896. * @param inTangent Start tangent of the animation curve
  26897. * @param gradient Scalar amount to interpolate
  26898. * @returns InterpolatedVector3 value
  26899. */
  26900. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26901. /**
  26902. * Interpolates a Vector2 linearly
  26903. * @param startValue Start value of the animation curve
  26904. * @param endValue End value of the animation curve
  26905. * @param gradient Scalar amount to interpolate
  26906. * @returns Interpolated Vector2 value
  26907. */
  26908. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26909. /**
  26910. * Interpolates a Vector2 cubically
  26911. * @param startValue Start value of the animation curve
  26912. * @param outTangent End tangent of the animation
  26913. * @param endValue End value of the animation curve
  26914. * @param inTangent Start tangent of the animation curve
  26915. * @param gradient Scalar amount to interpolate
  26916. * @returns Interpolated Vector2 value
  26917. */
  26918. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26919. /**
  26920. * Interpolates a size linearly
  26921. * @param startValue Start value of the animation curve
  26922. * @param endValue End value of the animation curve
  26923. * @param gradient Scalar amount to interpolate
  26924. * @returns Interpolated Size value
  26925. */
  26926. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26927. /**
  26928. * Interpolates a Color3 linearly
  26929. * @param startValue Start value of the animation curve
  26930. * @param endValue End value of the animation curve
  26931. * @param gradient Scalar amount to interpolate
  26932. * @returns Interpolated Color3 value
  26933. */
  26934. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26935. /**
  26936. * @hidden Internal use only
  26937. */ private _getKeyValue(value: any): any;
  26938. /**
  26939. * @hidden Internal use only
  26940. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26941. /**
  26942. * Defines the function to use to interpolate matrices
  26943. * @param startValue defines the start matrix
  26944. * @param endValue defines the end matrix
  26945. * @param gradient defines the gradient between both matrices
  26946. * @param result defines an optional target matrix where to store the interpolation
  26947. * @returns the interpolated matrix
  26948. */
  26949. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26950. /**
  26951. * Makes a copy of the animation
  26952. * @returns Cloned animation
  26953. */
  26954. clone(): Animation;
  26955. /**
  26956. * Sets the key frames of the animation
  26957. * @param values The animation key frames to set
  26958. */
  26959. setKeys(values: Array<IAnimationKey>): void;
  26960. /**
  26961. * Serializes the animation to an object
  26962. * @returns Serialized object
  26963. */
  26964. serialize(): any;
  26965. /**
  26966. * Float animation type
  26967. */
  26968. private static _ANIMATIONTYPE_FLOAT;
  26969. /**
  26970. * Vector3 animation type
  26971. */
  26972. private static _ANIMATIONTYPE_VECTOR3;
  26973. /**
  26974. * Quaternion animation type
  26975. */
  26976. private static _ANIMATIONTYPE_QUATERNION;
  26977. /**
  26978. * Matrix animation type
  26979. */
  26980. private static _ANIMATIONTYPE_MATRIX;
  26981. /**
  26982. * Color3 animation type
  26983. */
  26984. private static _ANIMATIONTYPE_COLOR3;
  26985. /**
  26986. * Vector2 animation type
  26987. */
  26988. private static _ANIMATIONTYPE_VECTOR2;
  26989. /**
  26990. * Size animation type
  26991. */
  26992. private static _ANIMATIONTYPE_SIZE;
  26993. /**
  26994. * Relative Loop Mode
  26995. */
  26996. private static _ANIMATIONLOOPMODE_RELATIVE;
  26997. /**
  26998. * Cycle Loop Mode
  26999. */
  27000. private static _ANIMATIONLOOPMODE_CYCLE;
  27001. /**
  27002. * Constant Loop Mode
  27003. */
  27004. private static _ANIMATIONLOOPMODE_CONSTANT;
  27005. /**
  27006. * Get the float animation type
  27007. */
  27008. static readonly ANIMATIONTYPE_FLOAT: number;
  27009. /**
  27010. * Get the Vector3 animation type
  27011. */
  27012. static readonly ANIMATIONTYPE_VECTOR3: number;
  27013. /**
  27014. * Get the Vector2 animation type
  27015. */
  27016. static readonly ANIMATIONTYPE_VECTOR2: number;
  27017. /**
  27018. * Get the Size animation type
  27019. */
  27020. static readonly ANIMATIONTYPE_SIZE: number;
  27021. /**
  27022. * Get the Quaternion animation type
  27023. */
  27024. static readonly ANIMATIONTYPE_QUATERNION: number;
  27025. /**
  27026. * Get the Matrix animation type
  27027. */
  27028. static readonly ANIMATIONTYPE_MATRIX: number;
  27029. /**
  27030. * Get the Color3 animation type
  27031. */
  27032. static readonly ANIMATIONTYPE_COLOR3: number;
  27033. /**
  27034. * Get the Relative Loop Mode
  27035. */
  27036. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27037. /**
  27038. * Get the Cycle Loop Mode
  27039. */
  27040. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27041. /**
  27042. * Get the Constant Loop Mode
  27043. */
  27044. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27045. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  27046. /**
  27047. * Parses an animation object and creates an animation
  27048. * @param parsedAnimation Parsed animation object
  27049. * @returns Animation object
  27050. */
  27051. static Parse(parsedAnimation: any): Animation;
  27052. /**
  27053. * Appends the serialized animations from the source animations
  27054. * @param source Source containing the animations
  27055. * @param destination Target to store the animations
  27056. */
  27057. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27058. }
  27059. }
  27060. declare module BABYLON {
  27061. /**
  27062. * Interface containing an array of animations
  27063. */
  27064. export interface IAnimatable {
  27065. /**
  27066. * Array of animations
  27067. */
  27068. animations: Nullable<Array<Animation>>;
  27069. }
  27070. }
  27071. declare module BABYLON {
  27072. /**
  27073. * This represents all the required information to add a fresnel effect on a material:
  27074. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27075. */
  27076. export class FresnelParameters {
  27077. private _isEnabled;
  27078. /**
  27079. * Define if the fresnel effect is enable or not.
  27080. */
  27081. isEnabled: boolean;
  27082. /**
  27083. * Define the color used on edges (grazing angle)
  27084. */
  27085. leftColor: Color3;
  27086. /**
  27087. * Define the color used on center
  27088. */
  27089. rightColor: Color3;
  27090. /**
  27091. * Define bias applied to computed fresnel term
  27092. */
  27093. bias: number;
  27094. /**
  27095. * Defined the power exponent applied to fresnel term
  27096. */
  27097. power: number;
  27098. /**
  27099. * Clones the current fresnel and its valuues
  27100. * @returns a clone fresnel configuration
  27101. */
  27102. clone(): FresnelParameters;
  27103. /**
  27104. * Serializes the current fresnel parameters to a JSON representation.
  27105. * @return the JSON serialization
  27106. */
  27107. serialize(): any;
  27108. /**
  27109. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27110. * @param parsedFresnelParameters Define the JSON representation
  27111. * @returns the parsed parameters
  27112. */
  27113. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27114. }
  27115. }
  27116. declare module BABYLON {
  27117. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27118. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27119. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27120. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27121. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27122. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27123. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27124. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27125. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27126. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27127. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27128. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27129. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27130. /**
  27131. * Decorator used to define property that can be serialized as reference to a camera
  27132. * @param sourceName defines the name of the property to decorate
  27133. */
  27134. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27135. /**
  27136. * Class used to help serialization objects
  27137. */
  27138. export class SerializationHelper {
  27139. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27140. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27141. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27142. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27143. /**
  27144. * Appends the serialized animations from the source animations
  27145. * @param source Source containing the animations
  27146. * @param destination Target to store the animations
  27147. */
  27148. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27149. /**
  27150. * Static function used to serialized a specific entity
  27151. * @param entity defines the entity to serialize
  27152. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27153. * @returns a JSON compatible object representing the serialization of the entity
  27154. */
  27155. static Serialize<T>(entity: T, serializationObject?: any): any;
  27156. /**
  27157. * Creates a new entity from a serialization data object
  27158. * @param creationFunction defines a function used to instanciated the new entity
  27159. * @param source defines the source serialization data
  27160. * @param scene defines the hosting scene
  27161. * @param rootUrl defines the root url for resources
  27162. * @returns a new entity
  27163. */
  27164. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27165. /**
  27166. * Clones an object
  27167. * @param creationFunction defines the function used to instanciate the new object
  27168. * @param source defines the source object
  27169. * @returns the cloned object
  27170. */
  27171. static Clone<T>(creationFunction: () => T, source: T): T;
  27172. /**
  27173. * Instanciates a new object based on a source one (some data will be shared between both object)
  27174. * @param creationFunction defines the function used to instanciate the new object
  27175. * @param source defines the source object
  27176. * @returns the new object
  27177. */
  27178. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27179. }
  27180. }
  27181. declare module BABYLON {
  27182. /**
  27183. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27184. */
  27185. export interface CubeMapInfo {
  27186. /**
  27187. * The pixel array for the front face.
  27188. * This is stored in format, left to right, up to down format.
  27189. */
  27190. front: Nullable<ArrayBufferView>;
  27191. /**
  27192. * The pixel array for the back face.
  27193. * This is stored in format, left to right, up to down format.
  27194. */
  27195. back: Nullable<ArrayBufferView>;
  27196. /**
  27197. * The pixel array for the left face.
  27198. * This is stored in format, left to right, up to down format.
  27199. */
  27200. left: Nullable<ArrayBufferView>;
  27201. /**
  27202. * The pixel array for the right face.
  27203. * This is stored in format, left to right, up to down format.
  27204. */
  27205. right: Nullable<ArrayBufferView>;
  27206. /**
  27207. * The pixel array for the up face.
  27208. * This is stored in format, left to right, up to down format.
  27209. */
  27210. up: Nullable<ArrayBufferView>;
  27211. /**
  27212. * The pixel array for the down face.
  27213. * This is stored in format, left to right, up to down format.
  27214. */
  27215. down: Nullable<ArrayBufferView>;
  27216. /**
  27217. * The size of the cubemap stored.
  27218. *
  27219. * Each faces will be size * size pixels.
  27220. */
  27221. size: number;
  27222. /**
  27223. * The format of the texture.
  27224. *
  27225. * RGBA, RGB.
  27226. */
  27227. format: number;
  27228. /**
  27229. * The type of the texture data.
  27230. *
  27231. * UNSIGNED_INT, FLOAT.
  27232. */
  27233. type: number;
  27234. /**
  27235. * Specifies whether the texture is in gamma space.
  27236. */
  27237. gammaSpace: boolean;
  27238. }
  27239. /**
  27240. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27241. */
  27242. export class PanoramaToCubeMapTools {
  27243. private static FACE_FRONT;
  27244. private static FACE_BACK;
  27245. private static FACE_RIGHT;
  27246. private static FACE_LEFT;
  27247. private static FACE_DOWN;
  27248. private static FACE_UP;
  27249. /**
  27250. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27251. *
  27252. * @param float32Array The source data.
  27253. * @param inputWidth The width of the input panorama.
  27254. * @param inputHeight The height of the input panorama.
  27255. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27256. * @return The cubemap data
  27257. */
  27258. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27259. private static CreateCubemapTexture;
  27260. private static CalcProjectionSpherical;
  27261. }
  27262. }
  27263. declare module BABYLON {
  27264. /**
  27265. * Helper class dealing with the extraction of spherical polynomial dataArray
  27266. * from a cube map.
  27267. */
  27268. export class CubeMapToSphericalPolynomialTools {
  27269. private static FileFaces;
  27270. /**
  27271. * Converts a texture to the according Spherical Polynomial data.
  27272. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27273. *
  27274. * @param texture The texture to extract the information from.
  27275. * @return The Spherical Polynomial data.
  27276. */
  27277. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27278. /**
  27279. * Converts a cubemap to the according Spherical Polynomial data.
  27280. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27281. *
  27282. * @param cubeInfo The Cube map to extract the information from.
  27283. * @return The Spherical Polynomial data.
  27284. */
  27285. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27286. }
  27287. }
  27288. declare module BABYLON {
  27289. /**
  27290. * Class used to manipulate GUIDs
  27291. */
  27292. export class GUID {
  27293. /**
  27294. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27295. * Be aware Math.random() could cause collisions, but:
  27296. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  27297. * @returns a pseudo random id
  27298. */
  27299. static RandomId(): string;
  27300. }
  27301. }
  27302. declare module BABYLON {
  27303. /**
  27304. * Base class of all the textures in babylon.
  27305. * It groups all the common properties the materials, post process, lights... might need
  27306. * in order to make a correct use of the texture.
  27307. */
  27308. export class BaseTexture implements IAnimatable {
  27309. /**
  27310. * Default anisotropic filtering level for the application.
  27311. * It is set to 4 as a good tradeoff between perf and quality.
  27312. */
  27313. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27314. /**
  27315. * Gets or sets the unique id of the texture
  27316. */
  27317. uniqueId: number;
  27318. /**
  27319. * Define the name of the texture.
  27320. */
  27321. name: string;
  27322. /**
  27323. * Gets or sets an object used to store user defined information.
  27324. */
  27325. metadata: any;
  27326. /**
  27327. * For internal use only. Please do not use.
  27328. */
  27329. reservedDataStore: any;
  27330. private _hasAlpha;
  27331. /**
  27332. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27333. */
  27334. hasAlpha: boolean;
  27335. /**
  27336. * Defines if the alpha value should be determined via the rgb values.
  27337. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27338. */
  27339. getAlphaFromRGB: boolean;
  27340. /**
  27341. * Intensity or strength of the texture.
  27342. * It is commonly used by materials to fine tune the intensity of the texture
  27343. */
  27344. level: number;
  27345. /**
  27346. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27347. * This is part of the texture as textures usually maps to one uv set.
  27348. */
  27349. coordinatesIndex: number;
  27350. private _coordinatesMode;
  27351. /**
  27352. * How a texture is mapped.
  27353. *
  27354. * | Value | Type | Description |
  27355. * | ----- | ----------------------------------- | ----------- |
  27356. * | 0 | EXPLICIT_MODE | |
  27357. * | 1 | SPHERICAL_MODE | |
  27358. * | 2 | PLANAR_MODE | |
  27359. * | 3 | CUBIC_MODE | |
  27360. * | 4 | PROJECTION_MODE | |
  27361. * | 5 | SKYBOX_MODE | |
  27362. * | 6 | INVCUBIC_MODE | |
  27363. * | 7 | EQUIRECTANGULAR_MODE | |
  27364. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27365. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27366. */
  27367. coordinatesMode: number;
  27368. /**
  27369. * | Value | Type | Description |
  27370. * | ----- | ------------------ | ----------- |
  27371. * | 0 | CLAMP_ADDRESSMODE | |
  27372. * | 1 | WRAP_ADDRESSMODE | |
  27373. * | 2 | MIRROR_ADDRESSMODE | |
  27374. */
  27375. wrapU: number;
  27376. /**
  27377. * | Value | Type | Description |
  27378. * | ----- | ------------------ | ----------- |
  27379. * | 0 | CLAMP_ADDRESSMODE | |
  27380. * | 1 | WRAP_ADDRESSMODE | |
  27381. * | 2 | MIRROR_ADDRESSMODE | |
  27382. */
  27383. wrapV: number;
  27384. /**
  27385. * | Value | Type | Description |
  27386. * | ----- | ------------------ | ----------- |
  27387. * | 0 | CLAMP_ADDRESSMODE | |
  27388. * | 1 | WRAP_ADDRESSMODE | |
  27389. * | 2 | MIRROR_ADDRESSMODE | |
  27390. */
  27391. wrapR: number;
  27392. /**
  27393. * With compliant hardware and browser (supporting anisotropic filtering)
  27394. * this defines the level of anisotropic filtering in the texture.
  27395. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27396. */
  27397. anisotropicFilteringLevel: number;
  27398. /**
  27399. * Define if the texture is a cube texture or if false a 2d texture.
  27400. */
  27401. isCube: boolean;
  27402. /**
  27403. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27404. */
  27405. is3D: boolean;
  27406. /**
  27407. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27408. * HDR texture are usually stored in linear space.
  27409. * This only impacts the PBR and Background materials
  27410. */
  27411. gammaSpace: boolean;
  27412. /**
  27413. * Gets or sets whether or not the texture contains RGBD data.
  27414. */
  27415. isRGBD: boolean;
  27416. /**
  27417. * Is Z inverted in the texture (useful in a cube texture).
  27418. */
  27419. invertZ: boolean;
  27420. /**
  27421. * Are mip maps generated for this texture or not.
  27422. */
  27423. readonly noMipmap: boolean;
  27424. /**
  27425. * @hidden
  27426. */
  27427. lodLevelInAlpha: boolean;
  27428. /**
  27429. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27430. */
  27431. lodGenerationOffset: number;
  27432. /**
  27433. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27434. */
  27435. lodGenerationScale: number;
  27436. /**
  27437. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27438. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27439. * average roughness values.
  27440. */
  27441. linearSpecularLOD: boolean;
  27442. /**
  27443. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27444. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27445. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27446. */
  27447. irradianceTexture: Nullable<BaseTexture>;
  27448. /**
  27449. * Define if the texture is a render target.
  27450. */
  27451. isRenderTarget: boolean;
  27452. /**
  27453. * Define the unique id of the texture in the scene.
  27454. */
  27455. readonly uid: string;
  27456. /**
  27457. * Return a string representation of the texture.
  27458. * @returns the texture as a string
  27459. */
  27460. toString(): string;
  27461. /**
  27462. * Get the class name of the texture.
  27463. * @returns "BaseTexture"
  27464. */
  27465. getClassName(): string;
  27466. /**
  27467. * Define the list of animation attached to the texture.
  27468. */
  27469. animations: Animation[];
  27470. /**
  27471. * An event triggered when the texture is disposed.
  27472. */
  27473. onDisposeObservable: Observable<BaseTexture>;
  27474. private _onDisposeObserver;
  27475. /**
  27476. * Callback triggered when the texture has been disposed.
  27477. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27478. */
  27479. onDispose: () => void;
  27480. /**
  27481. * Define the current state of the loading sequence when in delayed load mode.
  27482. */
  27483. delayLoadState: number;
  27484. private _scene;
  27485. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27486. private _uid;
  27487. /**
  27488. * Define if the texture is preventinga material to render or not.
  27489. * If not and the texture is not ready, the engine will use a default black texture instead.
  27490. */
  27491. readonly isBlocking: boolean;
  27492. /**
  27493. * Instantiates a new BaseTexture.
  27494. * Base class of all the textures in babylon.
  27495. * It groups all the common properties the materials, post process, lights... might need
  27496. * in order to make a correct use of the texture.
  27497. * @param scene Define the scene the texture blongs to
  27498. */
  27499. constructor(scene: Nullable<Scene>);
  27500. /**
  27501. * Get the scene the texture belongs to.
  27502. * @returns the scene or null if undefined
  27503. */
  27504. getScene(): Nullable<Scene>;
  27505. /**
  27506. * Get the texture transform matrix used to offset tile the texture for istance.
  27507. * @returns the transformation matrix
  27508. */
  27509. getTextureMatrix(): Matrix;
  27510. /**
  27511. * Get the texture reflection matrix used to rotate/transform the reflection.
  27512. * @returns the reflection matrix
  27513. */
  27514. getReflectionTextureMatrix(): Matrix;
  27515. /**
  27516. * Get the underlying lower level texture from Babylon.
  27517. * @returns the insternal texture
  27518. */
  27519. getInternalTexture(): Nullable<InternalTexture>;
  27520. /**
  27521. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27522. * @returns true if ready or not blocking
  27523. */
  27524. isReadyOrNotBlocking(): boolean;
  27525. /**
  27526. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27527. * @returns true if fully ready
  27528. */
  27529. isReady(): boolean;
  27530. private _cachedSize;
  27531. /**
  27532. * Get the size of the texture.
  27533. * @returns the texture size.
  27534. */
  27535. getSize(): ISize;
  27536. /**
  27537. * Get the base size of the texture.
  27538. * It can be different from the size if the texture has been resized for POT for instance
  27539. * @returns the base size
  27540. */
  27541. getBaseSize(): ISize;
  27542. /**
  27543. * Update the sampling mode of the texture.
  27544. * Default is Trilinear mode.
  27545. *
  27546. * | Value | Type | Description |
  27547. * | ----- | ------------------ | ----------- |
  27548. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27549. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27550. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27551. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27552. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27553. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27554. * | 7 | NEAREST_LINEAR | |
  27555. * | 8 | NEAREST_NEAREST | |
  27556. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27557. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27558. * | 11 | LINEAR_LINEAR | |
  27559. * | 12 | LINEAR_NEAREST | |
  27560. *
  27561. * > _mag_: magnification filter (close to the viewer)
  27562. * > _min_: minification filter (far from the viewer)
  27563. * > _mip_: filter used between mip map levels
  27564. *@param samplingMode Define the new sampling mode of the texture
  27565. */
  27566. updateSamplingMode(samplingMode: number): void;
  27567. /**
  27568. * Scales the texture if is `canRescale()`
  27569. * @param ratio the resize factor we want to use to rescale
  27570. */
  27571. scale(ratio: number): void;
  27572. /**
  27573. * Get if the texture can rescale.
  27574. */
  27575. readonly canRescale: boolean;
  27576. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27577. /** @hidden */ private _rebuild(): void;
  27578. /**
  27579. * Triggers the load sequence in delayed load mode.
  27580. */
  27581. delayLoad(): void;
  27582. /**
  27583. * Clones the texture.
  27584. * @returns the cloned texture
  27585. */
  27586. clone(): Nullable<BaseTexture>;
  27587. /**
  27588. * Get the texture underlying type (INT, FLOAT...)
  27589. */
  27590. readonly textureType: number;
  27591. /**
  27592. * Get the texture underlying format (RGB, RGBA...)
  27593. */
  27594. readonly textureFormat: number;
  27595. /**
  27596. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27597. * This will returns an RGBA array buffer containing either in values (0-255) or
  27598. * float values (0-1) depending of the underlying buffer type.
  27599. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27600. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27601. * @param buffer defines a user defined buffer to fill with data (can be null)
  27602. * @returns The Array buffer containing the pixels data.
  27603. */
  27604. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27605. /**
  27606. * Release and destroy the underlying lower level texture aka internalTexture.
  27607. */
  27608. releaseInternalTexture(): void;
  27609. /**
  27610. * Get the polynomial representation of the texture data.
  27611. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27612. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27613. */
  27614. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27615. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27616. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27617. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27618. /**
  27619. * Dispose the texture and release its associated resources.
  27620. */
  27621. dispose(): void;
  27622. /**
  27623. * Serialize the texture into a JSON representation that can be parsed later on.
  27624. * @returns the JSON representation of the texture
  27625. */
  27626. serialize(): any;
  27627. /**
  27628. * Helper function to be called back once a list of texture contains only ready textures.
  27629. * @param textures Define the list of textures to wait for
  27630. * @param callback Define the callback triggered once the entire list will be ready
  27631. */
  27632. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27633. }
  27634. }
  27635. declare module BABYLON {
  27636. /**
  27637. * Class used to store data associated with WebGL texture data for the engine
  27638. * This class should not be used directly
  27639. */
  27640. export class InternalTexture {
  27641. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27642. /**
  27643. * The source of the texture data is unknown
  27644. */
  27645. static DATASOURCE_UNKNOWN: number;
  27646. /**
  27647. * Texture data comes from an URL
  27648. */
  27649. static DATASOURCE_URL: number;
  27650. /**
  27651. * Texture data is only used for temporary storage
  27652. */
  27653. static DATASOURCE_TEMP: number;
  27654. /**
  27655. * Texture data comes from raw data (ArrayBuffer)
  27656. */
  27657. static DATASOURCE_RAW: number;
  27658. /**
  27659. * Texture content is dynamic (video or dynamic texture)
  27660. */
  27661. static DATASOURCE_DYNAMIC: number;
  27662. /**
  27663. * Texture content is generated by rendering to it
  27664. */
  27665. static DATASOURCE_RENDERTARGET: number;
  27666. /**
  27667. * Texture content is part of a multi render target process
  27668. */
  27669. static DATASOURCE_MULTIRENDERTARGET: number;
  27670. /**
  27671. * Texture data comes from a cube data file
  27672. */
  27673. static DATASOURCE_CUBE: number;
  27674. /**
  27675. * Texture data comes from a raw cube data
  27676. */
  27677. static DATASOURCE_CUBERAW: number;
  27678. /**
  27679. * Texture data come from a prefiltered cube data file
  27680. */
  27681. static DATASOURCE_CUBEPREFILTERED: number;
  27682. /**
  27683. * Texture content is raw 3D data
  27684. */
  27685. static DATASOURCE_RAW3D: number;
  27686. /**
  27687. * Texture content is a depth texture
  27688. */
  27689. static DATASOURCE_DEPTHTEXTURE: number;
  27690. /**
  27691. * Texture data comes from a raw cube data encoded with RGBD
  27692. */
  27693. static DATASOURCE_CUBERAW_RGBD: number;
  27694. /**
  27695. * Defines if the texture is ready
  27696. */
  27697. isReady: boolean;
  27698. /**
  27699. * Defines if the texture is a cube texture
  27700. */
  27701. isCube: boolean;
  27702. /**
  27703. * Defines if the texture contains 3D data
  27704. */
  27705. is3D: boolean;
  27706. /**
  27707. * Defines if the texture contains multiview data
  27708. */
  27709. isMultiview: boolean;
  27710. /**
  27711. * Gets the URL used to load this texture
  27712. */
  27713. url: string;
  27714. /**
  27715. * Gets the sampling mode of the texture
  27716. */
  27717. samplingMode: number;
  27718. /**
  27719. * Gets a boolean indicating if the texture needs mipmaps generation
  27720. */
  27721. generateMipMaps: boolean;
  27722. /**
  27723. * Gets the number of samples used by the texture (WebGL2+ only)
  27724. */
  27725. samples: number;
  27726. /**
  27727. * Gets the type of the texture (int, float...)
  27728. */
  27729. type: number;
  27730. /**
  27731. * Gets the format of the texture (RGB, RGBA...)
  27732. */
  27733. format: number;
  27734. /**
  27735. * Observable called when the texture is loaded
  27736. */
  27737. onLoadedObservable: Observable<InternalTexture>;
  27738. /**
  27739. * Gets the width of the texture
  27740. */
  27741. width: number;
  27742. /**
  27743. * Gets the height of the texture
  27744. */
  27745. height: number;
  27746. /**
  27747. * Gets the depth of the texture
  27748. */
  27749. depth: number;
  27750. /**
  27751. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27752. */
  27753. baseWidth: number;
  27754. /**
  27755. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27756. */
  27757. baseHeight: number;
  27758. /**
  27759. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27760. */
  27761. baseDepth: number;
  27762. /**
  27763. * Gets a boolean indicating if the texture is inverted on Y axis
  27764. */
  27765. invertY: boolean;
  27766. /** @hidden */ private _invertVScale: boolean;
  27767. /** @hidden */ private _associatedChannel: number;
  27768. /** @hidden */ private _dataSource: number;
  27769. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  27770. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  27771. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  27772. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27773. /** @hidden */ private _size: number;
  27774. /** @hidden */ private _extension: string;
  27775. /** @hidden */ private _files: Nullable<string[]>;
  27776. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27777. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27778. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  27779. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27780. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27781. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27782. /** @hidden */ private _attachments: Nullable<number[]>;
  27783. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  27784. /** @hidden */ private _cachedWrapU: Nullable<number>;
  27785. /** @hidden */ private _cachedWrapV: Nullable<number>;
  27786. /** @hidden */ private _cachedWrapR: Nullable<number>;
  27787. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  27788. /** @hidden */ private _isDisabled: boolean;
  27789. /** @hidden */ private _compression: Nullable<string>;
  27790. /** @hidden */ private _generateStencilBuffer: boolean;
  27791. /** @hidden */ private _generateDepthBuffer: boolean;
  27792. /** @hidden */ private _comparisonFunction: number;
  27793. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27794. /** @hidden */ private _lodGenerationScale: number;
  27795. /** @hidden */ private _lodGenerationOffset: number;
  27796. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  27797. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  27798. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  27799. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  27800. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  27801. /** @hidden */ private _isRGBD: boolean;
  27802. /** @hidden */ private _linearSpecularLOD: boolean;
  27803. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  27804. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  27805. /** @hidden */ private _webGPUTexture: Nullable<GPUTexture>;
  27806. /** @hidden */ private _webGPUSampler: Nullable<GPUSampler>;
  27807. /** @hidden */ private _webGPUTextureView: Nullable<GPUTextureView>;
  27808. /** @hidden */ private _references: number;
  27809. private _engine;
  27810. /**
  27811. * Gets the Engine the texture belongs to.
  27812. * @returns The babylon engine
  27813. */
  27814. getEngine(): Engine;
  27815. /**
  27816. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  27817. */
  27818. readonly dataSource: number;
  27819. /**
  27820. * Creates a new InternalTexture
  27821. * @param engine defines the engine to use
  27822. * @param dataSource defines the type of data that will be used
  27823. * @param delayAllocation if the texture allocation should be delayed (default: false)
  27824. */
  27825. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  27826. /**
  27827. * Increments the number of references (ie. the number of Texture that point to it)
  27828. */
  27829. incrementReferences(): void;
  27830. /**
  27831. * Change the size of the texture (not the size of the content)
  27832. * @param width defines the new width
  27833. * @param height defines the new height
  27834. * @param depth defines the new depth (1 by default)
  27835. */
  27836. updateSize(width: int, height: int, depth?: int): void;
  27837. /** @hidden */ private _rebuild(): void;
  27838. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  27839. /**
  27840. * Dispose the current allocated resources
  27841. */
  27842. dispose(): void;
  27843. }
  27844. }
  27845. declare module BABYLON {
  27846. /**
  27847. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27848. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27849. */
  27850. export class EffectFallbacks {
  27851. private _defines;
  27852. private _currentRank;
  27853. private _maxRank;
  27854. private _mesh;
  27855. /**
  27856. * Removes the fallback from the bound mesh.
  27857. */
  27858. unBindMesh(): void;
  27859. /**
  27860. * Adds a fallback on the specified property.
  27861. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27862. * @param define The name of the define in the shader
  27863. */
  27864. addFallback(rank: number, define: string): void;
  27865. /**
  27866. * Sets the mesh to use CPU skinning when needing to fallback.
  27867. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27868. * @param mesh The mesh to use the fallbacks.
  27869. */
  27870. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27871. /**
  27872. * Checks to see if more fallbacks are still availible.
  27873. */
  27874. readonly hasMoreFallbacks: boolean;
  27875. /**
  27876. * Removes the defines that should be removed when falling back.
  27877. * @param currentDefines defines the current define statements for the shader.
  27878. * @param effect defines the current effect we try to compile
  27879. * @returns The resulting defines with defines of the current rank removed.
  27880. */
  27881. reduce(currentDefines: string, effect: Effect): string;
  27882. }
  27883. /**
  27884. * Options to be used when creating an effect.
  27885. */
  27886. export class EffectCreationOptions {
  27887. /**
  27888. * Atrributes that will be used in the shader.
  27889. */
  27890. attributes: string[];
  27891. /**
  27892. * Uniform varible names that will be set in the shader.
  27893. */
  27894. uniformsNames: string[];
  27895. /**
  27896. * Uniform buffer varible names that will be set in the shader.
  27897. */
  27898. uniformBuffersNames: string[];
  27899. /**
  27900. * Sampler texture variable names that will be set in the shader.
  27901. */
  27902. samplers: string[];
  27903. /**
  27904. * Define statements that will be set in the shader.
  27905. */
  27906. defines: any;
  27907. /**
  27908. * Possible fallbacks for this effect to improve performance when needed.
  27909. */
  27910. fallbacks: Nullable<EffectFallbacks>;
  27911. /**
  27912. * Callback that will be called when the shader is compiled.
  27913. */
  27914. onCompiled: Nullable<(effect: Effect) => void>;
  27915. /**
  27916. * Callback that will be called if an error occurs during shader compilation.
  27917. */
  27918. onError: Nullable<(effect: Effect, errors: string) => void>;
  27919. /**
  27920. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27921. */
  27922. indexParameters: any;
  27923. /**
  27924. * Max number of lights that can be used in the shader.
  27925. */
  27926. maxSimultaneousLights: number;
  27927. /**
  27928. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27929. */
  27930. transformFeedbackVaryings: Nullable<string[]>;
  27931. }
  27932. /**
  27933. * Effect containing vertex and fragment shader that can be executed on an object.
  27934. */
  27935. export class Effect implements IDisposable {
  27936. /**
  27937. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27938. */
  27939. static ShadersRepository: string;
  27940. /**
  27941. * Name of the effect.
  27942. */
  27943. name: any;
  27944. /**
  27945. * String container all the define statements that should be set on the shader.
  27946. */
  27947. defines: string;
  27948. /**
  27949. * Callback that will be called when the shader is compiled.
  27950. */
  27951. onCompiled: Nullable<(effect: Effect) => void>;
  27952. /**
  27953. * Callback that will be called if an error occurs during shader compilation.
  27954. */
  27955. onError: Nullable<(effect: Effect, errors: string) => void>;
  27956. /**
  27957. * Callback that will be called when effect is bound.
  27958. */
  27959. onBind: Nullable<(effect: Effect) => void>;
  27960. /**
  27961. * Unique ID of the effect.
  27962. */
  27963. uniqueId: number;
  27964. /**
  27965. * Observable that will be called when the shader is compiled.
  27966. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27967. */
  27968. onCompileObservable: Observable<Effect>;
  27969. /**
  27970. * Observable that will be called if an error occurs during shader compilation.
  27971. */
  27972. onErrorObservable: Observable<Effect>;
  27973. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27974. /**
  27975. * Observable that will be called when effect is bound.
  27976. */
  27977. readonly onBindObservable: Observable<Effect>;
  27978. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27979. /** @hidden */ private _uniformBuffersNames: {
  27980. [key: string]: number;
  27981. };
  27982. /** @hidden */ private _samplerList: string[];
  27983. private static _uniqueIdSeed;
  27984. private _engine;
  27985. private _uniformsNames;
  27986. private _samplers;
  27987. private _isReady;
  27988. private _compilationError;
  27989. private _attributesNames;
  27990. private _attributes;
  27991. private _uniforms;
  27992. /**
  27993. * Key for the effect.
  27994. * @hidden
  27995. */ private _key: string;
  27996. private _indexParameters;
  27997. private _fallbacks;
  27998. private _vertexSourceCodeOverride;
  27999. private _fragmentSourceCodeOverride;
  28000. private _transformFeedbackVaryings;
  28001. /**
  28002. * Compiled shader to webGL program.
  28003. * @hidden
  28004. */ private _pipelineContext: Nullable<IPipelineContext>;
  28005. /** @hidden */ private _vertexSourceCode: string;
  28006. /** @hidden */ private _fragmentSourceCode: string;
  28007. private static _baseCache;
  28008. private _processingContext;
  28009. /**
  28010. * Instantiates an effect.
  28011. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28012. * @param baseName Name of the effect.
  28013. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28014. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28015. * @param samplers List of sampler variables that will be passed to the shader.
  28016. * @param engine Engine to be used to render the effect
  28017. * @param defines Define statements to be added to the shader.
  28018. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28019. * @param onCompiled Callback that will be called when the shader is compiled.
  28020. * @param onError Callback that will be called if an error occurs during shader compilation.
  28021. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28022. * @param key Effect Key identifying uniquely compiled shader variants
  28023. * @param sources Already processed sources for the current key.
  28024. */
  28025. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, key?: string, sources?: {
  28026. vertex: string;
  28027. fragment: string;
  28028. });
  28029. private _useFinalCode;
  28030. /**
  28031. * Unique key for this effect
  28032. */
  28033. readonly key: string;
  28034. /**
  28035. * If the effect has been compiled and prepared.
  28036. * @returns if the effect is compiled and prepared.
  28037. */
  28038. isReady(): boolean;
  28039. private _isReadyInternal;
  28040. /**
  28041. * The engine the effect was initialized with.
  28042. * @returns the engine.
  28043. */
  28044. getEngine(): Engine;
  28045. /**
  28046. * The pipeline context for this effect
  28047. * @returns the associated pipeline context
  28048. */
  28049. getPipelineContext(): Nullable<IPipelineContext>;
  28050. /**
  28051. * The set of names of attribute variables for the shader.
  28052. * @returns An array of attribute names.
  28053. */
  28054. getAttributesNames(): string[];
  28055. /**
  28056. * Returns the attribute at the given index.
  28057. * @param index The index of the attribute.
  28058. * @returns The location of the attribute.
  28059. */
  28060. getAttributeLocation(index: number): number;
  28061. /**
  28062. * Returns the attribute based on the name of the variable.
  28063. * @param name of the attribute to look up.
  28064. * @returns the attribute location.
  28065. */
  28066. getAttributeLocationByName(name: string): number;
  28067. /**
  28068. * The number of attributes.
  28069. * @returns the numnber of attributes.
  28070. */
  28071. getAttributesCount(): number;
  28072. /**
  28073. * Gets the index of a uniform variable.
  28074. * @param uniformName of the uniform to look up.
  28075. * @returns the index.
  28076. */
  28077. getUniformIndex(uniformName: string): number;
  28078. /**
  28079. * Returns the attribute based on the name of the variable.
  28080. * @param uniformName of the uniform to look up.
  28081. * @returns the location of the uniform.
  28082. */
  28083. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28084. /**
  28085. * Returns an array of sampler variable names
  28086. * @returns The array of sampler variable neames.
  28087. */
  28088. getSamplers(): string[];
  28089. /**
  28090. * The error from the last compilation.
  28091. * @returns the error string.
  28092. */
  28093. getCompilationError(): string;
  28094. /**
  28095. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28096. * @param func The callback to be used.
  28097. */
  28098. executeWhenCompiled(func: (effect: Effect) => void): void;
  28099. private _checkIsReady;
  28100. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28101. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28102. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28103. /**
  28104. * Recompiles the webGL program
  28105. * @param vertexSourceCode The source code for the vertex shader.
  28106. * @param fragmentSourceCode The source code for the fragment shader.
  28107. * @param onCompiled Callback called when completed.
  28108. * @param onError Callback called on error.
  28109. * @hidden
  28110. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28111. /**
  28112. * Prepares the effect
  28113. * @hidden
  28114. */ private _prepareEffect(): void;
  28115. private _processCompilationErrors;
  28116. /**
  28117. * Checks if the effect is supported. (Must be called after compilation)
  28118. */
  28119. readonly isSupported: boolean;
  28120. /**
  28121. * Binds a texture to the engine to be used as output of the shader.
  28122. * @param channel Name of the output variable.
  28123. * @param texture Texture to bind.
  28124. * @hidden
  28125. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  28126. /**
  28127. * Sets a texture on the engine to be used in the shader.
  28128. * @param channel Name of the sampler variable.
  28129. * @param texture Texture to set.
  28130. */
  28131. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28132. /**
  28133. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28134. * @param channel Name of the sampler variable.
  28135. * @param texture Texture to set.
  28136. */
  28137. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28138. /**
  28139. * Sets an array of textures on the engine to be used in the shader.
  28140. * @param channel Name of the variable.
  28141. * @param textures Textures to set.
  28142. */
  28143. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28144. /**
  28145. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  28146. * @param channel Name of the sampler variable.
  28147. * @param postProcess Post process to get the input texture from.
  28148. */
  28149. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28150. /**
  28151. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28152. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  28153. * @param channel Name of the sampler variable.
  28154. * @param postProcess Post process to get the output texture from.
  28155. */
  28156. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28157. /**
  28158. * Binds a buffer to a uniform.
  28159. * @param buffer Buffer to bind.
  28160. * @param name Name of the uniform variable to bind to.
  28161. */
  28162. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28163. /**
  28164. * Binds block to a uniform.
  28165. * @param blockName Name of the block to bind.
  28166. * @param index Index to bind.
  28167. */
  28168. bindUniformBlock(blockName: string, index: number): void;
  28169. /**
  28170. * Sets an interger value on a uniform variable.
  28171. * @param uniformName Name of the variable.
  28172. * @param value Value to be set.
  28173. * @returns this effect.
  28174. */
  28175. setInt(uniformName: string, value: number): Effect;
  28176. /**
  28177. * Sets an int array on a uniform variable.
  28178. * @param uniformName Name of the variable.
  28179. * @param array array to be set.
  28180. * @returns this effect.
  28181. */
  28182. setIntArray(uniformName: string, array: Int32Array): Effect;
  28183. /**
  28184. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  28185. * @param uniformName Name of the variable.
  28186. * @param array array to be set.
  28187. * @returns this effect.
  28188. */
  28189. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28190. /**
  28191. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  28192. * @param uniformName Name of the variable.
  28193. * @param array array to be set.
  28194. * @returns this effect.
  28195. */
  28196. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28197. /**
  28198. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  28199. * @param uniformName Name of the variable.
  28200. * @param array array to be set.
  28201. * @returns this effect.
  28202. */
  28203. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28204. /**
  28205. * Sets an float array on a uniform variable.
  28206. * @param uniformName Name of the variable.
  28207. * @param array array to be set.
  28208. * @returns this effect.
  28209. */
  28210. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28211. /**
  28212. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  28213. * @param uniformName Name of the variable.
  28214. * @param array array to be set.
  28215. * @returns this effect.
  28216. */
  28217. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28218. /**
  28219. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  28220. * @param uniformName Name of the variable.
  28221. * @param array array to be set.
  28222. * @returns this effect.
  28223. */
  28224. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28225. /**
  28226. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  28227. * @param uniformName Name of the variable.
  28228. * @param array array to be set.
  28229. * @returns this effect.
  28230. */
  28231. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28232. /**
  28233. * Sets an array on a uniform variable.
  28234. * @param uniformName Name of the variable.
  28235. * @param array array to be set.
  28236. * @returns this effect.
  28237. */
  28238. setArray(uniformName: string, array: number[]): Effect;
  28239. /**
  28240. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  28241. * @param uniformName Name of the variable.
  28242. * @param array array to be set.
  28243. * @returns this effect.
  28244. */
  28245. setArray2(uniformName: string, array: number[]): Effect;
  28246. /**
  28247. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  28248. * @param uniformName Name of the variable.
  28249. * @param array array to be set.
  28250. * @returns this effect.
  28251. */
  28252. setArray3(uniformName: string, array: number[]): Effect;
  28253. /**
  28254. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  28255. * @param uniformName Name of the variable.
  28256. * @param array array to be set.
  28257. * @returns this effect.
  28258. */
  28259. setArray4(uniformName: string, array: number[]): Effect;
  28260. /**
  28261. * Sets matrices on a uniform variable.
  28262. * @param uniformName Name of the variable.
  28263. * @param matrices matrices to be set.
  28264. * @returns this effect.
  28265. */
  28266. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28267. /**
  28268. * Sets matrix on a uniform variable.
  28269. * @param uniformName Name of the variable.
  28270. * @param matrix matrix to be set.
  28271. * @returns this effect.
  28272. */
  28273. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28274. /**
  28275. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  28276. * @param uniformName Name of the variable.
  28277. * @param matrix matrix to be set.
  28278. * @returns this effect.
  28279. */
  28280. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28281. /**
  28282. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28283. * @param uniformName Name of the variable.
  28284. * @param matrix matrix to be set.
  28285. * @returns this effect.
  28286. */
  28287. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28288. /**
  28289. * Sets a float on a uniform variable.
  28290. * @param uniformName Name of the variable.
  28291. * @param value value to be set.
  28292. * @returns this effect.
  28293. */
  28294. setFloat(uniformName: string, value: number): Effect;
  28295. /**
  28296. * Sets a boolean on a uniform variable.
  28297. * @param uniformName Name of the variable.
  28298. * @param bool value to be set.
  28299. * @returns this effect.
  28300. */
  28301. setBool(uniformName: string, bool: boolean): Effect;
  28302. /**
  28303. * Sets a Vector2 on a uniform variable.
  28304. * @param uniformName Name of the variable.
  28305. * @param vector2 vector2 to be set.
  28306. * @returns this effect.
  28307. */
  28308. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28309. /**
  28310. * Sets a float2 on a uniform variable.
  28311. * @param uniformName Name of the variable.
  28312. * @param x First float in float2.
  28313. * @param y Second float in float2.
  28314. * @returns this effect.
  28315. */
  28316. setFloat2(uniformName: string, x: number, y: number): Effect;
  28317. /**
  28318. * Sets a Vector3 on a uniform variable.
  28319. * @param uniformName Name of the variable.
  28320. * @param vector3 Value to be set.
  28321. * @returns this effect.
  28322. */
  28323. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28324. /**
  28325. * Sets a float3 on a uniform variable.
  28326. * @param uniformName Name of the variable.
  28327. * @param x First float in float3.
  28328. * @param y Second float in float3.
  28329. * @param z Third float in float3.
  28330. * @returns this effect.
  28331. */
  28332. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28333. /**
  28334. * Sets a Vector4 on a uniform variable.
  28335. * @param uniformName Name of the variable.
  28336. * @param vector4 Value to be set.
  28337. * @returns this effect.
  28338. */
  28339. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28340. /**
  28341. * Sets a float4 on a uniform variable.
  28342. * @param uniformName Name of the variable.
  28343. * @param x First float in float4.
  28344. * @param y Second float in float4.
  28345. * @param z Third float in float4.
  28346. * @param w Fourth float in float4.
  28347. * @returns this effect.
  28348. */
  28349. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28350. /**
  28351. * Sets a Color3 on a uniform variable.
  28352. * @param uniformName Name of the variable.
  28353. * @param color3 Value to be set.
  28354. * @returns this effect.
  28355. */
  28356. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28357. /**
  28358. * Sets a Color4 on a uniform variable.
  28359. * @param uniformName Name of the variable.
  28360. * @param color3 Value to be set.
  28361. * @param alpha Alpha value to be set.
  28362. * @returns this effect.
  28363. */
  28364. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28365. /**
  28366. * Sets a Color4 on a uniform variable
  28367. * @param uniformName defines the name of the variable
  28368. * @param color4 defines the value to be set
  28369. * @returns this effect.
  28370. */
  28371. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28372. /**
  28373. * Release all associated resources.
  28374. **/
  28375. dispose(): void;
  28376. /**
  28377. * This function will add a new shader to the shader store
  28378. * @param name the name of the shader
  28379. * @param pixelShader optional pixel shader content
  28380. * @param vertexShader optional vertex shader content
  28381. */
  28382. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28383. /**
  28384. * Store of each shader (The can be looked up using effect.key)
  28385. */
  28386. static ShadersStore: {
  28387. [key: string]: string;
  28388. };
  28389. /**
  28390. * Store of each included file for a shader (The can be looked up using effect.key)
  28391. */
  28392. static IncludesShadersStore: {
  28393. [key: string]: string;
  28394. };
  28395. /**
  28396. * Resets the cache of effects.
  28397. */
  28398. static ResetCache(): void;
  28399. }
  28400. }
  28401. declare module BABYLON {
  28402. /**
  28403. * Uniform buffer objects.
  28404. *
  28405. * Handles blocks of uniform on the GPU.
  28406. *
  28407. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28408. *
  28409. * For more information, please refer to :
  28410. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28411. */
  28412. export class UniformBuffer {
  28413. private _engine;
  28414. private _buffer;
  28415. private _data;
  28416. private _bufferData;
  28417. private _dynamic?;
  28418. private _uniformLocations;
  28419. private _uniformSizes;
  28420. private _uniformArraySizes;
  28421. private _uniformLocationPointer;
  28422. private _needSync;
  28423. private _noUBO;
  28424. private _currentEffect;
  28425. private static _MAX_UNIFORM_SIZE;
  28426. private static _tempBuffer;
  28427. /**
  28428. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28429. * This is dynamic to allow compat with webgl 1 and 2.
  28430. * You will need to pass the name of the uniform as well as the value.
  28431. */
  28432. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28433. /**
  28434. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28435. * This is dynamic to allow compat with webgl 1 and 2.
  28436. * You will need to pass the name of the uniform as well as the value.
  28437. */
  28438. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28439. /**
  28440. * Lambda to Update a single float in a uniform buffer.
  28441. * This is dynamic to allow compat with webgl 1 and 2.
  28442. * You will need to pass the name of the uniform as well as the value.
  28443. */
  28444. updateFloat: (name: string, x: number) => void;
  28445. /**
  28446. * Lambda to Update a vec2 of float in a uniform buffer.
  28447. * This is dynamic to allow compat with webgl 1 and 2.
  28448. * You will need to pass the name of the uniform as well as the value.
  28449. */
  28450. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28451. /**
  28452. * Lambda to Update a vec3 of float in a uniform buffer.
  28453. * This is dynamic to allow compat with webgl 1 and 2.
  28454. * You will need to pass the name of the uniform as well as the value.
  28455. */
  28456. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28457. /**
  28458. * Lambda to Update a vec4 of float in a uniform buffer.
  28459. * This is dynamic to allow compat with webgl 1 and 2.
  28460. * You will need to pass the name of the uniform as well as the value.
  28461. */
  28462. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28463. /**
  28464. * Lambda to Update an array of float in a uniform buffer.
  28465. * This is dynamic to allow compat with webgl 1 and 2.
  28466. * You will need to pass the name of the uniform as well as the value.
  28467. */
  28468. updateFloatArray: (name: string, array: Float32Array) => void;
  28469. /**
  28470. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28471. * This is dynamic to allow compat with webgl 1 and 2.
  28472. * You will need to pass the name of the uniform as well as the value.
  28473. */
  28474. updateMatrix: (name: string, mat: IMatrixLike) => void;
  28475. /**
  28476. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  28477. * This is dynamic to allow compat with webgl 1 and 2.
  28478. * You will need to pass the name of the uniform as well as the value.
  28479. */
  28480. updateMatrices: (name: string, mat: Float32Array) => void;
  28481. /**
  28482. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28483. * This is dynamic to allow compat with webgl 1 and 2.
  28484. * You will need to pass the name of the uniform as well as the value.
  28485. */
  28486. updateVector3: (name: string, vector: Vector3) => void;
  28487. /**
  28488. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28489. * This is dynamic to allow compat with webgl 1 and 2.
  28490. * You will need to pass the name of the uniform as well as the value.
  28491. */
  28492. updateVector4: (name: string, vector: Vector4) => void;
  28493. /**
  28494. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28495. * This is dynamic to allow compat with webgl 1 and 2.
  28496. * You will need to pass the name of the uniform as well as the value.
  28497. */
  28498. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28499. /**
  28500. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28501. * This is dynamic to allow compat with webgl 1 and 2.
  28502. * You will need to pass the name of the uniform as well as the value.
  28503. */
  28504. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28505. /**
  28506. * Instantiates a new Uniform buffer objects.
  28507. *
  28508. * Handles blocks of uniform on the GPU.
  28509. *
  28510. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28511. *
  28512. * For more information, please refer to :
  28513. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28514. * @param engine Define the engine the buffer is associated with
  28515. * @param data Define the data contained in the buffer
  28516. * @param dynamic Define if the buffer is updatable
  28517. */
  28518. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28519. /**
  28520. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28521. * or just falling back on setUniformXXX calls.
  28522. */
  28523. readonly useUbo: boolean;
  28524. /**
  28525. * Indicates if the WebGL underlying uniform buffer is in sync
  28526. * with the javascript cache data.
  28527. */
  28528. readonly isSync: boolean;
  28529. /**
  28530. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28531. * Also, a dynamic UniformBuffer will disable cache verification and always
  28532. * update the underlying WebGL uniform buffer to the GPU.
  28533. * @returns if Dynamic, otherwise false
  28534. */
  28535. isDynamic(): boolean;
  28536. /**
  28537. * The data cache on JS side.
  28538. * @returns the underlying data as a float array
  28539. */
  28540. getData(): Float32Array;
  28541. /**
  28542. * The underlying WebGL Uniform buffer.
  28543. * @returns the webgl buffer
  28544. */
  28545. getBuffer(): Nullable<DataBuffer>;
  28546. /**
  28547. * std140 layout specifies how to align data within an UBO structure.
  28548. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28549. * for specs.
  28550. */
  28551. private _fillAlignment;
  28552. /**
  28553. * Adds an uniform in the buffer.
  28554. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28555. * for the layout to be correct !
  28556. * @param name Name of the uniform, as used in the uniform block in the shader.
  28557. * @param size Data size, or data directly.
  28558. * @param arraySize The number of elements in the array, 0 if not an array.
  28559. */
  28560. addUniform(name: string, size: number | number[], arraySize?: number): void;
  28561. /**
  28562. * Adds a Matrix 4x4 to the uniform buffer.
  28563. * @param name Name of the uniform, as used in the uniform block in the shader.
  28564. * @param mat A 4x4 matrix.
  28565. */
  28566. addMatrix(name: string, mat: Matrix): void;
  28567. /**
  28568. * Adds a vec2 to the uniform buffer.
  28569. * @param name Name of the uniform, as used in the uniform block in the shader.
  28570. * @param x Define the x component value of the vec2
  28571. * @param y Define the y component value of the vec2
  28572. */
  28573. addFloat2(name: string, x: number, y: number): void;
  28574. /**
  28575. * Adds a vec3 to the uniform buffer.
  28576. * @param name Name of the uniform, as used in the uniform block in the shader.
  28577. * @param x Define the x component value of the vec3
  28578. * @param y Define the y component value of the vec3
  28579. * @param z Define the z component value of the vec3
  28580. */
  28581. addFloat3(name: string, x: number, y: number, z: number): void;
  28582. /**
  28583. * Adds a vec3 to the uniform buffer.
  28584. * @param name Name of the uniform, as used in the uniform block in the shader.
  28585. * @param color Define the vec3 from a Color
  28586. */
  28587. addColor3(name: string, color: Color3): void;
  28588. /**
  28589. * Adds a vec4 to the uniform buffer.
  28590. * @param name Name of the uniform, as used in the uniform block in the shader.
  28591. * @param color Define the rgb components from a Color
  28592. * @param alpha Define the a component of the vec4
  28593. */
  28594. addColor4(name: string, color: Color3, alpha: number): void;
  28595. /**
  28596. * Adds a vec3 to the uniform buffer.
  28597. * @param name Name of the uniform, as used in the uniform block in the shader.
  28598. * @param vector Define the vec3 components from a Vector
  28599. */
  28600. addVector3(name: string, vector: Vector3): void;
  28601. /**
  28602. * Adds a Matrix 3x3 to the uniform buffer.
  28603. * @param name Name of the uniform, as used in the uniform block in the shader.
  28604. */
  28605. addMatrix3x3(name: string): void;
  28606. /**
  28607. * Adds a Matrix 2x2 to the uniform buffer.
  28608. * @param name Name of the uniform, as used in the uniform block in the shader.
  28609. */
  28610. addMatrix2x2(name: string): void;
  28611. /**
  28612. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28613. */
  28614. create(): void;
  28615. /** @hidden */ private _rebuild(): void;
  28616. /**
  28617. * Updates the WebGL Uniform Buffer on the GPU.
  28618. * If the `dynamic` flag is set to true, no cache comparison is done.
  28619. * Otherwise, the buffer will be updated only if the cache differs.
  28620. */
  28621. update(): void;
  28622. /**
  28623. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28624. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28625. * @param data Define the flattened data
  28626. * @param size Define the size of the data.
  28627. */
  28628. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28629. /**
  28630. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28631. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28632. * @param data Define the flattened data
  28633. * @param size Define the size of the data.
  28634. */
  28635. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  28636. private _valueCache;
  28637. private _cacheMatrix;
  28638. private _updateMatrix3x3ForUniform;
  28639. private _updateMatrix3x3ForEffect;
  28640. private _updateMatrix2x2ForEffect;
  28641. private _updateMatrix2x2ForUniform;
  28642. private _updateFloatForEffect;
  28643. private _updateFloatForUniform;
  28644. private _updateFloat2ForEffect;
  28645. private _updateFloat2ForUniform;
  28646. private _updateFloat3ForEffect;
  28647. private _updateFloat3ForUniform;
  28648. private _updateFloat4ForEffect;
  28649. private _updateFloat4ForUniform;
  28650. private _updateFloatArrayForEffect;
  28651. private _updateFloatArrayForUniform;
  28652. private _updateMatrixForEffect;
  28653. private _updateMatrixForUniform;
  28654. private _updateMatricesForEffect;
  28655. private _updateMatricesForUniform;
  28656. private _updateVector3ForEffect;
  28657. private _updateVector3ForUniform;
  28658. private _updateVector4ForEffect;
  28659. private _updateVector4ForUniform;
  28660. private _updateColor3ForEffect;
  28661. private _updateColor3ForUniform;
  28662. private _updateColor4ForEffect;
  28663. private _updateColor4ForUniform;
  28664. /**
  28665. * Sets a sampler uniform on the effect.
  28666. * @param name Define the name of the sampler.
  28667. * @param texture Define the texture to set in the sampler
  28668. */
  28669. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28670. /**
  28671. * Directly updates the value of the uniform in the cache AND on the GPU.
  28672. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28673. * @param data Define the flattened data
  28674. */
  28675. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28676. /**
  28677. * Binds this uniform buffer to an effect.
  28678. * @param effect Define the effect to bind the buffer to
  28679. * @param name Name of the uniform block in the shader.
  28680. */
  28681. bindToEffect(effect: Effect, name: string): void;
  28682. /**
  28683. * Disposes the uniform buffer.
  28684. */
  28685. dispose(): void;
  28686. }
  28687. }
  28688. declare module BABYLON {
  28689. /**
  28690. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28692. */
  28693. export class Analyser {
  28694. /**
  28695. * Gets or sets the smoothing
  28696. * @ignorenaming
  28697. */
  28698. SMOOTHING: number;
  28699. /**
  28700. * Gets or sets the FFT table size
  28701. * @ignorenaming
  28702. */
  28703. FFT_SIZE: number;
  28704. /**
  28705. * Gets or sets the bar graph amplitude
  28706. * @ignorenaming
  28707. */
  28708. BARGRAPHAMPLITUDE: number;
  28709. /**
  28710. * Gets or sets the position of the debug canvas
  28711. * @ignorenaming
  28712. */
  28713. DEBUGCANVASPOS: {
  28714. x: number;
  28715. y: number;
  28716. };
  28717. /**
  28718. * Gets or sets the debug canvas size
  28719. * @ignorenaming
  28720. */
  28721. DEBUGCANVASSIZE: {
  28722. width: number;
  28723. height: number;
  28724. };
  28725. private _byteFreqs;
  28726. private _byteTime;
  28727. private _floatFreqs;
  28728. private _webAudioAnalyser;
  28729. private _debugCanvas;
  28730. private _debugCanvasContext;
  28731. private _scene;
  28732. private _registerFunc;
  28733. private _audioEngine;
  28734. /**
  28735. * Creates a new analyser
  28736. * @param scene defines hosting scene
  28737. */
  28738. constructor(scene: Scene);
  28739. /**
  28740. * Get the number of data values you will have to play with for the visualization
  28741. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28742. * @returns a number
  28743. */
  28744. getFrequencyBinCount(): number;
  28745. /**
  28746. * Gets the current frequency data as a byte array
  28747. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28748. * @returns a Uint8Array
  28749. */
  28750. getByteFrequencyData(): Uint8Array;
  28751. /**
  28752. * Gets the current waveform as a byte array
  28753. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28754. * @returns a Uint8Array
  28755. */
  28756. getByteTimeDomainData(): Uint8Array;
  28757. /**
  28758. * Gets the current frequency data as a float array
  28759. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28760. * @returns a Float32Array
  28761. */
  28762. getFloatFrequencyData(): Float32Array;
  28763. /**
  28764. * Renders the debug canvas
  28765. */
  28766. drawDebugCanvas(): void;
  28767. /**
  28768. * Stops rendering the debug canvas and removes it
  28769. */
  28770. stopDebugCanvas(): void;
  28771. /**
  28772. * Connects two audio nodes
  28773. * @param inputAudioNode defines first node to connect
  28774. * @param outputAudioNode defines second node to connect
  28775. */
  28776. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28777. /**
  28778. * Releases all associated resources
  28779. */
  28780. dispose(): void;
  28781. }
  28782. }
  28783. declare module BABYLON {
  28784. /**
  28785. * This represents an audio engine and it is responsible
  28786. * to play, synchronize and analyse sounds throughout the application.
  28787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28788. */
  28789. export interface IAudioEngine extends IDisposable {
  28790. /**
  28791. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28792. */
  28793. readonly canUseWebAudio: boolean;
  28794. /**
  28795. * Gets the current AudioContext if available.
  28796. */
  28797. readonly audioContext: Nullable<AudioContext>;
  28798. /**
  28799. * The master gain node defines the global audio volume of your audio engine.
  28800. */
  28801. readonly masterGain: GainNode;
  28802. /**
  28803. * Gets whether or not mp3 are supported by your browser.
  28804. */
  28805. readonly isMP3supported: boolean;
  28806. /**
  28807. * Gets whether or not ogg are supported by your browser.
  28808. */
  28809. readonly isOGGsupported: boolean;
  28810. /**
  28811. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28812. * @ignoreNaming
  28813. */
  28814. WarnedWebAudioUnsupported: boolean;
  28815. /**
  28816. * Defines if the audio engine relies on a custom unlocked button.
  28817. * In this case, the embedded button will not be displayed.
  28818. */
  28819. useCustomUnlockedButton: boolean;
  28820. /**
  28821. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  28822. */
  28823. readonly unlocked: boolean;
  28824. /**
  28825. * Event raised when audio has been unlocked on the browser.
  28826. */
  28827. onAudioUnlockedObservable: Observable<AudioEngine>;
  28828. /**
  28829. * Event raised when audio has been locked on the browser.
  28830. */
  28831. onAudioLockedObservable: Observable<AudioEngine>;
  28832. /**
  28833. * Flags the audio engine in Locked state.
  28834. * This happens due to new browser policies preventing audio to autoplay.
  28835. */
  28836. lock(): void;
  28837. /**
  28838. * Unlocks the audio engine once a user action has been done on the dom.
  28839. * This is helpful to resume play once browser policies have been satisfied.
  28840. */
  28841. unlock(): void;
  28842. }
  28843. /**
  28844. * This represents the default audio engine used in babylon.
  28845. * It is responsible to play, synchronize and analyse sounds throughout the application.
  28846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28847. */
  28848. export class AudioEngine implements IAudioEngine {
  28849. private _audioContext;
  28850. private _audioContextInitialized;
  28851. private _muteButton;
  28852. private _hostElement;
  28853. /**
  28854. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28855. */
  28856. canUseWebAudio: boolean;
  28857. /**
  28858. * The master gain node defines the global audio volume of your audio engine.
  28859. */
  28860. masterGain: GainNode;
  28861. /**
  28862. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28863. * @ignoreNaming
  28864. */
  28865. WarnedWebAudioUnsupported: boolean;
  28866. /**
  28867. * Gets whether or not mp3 are supported by your browser.
  28868. */
  28869. isMP3supported: boolean;
  28870. /**
  28871. * Gets whether or not ogg are supported by your browser.
  28872. */
  28873. isOGGsupported: boolean;
  28874. /**
  28875. * Gets whether audio has been unlocked on the device.
  28876. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  28877. * a user interaction has happened.
  28878. */
  28879. unlocked: boolean;
  28880. /**
  28881. * Defines if the audio engine relies on a custom unlocked button.
  28882. * In this case, the embedded button will not be displayed.
  28883. */
  28884. useCustomUnlockedButton: boolean;
  28885. /**
  28886. * Event raised when audio has been unlocked on the browser.
  28887. */
  28888. onAudioUnlockedObservable: Observable<AudioEngine>;
  28889. /**
  28890. * Event raised when audio has been locked on the browser.
  28891. */
  28892. onAudioLockedObservable: Observable<AudioEngine>;
  28893. /**
  28894. * Gets the current AudioContext if available.
  28895. */
  28896. readonly audioContext: Nullable<AudioContext>;
  28897. private _connectedAnalyser;
  28898. /**
  28899. * Instantiates a new audio engine.
  28900. *
  28901. * There should be only one per page as some browsers restrict the number
  28902. * of audio contexts you can create.
  28903. * @param hostElement defines the host element where to display the mute icon if necessary
  28904. */
  28905. constructor(hostElement?: Nullable<HTMLElement>);
  28906. /**
  28907. * Flags the audio engine in Locked state.
  28908. * This happens due to new browser policies preventing audio to autoplay.
  28909. */
  28910. lock(): void;
  28911. /**
  28912. * Unlocks the audio engine once a user action has been done on the dom.
  28913. * This is helpful to resume play once browser policies have been satisfied.
  28914. */
  28915. unlock(): void;
  28916. private _resumeAudioContext;
  28917. private _initializeAudioContext;
  28918. private _tryToRun;
  28919. private _triggerRunningState;
  28920. private _triggerSuspendedState;
  28921. private _displayMuteButton;
  28922. private _moveButtonToTopLeft;
  28923. private _onResize;
  28924. private _hideMuteButton;
  28925. /**
  28926. * Destroy and release the resources associated with the audio ccontext.
  28927. */
  28928. dispose(): void;
  28929. /**
  28930. * Gets the global volume sets on the master gain.
  28931. * @returns the global volume if set or -1 otherwise
  28932. */
  28933. getGlobalVolume(): number;
  28934. /**
  28935. * Sets the global volume of your experience (sets on the master gain).
  28936. * @param newVolume Defines the new global volume of the application
  28937. */
  28938. setGlobalVolume(newVolume: number): void;
  28939. /**
  28940. * Connect the audio engine to an audio analyser allowing some amazing
  28941. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  28942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  28943. * @param analyser The analyser to connect to the engine
  28944. */
  28945. connectToAnalyser(analyser: Analyser): void;
  28946. }
  28947. }
  28948. declare module BABYLON {
  28949. /**
  28950. * Interface used to present a loading screen while loading a scene
  28951. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28952. */
  28953. export interface ILoadingScreen {
  28954. /**
  28955. * Function called to display the loading screen
  28956. */
  28957. displayLoadingUI: () => void;
  28958. /**
  28959. * Function called to hide the loading screen
  28960. */
  28961. hideLoadingUI: () => void;
  28962. /**
  28963. * Gets or sets the color to use for the background
  28964. */
  28965. loadingUIBackgroundColor: string;
  28966. /**
  28967. * Gets or sets the text to display while loading
  28968. */
  28969. loadingUIText: string;
  28970. }
  28971. /**
  28972. * Class used for the default loading screen
  28973. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28974. */
  28975. export class DefaultLoadingScreen implements ILoadingScreen {
  28976. private _renderingCanvas;
  28977. private _loadingText;
  28978. private _loadingDivBackgroundColor;
  28979. private _loadingDiv;
  28980. private _loadingTextDiv;
  28981. /** Gets or sets the logo url to use for the default loading screen */
  28982. static DefaultLogoUrl: string;
  28983. /** Gets or sets the spinner url to use for the default loading screen */
  28984. static DefaultSpinnerUrl: string;
  28985. /**
  28986. * Creates a new default loading screen
  28987. * @param _renderingCanvas defines the canvas used to render the scene
  28988. * @param _loadingText defines the default text to display
  28989. * @param _loadingDivBackgroundColor defines the default background color
  28990. */
  28991. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  28992. /**
  28993. * Function called to display the loading screen
  28994. */
  28995. displayLoadingUI(): void;
  28996. /**
  28997. * Function called to hide the loading screen
  28998. */
  28999. hideLoadingUI(): void;
  29000. /**
  29001. * Gets or sets the text to display while loading
  29002. */
  29003. loadingUIText: string;
  29004. /**
  29005. * Gets or sets the color to use for the background
  29006. */
  29007. loadingUIBackgroundColor: string;
  29008. private _resizeLoadingUI;
  29009. }
  29010. }
  29011. declare module BABYLON {
  29012. /** @hidden */
  29013. export class WebGLPipelineContext implements IPipelineContext {
  29014. private _valueCache;
  29015. private _uniforms;
  29016. engine: Engine;
  29017. program: Nullable<WebGLProgram>;
  29018. context?: WebGLRenderingContext;
  29019. vertexShader?: WebGLShader;
  29020. fragmentShader?: WebGLShader;
  29021. isParallelCompiled: boolean;
  29022. onCompiled?: () => void;
  29023. transformFeedback?: WebGLTransformFeedback | null;
  29024. readonly isAsync: boolean;
  29025. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void; private _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  29026. [key: string]: number;
  29027. }, uniformsNames: string[], uniforms: {
  29028. [key: string]: Nullable<WebGLUniformLocation>;
  29029. }, samplerList: string[], samplers: {
  29030. [key: string]: number;
  29031. }, attributesNames: string[], attributes: number[]): void;
  29032. /**
  29033. * Release all associated resources.
  29034. **/
  29035. dispose(): void;
  29036. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29037. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29038. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29039. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29040. /**
  29041. * Sets an interger value on a uniform variable.
  29042. * @param uniformName Name of the variable.
  29043. * @param value Value to be set.
  29044. */
  29045. setInt(uniformName: string, value: number): void;
  29046. /**
  29047. * Sets an int array on a uniform variable.
  29048. * @param uniformName Name of the variable.
  29049. * @param array array to be set.
  29050. */
  29051. setIntArray(uniformName: string, array: Int32Array): void;
  29052. /**
  29053. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29054. * @param uniformName Name of the variable.
  29055. * @param array array to be set.
  29056. */
  29057. setIntArray2(uniformName: string, array: Int32Array): void;
  29058. /**
  29059. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29060. * @param uniformName Name of the variable.
  29061. * @param array array to be set.
  29062. */
  29063. setIntArray3(uniformName: string, array: Int32Array): void;
  29064. /**
  29065. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29066. * @param uniformName Name of the variable.
  29067. * @param array array to be set.
  29068. */
  29069. setIntArray4(uniformName: string, array: Int32Array): void;
  29070. /**
  29071. * Sets an float array on a uniform variable.
  29072. * @param uniformName Name of the variable.
  29073. * @param array array to be set.
  29074. */
  29075. setFloatArray(uniformName: string, array: Float32Array): void;
  29076. /**
  29077. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29078. * @param uniformName Name of the variable.
  29079. * @param array array to be set.
  29080. */
  29081. setFloatArray2(uniformName: string, array: Float32Array): void;
  29082. /**
  29083. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29084. * @param uniformName Name of the variable.
  29085. * @param array array to be set.
  29086. */
  29087. setFloatArray3(uniformName: string, array: Float32Array): void;
  29088. /**
  29089. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29090. * @param uniformName Name of the variable.
  29091. * @param array array to be set.
  29092. */
  29093. setFloatArray4(uniformName: string, array: Float32Array): void;
  29094. /**
  29095. * Sets an array on a uniform variable.
  29096. * @param uniformName Name of the variable.
  29097. * @param array array to be set.
  29098. */
  29099. setArray(uniformName: string, array: number[]): void;
  29100. /**
  29101. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29102. * @param uniformName Name of the variable.
  29103. * @param array array to be set.
  29104. */
  29105. setArray2(uniformName: string, array: number[]): void;
  29106. /**
  29107. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29108. * @param uniformName Name of the variable.
  29109. * @param array array to be set.
  29110. * @returns this effect.
  29111. */
  29112. setArray3(uniformName: string, array: number[]): void;
  29113. /**
  29114. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29115. * @param uniformName Name of the variable.
  29116. * @param array array to be set.
  29117. */
  29118. setArray4(uniformName: string, array: number[]): void;
  29119. /**
  29120. * Sets matrices on a uniform variable.
  29121. * @param uniformName Name of the variable.
  29122. * @param matrices matrices to be set.
  29123. */
  29124. setMatrices(uniformName: string, matrices: Float32Array): void;
  29125. /**
  29126. * Sets matrix on a uniform variable.
  29127. * @param uniformName Name of the variable.
  29128. * @param matrix matrix to be set.
  29129. */
  29130. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  29131. /**
  29132. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  29133. * @param uniformName Name of the variable.
  29134. * @param matrix matrix to be set.
  29135. */
  29136. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  29137. /**
  29138. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29139. * @param uniformName Name of the variable.
  29140. * @param matrix matrix to be set.
  29141. */
  29142. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  29143. /**
  29144. * Sets a float on a uniform variable.
  29145. * @param uniformName Name of the variable.
  29146. * @param value value to be set.
  29147. * @returns this effect.
  29148. */
  29149. setFloat(uniformName: string, value: number): void;
  29150. /**
  29151. * Sets a boolean on a uniform variable.
  29152. * @param uniformName Name of the variable.
  29153. * @param bool value to be set.
  29154. */
  29155. setBool(uniformName: string, bool: boolean): void;
  29156. /**
  29157. * Sets a Vector2 on a uniform variable.
  29158. * @param uniformName Name of the variable.
  29159. * @param vector2 vector2 to be set.
  29160. */
  29161. setVector2(uniformName: string, vector2: IVector2Like): void;
  29162. /**
  29163. * Sets a float2 on a uniform variable.
  29164. * @param uniformName Name of the variable.
  29165. * @param x First float in float2.
  29166. * @param y Second float in float2.
  29167. */
  29168. setFloat2(uniformName: string, x: number, y: number): void;
  29169. /**
  29170. * Sets a Vector3 on a uniform variable.
  29171. * @param uniformName Name of the variable.
  29172. * @param vector3 Value to be set.
  29173. */
  29174. setVector3(uniformName: string, vector3: IVector3Like): void;
  29175. /**
  29176. * Sets a float3 on a uniform variable.
  29177. * @param uniformName Name of the variable.
  29178. * @param x First float in float3.
  29179. * @param y Second float in float3.
  29180. * @param z Third float in float3.
  29181. */
  29182. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  29183. /**
  29184. * Sets a Vector4 on a uniform variable.
  29185. * @param uniformName Name of the variable.
  29186. * @param vector4 Value to be set.
  29187. */
  29188. setVector4(uniformName: string, vector4: IVector4Like): void;
  29189. /**
  29190. * Sets a float4 on a uniform variable.
  29191. * @param uniformName Name of the variable.
  29192. * @param x First float in float4.
  29193. * @param y Second float in float4.
  29194. * @param z Third float in float4.
  29195. * @param w Fourth float in float4.
  29196. * @returns this effect.
  29197. */
  29198. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  29199. /**
  29200. * Sets a Color3 on a uniform variable.
  29201. * @param uniformName Name of the variable.
  29202. * @param color3 Value to be set.
  29203. */
  29204. setColor3(uniformName: string, color3: IColor3Like): void;
  29205. /**
  29206. * Sets a Color4 on a uniform variable.
  29207. * @param uniformName Name of the variable.
  29208. * @param color3 Value to be set.
  29209. * @param alpha Alpha value to be set.
  29210. */
  29211. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  29212. /**
  29213. * Sets a Color4 on a uniform variable
  29214. * @param uniformName defines the name of the variable
  29215. * @param color4 defines the value to be set
  29216. */
  29217. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  29218. }
  29219. }
  29220. declare module BABYLON {
  29221. /** @hidden */
  29222. export class WebGLDataBuffer extends DataBuffer {
  29223. private _buffer;
  29224. constructor(resource: WebGLBuffer);
  29225. readonly underlyingResource: any;
  29226. }
  29227. }
  29228. declare module BABYLON {
  29229. /** @hidden */
  29230. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29231. attributeProcessor(attribute: string): string;
  29232. varyingProcessor(varying: string, isFragment: boolean): string;
  29233. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29234. }
  29235. }
  29236. declare module BABYLON {
  29237. /**
  29238. * This class is used to track a performance counter which is number based.
  29239. * The user has access to many properties which give statistics of different nature.
  29240. *
  29241. * The implementer can track two kinds of Performance Counter: time and count.
  29242. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  29243. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  29244. */
  29245. export class PerfCounter {
  29246. /**
  29247. * Gets or sets a global boolean to turn on and off all the counters
  29248. */
  29249. static Enabled: boolean;
  29250. /**
  29251. * Returns the smallest value ever
  29252. */
  29253. readonly min: number;
  29254. /**
  29255. * Returns the biggest value ever
  29256. */
  29257. readonly max: number;
  29258. /**
  29259. * Returns the average value since the performance counter is running
  29260. */
  29261. readonly average: number;
  29262. /**
  29263. * Returns the average value of the last second the counter was monitored
  29264. */
  29265. readonly lastSecAverage: number;
  29266. /**
  29267. * Returns the current value
  29268. */
  29269. readonly current: number;
  29270. /**
  29271. * Gets the accumulated total
  29272. */
  29273. readonly total: number;
  29274. /**
  29275. * Gets the total value count
  29276. */
  29277. readonly count: number;
  29278. /**
  29279. * Creates a new counter
  29280. */
  29281. constructor();
  29282. /**
  29283. * Call this method to start monitoring a new frame.
  29284. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  29285. */
  29286. fetchNewFrame(): void;
  29287. /**
  29288. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29289. * @param newCount the count value to add to the monitored count
  29290. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  29291. */
  29292. addCount(newCount: number, fetchResult: boolean): void;
  29293. /**
  29294. * Start monitoring this performance counter
  29295. */
  29296. beginMonitoring(): void;
  29297. /**
  29298. * Compute the time lapsed since the previous beginMonitoring() call.
  29299. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  29300. */
  29301. endMonitoring(newFrame?: boolean): void;
  29302. private _fetchResult;
  29303. private _startMonitoringTime;
  29304. private _min;
  29305. private _max;
  29306. private _average;
  29307. private _current;
  29308. private _totalValueCount;
  29309. private _totalAccumulated;
  29310. private _lastSecAverage;
  29311. private _lastSecAccumulated;
  29312. private _lastSecTime;
  29313. private _lastSecValueCount;
  29314. }
  29315. }
  29316. declare module BABYLON {
  29317. /**
  29318. * Interface for any object that can request an animation frame
  29319. */
  29320. export interface ICustomAnimationFrameRequester {
  29321. /**
  29322. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29323. */
  29324. renderFunction?: Function;
  29325. /**
  29326. * Called to request the next frame to render to
  29327. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29328. */
  29329. requestAnimationFrame: Function;
  29330. /**
  29331. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29332. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29333. */
  29334. requestID?: number;
  29335. }
  29336. }
  29337. declare module BABYLON {
  29338. /**
  29339. * Settings for finer control over video usage
  29340. */
  29341. export interface VideoTextureSettings {
  29342. /**
  29343. * Applies `autoplay` to video, if specified
  29344. */
  29345. autoPlay?: boolean;
  29346. /**
  29347. * Applies `loop` to video, if specified
  29348. */
  29349. loop?: boolean;
  29350. /**
  29351. * Automatically updates internal texture from video at every frame in the render loop
  29352. */
  29353. autoUpdateTexture: boolean;
  29354. /**
  29355. * Image src displayed during the video loading or until the user interacts with the video.
  29356. */
  29357. poster?: string;
  29358. }
  29359. /**
  29360. * If you want to display a video in your scene, this is the special texture for that.
  29361. * This special texture works similar to other textures, with the exception of a few parameters.
  29362. * @see https://doc.babylonjs.com/how_to/video_texture
  29363. */
  29364. export class VideoTexture extends Texture {
  29365. /**
  29366. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29367. */
  29368. readonly autoUpdateTexture: boolean;
  29369. /**
  29370. * The video instance used by the texture internally
  29371. */
  29372. readonly video: HTMLVideoElement;
  29373. private _onUserActionRequestedObservable;
  29374. /**
  29375. * Event triggerd when a dom action is required by the user to play the video.
  29376. * This happens due to recent changes in browser policies preventing video to auto start.
  29377. */
  29378. readonly onUserActionRequestedObservable: Observable<Texture>;
  29379. private _generateMipMaps;
  29380. private _engine;
  29381. private _stillImageCaptured;
  29382. private _displayingPosterTexture;
  29383. private _settings;
  29384. private _createInternalTextureOnEvent;
  29385. private _frameId;
  29386. /**
  29387. * Creates a video texture.
  29388. * If you want to display a video in your scene, this is the special texture for that.
  29389. * This special texture works similar to other textures, with the exception of a few parameters.
  29390. * @see https://doc.babylonjs.com/how_to/video_texture
  29391. * @param name optional name, will detect from video source, if not defined
  29392. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29393. * @param scene is obviously the current scene.
  29394. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29395. * @param invertY is false by default but can be used to invert video on Y axis
  29396. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29397. * @param settings allows finer control over video usage
  29398. */
  29399. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29400. private _getName;
  29401. private _getVideo;
  29402. private _createInternalTexture;
  29403. private reset;
  29404. /**
  29405. * @hidden Internal method to initiate `update`.
  29406. */ private _rebuild(): void;
  29407. /**
  29408. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29409. */
  29410. update(): void;
  29411. /**
  29412. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29413. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29414. */
  29415. updateTexture(isVisible: boolean): void;
  29416. protected _updateInternalTexture: () => void;
  29417. /**
  29418. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29419. * @param url New url.
  29420. */
  29421. updateURL(url: string): void;
  29422. /**
  29423. * Dispose the texture and release its associated resources.
  29424. */
  29425. dispose(): void;
  29426. /**
  29427. * Creates a video texture straight from a stream.
  29428. * @param scene Define the scene the texture should be created in
  29429. * @param stream Define the stream the texture should be created from
  29430. * @returns The created video texture as a promise
  29431. */
  29432. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29433. /**
  29434. * Creates a video texture straight from your WebCam video feed.
  29435. * @param scene Define the scene the texture should be created in
  29436. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29437. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29438. * @returns The created video texture as a promise
  29439. */
  29440. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29441. minWidth: number;
  29442. maxWidth: number;
  29443. minHeight: number;
  29444. maxHeight: number;
  29445. deviceId: string;
  29446. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29447. /**
  29448. * Creates a video texture straight from your WebCam video feed.
  29449. * @param scene Define the scene the texture should be created in
  29450. * @param onReady Define a callback to triggered once the texture will be ready
  29451. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29452. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29453. */
  29454. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29455. minWidth: number;
  29456. maxWidth: number;
  29457. minHeight: number;
  29458. maxHeight: number;
  29459. deviceId: string;
  29460. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29461. }
  29462. }
  29463. declare module BABYLON {
  29464. /**
  29465. * Defines the interface used by objects containing a viewport (like a camera)
  29466. */
  29467. interface IViewportOwnerLike {
  29468. /**
  29469. * Gets or sets the viewport
  29470. */
  29471. viewport: IViewportLike;
  29472. }
  29473. /**
  29474. * Interface for attribute information associated with buffer instanciation
  29475. */
  29476. export class InstancingAttributeInfo {
  29477. /**
  29478. * Index/offset of the attribute in the vertex shader
  29479. */
  29480. index: number;
  29481. /**
  29482. * size of the attribute, 1, 2, 3 or 4
  29483. */
  29484. attributeSize: number;
  29485. /**
  29486. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29487. * default is FLOAT
  29488. */
  29489. attribyteType: number;
  29490. /**
  29491. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29492. */
  29493. normalized: boolean;
  29494. /**
  29495. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29496. */
  29497. offset: number;
  29498. /**
  29499. * Name of the GLSL attribute, for debugging purpose only
  29500. */
  29501. attributeName: string;
  29502. }
  29503. /**
  29504. * Define options used to create a depth texture
  29505. */
  29506. export class DepthTextureCreationOptions {
  29507. /** Specifies whether or not a stencil should be allocated in the texture */
  29508. generateStencil?: boolean;
  29509. /** Specifies whether or not bilinear filtering is enable on the texture */
  29510. bilinearFiltering?: boolean;
  29511. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29512. comparisonFunction?: number;
  29513. /** Specifies if the created texture is a cube texture */
  29514. isCube?: boolean;
  29515. }
  29516. /**
  29517. * Class used to describe the capabilities of the engine relatively to the current browser
  29518. */
  29519. export class EngineCapabilities {
  29520. /** Maximum textures units per fragment shader */
  29521. maxTexturesImageUnits: number;
  29522. /** Maximum texture units per vertex shader */
  29523. maxVertexTextureImageUnits: number;
  29524. /** Maximum textures units in the entire pipeline */
  29525. maxCombinedTexturesImageUnits: number;
  29526. /** Maximum texture size */
  29527. maxTextureSize: number;
  29528. /** Maximum cube texture size */
  29529. maxCubemapTextureSize: number;
  29530. /** Maximum render texture size */
  29531. maxRenderTextureSize: number;
  29532. /** Maximum number of vertex attributes */
  29533. maxVertexAttribs: number;
  29534. /** Maximum number of varyings */
  29535. maxVaryingVectors: number;
  29536. /** Maximum number of uniforms per vertex shader */
  29537. maxVertexUniformVectors: number;
  29538. /** Maximum number of uniforms per fragment shader */
  29539. maxFragmentUniformVectors: number;
  29540. /** Defines if standard derivates (dx/dy) are supported */
  29541. standardDerivatives: boolean;
  29542. /** Defines if s3tc texture compression is supported */
  29543. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29544. /** Defines if pvrtc texture compression is supported */
  29545. pvrtc: any;
  29546. /** Defines if etc1 texture compression is supported */
  29547. etc1: any;
  29548. /** Defines if etc2 texture compression is supported */
  29549. etc2: any;
  29550. /** Defines if astc texture compression is supported */
  29551. astc: any;
  29552. /** Defines if float textures are supported */
  29553. textureFloat: boolean;
  29554. /** Defines if vertex array objects are supported */
  29555. vertexArrayObject: boolean;
  29556. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29557. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29558. /** Gets the maximum level of anisotropy supported */
  29559. maxAnisotropy: number;
  29560. /** Defines if instancing is supported */
  29561. instancedArrays: boolean;
  29562. /** Defines if 32 bits indices are supported */
  29563. uintIndices: boolean;
  29564. /** Defines if high precision shaders are supported */
  29565. highPrecisionShaderSupported: boolean;
  29566. /** Defines if depth reading in the fragment shader is supported */
  29567. fragmentDepthSupported: boolean;
  29568. /** Defines if float texture linear filtering is supported*/
  29569. textureFloatLinearFiltering: boolean;
  29570. /** Defines if rendering to float textures is supported */
  29571. textureFloatRender: boolean;
  29572. /** Defines if half float textures are supported*/
  29573. textureHalfFloat: boolean;
  29574. /** Defines if half float texture linear filtering is supported*/
  29575. textureHalfFloatLinearFiltering: boolean;
  29576. /** Defines if rendering to half float textures is supported */
  29577. textureHalfFloatRender: boolean;
  29578. /** Defines if textureLOD shader command is supported */
  29579. textureLOD: boolean;
  29580. /** Defines if draw buffers extension is supported */
  29581. drawBuffersExtension: boolean;
  29582. /** Defines if depth textures are supported */
  29583. depthTextureExtension: boolean;
  29584. /** Defines if float color buffer are supported */
  29585. colorBufferFloat: boolean;
  29586. /** Gets disjoint timer query extension (null if not supported) */
  29587. timerQuery: EXT_disjoint_timer_query;
  29588. /** Defines if timestamp can be used with timer query */
  29589. canUseTimestampForTimerQuery: boolean;
  29590. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29591. multiview: any;
  29592. /** Function used to let the system compiles shaders in background */
  29593. parallelShaderCompile: {
  29594. COMPLETION_STATUS_KHR: number;
  29595. };
  29596. /** Max number of texture samples for MSAA */
  29597. maxMSAASamples: number;
  29598. }
  29599. /** Interface defining initialization parameters for Engine class */
  29600. export interface EngineOptions extends WebGLContextAttributes {
  29601. /**
  29602. * Defines if the engine should no exceed a specified device ratio
  29603. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29604. */
  29605. limitDeviceRatio?: number;
  29606. /**
  29607. * Defines if webvr should be enabled automatically
  29608. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29609. */
  29610. autoEnableWebVR?: boolean;
  29611. /**
  29612. * Defines if webgl2 should be turned off even if supported
  29613. * @see http://doc.babylonjs.com/features/webgl2
  29614. */
  29615. disableWebGL2Support?: boolean;
  29616. /**
  29617. * Defines if webaudio should be initialized as well
  29618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29619. */
  29620. audioEngine?: boolean;
  29621. /**
  29622. * Defines if animations should run using a deterministic lock step
  29623. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29624. */
  29625. deterministicLockstep?: boolean;
  29626. /** Defines the maximum steps to use with deterministic lock step mode */
  29627. lockstepMaxSteps?: number;
  29628. /**
  29629. * Defines that engine should ignore context lost events
  29630. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29631. */
  29632. doNotHandleContextLost?: boolean;
  29633. /**
  29634. * Defines that engine should ignore modifying touch action attribute and style
  29635. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29636. */
  29637. doNotHandleTouchAction?: boolean;
  29638. /**
  29639. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29640. */
  29641. useHighPrecisionFloats?: boolean;
  29642. }
  29643. /**
  29644. * Defines the interface used by display changed events
  29645. */
  29646. export interface IDisplayChangedEventArgs {
  29647. /** Gets the vrDisplay object (if any) */
  29648. vrDisplay: Nullable<any>;
  29649. /** Gets a boolean indicating if webVR is supported */
  29650. vrSupported: boolean;
  29651. }
  29652. /**
  29653. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29654. */
  29655. export class Engine {
  29656. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29657. static ExceptionList: ({
  29658. key: string;
  29659. capture: string;
  29660. captureConstraint: number;
  29661. targets: string[];
  29662. } | {
  29663. key: string;
  29664. capture: null;
  29665. captureConstraint: null;
  29666. targets: string[];
  29667. })[];
  29668. /** Gets the list of created engines */
  29669. static readonly Instances: Engine[];
  29670. /**
  29671. * Gets the latest created engine
  29672. */
  29673. static readonly LastCreatedEngine: Nullable<Engine>;
  29674. /**
  29675. * Gets the latest created scene
  29676. */
  29677. static readonly LastCreatedScene: Nullable<Scene>;
  29678. /**
  29679. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29680. * @param flag defines which part of the materials must be marked as dirty
  29681. * @param predicate defines a predicate used to filter which materials should be affected
  29682. */
  29683. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29684. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  29685. /** Defines that alpha blending is disabled */
  29686. static readonly ALPHA_DISABLE: number;
  29687. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29688. static readonly ALPHA_ADD: number;
  29689. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29690. static readonly ALPHA_COMBINE: number;
  29691. /** Defines that alpha blending to DEST - SRC * DEST */
  29692. static readonly ALPHA_SUBTRACT: number;
  29693. /** Defines that alpha blending to SRC * DEST */
  29694. static readonly ALPHA_MULTIPLY: number;
  29695. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29696. static readonly ALPHA_MAXIMIZED: number;
  29697. /** Defines that alpha blending to SRC + DEST */
  29698. static readonly ALPHA_ONEONE: number;
  29699. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29700. static readonly ALPHA_PREMULTIPLIED: number;
  29701. /**
  29702. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29703. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29704. */
  29705. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29706. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29707. static readonly ALPHA_INTERPOLATE: number;
  29708. /**
  29709. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29710. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29711. */
  29712. static readonly ALPHA_SCREENMODE: number;
  29713. /** Defines that the ressource is not delayed*/
  29714. static readonly DELAYLOADSTATE_NONE: number;
  29715. /** Defines that the ressource was successfully delay loaded */
  29716. static readonly DELAYLOADSTATE_LOADED: number;
  29717. /** Defines that the ressource is currently delay loading */
  29718. static readonly DELAYLOADSTATE_LOADING: number;
  29719. /** Defines that the ressource is delayed and has not started loading */
  29720. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29721. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29722. static readonly NEVER: number;
  29723. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  29724. static readonly ALWAYS: number;
  29725. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29726. static readonly LESS: number;
  29727. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29728. static readonly EQUAL: number;
  29729. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  29730. static readonly LEQUAL: number;
  29731. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29732. static readonly GREATER: number;
  29733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  29734. static readonly GEQUAL: number;
  29735. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  29736. static readonly NOTEQUAL: number;
  29737. /** Passed to stencilOperation to specify that stencil value must be kept */
  29738. static readonly KEEP: number;
  29739. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29740. static readonly REPLACE: number;
  29741. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29742. static readonly INCR: number;
  29743. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29744. static readonly DECR: number;
  29745. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29746. static readonly INVERT: number;
  29747. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29748. static readonly INCR_WRAP: number;
  29749. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29750. static readonly DECR_WRAP: number;
  29751. /** Texture is not repeating outside of 0..1 UVs */
  29752. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29753. /** Texture is repeating outside of 0..1 UVs */
  29754. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29755. /** Texture is repeating and mirrored */
  29756. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29757. /** ALPHA */
  29758. static readonly TEXTUREFORMAT_ALPHA: number;
  29759. /** LUMINANCE */
  29760. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29761. /** LUMINANCE_ALPHA */
  29762. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29763. /** RGB */
  29764. static readonly TEXTUREFORMAT_RGB: number;
  29765. /** RGBA */
  29766. static readonly TEXTUREFORMAT_RGBA: number;
  29767. /** RED */
  29768. static readonly TEXTUREFORMAT_RED: number;
  29769. /** RED (2nd reference) */
  29770. static readonly TEXTUREFORMAT_R: number;
  29771. /** RG */
  29772. static readonly TEXTUREFORMAT_RG: number;
  29773. /** RED_INTEGER */
  29774. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29775. /** RED_INTEGER (2nd reference) */
  29776. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29777. /** RG_INTEGER */
  29778. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29779. /** RGB_INTEGER */
  29780. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29781. /** RGBA_INTEGER */
  29782. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29783. /** UNSIGNED_BYTE */
  29784. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29785. /** UNSIGNED_BYTE (2nd reference) */
  29786. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29787. /** FLOAT */
  29788. static readonly TEXTURETYPE_FLOAT: number;
  29789. /** HALF_FLOAT */
  29790. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29791. /** BYTE */
  29792. static readonly TEXTURETYPE_BYTE: number;
  29793. /** SHORT */
  29794. static readonly TEXTURETYPE_SHORT: number;
  29795. /** UNSIGNED_SHORT */
  29796. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29797. /** INT */
  29798. static readonly TEXTURETYPE_INT: number;
  29799. /** UNSIGNED_INT */
  29800. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29801. /** UNSIGNED_SHORT_4_4_4_4 */
  29802. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29803. /** UNSIGNED_SHORT_5_5_5_1 */
  29804. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29805. /** UNSIGNED_SHORT_5_6_5 */
  29806. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29807. /** UNSIGNED_INT_2_10_10_10_REV */
  29808. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29809. /** UNSIGNED_INT_24_8 */
  29810. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29811. /** UNSIGNED_INT_10F_11F_11F_REV */
  29812. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29813. /** UNSIGNED_INT_5_9_9_9_REV */
  29814. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29815. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29816. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29817. /** nearest is mag = nearest and min = nearest and mip = linear */
  29818. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29819. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29820. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29821. /** Trilinear is mag = linear and min = linear and mip = linear */
  29822. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29823. /** nearest is mag = nearest and min = nearest and mip = linear */
  29824. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29825. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29826. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29827. /** Trilinear is mag = linear and min = linear and mip = linear */
  29828. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29829. /** mag = nearest and min = nearest and mip = nearest */
  29830. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29831. /** mag = nearest and min = linear and mip = nearest */
  29832. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29833. /** mag = nearest and min = linear and mip = linear */
  29834. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29835. /** mag = nearest and min = linear and mip = none */
  29836. static readonly TEXTURE_NEAREST_LINEAR: number;
  29837. /** mag = nearest and min = nearest and mip = none */
  29838. static readonly TEXTURE_NEAREST_NEAREST: number;
  29839. /** mag = linear and min = nearest and mip = nearest */
  29840. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29841. /** mag = linear and min = nearest and mip = linear */
  29842. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29843. /** mag = linear and min = linear and mip = none */
  29844. static readonly TEXTURE_LINEAR_LINEAR: number;
  29845. /** mag = linear and min = nearest and mip = none */
  29846. static readonly TEXTURE_LINEAR_NEAREST: number;
  29847. /** Explicit coordinates mode */
  29848. static readonly TEXTURE_EXPLICIT_MODE: number;
  29849. /** Spherical coordinates mode */
  29850. static readonly TEXTURE_SPHERICAL_MODE: number;
  29851. /** Planar coordinates mode */
  29852. static readonly TEXTURE_PLANAR_MODE: number;
  29853. /** Cubic coordinates mode */
  29854. static readonly TEXTURE_CUBIC_MODE: number;
  29855. /** Projection coordinates mode */
  29856. static readonly TEXTURE_PROJECTION_MODE: number;
  29857. /** Skybox coordinates mode */
  29858. static readonly TEXTURE_SKYBOX_MODE: number;
  29859. /** Inverse Cubic coordinates mode */
  29860. static readonly TEXTURE_INVCUBIC_MODE: number;
  29861. /** Equirectangular coordinates mode */
  29862. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29863. /** Equirectangular Fixed coordinates mode */
  29864. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29865. /** Equirectangular Fixed Mirrored coordinates mode */
  29866. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29867. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29868. static readonly SCALEMODE_FLOOR: number;
  29869. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29870. static readonly SCALEMODE_NEAREST: number;
  29871. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29872. static readonly SCALEMODE_CEILING: number;
  29873. /**
  29874. * Returns the current npm package of the sdk
  29875. */
  29876. static readonly NpmPackage: string;
  29877. /**
  29878. * Returns the current version of the framework
  29879. */
  29880. static readonly Version: string;
  29881. /**
  29882. * Returns a string describing the current engine
  29883. */
  29884. readonly description: string;
  29885. /**
  29886. * Gets or sets the epsilon value used by collision engine
  29887. */
  29888. static CollisionsEpsilon: number;
  29889. /**
  29890. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29891. */
  29892. static ShadersRepository: string;
  29893. /**
  29894. * Method called to create the default loading screen.
  29895. * This can be overriden in your own app.
  29896. * @param canvas The rendering canvas element
  29897. * @returns The loading screen
  29898. */
  29899. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29900. /**
  29901. * Method called to create the default rescale post process on each engine.
  29902. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29903. /** @hidden */ private _shaderProcessor: Nullable<IShaderProcessor>;
  29904. /**
  29905. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29906. */
  29907. forcePOTTextures: boolean;
  29908. /**
  29909. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29910. */
  29911. isFullscreen: boolean;
  29912. /**
  29913. * Gets a boolean indicating if the pointer is currently locked
  29914. */
  29915. isPointerLock: boolean;
  29916. /**
  29917. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29918. */
  29919. cullBackFaces: boolean;
  29920. /**
  29921. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29922. */
  29923. renderEvenInBackground: boolean;
  29924. /**
  29925. * Gets or sets a boolean indicating that cache can be kept between frames
  29926. */
  29927. preventCacheWipeBetweenFrames: boolean;
  29928. /**
  29929. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29930. **/
  29931. enableOfflineSupport: boolean;
  29932. /**
  29933. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  29934. **/
  29935. disableManifestCheck: boolean;
  29936. /**
  29937. * Gets the list of created scenes
  29938. */
  29939. scenes: Scene[];
  29940. /**
  29941. * Event raised when a new scene is created
  29942. */
  29943. onNewSceneAddedObservable: Observable<Scene>;
  29944. /**
  29945. * Gets the list of created postprocesses
  29946. */
  29947. postProcesses: PostProcess[];
  29948. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29949. validateShaderPrograms: boolean;
  29950. /**
  29951. * Observable event triggered each time the rendering canvas is resized
  29952. */
  29953. onResizeObservable: Observable<Engine>;
  29954. /**
  29955. * Observable event triggered each time the canvas loses focus
  29956. */
  29957. onCanvasBlurObservable: Observable<Engine>;
  29958. /**
  29959. * Observable event triggered each time the canvas gains focus
  29960. */
  29961. onCanvasFocusObservable: Observable<Engine>;
  29962. /**
  29963. * Observable event triggered each time the canvas receives pointerout event
  29964. */
  29965. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29966. /**
  29967. * Observable event triggered before each texture is initialized
  29968. */
  29969. onBeforeTextureInitObservable: Observable<Texture>;
  29970. /**
  29971. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29972. */
  29973. disableUniformBuffers: boolean;
  29974. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  29975. /**
  29976. * Gets a boolean indicating that the engine supports uniform buffers
  29977. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29978. */
  29979. readonly supportsUniformBuffers: boolean;
  29980. /**
  29981. * Observable raised when the engine begins a new frame
  29982. */
  29983. onBeginFrameObservable: Observable<Engine>;
  29984. /**
  29985. * If set, will be used to request the next animation frame for the render loop
  29986. */
  29987. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29988. /**
  29989. * Observable raised when the engine ends the current frame
  29990. */
  29991. onEndFrameObservable: Observable<Engine>;
  29992. /**
  29993. * Observable raised when the engine is about to compile a shader
  29994. */
  29995. onBeforeShaderCompilationObservable: Observable<Engine>;
  29996. /**
  29997. * Observable raised when the engine has jsut compiled a shader
  29998. */
  29999. onAfterShaderCompilationObservable: Observable<Engine>;
  30000. /** @hidden */ private _gl: WebGLRenderingContext;
  30001. private _renderingCanvas;
  30002. private _windowIsBackground;
  30003. protected _webGLVersion: number;
  30004. protected _highPrecisionShadersAllowed: boolean;
  30005. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  30006. /**
  30007. * Gets a boolean indicating that only power of 2 textures are supported
  30008. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30009. */
  30010. readonly needPOTTextures: boolean;
  30011. /** @hidden */ private _badOS: boolean;
  30012. /** @hidden */ private _badDesktopOS: boolean;
  30013. /**
  30014. * Gets the audio engine
  30015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30016. * @ignorenaming
  30017. */
  30018. static audioEngine: IAudioEngine;
  30019. /**
  30020. * Default AudioEngine factory responsible of creating the Audio Engine.
  30021. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30022. */
  30023. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30024. /**
  30025. * Default offline support factory responsible of creating a tool used to store data locally.
  30026. * By default, this will create a Database object if the workload has been embedded.
  30027. */
  30028. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30029. private _onFocus;
  30030. private _onBlur;
  30031. private _onCanvasPointerOut;
  30032. private _onCanvasBlur;
  30033. private _onCanvasFocus;
  30034. private _onFullscreenChange;
  30035. private _onPointerLockChange;
  30036. protected _hardwareScalingLevel: number;
  30037. /** @hidden */ private _caps: EngineCapabilities;
  30038. private _pointerLockRequested;
  30039. private _isStencilEnable;
  30040. protected _colorWrite: boolean;
  30041. private _loadingScreen;
  30042. /** @hidden */ private _drawCalls: PerfCounter;
  30043. private _glVersion;
  30044. private _glRenderer;
  30045. private _glVendor;
  30046. private _videoTextureSupported;
  30047. private _renderingQueueLaunched;
  30048. private _activeRenderLoops;
  30049. protected _deterministicLockstep: boolean;
  30050. protected _lockstepMaxSteps: number;
  30051. /**
  30052. * Observable signaled when a context lost event is raised
  30053. */
  30054. onContextLostObservable: Observable<Engine>;
  30055. /**
  30056. * Observable signaled when a context restored event is raised
  30057. */
  30058. onContextRestoredObservable: Observable<Engine>;
  30059. private _onContextLost;
  30060. private _onContextRestored;
  30061. private _contextWasLost;
  30062. /** @hidden */ private _doNotHandleContextLost: boolean;
  30063. /**
  30064. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30066. */
  30067. doNotHandleContextLost: boolean;
  30068. private _performanceMonitor;
  30069. private _fps;
  30070. private _deltaTime;
  30071. /**
  30072. * Turn this value on if you want to pause FPS computation when in background
  30073. */
  30074. disablePerformanceMonitorInBackground: boolean;
  30075. /**
  30076. * Gets the performance monitor attached to this engine
  30077. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30078. */
  30079. readonly performanceMonitor: PerformanceMonitor;
  30080. /**
  30081. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30082. */
  30083. disableVertexArrayObjects: boolean;
  30084. /** @hidden */
  30085. protected _depthCullingState: _DepthCullingState;
  30086. /** @hidden */
  30087. protected _stencilState: _StencilState;
  30088. /** @hidden */
  30089. protected _alphaState: _AlphaState;
  30090. /** @hidden */
  30091. protected _alphaMode: number;
  30092. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  30093. /** @hidden */
  30094. protected _activeChannel: number;
  30095. private _currentTextureChannel;
  30096. /** @hidden */
  30097. protected _boundTexturesCache: {
  30098. [key: string]: Nullable<InternalTexture>;
  30099. };
  30100. /** @hidden */
  30101. protected _currentEffect: Nullable<Effect>;
  30102. /** @hidden */
  30103. protected _currentProgram: Nullable<WebGLProgram>;
  30104. private _compiledEffects;
  30105. private _vertexAttribArraysEnabled;
  30106. /** @hidden */
  30107. protected _cachedViewport: Nullable<IViewportLike>;
  30108. private _cachedVertexArrayObject;
  30109. /** @hidden */
  30110. protected _cachedVertexBuffers: any;
  30111. /** @hidden */
  30112. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30113. /** @hidden */
  30114. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30115. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  30116. private _uintIndicesCurrentlySet;
  30117. private _currentBoundBuffer;
  30118. /** @hidden */
  30119. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30120. private _currentBufferPointers;
  30121. private _currentInstanceLocations;
  30122. private _currentInstanceBuffers;
  30123. private _textureUnits;
  30124. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  30125. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  30126. private _rescalePostProcess;
  30127. private _dummyFramebuffer;
  30128. private _externalData;
  30129. /** @hidden */ private _bindedRenderFunction: any;
  30130. private _vaoRecordInProgress;
  30131. private _mustWipeVertexAttributes;
  30132. private _emptyTexture;
  30133. private _emptyCubeTexture;
  30134. private _emptyTexture3D;
  30135. /** @hidden */ private _frameHandler: number;
  30136. private _nextFreeTextureSlots;
  30137. private _maxSimultaneousTextures;
  30138. private _activeRequests;
  30139. private _texturesSupported;
  30140. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  30141. /**
  30142. * Gets the list of texture formats supported
  30143. */
  30144. readonly texturesSupported: Array<string>;
  30145. /**
  30146. * Gets the list of texture formats in use
  30147. */
  30148. readonly textureFormatInUse: Nullable<string>;
  30149. /**
  30150. * Gets the current viewport
  30151. */
  30152. readonly currentViewport: Nullable<IViewportLike>;
  30153. /**
  30154. * Gets the default empty texture
  30155. */
  30156. readonly emptyTexture: InternalTexture;
  30157. /**
  30158. * Gets the default empty 3D texture
  30159. */
  30160. readonly emptyTexture3D: InternalTexture;
  30161. /**
  30162. * Gets the default empty cube texture
  30163. */
  30164. readonly emptyCubeTexture: InternalTexture;
  30165. /**
  30166. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30167. */
  30168. readonly premultipliedAlpha: boolean;
  30169. /** @hidden */
  30170. protected _isWebGPU: boolean;
  30171. /**
  30172. * Gets a boolean indicating if the engine runs in WebGPU or not.
  30173. */
  30174. readonly isWebGPU: boolean;
  30175. /** @hidden */
  30176. protected _shaderPlatformName: string;
  30177. /**
  30178. * Gets the shader platfrom name used by the effects.
  30179. */
  30180. readonly shaderPlatformName: string;
  30181. /**
  30182. * Creates a new engine
  30183. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  30184. * @param antialias defines enable antialiasing (default: false)
  30185. * @param options defines further options to be sent to the getContext() function
  30186. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30187. */
  30188. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30189. /**
  30190. * Shared initialization across engines types.
  30191. * @param canvas The canvas associated with this instance of the engine.
  30192. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  30193. * @param audioEngine Defines if an audio engine should be created by default
  30194. */
  30195. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  30196. /**
  30197. * Gets a shader processor implementation fitting with the current engine type.
  30198. * @returns The shader processor implementation.
  30199. */
  30200. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  30201. /** @hidden */ private _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  30202. /**
  30203. * Initializes a webVR display and starts listening to display change events
  30204. * The onVRDisplayChangedObservable will be notified upon these changes
  30205. * @returns The onVRDisplayChangedObservable
  30206. */
  30207. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30208. /** @hidden */ private _prepareVRComponent(): void;
  30209. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  30210. /** @hidden */ private _submitVRFrame(): void;
  30211. /**
  30212. * Call this function to leave webVR mode
  30213. * Will do nothing if webVR is not supported or if there is no webVR device
  30214. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30215. */
  30216. disableVR(): void;
  30217. /**
  30218. * Gets a boolean indicating that the system is in VR mode and is presenting
  30219. * @returns true if VR mode is engaged
  30220. */
  30221. isVRPresenting(): boolean;
  30222. /** @hidden */ private _requestVRFrame(): void;
  30223. private _disableTouchAction;
  30224. private _rebuildInternalTextures;
  30225. private _rebuildEffects;
  30226. /**
  30227. * Gets a boolean indicating if all created effects are ready
  30228. * @returns true if all effects are ready
  30229. */
  30230. areAllEffectsReady(): boolean;
  30231. private _rebuildBuffers;
  30232. private _initGLContext;
  30233. /**
  30234. * Gets version of the current webGL context
  30235. */
  30236. readonly webGLVersion: number;
  30237. /**
  30238. * Gets a string idenfifying the name of the class
  30239. * @returns "Engine" string
  30240. */
  30241. getClassName(): string;
  30242. /**
  30243. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30244. */
  30245. readonly isStencilEnable: boolean;
  30246. /** @hidden */ private _prepareWorkingCanvas(): void;
  30247. /**
  30248. * Reset the texture cache to empty state
  30249. */
  30250. resetTextureCache(): void;
  30251. /**
  30252. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30253. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30254. * @returns true if engine is in deterministic lock step mode
  30255. */
  30256. isDeterministicLockStep(): boolean;
  30257. /**
  30258. * Gets the max steps when engine is running in deterministic lock step
  30259. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30260. * @returns the max steps
  30261. */
  30262. getLockstepMaxSteps(): number;
  30263. /**
  30264. * Gets an object containing information about the current webGL context
  30265. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30266. */
  30267. getGlInfo(): {
  30268. vendor: string;
  30269. renderer: string;
  30270. version: string;
  30271. };
  30272. /**
  30273. * Gets current aspect ratio
  30274. * @param viewportOwner defines the camera to use to get the aspect ratio
  30275. * @param useScreen defines if screen size must be used (or the current render target if any)
  30276. * @returns a number defining the aspect ratio
  30277. */
  30278. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30279. /**
  30280. * Gets current screen aspect ratio
  30281. * @returns a number defining the aspect ratio
  30282. */
  30283. getScreenAspectRatio(): number;
  30284. /**
  30285. * Gets the current render width
  30286. * @param useScreen defines if screen size must be used (or the current render target if any)
  30287. * @returns a number defining the current render width
  30288. */
  30289. getRenderWidth(useScreen?: boolean): number;
  30290. /**
  30291. * Gets the current render height
  30292. * @param useScreen defines if screen size must be used (or the current render target if any)
  30293. * @returns a number defining the current render height
  30294. */
  30295. getRenderHeight(useScreen?: boolean): number;
  30296. /**
  30297. * Gets the HTML canvas attached with the current webGL context
  30298. * @returns a HTML canvas
  30299. */
  30300. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30301. /**
  30302. * Gets host window
  30303. * @returns the host window object
  30304. */
  30305. getHostWindow(): Window;
  30306. /**
  30307. * Gets host document
  30308. * @returns the host document object
  30309. */
  30310. getHostDocument(): Document;
  30311. /**
  30312. * Gets the client rect of the HTML canvas attached with the current webGL context
  30313. * @returns a client rectanglee
  30314. */
  30315. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30316. /**
  30317. * Defines the hardware scaling level.
  30318. * By default the hardware scaling level is computed from the window device ratio.
  30319. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  30320. * @param level defines the level to use
  30321. */
  30322. setHardwareScalingLevel(level: number): void;
  30323. /**
  30324. * Gets the current hardware scaling level.
  30325. * By default the hardware scaling level is computed from the window device ratio.
  30326. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  30327. * @returns a number indicating the current hardware scaling level
  30328. */
  30329. getHardwareScalingLevel(): number;
  30330. /**
  30331. * Gets the list of loaded textures
  30332. * @returns an array containing all loaded textures
  30333. */
  30334. getLoadedTexturesCache(): InternalTexture[];
  30335. /**
  30336. * Gets the object containing all engine capabilities
  30337. * @returns the EngineCapabilities object
  30338. */
  30339. getCaps(): EngineCapabilities;
  30340. /**
  30341. * Gets the current depth function
  30342. * @returns a number defining the depth function
  30343. */
  30344. getDepthFunction(): Nullable<number>;
  30345. /**
  30346. * Sets the current depth function
  30347. * @param depthFunc defines the function to use
  30348. */
  30349. setDepthFunction(depthFunc: number): void;
  30350. /**
  30351. * Sets the current depth function to GREATER
  30352. */
  30353. setDepthFunctionToGreater(): void;
  30354. /**
  30355. * Sets the current depth function to GEQUAL
  30356. */
  30357. setDepthFunctionToGreaterOrEqual(): void;
  30358. /**
  30359. * Sets the current depth function to LESS
  30360. */
  30361. setDepthFunctionToLess(): void;
  30362. private _cachedStencilBuffer;
  30363. private _cachedStencilFunction;
  30364. private _cachedStencilMask;
  30365. private _cachedStencilOperationPass;
  30366. private _cachedStencilOperationFail;
  30367. private _cachedStencilOperationDepthFail;
  30368. private _cachedStencilReference;
  30369. /**
  30370. * Caches the the state of the stencil buffer
  30371. */
  30372. cacheStencilState(): void;
  30373. /**
  30374. * Restores the state of the stencil buffer
  30375. */
  30376. restoreStencilState(): void;
  30377. /**
  30378. * Sets the current depth function to LEQUAL
  30379. */
  30380. setDepthFunctionToLessOrEqual(): void;
  30381. /**
  30382. * Gets a boolean indicating if stencil buffer is enabled
  30383. * @returns the current stencil buffer state
  30384. */
  30385. getStencilBuffer(): boolean;
  30386. /**
  30387. * Enable or disable the stencil buffer
  30388. * @param enable defines if the stencil buffer must be enabled or disabled
  30389. */
  30390. setStencilBuffer(enable: boolean): void;
  30391. /**
  30392. * Gets the current stencil mask
  30393. * @returns a number defining the new stencil mask to use
  30394. */
  30395. getStencilMask(): number;
  30396. /**
  30397. * Sets the current stencil mask
  30398. * @param mask defines the new stencil mask to use
  30399. */
  30400. setStencilMask(mask: number): void;
  30401. /**
  30402. * Gets the current stencil function
  30403. * @returns a number defining the stencil function to use
  30404. */
  30405. getStencilFunction(): number;
  30406. /**
  30407. * Gets the current stencil reference value
  30408. * @returns a number defining the stencil reference value to use
  30409. */
  30410. getStencilFunctionReference(): number;
  30411. /**
  30412. * Gets the current stencil mask
  30413. * @returns a number defining the stencil mask to use
  30414. */
  30415. getStencilFunctionMask(): number;
  30416. /**
  30417. * Sets the current stencil function
  30418. * @param stencilFunc defines the new stencil function to use
  30419. */
  30420. setStencilFunction(stencilFunc: number): void;
  30421. /**
  30422. * Sets the current stencil reference
  30423. * @param reference defines the new stencil reference to use
  30424. */
  30425. setStencilFunctionReference(reference: number): void;
  30426. /**
  30427. * Sets the current stencil mask
  30428. * @param mask defines the new stencil mask to use
  30429. */
  30430. setStencilFunctionMask(mask: number): void;
  30431. /**
  30432. * Gets the current stencil operation when stencil fails
  30433. * @returns a number defining stencil operation to use when stencil fails
  30434. */
  30435. getStencilOperationFail(): number;
  30436. /**
  30437. * Gets the current stencil operation when depth fails
  30438. * @returns a number defining stencil operation to use when depth fails
  30439. */
  30440. getStencilOperationDepthFail(): number;
  30441. /**
  30442. * Gets the current stencil operation when stencil passes
  30443. * @returns a number defining stencil operation to use when stencil passes
  30444. */
  30445. getStencilOperationPass(): number;
  30446. /**
  30447. * Sets the stencil operation to use when stencil fails
  30448. * @param operation defines the stencil operation to use when stencil fails
  30449. */
  30450. setStencilOperationFail(operation: number): void;
  30451. /**
  30452. * Sets the stencil operation to use when depth fails
  30453. * @param operation defines the stencil operation to use when depth fails
  30454. */
  30455. setStencilOperationDepthFail(operation: number): void;
  30456. /**
  30457. * Sets the stencil operation to use when stencil passes
  30458. * @param operation defines the stencil operation to use when stencil passes
  30459. */
  30460. setStencilOperationPass(operation: number): void;
  30461. /**
  30462. * Sets a boolean indicating if the dithering state is enabled or disabled
  30463. * @param value defines the dithering state
  30464. */
  30465. setDitheringState(value: boolean): void;
  30466. /**
  30467. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30468. * @param value defines the rasterizer state
  30469. */
  30470. setRasterizerState(value: boolean): void;
  30471. /**
  30472. * stop executing a render loop function and remove it from the execution array
  30473. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30474. */
  30475. stopRenderLoop(renderFunction?: () => void): void;
  30476. /** @hidden */ private _renderLoop(): void;
  30477. /**
  30478. * Can be used to override the current requestAnimationFrame requester.
  30479. * @hidden
  30480. */
  30481. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30482. /**
  30483. * Register and execute a render loop. The engine can have more than one render function
  30484. * @param renderFunction defines the function to continuously execute
  30485. */
  30486. runRenderLoop(renderFunction: () => void): void;
  30487. /**
  30488. * Toggle full screen mode
  30489. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30490. */
  30491. switchFullscreen(requestPointerLock: boolean): void;
  30492. /**
  30493. * Enters full screen mode
  30494. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30495. */
  30496. enterFullscreen(requestPointerLock: boolean): void;
  30497. /**
  30498. * Exits full screen mode
  30499. */
  30500. exitFullscreen(): void;
  30501. /**
  30502. * Enters Pointerlock mode
  30503. */
  30504. enterPointerlock(): void;
  30505. /**
  30506. * Exits Pointerlock mode
  30507. */
  30508. exitPointerlock(): void;
  30509. /**
  30510. * Clear the current render buffer or the current render target (if any is set up)
  30511. * @param color defines the color to use
  30512. * @param backBuffer defines if the back buffer must be cleared
  30513. * @param depth defines if the depth buffer must be cleared
  30514. * @param stencil defines if the stencil buffer must be cleared
  30515. */
  30516. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30517. /**
  30518. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30519. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30520. * @param y defines the y-coordinate of the corner of the clear rectangle
  30521. * @param width defines the width of the clear rectangle
  30522. * @param height defines the height of the clear rectangle
  30523. * @param clearColor defines the clear color
  30524. */
  30525. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30526. /**
  30527. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30528. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30529. * @param y defines the y-coordinate of the corner of the clear rectangle
  30530. * @param width defines the width of the clear rectangle
  30531. * @param height defines the height of the clear rectangle
  30532. */
  30533. enableScissor(x: number, y: number, width: number, height: number): void;
  30534. /**
  30535. * Disable previously set scissor test rectangle
  30536. */
  30537. disableScissor(): void;
  30538. private _viewportCached;
  30539. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  30540. /**
  30541. * Set the WebGL's viewport
  30542. * @param viewport defines the viewport element to be used
  30543. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30544. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30545. */
  30546. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30547. /**
  30548. * Directly set the WebGL Viewport
  30549. * @param x defines the x coordinate of the viewport (in screen space)
  30550. * @param y defines the y coordinate of the viewport (in screen space)
  30551. * @param width defines the width of the viewport (in screen space)
  30552. * @param height defines the height of the viewport (in screen space)
  30553. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  30554. */
  30555. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30556. /**
  30557. * Begin a new frame
  30558. */
  30559. beginFrame(): void;
  30560. /**
  30561. * Enf the current frame
  30562. */
  30563. endFrame(): void;
  30564. /**
  30565. * Resize the view according to the canvas' size
  30566. */
  30567. resize(): void;
  30568. /**
  30569. * Force a specific size of the canvas
  30570. * @param width defines the new canvas' width
  30571. * @param height defines the new canvas' height
  30572. */
  30573. setSize(width: number, height: number): void;
  30574. /**
  30575. * Binds the frame buffer to the specified texture.
  30576. * @param texture The texture to render to or null for the default canvas
  30577. * @param faceIndex The face of the texture to render to in case of cube texture
  30578. * @param requiredWidth The width of the target to render to
  30579. * @param requiredHeight The height of the target to render to
  30580. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30581. * @param depthStencilTexture The depth stencil texture to use to render
  30582. * @param lodLevel defines le lod level to bind to the frame buffer
  30583. */
  30584. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30585. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30586. /**
  30587. * Unbind the current render target texture from the webGL context
  30588. * @param texture defines the render target texture to unbind
  30589. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30590. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30591. */
  30592. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30593. /**
  30594. * Force the mipmap generation for the given render target texture
  30595. * @param texture defines the render target texture to use
  30596. */
  30597. generateMipMapsForCubemap(texture: InternalTexture): void;
  30598. /**
  30599. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30600. */
  30601. flushFramebuffer(): void;
  30602. /**
  30603. * Unbind the current render target and bind the default framebuffer
  30604. */
  30605. restoreDefaultFramebuffer(): void;
  30606. /**
  30607. * Create an uniform buffer
  30608. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30609. * @param elements defines the content of the uniform buffer
  30610. * @returns the webGL uniform buffer
  30611. */
  30612. createUniformBuffer(elements: FloatArray): DataBuffer;
  30613. /**
  30614. * Create a dynamic uniform buffer
  30615. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30616. * @param elements defines the content of the uniform buffer
  30617. * @returns the webGL uniform buffer
  30618. */
  30619. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30620. /**
  30621. * Update an existing uniform buffer
  30622. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30623. * @param uniformBuffer defines the target uniform buffer
  30624. * @param elements defines the content to update
  30625. * @param offset defines the offset in the uniform buffer where update should start
  30626. * @param count defines the size of the data to update
  30627. */
  30628. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30629. private _resetVertexBufferBinding;
  30630. /**
  30631. * Creates a vertex buffer
  30632. * @param data the data for the vertex buffer
  30633. * @returns the new WebGL static buffer
  30634. */
  30635. createVertexBuffer(data: DataArray): DataBuffer;
  30636. /**
  30637. * Creates a dynamic vertex buffer
  30638. * @param data the data for the dynamic vertex buffer
  30639. * @returns the new WebGL dynamic buffer
  30640. */
  30641. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30642. /**
  30643. * Update a dynamic index buffer
  30644. * @param indexBuffer defines the target index buffer
  30645. * @param indices defines the data to update
  30646. * @param offset defines the offset in the target index buffer where update should start
  30647. */
  30648. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30649. /**
  30650. * Updates a dynamic vertex buffer.
  30651. * @param vertexBuffer the vertex buffer to update
  30652. * @param data the data used to update the vertex buffer
  30653. * @param byteOffset the byte offset of the data
  30654. * @param byteLength the byte length of the data
  30655. */
  30656. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30657. private _resetIndexBufferBinding;
  30658. /**
  30659. * Creates a new index buffer
  30660. * @param indices defines the content of the index buffer
  30661. * @param updatable defines if the index buffer must be updatable
  30662. * @returns a new webGL buffer
  30663. */
  30664. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30665. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30666. /**
  30667. * Bind a webGL buffer to the webGL context
  30668. * @param buffer defines the buffer to bind
  30669. */
  30670. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30671. /**
  30672. * Bind an uniform buffer to the current webGL context
  30673. * @param buffer defines the buffer to bind
  30674. */
  30675. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30676. /**
  30677. * Bind a buffer to the current webGL context at a given location
  30678. * @param buffer defines the buffer to bind
  30679. * @param location defines the index where to bind the buffer
  30680. * @param name Name of the uniform variable to bind
  30681. */
  30682. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  30683. /**
  30684. * Bind a specific block at a given index in a specific shader program
  30685. * @param pipelineContext defines the pipeline context to use
  30686. * @param blockName defines the block name
  30687. * @param index defines the index where to bind the block
  30688. */
  30689. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30690. private bindIndexBuffer;
  30691. private bindBuffer;
  30692. /**
  30693. * update the bound buffer with the given data
  30694. * @param data defines the data to update
  30695. */
  30696. updateArrayBuffer(data: Float32Array): void;
  30697. private _vertexAttribPointer;
  30698. private _bindIndexBufferWithCache;
  30699. private _bindVertexBuffersAttributes;
  30700. /**
  30701. * Records a vertex array object
  30702. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30703. * @param vertexBuffers defines the list of vertex buffers to store
  30704. * @param indexBuffer defines the index buffer to store
  30705. * @param effect defines the effect to store
  30706. * @returns the new vertex array object
  30707. */
  30708. recordVertexArrayObject(vertexBuffers: {
  30709. [key: string]: VertexBuffer;
  30710. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30711. /**
  30712. * Bind a specific vertex array object
  30713. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30714. * @param vertexArrayObject defines the vertex array object to bind
  30715. * @param indexBuffer defines the index buffer to bind
  30716. */
  30717. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30718. /**
  30719. * Bind webGl buffers directly to the webGL context
  30720. * @param vertexBuffer defines the vertex buffer to bind
  30721. * @param indexBuffer defines the index buffer to bind
  30722. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30723. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30724. * @param effect defines the effect associated with the vertex buffer
  30725. */
  30726. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30727. private _unbindVertexArrayObject;
  30728. /**
  30729. * Bind a list of vertex buffers to the webGL context
  30730. * @param vertexBuffers defines the list of vertex buffers to bind
  30731. * @param indexBuffer defines the index buffer to bind
  30732. * @param effect defines the effect associated with the vertex buffers
  30733. */
  30734. bindBuffers(vertexBuffers: {
  30735. [key: string]: Nullable<VertexBuffer>;
  30736. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30737. /**
  30738. * Unbind all instance attributes
  30739. */
  30740. unbindInstanceAttributes(): void;
  30741. /**
  30742. * Release and free the memory of a vertex array object
  30743. * @param vao defines the vertex array object to delete
  30744. */
  30745. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30746. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  30747. protected _deleteBuffer(buffer: DataBuffer): void;
  30748. /**
  30749. * Creates a webGL buffer to use with instanciation
  30750. * @param capacity defines the size of the buffer
  30751. * @returns the webGL buffer
  30752. */
  30753. createInstancesBuffer(capacity: number): DataBuffer;
  30754. /**
  30755. * Delete a webGL buffer used with instanciation
  30756. * @param buffer defines the webGL buffer to delete
  30757. */
  30758. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30759. /**
  30760. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30761. * @param instancesBuffer defines the webGL buffer to update and bind
  30762. * @param data defines the data to store in the buffer
  30763. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30764. */
  30765. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30766. /**
  30767. * Apply all cached states (depth, culling, stencil and alpha)
  30768. */
  30769. applyStates(): void;
  30770. /**
  30771. * Send a draw order
  30772. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30773. * @param indexStart defines the starting index
  30774. * @param indexCount defines the number of index to draw
  30775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30776. */
  30777. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30778. /**
  30779. * Draw a list of points
  30780. * @param verticesStart defines the index of first vertex to draw
  30781. * @param verticesCount defines the count of vertices to draw
  30782. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30783. */
  30784. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30785. /**
  30786. * Draw a list of unindexed primitives
  30787. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30788. * @param verticesStart defines the index of first vertex to draw
  30789. * @param verticesCount defines the count of vertices to draw
  30790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30791. */
  30792. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30793. /**
  30794. * Draw a list of indexed primitives
  30795. * @param fillMode defines the primitive to use
  30796. * @param indexStart defines the starting index
  30797. * @param indexCount defines the number of index to draw
  30798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30799. */
  30800. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30801. /**
  30802. * Draw a list of unindexed primitives
  30803. * @param fillMode defines the primitive to use
  30804. * @param verticesStart defines the index of first vertex to draw
  30805. * @param verticesCount defines the count of vertices to draw
  30806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30807. */
  30808. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30809. private _drawMode;
  30810. /** @hidden */ private _releaseEffect(effect: Effect): void;
  30811. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30812. /**
  30813. * Create a new effect (used to store vertex/fragment shaders)
  30814. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30815. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30816. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30817. * @param samplers defines an array of string used to represent textures
  30818. * @param defines defines the string containing the defines to use to compile the shaders
  30819. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30820. * @param onCompiled defines a function to call when the effect creation is successful
  30821. * @param onError defines a function to call when the effect creation has failed
  30822. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30823. * @returns the new Effect
  30824. */
  30825. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30826. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30827. private _compileShader;
  30828. private _compileRawShader;
  30829. /**
  30830. * Directly creates a webGL program
  30831. * @param pipelineContext defines the pipeline context to attach to
  30832. * @param vertexCode defines the vertex shader code to use
  30833. * @param fragmentCode defines the fragment shader code to use
  30834. * @param context defines the webGL context to use (if not set, the current one will be used)
  30835. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30836. * @returns the new webGL program
  30837. */
  30838. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30839. /**
  30840. * Creates a webGL program
  30841. * @param pipelineContext defines the pipeline context to attach to
  30842. * @param vertexCode defines the vertex shader code to use
  30843. * @param fragmentCode defines the fragment shader code to use
  30844. * @param defines defines the string containing the defines to use to compile the shaders
  30845. * @param context defines the webGL context to use (if not set, the current one will be used)
  30846. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30847. * @returns the new webGL program
  30848. */
  30849. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30850. /**
  30851. * Creates a new pipeline context
  30852. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  30853. * @returns the new pipeline
  30854. */
  30855. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  30856. private _createShaderProgram;
  30857. private _finalizePipelineContext;
  30858. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  30859. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30860. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30861. /**
  30862. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30863. * @param pipelineContext defines the pipeline context to use
  30864. * @param uniformsNames defines the list of uniform names
  30865. * @returns an array of webGL uniform locations
  30866. */
  30867. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30868. /**
  30869. * Gets the lsit of active attributes for a given webGL program
  30870. * @param pipelineContext defines the pipeline context to use
  30871. * @param attributesNames defines the list of attribute names to get
  30872. * @returns an array of indices indicating the offset of each attribute
  30873. */
  30874. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30875. /**
  30876. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30877. * @param effect defines the effect to activate
  30878. */
  30879. enableEffect(effect: Nullable<Effect>): void;
  30880. /**
  30881. * Set the value of an uniform to an array of int32
  30882. * @param uniform defines the webGL uniform location where to store the value
  30883. * @param array defines the array of int32 to store
  30884. */
  30885. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30886. /**
  30887. * Set the value of an uniform to an array of int32 (stored as vec2)
  30888. * @param uniform defines the webGL uniform location where to store the value
  30889. * @param array defines the array of int32 to store
  30890. */
  30891. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30892. /**
  30893. * Set the value of an uniform to an array of int32 (stored as vec3)
  30894. * @param uniform defines the webGL uniform location where to store the value
  30895. * @param array defines the array of int32 to store
  30896. */
  30897. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30898. /**
  30899. * Set the value of an uniform to an array of int32 (stored as vec4)
  30900. * @param uniform defines the webGL uniform location where to store the value
  30901. * @param array defines the array of int32 to store
  30902. */
  30903. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30904. /**
  30905. * Set the value of an uniform to an array of float32
  30906. * @param uniform defines the webGL uniform location where to store the value
  30907. * @param array defines the array of float32 to store
  30908. */
  30909. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30910. /**
  30911. * Set the value of an uniform to an array of float32 (stored as vec2)
  30912. * @param uniform defines the webGL uniform location where to store the value
  30913. * @param array defines the array of float32 to store
  30914. */
  30915. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30916. /**
  30917. * Set the value of an uniform to an array of float32 (stored as vec3)
  30918. * @param uniform defines the webGL uniform location where to store the value
  30919. * @param array defines the array of float32 to store
  30920. */
  30921. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30922. /**
  30923. * Set the value of an uniform to an array of float32 (stored as vec4)
  30924. * @param uniform defines the webGL uniform location where to store the value
  30925. * @param array defines the array of float32 to store
  30926. */
  30927. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30928. /**
  30929. * Set the value of an uniform to an array of number
  30930. * @param uniform defines the webGL uniform location where to store the value
  30931. * @param array defines the array of number to store
  30932. */
  30933. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30934. /**
  30935. * Set the value of an uniform to an array of number (stored as vec2)
  30936. * @param uniform defines the webGL uniform location where to store the value
  30937. * @param array defines the array of number to store
  30938. */
  30939. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30940. /**
  30941. * Set the value of an uniform to an array of number (stored as vec3)
  30942. * @param uniform defines the webGL uniform location where to store the value
  30943. * @param array defines the array of number to store
  30944. */
  30945. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30946. /**
  30947. * Set the value of an uniform to an array of number (stored as vec4)
  30948. * @param uniform defines the webGL uniform location where to store the value
  30949. * @param array defines the array of number to store
  30950. */
  30951. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30952. /**
  30953. * Set the value of an uniform to an array of float32 (stored as matrices)
  30954. * @param uniform defines the webGL uniform location where to store the value
  30955. * @param matrices defines the array of float32 to store
  30956. */
  30957. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30958. /**
  30959. * Set the value of an uniform to a matrix (3x3)
  30960. * @param uniform defines the webGL uniform location where to store the value
  30961. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30962. */
  30963. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30964. /**
  30965. * Set the value of an uniform to a matrix (2x2)
  30966. * @param uniform defines the webGL uniform location where to store the value
  30967. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30968. */
  30969. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30970. /**
  30971. * Set the value of an uniform to a number (int)
  30972. * @param uniform defines the webGL uniform location where to store the value
  30973. * @param value defines the int number to store
  30974. */
  30975. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30976. /**
  30977. * Set the value of an uniform to a number (float)
  30978. * @param uniform defines the webGL uniform location where to store the value
  30979. * @param value defines the float number to store
  30980. */
  30981. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30982. /**
  30983. * Set the value of an uniform to a vec2
  30984. * @param uniform defines the webGL uniform location where to store the value
  30985. * @param x defines the 1st component of the value
  30986. * @param y defines the 2nd component of the value
  30987. */
  30988. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30989. /**
  30990. * Set the value of an uniform to a vec3
  30991. * @param uniform defines the webGL uniform location where to store the value
  30992. * @param x defines the 1st component of the value
  30993. * @param y defines the 2nd component of the value
  30994. * @param z defines the 3rd component of the value
  30995. */
  30996. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30997. /**
  30998. * Set the value of an uniform to a boolean
  30999. * @param uniform defines the webGL uniform location where to store the value
  31000. * @param bool defines the boolean to store
  31001. */
  31002. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31003. /**
  31004. * Set the value of an uniform to a vec4
  31005. * @param uniform defines the webGL uniform location where to store the value
  31006. * @param x defines the 1st component of the value
  31007. * @param y defines the 2nd component of the value
  31008. * @param z defines the 3rd component of the value
  31009. * @param w defines the 4th component of the value
  31010. */
  31011. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31012. /**
  31013. * Sets a Color4 on a uniform variable
  31014. * @param uniform defines the uniform location
  31015. * @param color4 defines the value to be set
  31016. */
  31017. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31018. /**
  31019. * Set various states to the webGL context
  31020. * @param culling defines backface culling state
  31021. * @param zOffset defines the value to apply to zOffset (0 by default)
  31022. * @param force defines if states must be applied even if cache is up to date
  31023. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31024. */
  31025. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31026. /**
  31027. * Set the z offset to apply to current rendering
  31028. * @param value defines the offset to apply
  31029. */
  31030. setZOffset(value: number): void;
  31031. /**
  31032. * Gets the current value of the zOffset
  31033. * @returns the current zOffset state
  31034. */
  31035. getZOffset(): number;
  31036. /**
  31037. * Enable or disable depth buffering
  31038. * @param enable defines the state to set
  31039. */
  31040. setDepthBuffer(enable: boolean): void;
  31041. /**
  31042. * Gets a boolean indicating if depth writing is enabled
  31043. * @returns the current depth writing state
  31044. */
  31045. getDepthWrite(): boolean;
  31046. /**
  31047. * Enable or disable depth writing
  31048. * @param enable defines the state to set
  31049. */
  31050. setDepthWrite(enable: boolean): void;
  31051. /**
  31052. * Enable or disable color writing
  31053. * @param enable defines the state to set
  31054. */
  31055. setColorWrite(enable: boolean): void;
  31056. /**
  31057. * Gets a boolean indicating if color writing is enabled
  31058. * @returns the current color writing state
  31059. */
  31060. getColorWrite(): boolean;
  31061. /**
  31062. * Sets alpha constants used by some alpha blending modes
  31063. * @param r defines the red component
  31064. * @param g defines the green component
  31065. * @param b defines the blue component
  31066. * @param a defines the alpha component
  31067. */
  31068. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31069. /**
  31070. * Sets the current alpha mode
  31071. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31072. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31073. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31074. */
  31075. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31076. /**
  31077. * Gets the current alpha mode
  31078. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31079. * @returns the current alpha mode
  31080. */
  31081. getAlphaMode(): number;
  31082. /**
  31083. * Clears the list of texture accessible through engine.
  31084. * This can help preventing texture load conflict due to name collision.
  31085. */
  31086. clearInternalTexturesCache(): void;
  31087. /**
  31088. * Force the entire cache to be cleared
  31089. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31090. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31091. */
  31092. wipeCaches(bruteForce?: boolean): void;
  31093. /**
  31094. * Set the compressed texture format to use, based on the formats you have, and the formats
  31095. * supported by the hardware / browser.
  31096. *
  31097. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31098. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31099. * to API arguments needed to compressed textures. This puts the burden on the container
  31100. * generator to house the arcane code for determining these for current & future formats.
  31101. *
  31102. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31103. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31104. *
  31105. * Note: The result of this call is not taken into account when a texture is base64.
  31106. *
  31107. * @param formatsAvailable defines the list of those format families you have created
  31108. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31109. *
  31110. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31111. * @returns The extension selected.
  31112. */
  31113. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31114. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31115. min: number;
  31116. mag: number;
  31117. };
  31118. /** @hidden */ private _createTexture(): WebGLTexture;
  31119. /**
  31120. * Usually called from Texture.ts.
  31121. * Passed information to create a WebGLTexture
  31122. * @param urlArg defines a value which contains one of the following:
  31123. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31124. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31125. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31126. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31127. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  31128. * @param scene needed for loading to the correct scene
  31129. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31130. * @param onLoad optional callback to be called upon successful completion
  31131. * @param onError optional callback to be called upon failure
  31132. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  31133. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31134. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31135. * @param forcedExtension defines the extension to use to pick the right loader
  31136. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31137. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31138. */
  31139. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  31140. /**
  31141. * @hidden
  31142. * Rescales a texture
  31143. * @param source input texutre
  31144. * @param destination destination texture
  31145. * @param scene scene to use to render the resize
  31146. * @param internalFormat format to use when resizing
  31147. * @param onComplete callback to be called when resize has completed
  31148. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  31149. private _unpackFlipYCached;
  31150. /**
  31151. * In case you are sharing the context with other applications, it might
  31152. * be interested to not cache the unpack flip y state to ensure a consistent
  31153. * value would be set.
  31154. */
  31155. enableUnpackFlipYCached: boolean;
  31156. /** @hidden */ private _unpackFlipY(value: boolean): void;
  31157. /** @hidden */ private _getUnpackAlignement(): number;
  31158. /**
  31159. * Creates a dynamic texture
  31160. * @param width defines the width of the texture
  31161. * @param height defines the height of the texture
  31162. * @param generateMipMaps defines if the engine should generate the mip levels
  31163. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31164. * @returns the dynamic texture inside an InternalTexture
  31165. */
  31166. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  31167. /**
  31168. * Update the sampling mode of a given texture
  31169. * @param samplingMode defines the required sampling mode
  31170. * @param texture defines the texture to update
  31171. */
  31172. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31173. /**
  31174. * Update the content of a dynamic texture
  31175. * @param texture defines the texture to update
  31176. * @param canvas defines the canvas containing the source
  31177. * @param invertY defines if data must be stored with Y axis inverted
  31178. * @param premulAlpha defines if alpha is stored as premultiplied
  31179. * @param format defines the format of the data
  31180. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31181. */
  31182. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  31183. /**
  31184. * Update a video texture
  31185. * @param texture defines the texture to update
  31186. * @param video defines the video element to use
  31187. * @param invertY defines if data must be stored with Y axis inverted
  31188. */
  31189. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31190. /**
  31191. * Updates a depth texture Comparison Mode and Function.
  31192. * If the comparison Function is equal to 0, the mode will be set to none.
  31193. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31194. * @param texture The texture to set the comparison function for
  31195. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31196. */
  31197. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  31198. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31199. width: number;
  31200. height: number;
  31201. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31202. /**
  31203. * Creates a depth stencil texture.
  31204. * This is only available in WebGL 2 or with the depth texture extension available.
  31205. * @param size The size of face edge in the texture.
  31206. * @param options The options defining the texture.
  31207. * @returns The texture
  31208. */
  31209. createDepthStencilTexture(size: number | {
  31210. width: number;
  31211. height: number;
  31212. }, options: DepthTextureCreationOptions): InternalTexture;
  31213. /**
  31214. * Creates a depth stencil texture.
  31215. * This is only available in WebGL 2 or with the depth texture extension available.
  31216. * @param size The size of face edge in the texture.
  31217. * @param options The options defining the texture.
  31218. * @returns The texture
  31219. */
  31220. private _createDepthStencilTexture;
  31221. /**
  31222. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31223. * @param renderTarget The render target to set the frame buffer for
  31224. */
  31225. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31226. /**
  31227. * Creates a new render target texture
  31228. * @param size defines the size of the texture
  31229. * @param options defines the options used to create the texture
  31230. * @returns a new render target texture stored in an InternalTexture
  31231. */
  31232. createRenderTargetTexture(size: number | {
  31233. width: number;
  31234. height: number;
  31235. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31236. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31237. /**
  31238. * Updates the sample count of a render target texture
  31239. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31240. * @param texture defines the texture to update
  31241. * @param samples defines the sample count to set
  31242. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31243. */
  31244. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31245. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31246. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31247. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31248. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31249. /**
  31250. * @hidden
  31251. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  31252. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31253. private _prepareWebGLTexture;
  31254. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31255. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  31256. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  31257. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31258. protected _setProgram(program: WebGLProgram): void;
  31259. protected _boundUniforms: {
  31260. [key: number]: WebGLUniformLocation;
  31261. };
  31262. /**
  31263. * Binds an effect to the webGL context
  31264. * @param effect defines the effect to bind
  31265. */
  31266. bindSamplers(effect: Effect): void;
  31267. private _activateCurrentTexture;
  31268. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31269. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31270. /**
  31271. * Sets a texture to the webGL context from a postprocess
  31272. * @param channel defines the channel to use
  31273. * @param postProcess defines the source postprocess
  31274. */
  31275. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31276. /**
  31277. * Binds the output of the passed in post process to the texture channel specified
  31278. * @param channel The channel the texture should be bound to
  31279. * @param postProcess The post process which's output should be bound
  31280. */
  31281. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31282. /**
  31283. * Unbind all textures from the webGL context
  31284. */
  31285. unbindAllTextures(): void;
  31286. /**
  31287. * Sets a texture to the according uniform.
  31288. * @param channel The texture channel
  31289. * @param uniform The uniform to set
  31290. * @param texture The texture to apply
  31291. * @param name The name of the uniform in the effect
  31292. */
  31293. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  31294. /**
  31295. * Sets a depth stencil texture from a render target to the according uniform.
  31296. * @param channel The texture channel
  31297. * @param uniform The uniform to set
  31298. * @param texture The render target texture containing the depth stencil texture to apply
  31299. */
  31300. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31301. private _bindSamplerUniformToChannel;
  31302. private _getTextureWrapMode;
  31303. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31304. /**
  31305. * Sets an array of texture to the webGL context
  31306. * @param channel defines the channel where the texture array must be set
  31307. * @param uniform defines the associated uniform location
  31308. * @param textures defines the array of textures to bind
  31309. */
  31310. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31311. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31312. private _setTextureParameterFloat;
  31313. private _setTextureParameterInteger;
  31314. /**
  31315. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31316. * @param x defines the x coordinate of the rectangle where pixels must be read
  31317. * @param y defines the y coordinate of the rectangle where pixels must be read
  31318. * @param width defines the width of the rectangle where pixels must be read
  31319. * @param height defines the height of the rectangle where pixels must be read
  31320. * @returns a Uint8Array containing RGBA colors
  31321. */
  31322. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31323. /**
  31324. * Add an externaly attached data from its key.
  31325. * This method call will fail and return false, if such key already exists.
  31326. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  31327. * @param key the unique key that identifies the data
  31328. * @param data the data object to associate to the key for this Engine instance
  31329. * @return true if no such key were already present and the data was added successfully, false otherwise
  31330. */
  31331. addExternalData<T>(key: string, data: T): boolean;
  31332. /**
  31333. * Get an externaly attached data from its key
  31334. * @param key the unique key that identifies the data
  31335. * @return the associated data, if present (can be null), or undefined if not present
  31336. */
  31337. getExternalData<T>(key: string): T;
  31338. /**
  31339. * Get an externaly attached data from its key, create it using a factory if it's not already present
  31340. * @param key the unique key that identifies the data
  31341. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  31342. * @return the associated data, can be null if the factory returned null.
  31343. */
  31344. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  31345. /**
  31346. * Remove an externaly attached data from the Engine instance
  31347. * @param key the unique key that identifies the data
  31348. * @return true if the data was successfully removed, false if it doesn't exist
  31349. */
  31350. removeExternalData(key: string): boolean;
  31351. /**
  31352. * Unbind all vertex attributes from the webGL context
  31353. */
  31354. unbindAllAttributes(): void;
  31355. /**
  31356. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  31357. */
  31358. releaseEffects(): void;
  31359. /**
  31360. * Dispose and release all associated resources
  31361. */
  31362. dispose(): void;
  31363. /**
  31364. * Display the loading screen
  31365. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31366. */
  31367. displayLoadingUI(): void;
  31368. /**
  31369. * Hide the loading screen
  31370. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31371. */
  31372. hideLoadingUI(): void;
  31373. /**
  31374. * Gets the current loading screen object
  31375. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31376. */
  31377. /**
  31378. * Sets the current loading screen object
  31379. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31380. */
  31381. loadingScreen: ILoadingScreen;
  31382. /**
  31383. * Sets the current loading screen text
  31384. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31385. */
  31386. loadingUIText: string;
  31387. /**
  31388. * Sets the current loading screen background color
  31389. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31390. */
  31391. loadingUIBackgroundColor: string;
  31392. /**
  31393. * Attach a new callback raised when context lost event is fired
  31394. * @param callback defines the callback to call
  31395. */
  31396. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31397. /**
  31398. * Attach a new callback raised when context restored event is fired
  31399. * @param callback defines the callback to call
  31400. */
  31401. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31402. /**
  31403. * Gets the source code of the vertex shader associated with a specific webGL program
  31404. * @param program defines the program to use
  31405. * @returns a string containing the source code of the vertex shader associated with the program
  31406. */
  31407. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31408. /**
  31409. * Gets the source code of the fragment shader associated with a specific webGL program
  31410. * @param program defines the program to use
  31411. * @returns a string containing the source code of the fragment shader associated with the program
  31412. */
  31413. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31414. /**
  31415. * Get the current error code of the webGL context
  31416. * @returns the error code
  31417. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31418. */
  31419. getError(): number;
  31420. /**
  31421. * Gets the current framerate
  31422. * @returns a number representing the framerate
  31423. */
  31424. getFps(): number;
  31425. /**
  31426. * Gets the time spent between current and previous frame
  31427. * @returns a number representing the delta time in ms
  31428. */
  31429. getDeltaTime(): number;
  31430. private _measureFps;
  31431. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31432. private _canRenderToFloatFramebuffer;
  31433. private _canRenderToHalfFloatFramebuffer;
  31434. private _canRenderToFramebuffer;
  31435. /** @hidden */ private _getWebGLTextureType(type: number): number;
  31436. /** @hidden */ private _getInternalFormat(format: number): number;
  31437. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31438. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  31439. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31440. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31441. /** @hidden */ private _shouldOnlyUpdateCameras(): boolean;
  31442. /**
  31443. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31444. * @returns true if the engine can be created
  31445. * @ignorenaming
  31446. */
  31447. static isSupported(): boolean;
  31448. /**
  31449. * Find the next highest power of two.
  31450. * @param x Number to start search from.
  31451. * @return Next highest power of two.
  31452. */
  31453. static CeilingPOT(x: number): number;
  31454. /**
  31455. * Find the next lowest power of two.
  31456. * @param x Number to start search from.
  31457. * @return Next lowest power of two.
  31458. */
  31459. static FloorPOT(x: number): number;
  31460. /**
  31461. * Find the nearest power of two.
  31462. * @param x Number to start search from.
  31463. * @return Next nearest power of two.
  31464. */
  31465. static NearestPOT(x: number): number;
  31466. /**
  31467. * Get the closest exponent of two
  31468. * @param value defines the value to approximate
  31469. * @param max defines the maximum value to return
  31470. * @param mode defines how to define the closest value
  31471. * @returns closest exponent of two of the given value
  31472. */
  31473. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31474. /**
  31475. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31476. * @param func - the function to be called
  31477. * @param requester - the object that will request the next frame. Falls back to window.
  31478. * @returns frame number
  31479. */
  31480. static QueueNewFrame(func: () => void, requester?: any): number;
  31481. /**
  31482. * Ask the browser to promote the current element to pointerlock mode
  31483. * @param element defines the DOM element to promote
  31484. */ private static _RequestPointerlock(element: HTMLElement): void;
  31485. /**
  31486. * Asks the browser to exit pointerlock mode
  31487. */ private static _ExitPointerlock(): void;
  31488. /**
  31489. * Ask the browser to promote the current element to fullscreen rendering mode
  31490. * @param element defines the DOM element to promote
  31491. */ private static _RequestFullscreen(element: HTMLElement): void;
  31492. /**
  31493. * Asks the browser to exit fullscreen mode
  31494. */ private static _ExitFullscreen(): void;
  31495. }
  31496. }
  31497. declare module BABYLON {
  31498. /**
  31499. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31500. * during the life time of the application.
  31501. */
  31502. export class EngineStore {
  31503. /** Gets the list of created engines */
  31504. static Instances: Engine[];
  31505. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31506. /**
  31507. * Gets the latest created engine
  31508. */
  31509. static readonly LastCreatedEngine: Nullable<Engine>;
  31510. /**
  31511. * Gets the latest created scene
  31512. */
  31513. static readonly LastCreatedScene: Nullable<Scene>;
  31514. /**
  31515. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31516. * @ignorenaming
  31517. */
  31518. static UseFallbackTexture: boolean;
  31519. /**
  31520. * Texture content used if a texture cannot loaded
  31521. * @ignorenaming
  31522. */
  31523. static FallbackTexture: string;
  31524. }
  31525. }
  31526. declare module BABYLON {
  31527. /**
  31528. * Helper class that provides a small promise polyfill
  31529. */
  31530. export class PromisePolyfill {
  31531. /**
  31532. * Static function used to check if the polyfill is required
  31533. * If this is the case then the function will inject the polyfill to window.Promise
  31534. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31535. */
  31536. static Apply(force?: boolean): void;
  31537. }
  31538. }
  31539. declare module BABYLON {
  31540. /**
  31541. * Interface for screenshot methods with describe argument called `size` as object with options
  31542. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31543. */
  31544. export interface IScreenshotSize {
  31545. /**
  31546. * number in pixels for canvas height
  31547. */
  31548. height?: number;
  31549. /**
  31550. * multiplier allowing render at a higher or lower resolution
  31551. * If value is defined then height and width will be ignored and taken from camera
  31552. */
  31553. precision?: number;
  31554. /**
  31555. * number in pixels for canvas width
  31556. */
  31557. width?: number;
  31558. }
  31559. }
  31560. declare module BABYLON {
  31561. interface IColor4Like {
  31562. r: float;
  31563. g: float;
  31564. b: float;
  31565. a: float;
  31566. }
  31567. /**
  31568. * Class containing a set of static utilities functions
  31569. */
  31570. export class Tools {
  31571. /**
  31572. * Gets or sets the base URL to use to load assets
  31573. */
  31574. static BaseUrl: string;
  31575. /**
  31576. * Enable/Disable Custom HTTP Request Headers globally.
  31577. * default = false
  31578. * @see CustomRequestHeaders
  31579. */
  31580. static UseCustomRequestHeaders: boolean;
  31581. /**
  31582. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31583. * i.e. when loading files, where the server/service expects an Authorization header
  31584. */
  31585. static CustomRequestHeaders: {
  31586. [key: string]: string;
  31587. };
  31588. /**
  31589. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31590. */
  31591. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31592. /**
  31593. * Default behaviour for cors in the application.
  31594. * It can be a string if the expected behavior is identical in the entire app.
  31595. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31596. */
  31597. static CorsBehavior: string | ((url: string | string[]) => string);
  31598. /**
  31599. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31600. * @ignorenaming
  31601. */
  31602. static UseFallbackTexture: boolean;
  31603. /**
  31604. * Use this object to register external classes like custom textures or material
  31605. * to allow the laoders to instantiate them
  31606. */
  31607. static RegisteredExternalClasses: {
  31608. [key: string]: Object;
  31609. };
  31610. /**
  31611. * Texture content used if a texture cannot loaded
  31612. * @ignorenaming
  31613. */
  31614. static fallbackTexture: string;
  31615. /**
  31616. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31617. * @param u defines the coordinate on X axis
  31618. * @param v defines the coordinate on Y axis
  31619. * @param width defines the width of the source data
  31620. * @param height defines the height of the source data
  31621. * @param pixels defines the source byte array
  31622. * @param color defines the output color
  31623. */
  31624. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31625. /**
  31626. * Interpolates between a and b via alpha
  31627. * @param a The lower value (returned when alpha = 0)
  31628. * @param b The upper value (returned when alpha = 1)
  31629. * @param alpha The interpolation-factor
  31630. * @return The mixed value
  31631. */
  31632. static Mix(a: number, b: number, alpha: number): number;
  31633. /**
  31634. * Tries to instantiate a new object from a given class name
  31635. * @param className defines the class name to instantiate
  31636. * @returns the new object or null if the system was not able to do the instantiation
  31637. */
  31638. static Instantiate(className: string): any;
  31639. /**
  31640. * Provides a slice function that will work even on IE
  31641. * @param data defines the array to slice
  31642. * @param start defines the start of the data (optional)
  31643. * @param end defines the end of the data (optional)
  31644. * @returns the new sliced array
  31645. */
  31646. static Slice<T>(data: T, start?: number, end?: number): T;
  31647. /**
  31648. * Polyfill for setImmediate
  31649. * @param action defines the action to execute after the current execution block
  31650. */
  31651. static SetImmediate(action: () => void): void;
  31652. /**
  31653. * Function indicating if a number is an exponent of 2
  31654. * @param value defines the value to test
  31655. * @returns true if the value is an exponent of 2
  31656. */
  31657. static IsExponentOfTwo(value: number): boolean;
  31658. private static _tmpFloatArray;
  31659. /**
  31660. * Returns the nearest 32-bit single precision float representation of a Number
  31661. * @param value A Number. If the parameter is of a different type, it will get converted
  31662. * to a number or to NaN if it cannot be converted
  31663. * @returns number
  31664. */
  31665. static FloatRound(value: number): number;
  31666. /**
  31667. * Extracts the filename from a path
  31668. * @param path defines the path to use
  31669. * @returns the filename
  31670. */
  31671. static GetFilename(path: string): string;
  31672. /**
  31673. * Extracts the "folder" part of a path (everything before the filename).
  31674. * @param uri The URI to extract the info from
  31675. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31676. * @returns The "folder" part of the path
  31677. */
  31678. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31679. /**
  31680. * Extracts text content from a DOM element hierarchy
  31681. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31682. */
  31683. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31684. /**
  31685. * Convert an angle in radians to degrees
  31686. * @param angle defines the angle to convert
  31687. * @returns the angle in degrees
  31688. */
  31689. static ToDegrees(angle: number): number;
  31690. /**
  31691. * Convert an angle in degrees to radians
  31692. * @param angle defines the angle to convert
  31693. * @returns the angle in radians
  31694. */
  31695. static ToRadians(angle: number): number;
  31696. /**
  31697. * Encode a buffer to a base64 string
  31698. * @param buffer defines the buffer to encode
  31699. * @returns the encoded string
  31700. */
  31701. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31702. /**
  31703. * Returns an array if obj is not an array
  31704. * @param obj defines the object to evaluate as an array
  31705. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31706. * @returns either obj directly if obj is an array or a new array containing obj
  31707. */
  31708. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31709. /**
  31710. * Gets the pointer prefix to use
  31711. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31712. */
  31713. static GetPointerPrefix(): string;
  31714. /**
  31715. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31716. * @param url define the url we are trying
  31717. * @param element define the dom element where to configure the cors policy
  31718. */
  31719. static SetCorsBehavior(url: string | string[], element: {
  31720. crossOrigin: string | null;
  31721. }): void;
  31722. /**
  31723. * Removes unwanted characters from an url
  31724. * @param url defines the url to clean
  31725. * @returns the cleaned url
  31726. */
  31727. static CleanUrl(url: string): string;
  31728. /**
  31729. * Gets or sets a function used to pre-process url before using them to load assets
  31730. */
  31731. static PreprocessUrl: (url: string) => string;
  31732. /**
  31733. * Loads an image as an HTMLImageElement.
  31734. * @param input url string, ArrayBuffer, or Blob to load
  31735. * @param onLoad callback called when the image successfully loads
  31736. * @param onError callback called when the image fails to load
  31737. * @param offlineProvider offline provider for caching
  31738. * @returns the HTMLImageElement of the loaded image
  31739. */
  31740. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31741. /**
  31742. * Loads a file
  31743. * @param url url string, ArrayBuffer, or Blob to load
  31744. * @param onSuccess callback called when the file successfully loads
  31745. * @param onProgress callback called while file is loading (if the server supports this mode)
  31746. * @param offlineProvider defines the offline provider for caching
  31747. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31748. * @param onError callback called when the file fails to load
  31749. * @returns a file request object
  31750. */
  31751. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31752. /**
  31753. * Loads a file from a url
  31754. * @param url the file url to load
  31755. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31756. */
  31757. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31758. /**
  31759. * Load a script (identified by an url). When the url returns, the
  31760. * content of this file is added into a new script element, attached to the DOM (body element)
  31761. * @param scriptUrl defines the url of the script to laod
  31762. * @param onSuccess defines the callback called when the script is loaded
  31763. * @param onError defines the callback to call if an error occurs
  31764. * @param scriptId defines the id of the script element
  31765. */
  31766. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31767. /**
  31768. * Load an asynchronous script (identified by an url). When the url returns, the
  31769. * content of this file is added into a new script element, attached to the DOM (body element)
  31770. * @param scriptUrl defines the url of the script to laod
  31771. * @param scriptId defines the id of the script element
  31772. * @returns a promise request object
  31773. */
  31774. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31775. /**
  31776. * Loads a file from a blob
  31777. * @param fileToLoad defines the blob to use
  31778. * @param callback defines the callback to call when data is loaded
  31779. * @param progressCallback defines the callback to call during loading process
  31780. * @returns a file request object
  31781. */
  31782. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31783. /**
  31784. * Loads a file
  31785. * @param fileToLoad defines the file to load
  31786. * @param callback defines the callback to call when data is loaded
  31787. * @param progressCallBack defines the callback to call during loading process
  31788. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31789. * @returns a file request object
  31790. */
  31791. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31792. /**
  31793. * Creates a data url from a given string content
  31794. * @param content defines the content to convert
  31795. * @returns the new data url link
  31796. */
  31797. static FileAsURL(content: string): string;
  31798. /**
  31799. * Format the given number to a specific decimal format
  31800. * @param value defines the number to format
  31801. * @param decimals defines the number of decimals to use
  31802. * @returns the formatted string
  31803. */
  31804. static Format(value: number, decimals?: number): string;
  31805. /**
  31806. * Tries to copy an object by duplicating every property
  31807. * @param source defines the source object
  31808. * @param destination defines the target object
  31809. * @param doNotCopyList defines a list of properties to avoid
  31810. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31811. */
  31812. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31813. /**
  31814. * Gets a boolean indicating if the given object has no own property
  31815. * @param obj defines the object to test
  31816. * @returns true if object has no own property
  31817. */
  31818. static IsEmpty(obj: any): boolean;
  31819. /**
  31820. * Function used to register events at window level
  31821. * @param windowElement defines the Window object to use
  31822. * @param events defines the events to register
  31823. */
  31824. static RegisterTopRootEvents(windowElement: Window, events: {
  31825. name: string;
  31826. handler: Nullable<(e: FocusEvent) => any>;
  31827. }[]): void;
  31828. /**
  31829. * Function used to unregister events from window level
  31830. * @param windowElement defines the Window object to use
  31831. * @param events defines the events to unregister
  31832. */
  31833. static UnregisterTopRootEvents(windowElement: Window, events: {
  31834. name: string;
  31835. handler: Nullable<(e: FocusEvent) => any>;
  31836. }[]): void;
  31837. /**
  31838. * @ignore
  31839. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31840. /**
  31841. * Dumps the current bound framebuffer
  31842. * @param width defines the rendering width
  31843. * @param height defines the rendering height
  31844. * @param engine defines the hosting engine
  31845. * @param successCallback defines the callback triggered once the data are available
  31846. * @param mimeType defines the mime type of the result
  31847. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31848. */
  31849. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31850. /**
  31851. * Converts the canvas data to blob.
  31852. * This acts as a polyfill for browsers not supporting the to blob function.
  31853. * @param canvas Defines the canvas to extract the data from
  31854. * @param successCallback Defines the callback triggered once the data are available
  31855. * @param mimeType Defines the mime type of the result
  31856. */
  31857. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31858. /**
  31859. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31860. * @param successCallback defines the callback triggered once the data are available
  31861. * @param mimeType defines the mime type of the result
  31862. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31863. */
  31864. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31865. /**
  31866. * Downloads a blob in the browser
  31867. * @param blob defines the blob to download
  31868. * @param fileName defines the name of the downloaded file
  31869. */
  31870. static Download(blob: Blob, fileName: string): void;
  31871. /**
  31872. * Captures a screenshot of the current rendering
  31873. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31874. * @param engine defines the rendering engine
  31875. * @param camera defines the source camera
  31876. * @param size This parameter can be set to a single number or to an object with the
  31877. * following (optional) properties: precision, width, height. If a single number is passed,
  31878. * it will be used for both width and height. If an object is passed, the screenshot size
  31879. * will be derived from the parameters. The precision property is a multiplier allowing
  31880. * rendering at a higher or lower resolution
  31881. * @param successCallback defines the callback receives a single parameter which contains the
  31882. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31883. * src parameter of an <img> to display it
  31884. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31885. * Check your browser for supported MIME types
  31886. */
  31887. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31888. /**
  31889. * Captures a screenshot of the current rendering
  31890. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31891. * @param engine defines the rendering engine
  31892. * @param camera defines the source camera
  31893. * @param size This parameter can be set to a single number or to an object with the
  31894. * following (optional) properties: precision, width, height. If a single number is passed,
  31895. * it will be used for both width and height. If an object is passed, the screenshot size
  31896. * will be derived from the parameters. The precision property is a multiplier allowing
  31897. * rendering at a higher or lower resolution
  31898. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31899. * Check your browser for supported MIME types
  31900. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31901. * to the src parameter of an <img> to display it
  31902. */
  31903. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31904. /**
  31905. * Generates an image screenshot from the specified camera.
  31906. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31907. * @param engine The engine to use for rendering
  31908. * @param camera The camera to use for rendering
  31909. * @param size This parameter can be set to a single number or to an object with the
  31910. * following (optional) properties: precision, width, height. If a single number is passed,
  31911. * it will be used for both width and height. If an object is passed, the screenshot size
  31912. * will be derived from the parameters. The precision property is a multiplier allowing
  31913. * rendering at a higher or lower resolution
  31914. * @param successCallback The callback receives a single parameter which contains the
  31915. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31916. * src parameter of an <img> to display it
  31917. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31918. * Check your browser for supported MIME types
  31919. * @param samples Texture samples (default: 1)
  31920. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31921. * @param fileName A name for for the downloaded file.
  31922. */
  31923. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31924. /**
  31925. * Generates an image screenshot from the specified camera.
  31926. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31927. * @param engine The engine to use for rendering
  31928. * @param camera The camera to use for rendering
  31929. * @param size This parameter can be set to a single number or to an object with the
  31930. * following (optional) properties: precision, width, height. If a single number is passed,
  31931. * it will be used for both width and height. If an object is passed, the screenshot size
  31932. * will be derived from the parameters. The precision property is a multiplier allowing
  31933. * rendering at a higher or lower resolution
  31934. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31935. * Check your browser for supported MIME types
  31936. * @param samples Texture samples (default: 1)
  31937. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31938. * @param fileName A name for for the downloaded file.
  31939. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31940. * to the src parameter of an <img> to display it
  31941. */
  31942. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31943. /**
  31944. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31945. * Be aware Math.random() could cause collisions, but:
  31946. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  31947. * @returns a pseudo random id
  31948. */
  31949. static RandomId(): string;
  31950. /**
  31951. * Test if the given uri is a base64 string
  31952. * @param uri The uri to test
  31953. * @return True if the uri is a base64 string or false otherwise
  31954. */
  31955. static IsBase64(uri: string): boolean;
  31956. /**
  31957. * Decode the given base64 uri.
  31958. * @param uri The uri to decode
  31959. * @return The decoded base64 data.
  31960. */
  31961. static DecodeBase64(uri: string): ArrayBuffer;
  31962. /**
  31963. * Gets the absolute url.
  31964. * @param url the input url
  31965. * @return the absolute url
  31966. */
  31967. static GetAbsoluteUrl(url: string): string;
  31968. /**
  31969. * No log
  31970. */
  31971. static readonly NoneLogLevel: number;
  31972. /**
  31973. * Only message logs
  31974. */
  31975. static readonly MessageLogLevel: number;
  31976. /**
  31977. * Only warning logs
  31978. */
  31979. static readonly WarningLogLevel: number;
  31980. /**
  31981. * Only error logs
  31982. */
  31983. static readonly ErrorLogLevel: number;
  31984. /**
  31985. * All logs
  31986. */
  31987. static readonly AllLogLevel: number;
  31988. /**
  31989. * Gets a value indicating the number of loading errors
  31990. * @ignorenaming
  31991. */
  31992. static readonly errorsCount: number;
  31993. /**
  31994. * Callback called when a new log is added
  31995. */
  31996. static OnNewCacheEntry: (entry: string) => void;
  31997. /**
  31998. * Log a message to the console
  31999. * @param message defines the message to log
  32000. */
  32001. static Log(message: string): void;
  32002. /**
  32003. * Write a warning message to the console
  32004. * @param message defines the message to log
  32005. */
  32006. static Warn(message: string): void;
  32007. /**
  32008. * Write an error message to the console
  32009. * @param message defines the message to log
  32010. */
  32011. static Error(message: string): void;
  32012. /**
  32013. * Gets current log cache (list of logs)
  32014. */
  32015. static readonly LogCache: string;
  32016. /**
  32017. * Clears the log cache
  32018. */
  32019. static ClearLogCache(): void;
  32020. /**
  32021. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32022. */
  32023. static LogLevels: number;
  32024. /**
  32025. * Checks if the window object exists
  32026. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32027. */
  32028. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32029. /**
  32030. * No performance log
  32031. */
  32032. static readonly PerformanceNoneLogLevel: number;
  32033. /**
  32034. * Use user marks to log performance
  32035. */
  32036. static readonly PerformanceUserMarkLogLevel: number;
  32037. /**
  32038. * Log performance to the console
  32039. */
  32040. static readonly PerformanceConsoleLogLevel: number;
  32041. private static _performance;
  32042. /**
  32043. * Sets the current performance log level
  32044. */
  32045. static PerformanceLogLevel: number;
  32046. private static _StartPerformanceCounterDisabled;
  32047. private static _EndPerformanceCounterDisabled;
  32048. private static _StartUserMark;
  32049. private static _EndUserMark;
  32050. private static _StartPerformanceConsole;
  32051. private static _EndPerformanceConsole;
  32052. /**
  32053. * Starts a performance counter
  32054. */
  32055. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32056. /**
  32057. * Ends a specific performance coutner
  32058. */
  32059. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32060. /**
  32061. * Gets either window.performance.now() if supported or Date.now() else
  32062. */
  32063. static readonly Now: number;
  32064. /**
  32065. * This method will return the name of the class used to create the instance of the given object.
  32066. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32067. * @param object the object to get the class name from
  32068. * @param isType defines if the object is actually a type
  32069. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32070. */
  32071. static GetClassName(object: any, isType?: boolean): string;
  32072. /**
  32073. * Gets the first element of an array satisfying a given predicate
  32074. * @param array defines the array to browse
  32075. * @param predicate defines the predicate to use
  32076. * @returns null if not found or the element
  32077. */
  32078. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32079. /**
  32080. * This method will return the name of the full name of the class, including its owning module (if any).
  32081. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  32082. * @param object the object to get the class name from
  32083. * @param isType defines if the object is actually a type
  32084. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  32085. * @ignorenaming
  32086. */
  32087. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32088. /**
  32089. * Returns a promise that resolves after the given amount of time.
  32090. * @param delay Number of milliseconds to delay
  32091. * @returns Promise that resolves after the given amount of time
  32092. */
  32093. static DelayAsync(delay: number): Promise<void>;
  32094. }
  32095. /**
  32096. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32097. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32098. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32099. * @param name The name of the class, case should be preserved
  32100. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32101. */
  32102. export function className(name: string, module?: string): (target: Object) => void;
  32103. /**
  32104. * An implementation of a loop for asynchronous functions.
  32105. */
  32106. export class AsyncLoop {
  32107. /**
  32108. * Defines the number of iterations for the loop
  32109. */
  32110. iterations: number;
  32111. /**
  32112. * Defines the current index of the loop.
  32113. */
  32114. index: number;
  32115. private _done;
  32116. private _fn;
  32117. private _successCallback;
  32118. /**
  32119. * Constructor.
  32120. * @param iterations the number of iterations.
  32121. * @param func the function to run each iteration
  32122. * @param successCallback the callback that will be called upon succesful execution
  32123. * @param offset starting offset.
  32124. */
  32125. constructor(
  32126. /**
  32127. * Defines the number of iterations for the loop
  32128. */
  32129. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32130. /**
  32131. * Execute the next iteration. Must be called after the last iteration was finished.
  32132. */
  32133. executeNext(): void;
  32134. /**
  32135. * Break the loop and run the success callback.
  32136. */
  32137. breakLoop(): void;
  32138. /**
  32139. * Create and run an async loop.
  32140. * @param iterations the number of iterations.
  32141. * @param fn the function to run each iteration
  32142. * @param successCallback the callback that will be called upon succesful execution
  32143. * @param offset starting offset.
  32144. * @returns the created async loop object
  32145. */
  32146. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32147. /**
  32148. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32149. * @param iterations total number of iterations
  32150. * @param syncedIterations number of synchronous iterations in each async iteration.
  32151. * @param fn the function to call each iteration.
  32152. * @param callback a success call back that will be called when iterating stops.
  32153. * @param breakFunction a break condition (optional)
  32154. * @param timeout timeout settings for the setTimeout function. default - 0.
  32155. * @returns the created async loop object
  32156. */
  32157. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32158. }
  32159. }
  32160. declare module BABYLON {
  32161. /** @hidden */
  32162. export interface ICollisionCoordinator {
  32163. createCollider(): Collider;
  32164. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32165. init(scene: Scene): void;
  32166. }
  32167. /** @hidden */
  32168. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32169. private _scene;
  32170. private _scaledPosition;
  32171. private _scaledVelocity;
  32172. private _finalPosition;
  32173. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32174. createCollider(): Collider;
  32175. init(scene: Scene): void;
  32176. private _collideWithWorld;
  32177. }
  32178. }
  32179. declare module BABYLON {
  32180. /**
  32181. * Class used to manage all inputs for the scene.
  32182. */
  32183. export class InputManager {
  32184. /** The distance in pixel that you have to move to prevent some events */
  32185. static DragMovementThreshold: number;
  32186. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32187. static LongPressDelay: number;
  32188. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32189. static DoubleClickDelay: number;
  32190. /** If you need to check double click without raising a single click at first click, enable this flag */
  32191. static ExclusiveDoubleClickMode: boolean;
  32192. private _wheelEventName;
  32193. private _onPointerMove;
  32194. private _onPointerDown;
  32195. private _onPointerUp;
  32196. private _initClickEvent;
  32197. private _initActionManager;
  32198. private _delayedSimpleClick;
  32199. private _delayedSimpleClickTimeout;
  32200. private _previousDelayedSimpleClickTimeout;
  32201. private _meshPickProceed;
  32202. private _previousButtonPressed;
  32203. private _currentPickResult;
  32204. private _previousPickResult;
  32205. private _totalPointersPressed;
  32206. private _doubleClickOccured;
  32207. private _pointerOverMesh;
  32208. private _pickedDownMesh;
  32209. private _pickedUpMesh;
  32210. private _pointerX;
  32211. private _pointerY;
  32212. private _unTranslatedPointerX;
  32213. private _unTranslatedPointerY;
  32214. private _startingPointerPosition;
  32215. private _previousStartingPointerPosition;
  32216. private _startingPointerTime;
  32217. private _previousStartingPointerTime;
  32218. private _pointerCaptures;
  32219. private _onKeyDown;
  32220. private _onKeyUp;
  32221. private _onCanvasFocusObserver;
  32222. private _onCanvasBlurObserver;
  32223. private _scene;
  32224. /**
  32225. * Creates a new InputManager
  32226. * @param scene defines the hosting scene
  32227. */
  32228. constructor(scene: Scene);
  32229. /**
  32230. * Gets the mesh that is currently under the pointer
  32231. */
  32232. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32233. /**
  32234. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32235. */
  32236. readonly unTranslatedPointer: Vector2;
  32237. /**
  32238. * Gets or sets the current on-screen X position of the pointer
  32239. */
  32240. pointerX: number;
  32241. /**
  32242. * Gets or sets the current on-screen Y position of the pointer
  32243. */
  32244. pointerY: number;
  32245. private _updatePointerPosition;
  32246. private _processPointerMove;
  32247. private _setRayOnPointerInfo;
  32248. private _checkPrePointerObservable;
  32249. /**
  32250. * Use this method to simulate a pointer move on a mesh
  32251. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32252. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32253. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32254. */
  32255. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32256. /**
  32257. * Use this method to simulate a pointer down on a mesh
  32258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32261. */
  32262. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32263. private _processPointerDown;
  32264. /** @hidden */ private _isPointerSwiping(): boolean;
  32265. /**
  32266. * Use this method to simulate a pointer up on a mesh
  32267. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32268. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32269. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32270. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32271. */
  32272. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32273. private _processPointerUp;
  32274. /**
  32275. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32276. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32277. * @returns true if the pointer was captured
  32278. */
  32279. isPointerCaptured(pointerId?: number): boolean;
  32280. /**
  32281. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32282. * @param attachUp defines if you want to attach events to pointerup
  32283. * @param attachDown defines if you want to attach events to pointerdown
  32284. * @param attachMove defines if you want to attach events to pointermove
  32285. */
  32286. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32287. /**
  32288. * Detaches all event handlers
  32289. */
  32290. detachControl(): void;
  32291. /**
  32292. * Force the value of meshUnderPointer
  32293. * @param mesh defines the mesh to use
  32294. */
  32295. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32296. /**
  32297. * Gets the mesh under the pointer
  32298. * @returns a Mesh or null if no mesh is under the pointer
  32299. */
  32300. getPointerOverMesh(): Nullable<AbstractMesh>;
  32301. }
  32302. }
  32303. declare module BABYLON {
  32304. /**
  32305. * Helper class used to generate session unique ID
  32306. */
  32307. export class UniqueIdGenerator {
  32308. private static _UniqueIdCounter;
  32309. /**
  32310. * Gets an unique (relatively to the current scene) Id
  32311. */
  32312. static readonly UniqueId: number;
  32313. }
  32314. }
  32315. declare module BABYLON {
  32316. /**
  32317. * This class defines the direct association between an animation and a target
  32318. */
  32319. export class TargetedAnimation {
  32320. /**
  32321. * Animation to perform
  32322. */
  32323. animation: Animation;
  32324. /**
  32325. * Target to animate
  32326. */
  32327. target: any;
  32328. /**
  32329. * Serialize the object
  32330. * @returns the JSON object representing the current entity
  32331. */
  32332. serialize(): any;
  32333. }
  32334. /**
  32335. * Use this class to create coordinated animations on multiple targets
  32336. */
  32337. export class AnimationGroup implements IDisposable {
  32338. /** The name of the animation group */
  32339. name: string;
  32340. private _scene;
  32341. private _targetedAnimations;
  32342. private _animatables;
  32343. private _from;
  32344. private _to;
  32345. private _isStarted;
  32346. private _isPaused;
  32347. private _speedRatio;
  32348. private _loopAnimation;
  32349. /**
  32350. * Gets or sets the unique id of the node
  32351. */
  32352. uniqueId: number;
  32353. /**
  32354. * This observable will notify when one animation have ended
  32355. */
  32356. onAnimationEndObservable: Observable<TargetedAnimation>;
  32357. /**
  32358. * Observer raised when one animation loops
  32359. */
  32360. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32361. /**
  32362. * This observable will notify when all animations have ended.
  32363. */
  32364. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32365. /**
  32366. * This observable will notify when all animations have paused.
  32367. */
  32368. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32369. /**
  32370. * This observable will notify when all animations are playing.
  32371. */
  32372. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32373. /**
  32374. * Gets the first frame
  32375. */
  32376. readonly from: number;
  32377. /**
  32378. * Gets the last frame
  32379. */
  32380. readonly to: number;
  32381. /**
  32382. * Define if the animations are started
  32383. */
  32384. readonly isStarted: boolean;
  32385. /**
  32386. * Gets a value indicating that the current group is playing
  32387. */
  32388. readonly isPlaying: boolean;
  32389. /**
  32390. * Gets or sets the speed ratio to use for all animations
  32391. */
  32392. /**
  32393. * Gets or sets the speed ratio to use for all animations
  32394. */
  32395. speedRatio: number;
  32396. /**
  32397. * Gets or sets if all animations should loop or not
  32398. */
  32399. loopAnimation: boolean;
  32400. /**
  32401. * Gets the targeted animations for this animation group
  32402. */
  32403. readonly targetedAnimations: Array<TargetedAnimation>;
  32404. /**
  32405. * returning the list of animatables controlled by this animation group.
  32406. */
  32407. readonly animatables: Array<Animatable>;
  32408. /**
  32409. * Instantiates a new Animation Group.
  32410. * This helps managing several animations at once.
  32411. * @see http://doc.babylonjs.com/how_to/group
  32412. * @param name Defines the name of the group
  32413. * @param scene Defines the scene the group belongs to
  32414. */
  32415. constructor(
  32416. /** The name of the animation group */
  32417. name: string, scene?: Nullable<Scene>);
  32418. /**
  32419. * Add an animation (with its target) in the group
  32420. * @param animation defines the animation we want to add
  32421. * @param target defines the target of the animation
  32422. * @returns the TargetedAnimation object
  32423. */
  32424. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32425. /**
  32426. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32427. * It can add constant keys at begin or end
  32428. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32429. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32430. * @returns the animation group
  32431. */
  32432. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32433. /**
  32434. * Start all animations on given targets
  32435. * @param loop defines if animations must loop
  32436. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32437. * @param from defines the from key (optional)
  32438. * @param to defines the to key (optional)
  32439. * @returns the current animation group
  32440. */
  32441. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32442. /**
  32443. * Pause all animations
  32444. * @returns the animation group
  32445. */
  32446. pause(): AnimationGroup;
  32447. /**
  32448. * Play all animations to initial state
  32449. * This function will start() the animations if they were not started or will restart() them if they were paused
  32450. * @param loop defines if animations must loop
  32451. * @returns the animation group
  32452. */
  32453. play(loop?: boolean): AnimationGroup;
  32454. /**
  32455. * Reset all animations to initial state
  32456. * @returns the animation group
  32457. */
  32458. reset(): AnimationGroup;
  32459. /**
  32460. * Restart animations from key 0
  32461. * @returns the animation group
  32462. */
  32463. restart(): AnimationGroup;
  32464. /**
  32465. * Stop all animations
  32466. * @returns the animation group
  32467. */
  32468. stop(): AnimationGroup;
  32469. /**
  32470. * Set animation weight for all animatables
  32471. * @param weight defines the weight to use
  32472. * @return the animationGroup
  32473. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32474. */
  32475. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32476. /**
  32477. * Synchronize and normalize all animatables with a source animatable
  32478. * @param root defines the root animatable to synchronize with
  32479. * @return the animationGroup
  32480. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32481. */
  32482. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32483. /**
  32484. * Goes to a specific frame in this animation group
  32485. * @param frame the frame number to go to
  32486. * @return the animationGroup
  32487. */
  32488. goToFrame(frame: number): AnimationGroup;
  32489. /**
  32490. * Dispose all associated resources
  32491. */
  32492. dispose(): void;
  32493. private _checkAnimationGroupEnded;
  32494. /**
  32495. * Clone the current animation group and returns a copy
  32496. * @param newName defines the name of the new group
  32497. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32498. * @returns the new aniamtion group
  32499. */
  32500. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32501. /**
  32502. * Serializes the animationGroup to an object
  32503. * @returns Serialized object
  32504. */
  32505. serialize(): any;
  32506. /**
  32507. * Returns a new AnimationGroup object parsed from the source provided.
  32508. * @param parsedAnimationGroup defines the source
  32509. * @param scene defines the scene that will receive the animationGroup
  32510. * @returns a new AnimationGroup
  32511. */
  32512. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32513. /**
  32514. * Returns the string "AnimationGroup"
  32515. * @returns "AnimationGroup"
  32516. */
  32517. getClassName(): string;
  32518. /**
  32519. * Creates a detailled string about the object
  32520. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32521. * @returns a string representing the object
  32522. */
  32523. toString(fullDetails?: boolean): string;
  32524. }
  32525. }
  32526. declare module BABYLON {
  32527. /**
  32528. * Define an interface for all classes that will hold resources
  32529. */
  32530. export interface IDisposable {
  32531. /**
  32532. * Releases all held resources
  32533. */
  32534. dispose(): void;
  32535. }
  32536. /** Interface defining initialization parameters for Scene class */
  32537. export interface SceneOptions {
  32538. /**
  32539. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32540. * It will improve performance when the number of geometries becomes important.
  32541. */
  32542. useGeometryUniqueIdsMap?: boolean;
  32543. /**
  32544. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32545. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32546. */
  32547. useMaterialMeshMap?: boolean;
  32548. /**
  32549. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32550. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32551. */
  32552. useClonedMeshhMap?: boolean;
  32553. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32554. virtual?: boolean;
  32555. }
  32556. /**
  32557. * Represents a scene to be rendered by the engine.
  32558. * @see http://doc.babylonjs.com/features/scene
  32559. */
  32560. export class Scene extends AbstractScene implements IAnimatable {
  32561. /** The fog is deactivated */
  32562. static readonly FOGMODE_NONE: number;
  32563. /** The fog density is following an exponential function */
  32564. static readonly FOGMODE_EXP: number;
  32565. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32566. static readonly FOGMODE_EXP2: number;
  32567. /** The fog density is following a linear function. */
  32568. static readonly FOGMODE_LINEAR: number;
  32569. /**
  32570. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32571. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32572. */
  32573. static MinDeltaTime: number;
  32574. /**
  32575. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32576. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32577. */
  32578. static MaxDeltaTime: number;
  32579. /**
  32580. * Factory used to create the default material.
  32581. * @param name The name of the material to create
  32582. * @param scene The scene to create the material for
  32583. * @returns The default material
  32584. */
  32585. static DefaultMaterialFactory(scene: Scene): Material;
  32586. /**
  32587. * Factory used to create the a collision coordinator.
  32588. * @returns The collision coordinator
  32589. */
  32590. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32591. /** @hidden */ private _inputManager: InputManager;
  32592. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32593. cameraToUseForPointers: Nullable<Camera>;
  32594. /** @hidden */ protected readonly _isScene: boolean;
  32595. /**
  32596. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32597. */
  32598. autoClear: boolean;
  32599. /**
  32600. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32601. */
  32602. autoClearDepthAndStencil: boolean;
  32603. /**
  32604. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32605. */
  32606. clearColor: Color4;
  32607. /**
  32608. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32609. */
  32610. ambientColor: Color3;
  32611. /**
  32612. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32613. * It should only be one of the following (if not the default embedded one):
  32614. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32615. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32616. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32617. * The material properties need to be setup according to the type of texture in use.
  32618. */
  32619. environmentBRDFTexture: BaseTexture;
  32620. /** @hidden */
  32621. protected _environmentTexture: Nullable<BaseTexture>;
  32622. /**
  32623. * Texture used in all pbr material as the reflection texture.
  32624. * As in the majority of the scene they are the same (exception for multi room and so on),
  32625. * this is easier to reference from here than from all the materials.
  32626. */
  32627. /**
  32628. * Texture used in all pbr material as the reflection texture.
  32629. * As in the majority of the scene they are the same (exception for multi room and so on),
  32630. * this is easier to set here than in all the materials.
  32631. */
  32632. environmentTexture: Nullable<BaseTexture>;
  32633. /** @hidden */
  32634. protected _environmentIntensity: number;
  32635. /**
  32636. * Intensity of the environment in all pbr material.
  32637. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32638. * As in the majority of the scene they are the same (exception for multi room and so on),
  32639. * this is easier to reference from here than from all the materials.
  32640. */
  32641. /**
  32642. * Intensity of the environment in all pbr material.
  32643. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32644. * As in the majority of the scene they are the same (exception for multi room and so on),
  32645. * this is easier to set here than in all the materials.
  32646. */
  32647. environmentIntensity: number;
  32648. /** @hidden */
  32649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32650. /**
  32651. * Default image processing configuration used either in the rendering
  32652. * Forward main pass or through the imageProcessingPostProcess if present.
  32653. * As in the majority of the scene they are the same (exception for multi camera),
  32654. * this is easier to reference from here than from all the materials and post process.
  32655. *
  32656. * No setter as we it is a shared configuration, you can set the values instead.
  32657. */
  32658. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32659. private _forceWireframe;
  32660. /**
  32661. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32662. */
  32663. forceWireframe: boolean;
  32664. private _forcePointsCloud;
  32665. /**
  32666. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32667. */
  32668. forcePointsCloud: boolean;
  32669. /**
  32670. * Gets or sets the active clipplane 1
  32671. */
  32672. clipPlane: Nullable<Plane>;
  32673. /**
  32674. * Gets or sets the active clipplane 2
  32675. */
  32676. clipPlane2: Nullable<Plane>;
  32677. /**
  32678. * Gets or sets the active clipplane 3
  32679. */
  32680. clipPlane3: Nullable<Plane>;
  32681. /**
  32682. * Gets or sets the active clipplane 4
  32683. */
  32684. clipPlane4: Nullable<Plane>;
  32685. /**
  32686. * Gets or sets a boolean indicating if animations are enabled
  32687. */
  32688. animationsEnabled: boolean;
  32689. private _animationPropertiesOverride;
  32690. /**
  32691. * Gets or sets the animation properties override
  32692. */
  32693. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32694. /**
  32695. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32696. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32697. */
  32698. useConstantAnimationDeltaTime: boolean;
  32699. /**
  32700. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32701. * Please note that it requires to run a ray cast through the scene on every frame
  32702. */
  32703. constantlyUpdateMeshUnderPointer: boolean;
  32704. /**
  32705. * Defines the HTML cursor to use when hovering over interactive elements
  32706. */
  32707. hoverCursor: string;
  32708. /**
  32709. * Defines the HTML default cursor to use (empty by default)
  32710. */
  32711. defaultCursor: string;
  32712. /**
  32713. * This is used to call preventDefault() on pointer down
  32714. * in order to block unwanted artifacts like system double clicks
  32715. */
  32716. preventDefaultOnPointerDown: boolean;
  32717. /**
  32718. * This is used to call preventDefault() on pointer up
  32719. * in order to block unwanted artifacts like system double clicks
  32720. */
  32721. preventDefaultOnPointerUp: boolean;
  32722. /**
  32723. * Gets or sets user defined metadata
  32724. */
  32725. metadata: any;
  32726. /**
  32727. * For internal use only. Please do not use.
  32728. */
  32729. reservedDataStore: any;
  32730. /**
  32731. * Gets the name of the plugin used to load this scene (null by default)
  32732. */
  32733. loadingPluginName: string;
  32734. /**
  32735. * Use this array to add regular expressions used to disable offline support for specific urls
  32736. */
  32737. disableOfflineSupportExceptionRules: RegExp[];
  32738. /**
  32739. * An event triggered when the scene is disposed.
  32740. */
  32741. onDisposeObservable: Observable<Scene>;
  32742. private _onDisposeObserver;
  32743. /** Sets a function to be executed when this scene is disposed. */
  32744. onDispose: () => void;
  32745. /**
  32746. * An event triggered before rendering the scene (right after animations and physics)
  32747. */
  32748. onBeforeRenderObservable: Observable<Scene>;
  32749. private _onBeforeRenderObserver;
  32750. /** Sets a function to be executed before rendering this scene */
  32751. beforeRender: Nullable<() => void>;
  32752. /**
  32753. * An event triggered after rendering the scene
  32754. */
  32755. onAfterRenderObservable: Observable<Scene>;
  32756. /**
  32757. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32758. */
  32759. onAfterRenderCameraObservable: Observable<Camera>;
  32760. private _onAfterRenderObserver;
  32761. /** Sets a function to be executed after rendering this scene */
  32762. afterRender: Nullable<() => void>;
  32763. /**
  32764. * An event triggered before animating the scene
  32765. */
  32766. onBeforeAnimationsObservable: Observable<Scene>;
  32767. /**
  32768. * An event triggered after animations processing
  32769. */
  32770. onAfterAnimationsObservable: Observable<Scene>;
  32771. /**
  32772. * An event triggered before draw calls are ready to be sent
  32773. */
  32774. onBeforeDrawPhaseObservable: Observable<Scene>;
  32775. /**
  32776. * An event triggered after draw calls have been sent
  32777. */
  32778. onAfterDrawPhaseObservable: Observable<Scene>;
  32779. /**
  32780. * An event triggered when the scene is ready
  32781. */
  32782. onReadyObservable: Observable<Scene>;
  32783. /**
  32784. * An event triggered before rendering a camera
  32785. */
  32786. onBeforeCameraRenderObservable: Observable<Camera>;
  32787. private _onBeforeCameraRenderObserver;
  32788. /** Sets a function to be executed before rendering a camera*/
  32789. beforeCameraRender: () => void;
  32790. /**
  32791. * An event triggered after rendering a camera
  32792. */
  32793. onAfterCameraRenderObservable: Observable<Camera>;
  32794. private _onAfterCameraRenderObserver;
  32795. /** Sets a function to be executed after rendering a camera*/
  32796. afterCameraRender: () => void;
  32797. /**
  32798. * An event triggered when active meshes evaluation is about to start
  32799. */
  32800. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32801. /**
  32802. * An event triggered when active meshes evaluation is done
  32803. */
  32804. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32805. /**
  32806. * An event triggered when particles rendering is about to start
  32807. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32808. */
  32809. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32810. /**
  32811. * An event triggered when particles rendering is done
  32812. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32813. */
  32814. onAfterParticlesRenderingObservable: Observable<Scene>;
  32815. /**
  32816. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32817. */
  32818. onDataLoadedObservable: Observable<Scene>;
  32819. /**
  32820. * An event triggered when a camera is created
  32821. */
  32822. onNewCameraAddedObservable: Observable<Camera>;
  32823. /**
  32824. * An event triggered when a camera is removed
  32825. */
  32826. onCameraRemovedObservable: Observable<Camera>;
  32827. /**
  32828. * An event triggered when a light is created
  32829. */
  32830. onNewLightAddedObservable: Observable<Light>;
  32831. /**
  32832. * An event triggered when a light is removed
  32833. */
  32834. onLightRemovedObservable: Observable<Light>;
  32835. /**
  32836. * An event triggered when a geometry is created
  32837. */
  32838. onNewGeometryAddedObservable: Observable<Geometry>;
  32839. /**
  32840. * An event triggered when a geometry is removed
  32841. */
  32842. onGeometryRemovedObservable: Observable<Geometry>;
  32843. /**
  32844. * An event triggered when a transform node is created
  32845. */
  32846. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32847. /**
  32848. * An event triggered when a transform node is removed
  32849. */
  32850. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32851. /**
  32852. * An event triggered when a mesh is created
  32853. */
  32854. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32855. /**
  32856. * An event triggered when a mesh is removed
  32857. */
  32858. onMeshRemovedObservable: Observable<AbstractMesh>;
  32859. /**
  32860. * An event triggered when a skeleton is created
  32861. */
  32862. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32863. /**
  32864. * An event triggered when a skeleton is removed
  32865. */
  32866. onSkeletonRemovedObservable: Observable<Skeleton>;
  32867. /**
  32868. * An event triggered when a material is created
  32869. */
  32870. onNewMaterialAddedObservable: Observable<Material>;
  32871. /**
  32872. * An event triggered when a material is removed
  32873. */
  32874. onMaterialRemovedObservable: Observable<Material>;
  32875. /**
  32876. * An event triggered when a texture is created
  32877. */
  32878. onNewTextureAddedObservable: Observable<BaseTexture>;
  32879. /**
  32880. * An event triggered when a texture is removed
  32881. */
  32882. onTextureRemovedObservable: Observable<BaseTexture>;
  32883. /**
  32884. * An event triggered when render targets are about to be rendered
  32885. * Can happen multiple times per frame.
  32886. */
  32887. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32888. /**
  32889. * An event triggered when render targets were rendered.
  32890. * Can happen multiple times per frame.
  32891. */
  32892. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32893. /**
  32894. * An event triggered before calculating deterministic simulation step
  32895. */
  32896. onBeforeStepObservable: Observable<Scene>;
  32897. /**
  32898. * An event triggered after calculating deterministic simulation step
  32899. */
  32900. onAfterStepObservable: Observable<Scene>;
  32901. /**
  32902. * An event triggered when the activeCamera property is updated
  32903. */
  32904. onActiveCameraChanged: Observable<Scene>;
  32905. /**
  32906. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32907. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32908. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  32909. */
  32910. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32911. /**
  32912. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32913. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32914. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  32915. */
  32916. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32917. /**
  32918. * This Observable will when a mesh has been imported into the scene.
  32919. */
  32920. onMeshImportedObservable: Observable<AbstractMesh>;
  32921. /**
  32922. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32923. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32924. */
  32925. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32926. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32927. /**
  32928. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32929. */
  32930. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32931. /**
  32932. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32933. */
  32934. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32935. /**
  32936. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32937. */
  32938. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32939. /** Callback called when a pointer move is detected */
  32940. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32941. /** Callback called when a pointer down is detected */
  32942. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32943. /** Callback called when a pointer up is detected */
  32944. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32945. /** Callback called when a pointer pick is detected */
  32946. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32947. /**
  32948. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  32949. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32950. */
  32951. onPrePointerObservable: Observable<PointerInfoPre>;
  32952. /**
  32953. * Observable event triggered each time an input event is received from the rendering canvas
  32954. */
  32955. onPointerObservable: Observable<PointerInfo>;
  32956. /**
  32957. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32958. */
  32959. readonly unTranslatedPointer: Vector2;
  32960. /**
  32961. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32962. */
  32963. static DragMovementThreshold: number;
  32964. /**
  32965. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32966. */
  32967. static LongPressDelay: number;
  32968. /**
  32969. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32970. */
  32971. static DoubleClickDelay: number;
  32972. /** If you need to check double click without raising a single click at first click, enable this flag */
  32973. static ExclusiveDoubleClickMode: boolean;
  32974. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32975. /**
  32976. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32977. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32978. */
  32979. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32980. /**
  32981. * Observable event triggered each time an keyboard event is received from the hosting window
  32982. */
  32983. onKeyboardObservable: Observable<KeyboardInfo>;
  32984. private _useRightHandedSystem;
  32985. /**
  32986. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32987. */
  32988. useRightHandedSystem: boolean;
  32989. private _timeAccumulator;
  32990. private _currentStepId;
  32991. private _currentInternalStep;
  32992. /**
  32993. * Sets the step Id used by deterministic lock step
  32994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32995. * @param newStepId defines the step Id
  32996. */
  32997. setStepId(newStepId: number): void;
  32998. /**
  32999. * Gets the step Id used by deterministic lock step
  33000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33001. * @returns the step Id
  33002. */
  33003. getStepId(): number;
  33004. /**
  33005. * Gets the internal step used by deterministic lock step
  33006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33007. * @returns the internal step
  33008. */
  33009. getInternalStep(): number;
  33010. private _fogEnabled;
  33011. /**
  33012. * Gets or sets a boolean indicating if fog is enabled on this scene
  33013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33014. * (Default is true)
  33015. */
  33016. fogEnabled: boolean;
  33017. private _fogMode;
  33018. /**
  33019. * Gets or sets the fog mode to use
  33020. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33021. * | mode | value |
  33022. * | --- | --- |
  33023. * | FOGMODE_NONE | 0 |
  33024. * | FOGMODE_EXP | 1 |
  33025. * | FOGMODE_EXP2 | 2 |
  33026. * | FOGMODE_LINEAR | 3 |
  33027. */
  33028. fogMode: number;
  33029. /**
  33030. * Gets or sets the fog color to use
  33031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33032. * (Default is Color3(0.2, 0.2, 0.3))
  33033. */
  33034. fogColor: Color3;
  33035. /**
  33036. * Gets or sets the fog density to use
  33037. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33038. * (Default is 0.1)
  33039. */
  33040. fogDensity: number;
  33041. /**
  33042. * Gets or sets the fog start distance to use
  33043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33044. * (Default is 0)
  33045. */
  33046. fogStart: number;
  33047. /**
  33048. * Gets or sets the fog end distance to use
  33049. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33050. * (Default is 1000)
  33051. */
  33052. fogEnd: number;
  33053. private _shadowsEnabled;
  33054. /**
  33055. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33056. */
  33057. shadowsEnabled: boolean;
  33058. private _lightsEnabled;
  33059. /**
  33060. * Gets or sets a boolean indicating if lights are enabled on this scene
  33061. */
  33062. lightsEnabled: boolean;
  33063. /** All of the active cameras added to this scene. */
  33064. activeCameras: Camera[];
  33065. /** @hidden */ private _activeCamera: Nullable<Camera>;
  33066. /** Gets or sets the current active camera */
  33067. activeCamera: Nullable<Camera>;
  33068. private _defaultMaterial;
  33069. /** The default material used on meshes when no material is affected */
  33070. /** The default material used on meshes when no material is affected */
  33071. defaultMaterial: Material;
  33072. private _texturesEnabled;
  33073. /**
  33074. * Gets or sets a boolean indicating if textures are enabled on this scene
  33075. */
  33076. texturesEnabled: boolean;
  33077. /**
  33078. * Gets or sets a boolean indicating if particles are enabled on this scene
  33079. */
  33080. particlesEnabled: boolean;
  33081. /**
  33082. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33083. */
  33084. spritesEnabled: boolean;
  33085. private _skeletonsEnabled;
  33086. /**
  33087. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33088. */
  33089. skeletonsEnabled: boolean;
  33090. /**
  33091. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33092. */
  33093. lensFlaresEnabled: boolean;
  33094. /**
  33095. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33097. */
  33098. collisionsEnabled: boolean;
  33099. private _collisionCoordinator;
  33100. /** @hidden */
  33101. readonly collisionCoordinator: ICollisionCoordinator;
  33102. /**
  33103. * Defines the gravity applied to this scene (used only for collisions)
  33104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33105. */
  33106. gravity: Vector3;
  33107. /**
  33108. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33109. */
  33110. postProcessesEnabled: boolean;
  33111. /**
  33112. * The list of postprocesses added to the scene
  33113. */
  33114. postProcesses: PostProcess[];
  33115. /**
  33116. * Gets the current postprocess manager
  33117. */
  33118. postProcessManager: PostProcessManager;
  33119. /**
  33120. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33121. */
  33122. renderTargetsEnabled: boolean;
  33123. /**
  33124. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33125. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33126. */
  33127. dumpNextRenderTargets: boolean;
  33128. /**
  33129. * The list of user defined render targets added to the scene
  33130. */
  33131. customRenderTargets: RenderTargetTexture[];
  33132. /**
  33133. * Defines if texture loading must be delayed
  33134. * If true, textures will only be loaded when they need to be rendered
  33135. */
  33136. useDelayedTextureLoading: boolean;
  33137. /**
  33138. * Gets the list of meshes imported to the scene through SceneLoader
  33139. */
  33140. importedMeshesFiles: String[];
  33141. /**
  33142. * Gets or sets a boolean indicating if probes are enabled on this scene
  33143. */
  33144. probesEnabled: boolean;
  33145. /**
  33146. * Gets or sets the current offline provider to use to store scene data
  33147. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33148. */
  33149. offlineProvider: IOfflineProvider;
  33150. /**
  33151. * Gets or sets the action manager associated with the scene
  33152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33153. */
  33154. actionManager: AbstractActionManager;
  33155. private _meshesForIntersections;
  33156. /**
  33157. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33158. */
  33159. proceduralTexturesEnabled: boolean;
  33160. private _engine;
  33161. private _totalVertices;
  33162. /** @hidden */ private _activeIndices: PerfCounter;
  33163. /** @hidden */ private _activeParticles: PerfCounter;
  33164. /** @hidden */ private _activeBones: PerfCounter;
  33165. private _animationRatio;
  33166. /** @hidden */ private _animationTimeLast: number;
  33167. /** @hidden */ private _animationTime: number;
  33168. /**
  33169. * Gets or sets a general scale for animation speed
  33170. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33171. */
  33172. animationTimeScale: number;
  33173. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  33174. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  33175. /** @hidden */ private _cachedVisibility: Nullable<number>;
  33176. private _renderId;
  33177. private _frameId;
  33178. private _executeWhenReadyTimeoutId;
  33179. private _intermediateRendering;
  33180. private _viewUpdateFlag;
  33181. private _projectionUpdateFlag;
  33182. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  33183. private _activeRequests;
  33184. /** @hidden */ private _pendingData: any[];
  33185. private _isDisposed;
  33186. /**
  33187. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33188. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33189. */
  33190. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33191. private _activeMeshes;
  33192. private _processedMaterials;
  33193. private _renderTargets;
  33194. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  33195. private _activeSkeletons;
  33196. private _softwareSkinnedMeshes;
  33197. private _renderingManager;
  33198. /** @hidden */ private _activeAnimatables: Animatable[];
  33199. private _transformMatrix;
  33200. private _sceneUbo;
  33201. /** @hidden */ private _viewMatrix: Matrix;
  33202. private _projectionMatrix;
  33203. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  33204. /** @hidden */ private _frustumPlanes: Plane[];
  33205. /**
  33206. * Gets the list of frustum planes (built from the active camera)
  33207. */
  33208. readonly frustumPlanes: Plane[];
  33209. /**
  33210. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33211. * This is useful if there are more lights that the maximum simulteanous authorized
  33212. */
  33213. requireLightSorting: boolean;
  33214. /** @hidden */
  33215. readonly useMaterialMeshMap: boolean;
  33216. /** @hidden */
  33217. readonly useClonedMeshhMap: boolean;
  33218. private _externalData;
  33219. private _uid;
  33220. /**
  33221. * @hidden
  33222. * Backing store of defined scene components.
  33223. */ private _components: ISceneComponent[];
  33224. /**
  33225. * @hidden
  33226. * Backing store of defined scene components.
  33227. */ private _serializableComponents: ISceneSerializableComponent[];
  33228. /**
  33229. * List of components to register on the next registration step.
  33230. */
  33231. private _transientComponents;
  33232. /**
  33233. * Registers the transient components if needed.
  33234. */
  33235. private _registerTransientComponents;
  33236. /**
  33237. * @hidden
  33238. * Add a component to the scene.
  33239. * Note that the ccomponent could be registered on th next frame if this is called after
  33240. * the register component stage.
  33241. * @param component Defines the component to add to the scene
  33242. */ private _addComponent(component: ISceneComponent): void;
  33243. /**
  33244. * @hidden
  33245. * Gets a component from the scene.
  33246. * @param name defines the name of the component to retrieve
  33247. * @returns the component or null if not present
  33248. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  33249. /**
  33250. * @hidden
  33251. * Defines the actions happening before camera updates.
  33252. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33253. /**
  33254. * @hidden
  33255. * Defines the actions happening before clear the canvas.
  33256. */ private _beforeClearStage: Stage<SimpleStageAction>;
  33257. /**
  33258. * @hidden
  33259. * Defines the actions when collecting render targets for the frame.
  33260. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33261. /**
  33262. * @hidden
  33263. * Defines the actions happening for one camera in the frame.
  33264. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33265. /**
  33266. * @hidden
  33267. * Defines the actions happening during the per mesh ready checks.
  33268. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  33269. /**
  33270. * @hidden
  33271. * Defines the actions happening before evaluate active mesh checks.
  33272. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33273. /**
  33274. * @hidden
  33275. * Defines the actions happening during the evaluate sub mesh checks.
  33276. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33277. /**
  33278. * @hidden
  33279. * Defines the actions happening during the active mesh stage.
  33280. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  33281. /**
  33282. * @hidden
  33283. * Defines the actions happening during the per camera render target step.
  33284. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33285. /**
  33286. * @hidden
  33287. * Defines the actions happening just before the active camera is drawing.
  33288. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  33289. /**
  33290. * @hidden
  33291. * Defines the actions happening just before a render target is drawing.
  33292. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33293. /**
  33294. * @hidden
  33295. * Defines the actions happening just before a rendering group is drawing.
  33296. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33297. /**
  33298. * @hidden
  33299. * Defines the actions happening just before a mesh is drawing.
  33300. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33301. /**
  33302. * @hidden
  33303. * Defines the actions happening just after a mesh has been drawn.
  33304. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33305. /**
  33306. * @hidden
  33307. * Defines the actions happening just after a rendering group has been drawn.
  33308. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33309. /**
  33310. * @hidden
  33311. * Defines the actions happening just after the active camera has been drawn.
  33312. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  33313. /**
  33314. * @hidden
  33315. * Defines the actions happening just after a render target has been drawn.
  33316. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33317. /**
  33318. * @hidden
  33319. * Defines the actions happening just after rendering all cameras and computing intersections.
  33320. */ private _afterRenderStage: Stage<SimpleStageAction>;
  33321. /**
  33322. * @hidden
  33323. * Defines the actions happening when a pointer move event happens.
  33324. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  33325. /**
  33326. * @hidden
  33327. * Defines the actions happening when a pointer down event happens.
  33328. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  33329. /**
  33330. * @hidden
  33331. * Defines the actions happening when a pointer up event happens.
  33332. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  33333. /**
  33334. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33335. */
  33336. private geometriesByUniqueId;
  33337. /**
  33338. * Creates a new Scene
  33339. * @param engine defines the engine to use to render this scene
  33340. * @param options defines the scene options
  33341. */
  33342. constructor(engine: Engine, options?: SceneOptions);
  33343. /**
  33344. * Gets a string idenfifying the name of the class
  33345. * @returns "Scene" string
  33346. */
  33347. getClassName(): string;
  33348. private _defaultMeshCandidates;
  33349. /**
  33350. * @hidden
  33351. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33352. private _defaultSubMeshCandidates;
  33353. /**
  33354. * @hidden
  33355. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33356. /**
  33357. * Sets the default candidate providers for the scene.
  33358. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33359. * and getCollidingSubMeshCandidates to their default function
  33360. */
  33361. setDefaultCandidateProviders(): void;
  33362. /**
  33363. * Gets the mesh that is currently under the pointer
  33364. */
  33365. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33366. /**
  33367. * Gets or sets the current on-screen X position of the pointer
  33368. */
  33369. pointerX: number;
  33370. /**
  33371. * Gets or sets the current on-screen Y position of the pointer
  33372. */
  33373. pointerY: number;
  33374. /**
  33375. * Gets the cached material (ie. the latest rendered one)
  33376. * @returns the cached material
  33377. */
  33378. getCachedMaterial(): Nullable<Material>;
  33379. /**
  33380. * Gets the cached effect (ie. the latest rendered one)
  33381. * @returns the cached effect
  33382. */
  33383. getCachedEffect(): Nullable<Effect>;
  33384. /**
  33385. * Gets the cached visibility state (ie. the latest rendered one)
  33386. * @returns the cached visibility state
  33387. */
  33388. getCachedVisibility(): Nullable<number>;
  33389. /**
  33390. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33391. * @param material defines the current material
  33392. * @param effect defines the current effect
  33393. * @param visibility defines the current visibility state
  33394. * @returns true if one parameter is not cached
  33395. */
  33396. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33397. /**
  33398. * Gets the engine associated with the scene
  33399. * @returns an Engine
  33400. */
  33401. getEngine(): Engine;
  33402. /**
  33403. * Gets the total number of vertices rendered per frame
  33404. * @returns the total number of vertices rendered per frame
  33405. */
  33406. getTotalVertices(): number;
  33407. /**
  33408. * Gets the performance counter for total vertices
  33409. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33410. */
  33411. readonly totalVerticesPerfCounter: PerfCounter;
  33412. /**
  33413. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33414. * @returns the total number of active indices rendered per frame
  33415. */
  33416. getActiveIndices(): number;
  33417. /**
  33418. * Gets the performance counter for active indices
  33419. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33420. */
  33421. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33422. /**
  33423. * Gets the total number of active particles rendered per frame
  33424. * @returns the total number of active particles rendered per frame
  33425. */
  33426. getActiveParticles(): number;
  33427. /**
  33428. * Gets the performance counter for active particles
  33429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33430. */
  33431. readonly activeParticlesPerfCounter: PerfCounter;
  33432. /**
  33433. * Gets the total number of active bones rendered per frame
  33434. * @returns the total number of active bones rendered per frame
  33435. */
  33436. getActiveBones(): number;
  33437. /**
  33438. * Gets the performance counter for active bones
  33439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33440. */
  33441. readonly activeBonesPerfCounter: PerfCounter;
  33442. /**
  33443. * Gets the array of active meshes
  33444. * @returns an array of AbstractMesh
  33445. */
  33446. getActiveMeshes(): SmartArray<AbstractMesh>;
  33447. /**
  33448. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33449. * @returns a number
  33450. */
  33451. getAnimationRatio(): number;
  33452. /**
  33453. * Gets an unique Id for the current render phase
  33454. * @returns a number
  33455. */
  33456. getRenderId(): number;
  33457. /**
  33458. * Gets an unique Id for the current frame
  33459. * @returns a number
  33460. */
  33461. getFrameId(): number;
  33462. /** Call this function if you want to manually increment the render Id*/
  33463. incrementRenderId(): void;
  33464. private _createUbo;
  33465. /**
  33466. * Use this method to simulate a pointer move on a mesh
  33467. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33468. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33469. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33470. * @returns the current scene
  33471. */
  33472. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33473. /**
  33474. * Use this method to simulate a pointer down on a mesh
  33475. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33476. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33477. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33478. * @returns the current scene
  33479. */
  33480. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33481. /**
  33482. * Use this method to simulate a pointer up on a mesh
  33483. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33484. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33485. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33486. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33487. * @returns the current scene
  33488. */
  33489. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33490. /**
  33491. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33492. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33493. * @returns true if the pointer was captured
  33494. */
  33495. isPointerCaptured(pointerId?: number): boolean;
  33496. /**
  33497. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33498. * @param attachUp defines if you want to attach events to pointerup
  33499. * @param attachDown defines if you want to attach events to pointerdown
  33500. * @param attachMove defines if you want to attach events to pointermove
  33501. */
  33502. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33503. /** Detaches all event handlers*/
  33504. detachControl(): void;
  33505. /**
  33506. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33507. * Delay loaded resources are not taking in account
  33508. * @return true if all required resources are ready
  33509. */
  33510. isReady(): boolean;
  33511. /** Resets all cached information relative to material (including effect and visibility) */
  33512. resetCachedMaterial(): void;
  33513. /**
  33514. * Registers a function to be called before every frame render
  33515. * @param func defines the function to register
  33516. */
  33517. registerBeforeRender(func: () => void): void;
  33518. /**
  33519. * Unregisters a function called before every frame render
  33520. * @param func defines the function to unregister
  33521. */
  33522. unregisterBeforeRender(func: () => void): void;
  33523. /**
  33524. * Registers a function to be called after every frame render
  33525. * @param func defines the function to register
  33526. */
  33527. registerAfterRender(func: () => void): void;
  33528. /**
  33529. * Unregisters a function called after every frame render
  33530. * @param func defines the function to unregister
  33531. */
  33532. unregisterAfterRender(func: () => void): void;
  33533. private _executeOnceBeforeRender;
  33534. /**
  33535. * The provided function will run before render once and will be disposed afterwards.
  33536. * A timeout delay can be provided so that the function will be executed in N ms.
  33537. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33538. * @param func The function to be executed.
  33539. * @param timeout optional delay in ms
  33540. */
  33541. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33542. /** @hidden */ private _addPendingData(data: any): void;
  33543. /** @hidden */ private _removePendingData(data: any): void;
  33544. /**
  33545. * Returns the number of items waiting to be loaded
  33546. * @returns the number of items waiting to be loaded
  33547. */
  33548. getWaitingItemsCount(): number;
  33549. /**
  33550. * Returns a boolean indicating if the scene is still loading data
  33551. */
  33552. readonly isLoading: boolean;
  33553. /**
  33554. * Registers a function to be executed when the scene is ready
  33555. * @param {Function} func - the function to be executed
  33556. */
  33557. executeWhenReady(func: () => void): void;
  33558. /**
  33559. * Returns a promise that resolves when the scene is ready
  33560. * @returns A promise that resolves when the scene is ready
  33561. */
  33562. whenReadyAsync(): Promise<void>;
  33563. /** @hidden */ private _checkIsReady(): void;
  33564. /**
  33565. * Gets all animatable attached to the scene
  33566. */
  33567. readonly animatables: Animatable[];
  33568. /**
  33569. * Resets the last animation time frame.
  33570. * Useful to override when animations start running when loading a scene for the first time.
  33571. */
  33572. resetLastAnimationTimeFrame(): void;
  33573. /**
  33574. * Gets the current view matrix
  33575. * @returns a Matrix
  33576. */
  33577. getViewMatrix(): Matrix;
  33578. /**
  33579. * Gets the current projection matrix
  33580. * @returns a Matrix
  33581. */
  33582. getProjectionMatrix(): Matrix;
  33583. /**
  33584. * Gets the current transform matrix
  33585. * @returns a Matrix made of View * Projection
  33586. */
  33587. getTransformMatrix(): Matrix;
  33588. /**
  33589. * Sets the current transform matrix
  33590. * @param viewL defines the View matrix to use
  33591. * @param projectionL defines the Projection matrix to use
  33592. * @param viewR defines the right View matrix to use (if provided)
  33593. * @param projectionR defines the right Projection matrix to use (if provided)
  33594. */
  33595. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33596. /**
  33597. * Gets the uniform buffer used to store scene data
  33598. * @returns a UniformBuffer
  33599. */
  33600. getSceneUniformBuffer(): UniformBuffer;
  33601. /**
  33602. * Gets an unique (relatively to the current scene) Id
  33603. * @returns an unique number for the scene
  33604. */
  33605. getUniqueId(): number;
  33606. /**
  33607. * Add a mesh to the list of scene's meshes
  33608. * @param newMesh defines the mesh to add
  33609. * @param recursive if all child meshes should also be added to the scene
  33610. */
  33611. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33612. /**
  33613. * Remove a mesh for the list of scene's meshes
  33614. * @param toRemove defines the mesh to remove
  33615. * @param recursive if all child meshes should also be removed from the scene
  33616. * @returns the index where the mesh was in the mesh list
  33617. */
  33618. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33619. /**
  33620. * Add a transform node to the list of scene's transform nodes
  33621. * @param newTransformNode defines the transform node to add
  33622. */
  33623. addTransformNode(newTransformNode: TransformNode): void;
  33624. /**
  33625. * Remove a transform node for the list of scene's transform nodes
  33626. * @param toRemove defines the transform node to remove
  33627. * @returns the index where the transform node was in the transform node list
  33628. */
  33629. removeTransformNode(toRemove: TransformNode): number;
  33630. /**
  33631. * Remove a skeleton for the list of scene's skeletons
  33632. * @param toRemove defines the skeleton to remove
  33633. * @returns the index where the skeleton was in the skeleton list
  33634. */
  33635. removeSkeleton(toRemove: Skeleton): number;
  33636. /**
  33637. * Remove a morph target for the list of scene's morph targets
  33638. * @param toRemove defines the morph target to remove
  33639. * @returns the index where the morph target was in the morph target list
  33640. */
  33641. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33642. /**
  33643. * Remove a light for the list of scene's lights
  33644. * @param toRemove defines the light to remove
  33645. * @returns the index where the light was in the light list
  33646. */
  33647. removeLight(toRemove: Light): number;
  33648. /**
  33649. * Remove a camera for the list of scene's cameras
  33650. * @param toRemove defines the camera to remove
  33651. * @returns the index where the camera was in the camera list
  33652. */
  33653. removeCamera(toRemove: Camera): number;
  33654. /**
  33655. * Remove a particle system for the list of scene's particle systems
  33656. * @param toRemove defines the particle system to remove
  33657. * @returns the index where the particle system was in the particle system list
  33658. */
  33659. removeParticleSystem(toRemove: IParticleSystem): number;
  33660. /**
  33661. * Remove a animation for the list of scene's animations
  33662. * @param toRemove defines the animation to remove
  33663. * @returns the index where the animation was in the animation list
  33664. */
  33665. removeAnimation(toRemove: Animation): number;
  33666. /**
  33667. * Will stop the animation of the given target
  33668. * @param target - the target
  33669. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33670. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  33671. */
  33672. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33673. /**
  33674. * Removes the given animation group from this scene.
  33675. * @param toRemove The animation group to remove
  33676. * @returns The index of the removed animation group
  33677. */
  33678. removeAnimationGroup(toRemove: AnimationGroup): number;
  33679. /**
  33680. * Removes the given multi-material from this scene.
  33681. * @param toRemove The multi-material to remove
  33682. * @returns The index of the removed multi-material
  33683. */
  33684. removeMultiMaterial(toRemove: MultiMaterial): number;
  33685. /**
  33686. * Removes the given material from this scene.
  33687. * @param toRemove The material to remove
  33688. * @returns The index of the removed material
  33689. */
  33690. removeMaterial(toRemove: Material): number;
  33691. /**
  33692. * Removes the given action manager from this scene.
  33693. * @param toRemove The action manager to remove
  33694. * @returns The index of the removed action manager
  33695. */
  33696. removeActionManager(toRemove: AbstractActionManager): number;
  33697. /**
  33698. * Removes the given texture from this scene.
  33699. * @param toRemove The texture to remove
  33700. * @returns The index of the removed texture
  33701. */
  33702. removeTexture(toRemove: BaseTexture): number;
  33703. /**
  33704. * Adds the given light to this scene
  33705. * @param newLight The light to add
  33706. */
  33707. addLight(newLight: Light): void;
  33708. /**
  33709. * Sorts the list list based on light priorities
  33710. */
  33711. sortLightsByPriority(): void;
  33712. /**
  33713. * Adds the given camera to this scene
  33714. * @param newCamera The camera to add
  33715. */
  33716. addCamera(newCamera: Camera): void;
  33717. /**
  33718. * Adds the given skeleton to this scene
  33719. * @param newSkeleton The skeleton to add
  33720. */
  33721. addSkeleton(newSkeleton: Skeleton): void;
  33722. /**
  33723. * Adds the given particle system to this scene
  33724. * @param newParticleSystem The particle system to add
  33725. */
  33726. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33727. /**
  33728. * Adds the given animation to this scene
  33729. * @param newAnimation The animation to add
  33730. */
  33731. addAnimation(newAnimation: Animation): void;
  33732. /**
  33733. * Adds the given animation group to this scene.
  33734. * @param newAnimationGroup The animation group to add
  33735. */
  33736. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33737. /**
  33738. * Adds the given multi-material to this scene
  33739. * @param newMultiMaterial The multi-material to add
  33740. */
  33741. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33742. /**
  33743. * Adds the given material to this scene
  33744. * @param newMaterial The material to add
  33745. */
  33746. addMaterial(newMaterial: Material): void;
  33747. /**
  33748. * Adds the given morph target to this scene
  33749. * @param newMorphTargetManager The morph target to add
  33750. */
  33751. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33752. /**
  33753. * Adds the given geometry to this scene
  33754. * @param newGeometry The geometry to add
  33755. */
  33756. addGeometry(newGeometry: Geometry): void;
  33757. /**
  33758. * Adds the given action manager to this scene
  33759. * @param newActionManager The action manager to add
  33760. */
  33761. addActionManager(newActionManager: AbstractActionManager): void;
  33762. /**
  33763. * Adds the given texture to this scene.
  33764. * @param newTexture The texture to add
  33765. */
  33766. addTexture(newTexture: BaseTexture): void;
  33767. /**
  33768. * Switch active camera
  33769. * @param newCamera defines the new active camera
  33770. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33771. */
  33772. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33773. /**
  33774. * sets the active camera of the scene using its ID
  33775. * @param id defines the camera's ID
  33776. * @return the new active camera or null if none found.
  33777. */
  33778. setActiveCameraByID(id: string): Nullable<Camera>;
  33779. /**
  33780. * sets the active camera of the scene using its name
  33781. * @param name defines the camera's name
  33782. * @returns the new active camera or null if none found.
  33783. */
  33784. setActiveCameraByName(name: string): Nullable<Camera>;
  33785. /**
  33786. * get an animation group using its name
  33787. * @param name defines the material's name
  33788. * @return the animation group or null if none found.
  33789. */
  33790. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33791. /**
  33792. * Get a material using its unique id
  33793. * @param uniqueId defines the material's unique id
  33794. * @return the material or null if none found.
  33795. */
  33796. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33797. /**
  33798. * get a material using its id
  33799. * @param id defines the material's ID
  33800. * @return the material or null if none found.
  33801. */
  33802. getMaterialByID(id: string): Nullable<Material>;
  33803. /**
  33804. * Gets a the last added material using a given id
  33805. * @param id defines the material's ID
  33806. * @return the last material with the given id or null if none found.
  33807. */
  33808. getLastMaterialByID(id: string): Nullable<Material>;
  33809. /**
  33810. * Gets a material using its name
  33811. * @param name defines the material's name
  33812. * @return the material or null if none found.
  33813. */
  33814. getMaterialByName(name: string): Nullable<Material>;
  33815. /**
  33816. * Get a texture using its unique id
  33817. * @param uniqueId defines the texture's unique id
  33818. * @return the texture or null if none found.
  33819. */
  33820. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33821. /**
  33822. * Gets a camera using its id
  33823. * @param id defines the id to look for
  33824. * @returns the camera or null if not found
  33825. */
  33826. getCameraByID(id: string): Nullable<Camera>;
  33827. /**
  33828. * Gets a camera using its unique id
  33829. * @param uniqueId defines the unique id to look for
  33830. * @returns the camera or null if not found
  33831. */
  33832. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33833. /**
  33834. * Gets a camera using its name
  33835. * @param name defines the camera's name
  33836. * @return the camera or null if none found.
  33837. */
  33838. getCameraByName(name: string): Nullable<Camera>;
  33839. /**
  33840. * Gets a bone using its id
  33841. * @param id defines the bone's id
  33842. * @return the bone or null if not found
  33843. */
  33844. getBoneByID(id: string): Nullable<Bone>;
  33845. /**
  33846. * Gets a bone using its id
  33847. * @param name defines the bone's name
  33848. * @return the bone or null if not found
  33849. */
  33850. getBoneByName(name: string): Nullable<Bone>;
  33851. /**
  33852. * Gets a light node using its name
  33853. * @param name defines the the light's name
  33854. * @return the light or null if none found.
  33855. */
  33856. getLightByName(name: string): Nullable<Light>;
  33857. /**
  33858. * Gets a light node using its id
  33859. * @param id defines the light's id
  33860. * @return the light or null if none found.
  33861. */
  33862. getLightByID(id: string): Nullable<Light>;
  33863. /**
  33864. * Gets a light node using its scene-generated unique ID
  33865. * @param uniqueId defines the light's unique id
  33866. * @return the light or null if none found.
  33867. */
  33868. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33869. /**
  33870. * Gets a particle system by id
  33871. * @param id defines the particle system id
  33872. * @return the corresponding system or null if none found
  33873. */
  33874. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33875. /**
  33876. * Gets a geometry using its ID
  33877. * @param id defines the geometry's id
  33878. * @return the geometry or null if none found.
  33879. */
  33880. getGeometryByID(id: string): Nullable<Geometry>;
  33881. private _getGeometryByUniqueID;
  33882. /**
  33883. * Add a new geometry to this scene
  33884. * @param geometry defines the geometry to be added to the scene.
  33885. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33886. * @return a boolean defining if the geometry was added or not
  33887. */
  33888. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33889. /**
  33890. * Removes an existing geometry
  33891. * @param geometry defines the geometry to be removed from the scene
  33892. * @return a boolean defining if the geometry was removed or not
  33893. */
  33894. removeGeometry(geometry: Geometry): boolean;
  33895. /**
  33896. * Gets the list of geometries attached to the scene
  33897. * @returns an array of Geometry
  33898. */
  33899. getGeometries(): Geometry[];
  33900. /**
  33901. * Gets the first added mesh found of a given ID
  33902. * @param id defines the id to search for
  33903. * @return the mesh found or null if not found at all
  33904. */
  33905. getMeshByID(id: string): Nullable<AbstractMesh>;
  33906. /**
  33907. * Gets a list of meshes using their id
  33908. * @param id defines the id to search for
  33909. * @returns a list of meshes
  33910. */
  33911. getMeshesByID(id: string): Array<AbstractMesh>;
  33912. /**
  33913. * Gets the first added transform node found of a given ID
  33914. * @param id defines the id to search for
  33915. * @return the found transform node or null if not found at all.
  33916. */
  33917. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33918. /**
  33919. * Gets a transform node with its auto-generated unique id
  33920. * @param uniqueId efines the unique id to search for
  33921. * @return the found transform node or null if not found at all.
  33922. */
  33923. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33924. /**
  33925. * Gets a list of transform nodes using their id
  33926. * @param id defines the id to search for
  33927. * @returns a list of transform nodes
  33928. */
  33929. getTransformNodesByID(id: string): Array<TransformNode>;
  33930. /**
  33931. * Gets a mesh with its auto-generated unique id
  33932. * @param uniqueId defines the unique id to search for
  33933. * @return the found mesh or null if not found at all.
  33934. */
  33935. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33936. /**
  33937. * Gets a the last added mesh using a given id
  33938. * @param id defines the id to search for
  33939. * @return the found mesh or null if not found at all.
  33940. */
  33941. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33942. /**
  33943. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33944. * @param id defines the id to search for
  33945. * @return the found node or null if not found at all
  33946. */
  33947. getLastEntryByID(id: string): Nullable<Node>;
  33948. /**
  33949. * Gets a node (Mesh, Camera, Light) using a given id
  33950. * @param id defines the id to search for
  33951. * @return the found node or null if not found at all
  33952. */
  33953. getNodeByID(id: string): Nullable<Node>;
  33954. /**
  33955. * Gets a node (Mesh, Camera, Light) using a given name
  33956. * @param name defines the name to search for
  33957. * @return the found node or null if not found at all.
  33958. */
  33959. getNodeByName(name: string): Nullable<Node>;
  33960. /**
  33961. * Gets a mesh using a given name
  33962. * @param name defines the name to search for
  33963. * @return the found mesh or null if not found at all.
  33964. */
  33965. getMeshByName(name: string): Nullable<AbstractMesh>;
  33966. /**
  33967. * Gets a transform node using a given name
  33968. * @param name defines the name to search for
  33969. * @return the found transform node or null if not found at all.
  33970. */
  33971. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33972. /**
  33973. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33974. * @param id defines the id to search for
  33975. * @return the found skeleton or null if not found at all.
  33976. */
  33977. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33978. /**
  33979. * Gets a skeleton using a given auto generated unique id
  33980. * @param uniqueId defines the unique id to search for
  33981. * @return the found skeleton or null if not found at all.
  33982. */
  33983. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33984. /**
  33985. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33986. * @param id defines the id to search for
  33987. * @return the found skeleton or null if not found at all.
  33988. */
  33989. getSkeletonById(id: string): Nullable<Skeleton>;
  33990. /**
  33991. * Gets a skeleton using a given name
  33992. * @param name defines the name to search for
  33993. * @return the found skeleton or null if not found at all.
  33994. */
  33995. getSkeletonByName(name: string): Nullable<Skeleton>;
  33996. /**
  33997. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33998. * @param id defines the id to search for
  33999. * @return the found morph target manager or null if not found at all.
  34000. */
  34001. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34002. /**
  34003. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34004. * @param id defines the id to search for
  34005. * @return the found morph target or null if not found at all.
  34006. */
  34007. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34008. /**
  34009. * Gets a boolean indicating if the given mesh is active
  34010. * @param mesh defines the mesh to look for
  34011. * @returns true if the mesh is in the active list
  34012. */
  34013. isActiveMesh(mesh: AbstractMesh): boolean;
  34014. /**
  34015. * Return a unique id as a string which can serve as an identifier for the scene
  34016. */
  34017. readonly uid: string;
  34018. /**
  34019. * Add an externaly attached data from its key.
  34020. * This method call will fail and return false, if such key already exists.
  34021. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34022. * @param key the unique key that identifies the data
  34023. * @param data the data object to associate to the key for this Engine instance
  34024. * @return true if no such key were already present and the data was added successfully, false otherwise
  34025. */
  34026. addExternalData<T>(key: string, data: T): boolean;
  34027. /**
  34028. * Get an externaly attached data from its key
  34029. * @param key the unique key that identifies the data
  34030. * @return the associated data, if present (can be null), or undefined if not present
  34031. */
  34032. getExternalData<T>(key: string): Nullable<T>;
  34033. /**
  34034. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34035. * @param key the unique key that identifies the data
  34036. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34037. * @return the associated data, can be null if the factory returned null.
  34038. */
  34039. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34040. /**
  34041. * Remove an externaly attached data from the Engine instance
  34042. * @param key the unique key that identifies the data
  34043. * @return true if the data was successfully removed, false if it doesn't exist
  34044. */
  34045. removeExternalData(key: string): boolean;
  34046. private _evaluateSubMesh;
  34047. /**
  34048. * Clear the processed materials smart array preventing retention point in material dispose.
  34049. */
  34050. freeProcessedMaterials(): void;
  34051. private _preventFreeActiveMeshesAndRenderingGroups;
  34052. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34053. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34054. * when disposing several meshes in a row or a hierarchy of meshes.
  34055. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34056. */
  34057. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34058. /**
  34059. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34060. */
  34061. freeActiveMeshes(): void;
  34062. /**
  34063. * Clear the info related to rendering groups preventing retention points during dispose.
  34064. */
  34065. freeRenderingGroups(): void;
  34066. /** @hidden */ private _isInIntermediateRendering(): boolean;
  34067. /**
  34068. * Lambda returning the list of potentially active meshes.
  34069. */
  34070. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34071. /**
  34072. * Lambda returning the list of potentially active sub meshes.
  34073. */
  34074. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34075. /**
  34076. * Lambda returning the list of potentially intersecting sub meshes.
  34077. */
  34078. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34079. /**
  34080. * Lambda returning the list of potentially colliding sub meshes.
  34081. */
  34082. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34083. private _activeMeshesFrozen;
  34084. /**
  34085. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34086. * @returns the current scene
  34087. */
  34088. freezeActiveMeshes(): Scene;
  34089. /**
  34090. * Use this function to restart evaluating active meshes on every frame
  34091. * @returns the current scene
  34092. */
  34093. unfreezeActiveMeshes(): Scene;
  34094. private _evaluateActiveMeshes;
  34095. private _activeMesh;
  34096. /**
  34097. * Update the transform matrix to update from the current active camera
  34098. * @param force defines a boolean used to force the update even if cache is up to date
  34099. */
  34100. updateTransformMatrix(force?: boolean): void;
  34101. private _bindFrameBuffer;
  34102. /** @hidden */ private _allowPostProcessClearColor: boolean;
  34103. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34104. private _processSubCameras;
  34105. private _checkIntersections;
  34106. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  34107. /**
  34108. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34109. */
  34110. getDeterministicFrameTime: () => number;
  34111. /** @hidden */ private _animate(): void;
  34112. /** Execute all animations (for a frame) */
  34113. animate(): void;
  34114. /**
  34115. * Render the scene
  34116. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34117. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34118. */
  34119. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34120. /**
  34121. * Freeze all materials
  34122. * A frozen material will not be updatable but should be faster to render
  34123. */
  34124. freezeMaterials(): void;
  34125. /**
  34126. * Unfreeze all materials
  34127. * A frozen material will not be updatable but should be faster to render
  34128. */
  34129. unfreezeMaterials(): void;
  34130. /**
  34131. * Releases all held ressources
  34132. */
  34133. dispose(): void;
  34134. /**
  34135. * Gets if the scene is already disposed
  34136. */
  34137. readonly isDisposed: boolean;
  34138. /**
  34139. * Call this function to reduce memory footprint of the scene.
  34140. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34141. */
  34142. clearCachedVertexData(): void;
  34143. /**
  34144. * This function will remove the local cached buffer data from texture.
  34145. * It will save memory but will prevent the texture from being rebuilt
  34146. */
  34147. cleanCachedTextureBuffer(): void;
  34148. /**
  34149. * Get the world extend vectors with an optional filter
  34150. *
  34151. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34152. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34153. */
  34154. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34155. min: Vector3;
  34156. max: Vector3;
  34157. };
  34158. /**
  34159. * Creates a ray that can be used to pick in the scene
  34160. * @param x defines the x coordinate of the origin (on-screen)
  34161. * @param y defines the y coordinate of the origin (on-screen)
  34162. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34163. * @param camera defines the camera to use for the picking
  34164. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34165. * @returns a Ray
  34166. */
  34167. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34168. /**
  34169. * Creates a ray that can be used to pick in the scene
  34170. * @param x defines the x coordinate of the origin (on-screen)
  34171. * @param y defines the y coordinate of the origin (on-screen)
  34172. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34173. * @param result defines the ray where to store the picking ray
  34174. * @param camera defines the camera to use for the picking
  34175. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34176. * @returns the current scene
  34177. */
  34178. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34179. /**
  34180. * Creates a ray that can be used to pick in the scene
  34181. * @param x defines the x coordinate of the origin (on-screen)
  34182. * @param y defines the y coordinate of the origin (on-screen)
  34183. * @param camera defines the camera to use for the picking
  34184. * @returns a Ray
  34185. */
  34186. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34187. /**
  34188. * Creates a ray that can be used to pick in the scene
  34189. * @param x defines the x coordinate of the origin (on-screen)
  34190. * @param y defines the y coordinate of the origin (on-screen)
  34191. * @param result defines the ray where to store the picking ray
  34192. * @param camera defines the camera to use for the picking
  34193. * @returns the current scene
  34194. */
  34195. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34196. /** Launch a ray to try to pick a mesh in the scene
  34197. * @param x position on screen
  34198. * @param y position on screen
  34199. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  34200. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34201. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34202. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34203. * @returns a PickingInfo
  34204. */
  34205. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34206. /** Use the given ray to pick a mesh in the scene
  34207. * @param ray The ray to use to pick meshes
  34208. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  34209. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34210. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34211. * @returns a PickingInfo
  34212. */
  34213. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34214. /**
  34215. * Launch a ray to try to pick a mesh in the scene
  34216. * @param x X position on screen
  34217. * @param y Y position on screen
  34218. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  34219. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34220. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34221. * @returns an array of PickingInfo
  34222. */
  34223. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34224. /**
  34225. * Launch a ray to try to pick a mesh in the scene
  34226. * @param ray Ray to use
  34227. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  34228. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34229. * @returns an array of PickingInfo
  34230. */
  34231. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34232. /**
  34233. * Force the value of meshUnderPointer
  34234. * @param mesh defines the mesh to use
  34235. */
  34236. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34237. /**
  34238. * Gets the mesh under the pointer
  34239. * @returns a Mesh or null if no mesh is under the pointer
  34240. */
  34241. getPointerOverMesh(): Nullable<AbstractMesh>;
  34242. /** @hidden */ private _rebuildGeometries(): void;
  34243. /** @hidden */ private _rebuildTextures(): void;
  34244. private _getByTags;
  34245. /**
  34246. * Get a list of meshes by tags
  34247. * @param tagsQuery defines the tags query to use
  34248. * @param forEach defines a predicate used to filter results
  34249. * @returns an array of Mesh
  34250. */
  34251. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34252. /**
  34253. * Get a list of cameras by tags
  34254. * @param tagsQuery defines the tags query to use
  34255. * @param forEach defines a predicate used to filter results
  34256. * @returns an array of Camera
  34257. */
  34258. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34259. /**
  34260. * Get a list of lights by tags
  34261. * @param tagsQuery defines the tags query to use
  34262. * @param forEach defines a predicate used to filter results
  34263. * @returns an array of Light
  34264. */
  34265. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34266. /**
  34267. * Get a list of materials by tags
  34268. * @param tagsQuery defines the tags query to use
  34269. * @param forEach defines a predicate used to filter results
  34270. * @returns an array of Material
  34271. */
  34272. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34273. /**
  34274. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34275. * This allowed control for front to back rendering or reversly depending of the special needs.
  34276. *
  34277. * @param renderingGroupId The rendering group id corresponding to its index
  34278. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34279. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34280. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34281. */
  34282. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  34283. /**
  34284. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34285. *
  34286. * @param renderingGroupId The rendering group id corresponding to its index
  34287. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34288. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34289. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34290. */
  34291. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34292. /**
  34293. * Gets the current auto clear configuration for one rendering group of the rendering
  34294. * manager.
  34295. * @param index the rendering group index to get the information for
  34296. * @returns The auto clear setup for the requested rendering group
  34297. */
  34298. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34299. private _blockMaterialDirtyMechanism;
  34300. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34301. blockMaterialDirtyMechanism: boolean;
  34302. /**
  34303. * Will flag all materials as dirty to trigger new shader compilation
  34304. * @param flag defines the flag used to specify which material part must be marked as dirty
  34305. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34306. */
  34307. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34308. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34309. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34310. }
  34311. }
  34312. declare module BABYLON {
  34313. /**
  34314. * Set of assets to keep when moving a scene into an asset container.
  34315. */
  34316. export class KeepAssets extends AbstractScene {
  34317. }
  34318. /**
  34319. * Container with a set of assets that can be added or removed from a scene.
  34320. */
  34321. export class AssetContainer extends AbstractScene {
  34322. /**
  34323. * The scene the AssetContainer belongs to.
  34324. */
  34325. scene: Scene;
  34326. /**
  34327. * Instantiates an AssetContainer.
  34328. * @param scene The scene the AssetContainer belongs to.
  34329. */
  34330. constructor(scene: Scene);
  34331. /**
  34332. * Adds all the assets from the container to the scene.
  34333. */
  34334. addAllToScene(): void;
  34335. /**
  34336. * Removes all the assets in the container from the scene
  34337. */
  34338. removeAllFromScene(): void;
  34339. /**
  34340. * Disposes all the assets in the container
  34341. */
  34342. dispose(): void;
  34343. private _moveAssets;
  34344. /**
  34345. * Removes all the assets contained in the scene and adds them to the container.
  34346. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34347. */
  34348. moveAllFromScene(keepAssets?: KeepAssets): void;
  34349. /**
  34350. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  34351. * @returns the root mesh
  34352. */
  34353. createRootMesh(): Mesh;
  34354. }
  34355. }
  34356. declare module BABYLON {
  34357. /**
  34358. * Defines how the parser contract is defined.
  34359. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34360. */
  34361. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34362. /**
  34363. * Defines how the individual parser contract is defined.
  34364. * These parser can parse an individual asset
  34365. */
  34366. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34367. /**
  34368. * Base class of the scene acting as a container for the different elements composing a scene.
  34369. * This class is dynamically extended by the different components of the scene increasing
  34370. * flexibility and reducing coupling
  34371. */
  34372. export abstract class AbstractScene {
  34373. /**
  34374. * Stores the list of available parsers in the application.
  34375. */
  34376. private static _BabylonFileParsers;
  34377. /**
  34378. * Stores the list of available individual parsers in the application.
  34379. */
  34380. private static _IndividualBabylonFileParsers;
  34381. /**
  34382. * Adds a parser in the list of available ones
  34383. * @param name Defines the name of the parser
  34384. * @param parser Defines the parser to add
  34385. */
  34386. static AddParser(name: string, parser: BabylonFileParser): void;
  34387. /**
  34388. * Gets a general parser from the list of avaialble ones
  34389. * @param name Defines the name of the parser
  34390. * @returns the requested parser or null
  34391. */
  34392. static GetParser(name: string): Nullable<BabylonFileParser>;
  34393. /**
  34394. * Adds n individual parser in the list of available ones
  34395. * @param name Defines the name of the parser
  34396. * @param parser Defines the parser to add
  34397. */
  34398. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34399. /**
  34400. * Gets an individual parser from the list of avaialble ones
  34401. * @param name Defines the name of the parser
  34402. * @returns the requested parser or null
  34403. */
  34404. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34405. /**
  34406. * Parser json data and populate both a scene and its associated container object
  34407. * @param jsonData Defines the data to parse
  34408. * @param scene Defines the scene to parse the data for
  34409. * @param container Defines the container attached to the parsing sequence
  34410. * @param rootUrl Defines the root url of the data
  34411. */
  34412. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34413. /**
  34414. * Gets the list of root nodes (ie. nodes with no parent)
  34415. */
  34416. rootNodes: Node[];
  34417. /** All of the cameras added to this scene
  34418. * @see http://doc.babylonjs.com/babylon101/cameras
  34419. */
  34420. cameras: Camera[];
  34421. /**
  34422. * All of the lights added to this scene
  34423. * @see http://doc.babylonjs.com/babylon101/lights
  34424. */
  34425. lights: Light[];
  34426. /**
  34427. * All of the (abstract) meshes added to this scene
  34428. */
  34429. meshes: AbstractMesh[];
  34430. /**
  34431. * The list of skeletons added to the scene
  34432. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34433. */
  34434. skeletons: Skeleton[];
  34435. /**
  34436. * All of the particle systems added to this scene
  34437. * @see http://doc.babylonjs.com/babylon101/particles
  34438. */
  34439. particleSystems: IParticleSystem[];
  34440. /**
  34441. * Gets a list of Animations associated with the scene
  34442. */
  34443. animations: Animation[];
  34444. /**
  34445. * All of the animation groups added to this scene
  34446. * @see http://doc.babylonjs.com/how_to/group
  34447. */
  34448. animationGroups: AnimationGroup[];
  34449. /**
  34450. * All of the multi-materials added to this scene
  34451. * @see http://doc.babylonjs.com/how_to/multi_materials
  34452. */
  34453. multiMaterials: MultiMaterial[];
  34454. /**
  34455. * All of the materials added to this scene
  34456. * In the context of a Scene, it is not supposed to be modified manually.
  34457. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34458. * Note also that the order of the Material wihin the array is not significant and might change.
  34459. * @see http://doc.babylonjs.com/babylon101/materials
  34460. */
  34461. materials: Material[];
  34462. /**
  34463. * The list of morph target managers added to the scene
  34464. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34465. */
  34466. morphTargetManagers: MorphTargetManager[];
  34467. /**
  34468. * The list of geometries used in the scene.
  34469. */
  34470. geometries: Geometry[];
  34471. /**
  34472. * All of the tranform nodes added to this scene
  34473. * In the context of a Scene, it is not supposed to be modified manually.
  34474. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34475. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34476. * @see http://doc.babylonjs.com/how_to/transformnode
  34477. */
  34478. transformNodes: TransformNode[];
  34479. /**
  34480. * ActionManagers available on the scene.
  34481. */
  34482. actionManagers: AbstractActionManager[];
  34483. /**
  34484. * Textures to keep.
  34485. */
  34486. textures: BaseTexture[];
  34487. /**
  34488. * Environment texture for the scene
  34489. */
  34490. environmentTexture: Nullable<BaseTexture>;
  34491. }
  34492. }
  34493. declare module BABYLON {
  34494. /**
  34495. * Interface used to define options for Sound class
  34496. */
  34497. export interface ISoundOptions {
  34498. /**
  34499. * Does the sound autoplay once loaded.
  34500. */
  34501. autoplay?: boolean;
  34502. /**
  34503. * Does the sound loop after it finishes playing once.
  34504. */
  34505. loop?: boolean;
  34506. /**
  34507. * Sound's volume
  34508. */
  34509. volume?: number;
  34510. /**
  34511. * Is it a spatial sound?
  34512. */
  34513. spatialSound?: boolean;
  34514. /**
  34515. * Maximum distance to hear that sound
  34516. */
  34517. maxDistance?: number;
  34518. /**
  34519. * Uses user defined attenuation function
  34520. */
  34521. useCustomAttenuation?: boolean;
  34522. /**
  34523. * Define the roll off factor of spatial sounds.
  34524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34525. */
  34526. rolloffFactor?: number;
  34527. /**
  34528. * Define the reference distance the sound should be heard perfectly.
  34529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34530. */
  34531. refDistance?: number;
  34532. /**
  34533. * Define the distance attenuation model the sound will follow.
  34534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34535. */
  34536. distanceModel?: string;
  34537. /**
  34538. * Defines the playback speed (1 by default)
  34539. */
  34540. playbackRate?: number;
  34541. /**
  34542. * Defines if the sound is from a streaming source
  34543. */
  34544. streaming?: boolean;
  34545. /**
  34546. * Defines an optional length (in seconds) inside the sound file
  34547. */
  34548. length?: number;
  34549. /**
  34550. * Defines an optional offset (in seconds) inside the sound file
  34551. */
  34552. offset?: number;
  34553. /**
  34554. * If true, URLs will not be required to state the audio file codec to use.
  34555. */
  34556. skipCodecCheck?: boolean;
  34557. }
  34558. /**
  34559. * Defines a sound that can be played in the application.
  34560. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34562. */
  34563. export class Sound {
  34564. /**
  34565. * The name of the sound in the scene.
  34566. */
  34567. name: string;
  34568. /**
  34569. * Does the sound autoplay once loaded.
  34570. */
  34571. autoplay: boolean;
  34572. /**
  34573. * Does the sound loop after it finishes playing once.
  34574. */
  34575. loop: boolean;
  34576. /**
  34577. * Does the sound use a custom attenuation curve to simulate the falloff
  34578. * happening when the source gets further away from the camera.
  34579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34580. */
  34581. useCustomAttenuation: boolean;
  34582. /**
  34583. * The sound track id this sound belongs to.
  34584. */
  34585. soundTrackId: number;
  34586. /**
  34587. * Is this sound currently played.
  34588. */
  34589. isPlaying: boolean;
  34590. /**
  34591. * Is this sound currently paused.
  34592. */
  34593. isPaused: boolean;
  34594. /**
  34595. * Does this sound enables spatial sound.
  34596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34597. */
  34598. spatialSound: boolean;
  34599. /**
  34600. * Define the reference distance the sound should be heard perfectly.
  34601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34602. */
  34603. refDistance: number;
  34604. /**
  34605. * Define the roll off factor of spatial sounds.
  34606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34607. */
  34608. rolloffFactor: number;
  34609. /**
  34610. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34612. */
  34613. maxDistance: number;
  34614. /**
  34615. * Define the distance attenuation model the sound will follow.
  34616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34617. */
  34618. distanceModel: string;
  34619. /**
  34620. * @hidden
  34621. * Back Compat
  34622. **/
  34623. onended: () => any;
  34624. /**
  34625. * Observable event when the current playing sound finishes.
  34626. */
  34627. onEndedObservable: Observable<Sound>;
  34628. private _panningModel;
  34629. private _playbackRate;
  34630. private _streaming;
  34631. private _startTime;
  34632. private _startOffset;
  34633. private _position;
  34634. /** @hidden */ private _positionInEmitterSpace: boolean;
  34635. private _localDirection;
  34636. private _volume;
  34637. private _isReadyToPlay;
  34638. private _isDirectional;
  34639. private _readyToPlayCallback;
  34640. private _audioBuffer;
  34641. private _soundSource;
  34642. private _streamingSource;
  34643. private _soundPanner;
  34644. private _soundGain;
  34645. private _inputAudioNode;
  34646. private _outputAudioNode;
  34647. private _coneInnerAngle;
  34648. private _coneOuterAngle;
  34649. private _coneOuterGain;
  34650. private _scene;
  34651. private _connectedTransformNode;
  34652. private _customAttenuationFunction;
  34653. private _registerFunc;
  34654. private _isOutputConnected;
  34655. private _htmlAudioElement;
  34656. private _urlType;
  34657. private _length?;
  34658. private _offset?;
  34659. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34660. /**
  34661. * Create a sound and attach it to a scene
  34662. * @param name Name of your sound
  34663. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34664. * @param scene defines the scene the sound belongs to
  34665. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34666. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34667. */
  34668. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34669. /**
  34670. * Release the sound and its associated resources
  34671. */
  34672. dispose(): void;
  34673. /**
  34674. * Gets if the sounds is ready to be played or not.
  34675. * @returns true if ready, otherwise false
  34676. */
  34677. isReady(): boolean;
  34678. private _soundLoaded;
  34679. /**
  34680. * Sets the data of the sound from an audiobuffer
  34681. * @param audioBuffer The audioBuffer containing the data
  34682. */
  34683. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34684. /**
  34685. * Updates the current sounds options such as maxdistance, loop...
  34686. * @param options A JSON object containing values named as the object properties
  34687. */
  34688. updateOptions(options: ISoundOptions): void;
  34689. private _createSpatialParameters;
  34690. private _updateSpatialParameters;
  34691. /**
  34692. * Switch the panning model to HRTF:
  34693. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34695. */
  34696. switchPanningModelToHRTF(): void;
  34697. /**
  34698. * Switch the panning model to Equal Power:
  34699. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34701. */
  34702. switchPanningModelToEqualPower(): void;
  34703. private _switchPanningModel;
  34704. /**
  34705. * Connect this sound to a sound track audio node like gain...
  34706. * @param soundTrackAudioNode the sound track audio node to connect to
  34707. */
  34708. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34709. /**
  34710. * Transform this sound into a directional source
  34711. * @param coneInnerAngle Size of the inner cone in degree
  34712. * @param coneOuterAngle Size of the outer cone in degree
  34713. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34714. */
  34715. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34716. /**
  34717. * Gets or sets the inner angle for the directional cone.
  34718. */
  34719. /**
  34720. * Gets or sets the inner angle for the directional cone.
  34721. */
  34722. directionalConeInnerAngle: number;
  34723. /**
  34724. * Gets or sets the outer angle for the directional cone.
  34725. */
  34726. /**
  34727. * Gets or sets the outer angle for the directional cone.
  34728. */
  34729. directionalConeOuterAngle: number;
  34730. /**
  34731. * Sets the position of the emitter if spatial sound is enabled
  34732. * @param newPosition Defines the new posisiton
  34733. */
  34734. setPosition(newPosition: Vector3): void;
  34735. /**
  34736. * Sets the local direction of the emitter if spatial sound is enabled
  34737. * @param newLocalDirection Defines the new local direction
  34738. */
  34739. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34740. private _updateDirection;
  34741. /** @hidden */
  34742. updateDistanceFromListener(): void;
  34743. /**
  34744. * Sets a new custom attenuation function for the sound.
  34745. * @param callback Defines the function used for the attenuation
  34746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34747. */
  34748. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34749. /**
  34750. * Play the sound
  34751. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34752. * @param offset (optional) Start the sound at a specific time in seconds
  34753. * @param length (optional) Sound duration (in seconds)
  34754. */
  34755. play(time?: number, offset?: number, length?: number): void;
  34756. private _onended;
  34757. /**
  34758. * Stop the sound
  34759. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34760. */
  34761. stop(time?: number): void;
  34762. /**
  34763. * Put the sound in pause
  34764. */
  34765. pause(): void;
  34766. /**
  34767. * Sets a dedicated volume for this sounds
  34768. * @param newVolume Define the new volume of the sound
  34769. * @param time Define time for gradual change to new volume
  34770. */
  34771. setVolume(newVolume: number, time?: number): void;
  34772. /**
  34773. * Set the sound play back rate
  34774. * @param newPlaybackRate Define the playback rate the sound should be played at
  34775. */
  34776. setPlaybackRate(newPlaybackRate: number): void;
  34777. /**
  34778. * Gets the volume of the sound.
  34779. * @returns the volume of the sound
  34780. */
  34781. getVolume(): number;
  34782. /**
  34783. * Attach the sound to a dedicated mesh
  34784. * @param transformNode The transform node to connect the sound with
  34785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34786. */
  34787. attachToMesh(transformNode: TransformNode): void;
  34788. /**
  34789. * Detach the sound from the previously attached mesh
  34790. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34791. */
  34792. detachFromMesh(): void;
  34793. private _onRegisterAfterWorldMatrixUpdate;
  34794. /**
  34795. * Clone the current sound in the scene.
  34796. * @returns the new sound clone
  34797. */
  34798. clone(): Nullable<Sound>;
  34799. /**
  34800. * Gets the current underlying audio buffer containing the data
  34801. * @returns the audio buffer
  34802. */
  34803. getAudioBuffer(): Nullable<AudioBuffer>;
  34804. /**
  34805. * Serializes the Sound in a JSON representation
  34806. * @returns the JSON representation of the sound
  34807. */
  34808. serialize(): any;
  34809. /**
  34810. * Parse a JSON representation of a sound to innstantiate in a given scene
  34811. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34812. * @param scene Define the scene the new parsed sound should be created in
  34813. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34814. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34815. * @returns the newly parsed sound
  34816. */
  34817. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34818. }
  34819. }
  34820. declare module BABYLON {
  34821. /**
  34822. * This defines an action helpful to play a defined sound on a triggered action.
  34823. */
  34824. export class PlaySoundAction extends Action {
  34825. private _sound;
  34826. /**
  34827. * Instantiate the action
  34828. * @param triggerOptions defines the trigger options
  34829. * @param sound defines the sound to play
  34830. * @param condition defines the trigger related conditions
  34831. */
  34832. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34833. /** @hidden */ private _prepare(): void;
  34834. /**
  34835. * Execute the action and play the sound.
  34836. */
  34837. execute(): void;
  34838. /**
  34839. * Serializes the actions and its related information.
  34840. * @param parent defines the object to serialize in
  34841. * @returns the serialized object
  34842. */
  34843. serialize(parent: any): any;
  34844. }
  34845. /**
  34846. * This defines an action helpful to stop a defined sound on a triggered action.
  34847. */
  34848. export class StopSoundAction extends Action {
  34849. private _sound;
  34850. /**
  34851. * Instantiate the action
  34852. * @param triggerOptions defines the trigger options
  34853. * @param sound defines the sound to stop
  34854. * @param condition defines the trigger related conditions
  34855. */
  34856. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34857. /** @hidden */ private _prepare(): void;
  34858. /**
  34859. * Execute the action and stop the sound.
  34860. */
  34861. execute(): void;
  34862. /**
  34863. * Serializes the actions and its related information.
  34864. * @param parent defines the object to serialize in
  34865. * @returns the serialized object
  34866. */
  34867. serialize(parent: any): any;
  34868. }
  34869. }
  34870. declare module BABYLON {
  34871. /**
  34872. * This defines an action responsible to change the value of a property
  34873. * by interpolating between its current value and the newly set one once triggered.
  34874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34875. */
  34876. export class InterpolateValueAction extends Action {
  34877. /**
  34878. * Defines the path of the property where the value should be interpolated
  34879. */
  34880. propertyPath: string;
  34881. /**
  34882. * Defines the target value at the end of the interpolation.
  34883. */
  34884. value: any;
  34885. /**
  34886. * Defines the time it will take for the property to interpolate to the value.
  34887. */
  34888. duration: number;
  34889. /**
  34890. * Defines if the other scene animations should be stopped when the action has been triggered
  34891. */
  34892. stopOtherAnimations?: boolean;
  34893. /**
  34894. * Defines a callback raised once the interpolation animation has been done.
  34895. */
  34896. onInterpolationDone?: () => void;
  34897. /**
  34898. * Observable triggered once the interpolation animation has been done.
  34899. */
  34900. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34901. private _target;
  34902. private _effectiveTarget;
  34903. private _property;
  34904. /**
  34905. * Instantiate the action
  34906. * @param triggerOptions defines the trigger options
  34907. * @param target defines the object containing the value to interpolate
  34908. * @param propertyPath defines the path to the property in the target object
  34909. * @param value defines the target value at the end of the interpolation
  34910. * @param duration deines the time it will take for the property to interpolate to the value.
  34911. * @param condition defines the trigger related conditions
  34912. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34913. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34914. */
  34915. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34916. /** @hidden */ private _prepare(): void;
  34917. /**
  34918. * Execute the action starts the value interpolation.
  34919. */
  34920. execute(): void;
  34921. /**
  34922. * Serializes the actions and its related information.
  34923. * @param parent defines the object to serialize in
  34924. * @returns the serialized object
  34925. */
  34926. serialize(parent: any): any;
  34927. }
  34928. }
  34929. declare module BABYLON {
  34930. /**
  34931. * Options allowed during the creation of a sound track.
  34932. */
  34933. export interface ISoundTrackOptions {
  34934. /**
  34935. * The volume the sound track should take during creation
  34936. */
  34937. volume?: number;
  34938. /**
  34939. * Define if the sound track is the main sound track of the scene
  34940. */
  34941. mainTrack?: boolean;
  34942. }
  34943. /**
  34944. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34945. * It will be also used in a future release to apply effects on a specific track.
  34946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34947. */
  34948. export class SoundTrack {
  34949. /**
  34950. * The unique identifier of the sound track in the scene.
  34951. */
  34952. id: number;
  34953. /**
  34954. * The list of sounds included in the sound track.
  34955. */
  34956. soundCollection: Array<Sound>;
  34957. private _outputAudioNode;
  34958. private _scene;
  34959. private _isMainTrack;
  34960. private _connectedAnalyser;
  34961. private _options;
  34962. private _isInitialized;
  34963. /**
  34964. * Creates a new sound track.
  34965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34966. * @param scene Define the scene the sound track belongs to
  34967. * @param options
  34968. */
  34969. constructor(scene: Scene, options?: ISoundTrackOptions);
  34970. private _initializeSoundTrackAudioGraph;
  34971. /**
  34972. * Release the sound track and its associated resources
  34973. */
  34974. dispose(): void;
  34975. /**
  34976. * Adds a sound to this sound track
  34977. * @param sound define the cound to add
  34978. * @ignoreNaming
  34979. */
  34980. AddSound(sound: Sound): void;
  34981. /**
  34982. * Removes a sound to this sound track
  34983. * @param sound define the cound to remove
  34984. * @ignoreNaming
  34985. */
  34986. RemoveSound(sound: Sound): void;
  34987. /**
  34988. * Set a global volume for the full sound track.
  34989. * @param newVolume Define the new volume of the sound track
  34990. */
  34991. setVolume(newVolume: number): void;
  34992. /**
  34993. * Switch the panning model to HRTF:
  34994. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34996. */
  34997. switchPanningModelToHRTF(): void;
  34998. /**
  34999. * Switch the panning model to Equal Power:
  35000. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35002. */
  35003. switchPanningModelToEqualPower(): void;
  35004. /**
  35005. * Connect the sound track to an audio analyser allowing some amazing
  35006. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35008. * @param analyser The analyser to connect to the engine
  35009. */
  35010. connectToAnalyser(analyser: Analyser): void;
  35011. }
  35012. }
  35013. declare module BABYLON {
  35014. interface AbstractScene {
  35015. /**
  35016. * The list of sounds used in the scene.
  35017. */
  35018. sounds: Nullable<Array<Sound>>;
  35019. }
  35020. interface Scene {
  35021. /**
  35022. * @hidden
  35023. * Backing field
  35024. */ private _mainSoundTrack: SoundTrack;
  35025. /**
  35026. * The main sound track played by the scene.
  35027. * It cotains your primary collection of sounds.
  35028. */
  35029. mainSoundTrack: SoundTrack;
  35030. /**
  35031. * The list of sound tracks added to the scene
  35032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35033. */
  35034. soundTracks: Nullable<Array<SoundTrack>>;
  35035. /**
  35036. * Gets a sound using a given name
  35037. * @param name defines the name to search for
  35038. * @return the found sound or null if not found at all.
  35039. */
  35040. getSoundByName(name: string): Nullable<Sound>;
  35041. /**
  35042. * Gets or sets if audio support is enabled
  35043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35044. */
  35045. audioEnabled: boolean;
  35046. /**
  35047. * Gets or sets if audio will be output to headphones
  35048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35049. */
  35050. headphone: boolean;
  35051. /**
  35052. * Gets or sets custom audio listener position provider
  35053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35054. */
  35055. audioListenerPositionProvider: Nullable<() => Vector3>;
  35056. }
  35057. /**
  35058. * Defines the sound scene component responsible to manage any sounds
  35059. * in a given scene.
  35060. */
  35061. export class AudioSceneComponent implements ISceneSerializableComponent {
  35062. /**
  35063. * The component name helpfull to identify the component in the list of scene components.
  35064. */
  35065. readonly name: string;
  35066. /**
  35067. * The scene the component belongs to.
  35068. */
  35069. scene: Scene;
  35070. private _audioEnabled;
  35071. /**
  35072. * Gets whether audio is enabled or not.
  35073. * Please use related enable/disable method to switch state.
  35074. */
  35075. readonly audioEnabled: boolean;
  35076. private _headphone;
  35077. /**
  35078. * Gets whether audio is outputing to headphone or not.
  35079. * Please use the according Switch methods to change output.
  35080. */
  35081. readonly headphone: boolean;
  35082. private _audioListenerPositionProvider;
  35083. /**
  35084. * Gets the current audio listener position provider
  35085. */
  35086. /**
  35087. * Sets a custom listener position for all sounds in the scene
  35088. * By default, this is the position of the first active camera
  35089. */
  35090. audioListenerPositionProvider: Nullable<() => Vector3>;
  35091. /**
  35092. * Creates a new instance of the component for the given scene
  35093. * @param scene Defines the scene to register the component in
  35094. */
  35095. constructor(scene: Scene);
  35096. /**
  35097. * Registers the component in a given scene
  35098. */
  35099. register(): void;
  35100. /**
  35101. * Rebuilds the elements related to this component in case of
  35102. * context lost for instance.
  35103. */
  35104. rebuild(): void;
  35105. /**
  35106. * Serializes the component data to the specified json object
  35107. * @param serializationObject The object to serialize to
  35108. */
  35109. serialize(serializationObject: any): void;
  35110. /**
  35111. * Adds all the elements from the container to the scene
  35112. * @param container the container holding the elements
  35113. */
  35114. addFromContainer(container: AbstractScene): void;
  35115. /**
  35116. * Removes all the elements in the container from the scene
  35117. * @param container contains the elements to remove
  35118. * @param dispose if the removed element should be disposed (default: false)
  35119. */
  35120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35121. /**
  35122. * Disposes the component and the associated ressources.
  35123. */
  35124. dispose(): void;
  35125. /**
  35126. * Disables audio in the associated scene.
  35127. */
  35128. disableAudio(): void;
  35129. /**
  35130. * Enables audio in the associated scene.
  35131. */
  35132. enableAudio(): void;
  35133. /**
  35134. * Switch audio to headphone output.
  35135. */
  35136. switchAudioModeForHeadphones(): void;
  35137. /**
  35138. * Switch audio to normal speakers.
  35139. */
  35140. switchAudioModeForNormalSpeakers(): void;
  35141. private _afterRender;
  35142. }
  35143. }
  35144. declare module BABYLON {
  35145. /**
  35146. * Wraps one or more Sound objects and selects one with random weight for playback.
  35147. */
  35148. export class WeightedSound {
  35149. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35150. loop: boolean;
  35151. private _coneInnerAngle;
  35152. private _coneOuterAngle;
  35153. private _volume;
  35154. /** A Sound is currently playing. */
  35155. isPlaying: boolean;
  35156. /** A Sound is currently paused. */
  35157. isPaused: boolean;
  35158. private _sounds;
  35159. private _weights;
  35160. private _currentIndex?;
  35161. /**
  35162. * Creates a new WeightedSound from the list of sounds given.
  35163. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35164. * @param sounds Array of Sounds that will be selected from.
  35165. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35166. */
  35167. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35168. /**
  35169. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35170. */
  35171. /**
  35172. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35173. */
  35174. directionalConeInnerAngle: number;
  35175. /**
  35176. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35177. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35178. */
  35179. /**
  35180. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35181. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35182. */
  35183. directionalConeOuterAngle: number;
  35184. /**
  35185. * Playback volume.
  35186. */
  35187. /**
  35188. * Playback volume.
  35189. */
  35190. volume: number;
  35191. private _onended;
  35192. /**
  35193. * Suspend playback
  35194. */
  35195. pause(): void;
  35196. /**
  35197. * Stop playback
  35198. */
  35199. stop(): void;
  35200. /**
  35201. * Start playback.
  35202. * @param startOffset Position the clip head at a specific time in seconds.
  35203. */
  35204. play(startOffset?: number): void;
  35205. }
  35206. }
  35207. declare module BABYLON {
  35208. /**
  35209. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35210. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35211. */
  35212. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35213. /**
  35214. * Gets the name of the behavior.
  35215. */
  35216. readonly name: string;
  35217. /**
  35218. * The easing function used by animations
  35219. */
  35220. static EasingFunction: BackEase;
  35221. /**
  35222. * The easing mode used by animations
  35223. */
  35224. static EasingMode: number;
  35225. /**
  35226. * The duration of the animation, in milliseconds
  35227. */
  35228. transitionDuration: number;
  35229. /**
  35230. * Length of the distance animated by the transition when lower radius is reached
  35231. */
  35232. lowerRadiusTransitionRange: number;
  35233. /**
  35234. * Length of the distance animated by the transition when upper radius is reached
  35235. */
  35236. upperRadiusTransitionRange: number;
  35237. private _autoTransitionRange;
  35238. /**
  35239. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35240. */
  35241. /**
  35242. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35243. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35244. */
  35245. autoTransitionRange: boolean;
  35246. private _attachedCamera;
  35247. private _onAfterCheckInputsObserver;
  35248. private _onMeshTargetChangedObserver;
  35249. /**
  35250. * Initializes the behavior.
  35251. */
  35252. init(): void;
  35253. /**
  35254. * Attaches the behavior to its arc rotate camera.
  35255. * @param camera Defines the camera to attach the behavior to
  35256. */
  35257. attach(camera: ArcRotateCamera): void;
  35258. /**
  35259. * Detaches the behavior from its current arc rotate camera.
  35260. */
  35261. detach(): void;
  35262. private _radiusIsAnimating;
  35263. private _radiusBounceTransition;
  35264. private _animatables;
  35265. private _cachedWheelPrecision;
  35266. /**
  35267. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35268. * @param radiusLimit The limit to check against.
  35269. * @return Bool to indicate if at limit.
  35270. */
  35271. private _isRadiusAtLimit;
  35272. /**
  35273. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35274. * @param radiusDelta The delta by which to animate to. Can be negative.
  35275. */
  35276. private _applyBoundRadiusAnimation;
  35277. /**
  35278. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35279. */
  35280. protected _clearAnimationLocks(): void;
  35281. /**
  35282. * Stops and removes all animations that have been applied to the camera
  35283. */
  35284. stopAllAnimations(): void;
  35285. }
  35286. }
  35287. declare module BABYLON {
  35288. /**
  35289. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  35290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35291. */
  35292. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35293. /**
  35294. * Gets the name of the behavior.
  35295. */
  35296. readonly name: string;
  35297. private _mode;
  35298. private _radiusScale;
  35299. private _positionScale;
  35300. private _defaultElevation;
  35301. private _elevationReturnTime;
  35302. private _elevationReturnWaitTime;
  35303. private _zoomStopsAnimation;
  35304. private _framingTime;
  35305. /**
  35306. * The easing function used by animations
  35307. */
  35308. static EasingFunction: ExponentialEase;
  35309. /**
  35310. * The easing mode used by animations
  35311. */
  35312. static EasingMode: number;
  35313. /**
  35314. * Sets the current mode used by the behavior
  35315. */
  35316. /**
  35317. * Gets current mode used by the behavior.
  35318. */
  35319. mode: number;
  35320. /**
  35321. * Sets the scale applied to the radius (1 by default)
  35322. */
  35323. /**
  35324. * Gets the scale applied to the radius
  35325. */
  35326. radiusScale: number;
  35327. /**
  35328. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35329. */
  35330. /**
  35331. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35332. */
  35333. positionScale: number;
  35334. /**
  35335. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35336. * behaviour is triggered, in radians.
  35337. */
  35338. /**
  35339. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35340. * behaviour is triggered, in radians.
  35341. */
  35342. defaultElevation: number;
  35343. /**
  35344. * Sets the time (in milliseconds) taken to return to the default beta position.
  35345. * Negative value indicates camera should not return to default.
  35346. */
  35347. /**
  35348. * Gets the time (in milliseconds) taken to return to the default beta position.
  35349. * Negative value indicates camera should not return to default.
  35350. */
  35351. elevationReturnTime: number;
  35352. /**
  35353. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35354. */
  35355. /**
  35356. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35357. */
  35358. elevationReturnWaitTime: number;
  35359. /**
  35360. * Sets the flag that indicates if user zooming should stop animation.
  35361. */
  35362. /**
  35363. * Gets the flag that indicates if user zooming should stop animation.
  35364. */
  35365. zoomStopsAnimation: boolean;
  35366. /**
  35367. * Sets the transition time when framing the mesh, in milliseconds
  35368. */
  35369. /**
  35370. * Gets the transition time when framing the mesh, in milliseconds
  35371. */
  35372. framingTime: number;
  35373. /**
  35374. * Define if the behavior should automatically change the configured
  35375. * camera limits and sensibilities.
  35376. */
  35377. autoCorrectCameraLimitsAndSensibility: boolean;
  35378. private _onPrePointerObservableObserver;
  35379. private _onAfterCheckInputsObserver;
  35380. private _onMeshTargetChangedObserver;
  35381. private _attachedCamera;
  35382. private _isPointerDown;
  35383. private _lastInteractionTime;
  35384. /**
  35385. * Initializes the behavior.
  35386. */
  35387. init(): void;
  35388. /**
  35389. * Attaches the behavior to its arc rotate camera.
  35390. * @param camera Defines the camera to attach the behavior to
  35391. */
  35392. attach(camera: ArcRotateCamera): void;
  35393. /**
  35394. * Detaches the behavior from its current arc rotate camera.
  35395. */
  35396. detach(): void;
  35397. private _animatables;
  35398. private _betaIsAnimating;
  35399. private _betaTransition;
  35400. private _radiusTransition;
  35401. private _vectorTransition;
  35402. /**
  35403. * Targets the given mesh and updates zoom level accordingly.
  35404. * @param mesh The mesh to target.
  35405. * @param radius Optional. If a cached radius position already exists, overrides default.
  35406. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35407. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35408. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35409. */
  35410. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35411. /**
  35412. * Targets the given mesh with its children and updates zoom level accordingly.
  35413. * @param mesh The mesh to target.
  35414. * @param radius Optional. If a cached radius position already exists, overrides default.
  35415. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35416. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35417. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35418. */
  35419. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35420. /**
  35421. * Targets the given meshes with their children and updates zoom level accordingly.
  35422. * @param meshes The mesh to target.
  35423. * @param radius Optional. If a cached radius position already exists, overrides default.
  35424. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35425. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35426. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35427. */
  35428. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35429. /**
  35430. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35431. * @param minimumWorld Determines the smaller position of the bounding box extend
  35432. * @param maximumWorld Determines the bigger position of the bounding box extend
  35433. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35434. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35435. */
  35436. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35437. /**
  35438. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35439. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35440. * frustum width.
  35441. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35442. * to fully enclose the mesh in the viewing frustum.
  35443. */
  35444. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35445. /**
  35446. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35447. * is automatically returned to its default position (expected to be above ground plane).
  35448. */
  35449. private _maintainCameraAboveGround;
  35450. /**
  35451. * Returns the frustum slope based on the canvas ratio and camera FOV
  35452. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35453. */
  35454. private _getFrustumSlope;
  35455. /**
  35456. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35457. */
  35458. private _clearAnimationLocks;
  35459. /**
  35460. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35461. */
  35462. private _applyUserInteraction;
  35463. /**
  35464. * Stops and removes all animations that have been applied to the camera
  35465. */
  35466. stopAllAnimations(): void;
  35467. /**
  35468. * Gets a value indicating if the user is moving the camera
  35469. */
  35470. readonly isUserIsMoving: boolean;
  35471. /**
  35472. * The camera can move all the way towards the mesh.
  35473. */
  35474. static IgnoreBoundsSizeMode: number;
  35475. /**
  35476. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35477. */
  35478. static FitFrustumSidesMode: number;
  35479. }
  35480. }
  35481. declare module BABYLON {
  35482. /**
  35483. * Base class for Camera Pointer Inputs.
  35484. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35485. * for example usage.
  35486. */
  35487. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35488. /**
  35489. * Defines the camera the input is attached to.
  35490. */
  35491. abstract camera: Camera;
  35492. /**
  35493. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35494. */
  35495. protected _altKey: boolean;
  35496. protected _ctrlKey: boolean;
  35497. protected _metaKey: boolean;
  35498. protected _shiftKey: boolean;
  35499. /**
  35500. * Which mouse buttons were pressed at time of last mouse event.
  35501. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35502. */
  35503. protected _buttonsPressed: number;
  35504. /**
  35505. * Defines the buttons associated with the input to handle camera move.
  35506. */
  35507. buttons: number[];
  35508. /**
  35509. * Attach the input controls to a specific dom element to get the input from.
  35510. * @param element Defines the element the controls should be listened from
  35511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35512. */
  35513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35514. /**
  35515. * Detach the current controls from the specified dom element.
  35516. * @param element Defines the element to stop listening the inputs from
  35517. */
  35518. detachControl(element: Nullable<HTMLElement>): void;
  35519. /**
  35520. * Gets the class name of the current input.
  35521. * @returns the class name
  35522. */
  35523. getClassName(): string;
  35524. /**
  35525. * Get the friendly name associated with the input class.
  35526. * @returns the input friendly name
  35527. */
  35528. getSimpleName(): string;
  35529. /**
  35530. * Called on pointer POINTERDOUBLETAP event.
  35531. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35532. */
  35533. protected onDoubleTap(type: string): void;
  35534. /**
  35535. * Called on pointer POINTERMOVE event if only a single touch is active.
  35536. * Override this method to provide functionality.
  35537. */
  35538. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35539. /**
  35540. * Called on pointer POINTERMOVE event if multiple touches are active.
  35541. * Override this method to provide functionality.
  35542. */
  35543. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35544. /**
  35545. * Called on JS contextmenu event.
  35546. * Override this method to provide functionality.
  35547. */
  35548. protected onContextMenu(evt: PointerEvent): void;
  35549. /**
  35550. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35551. * press.
  35552. * Override this method to provide functionality.
  35553. */
  35554. protected onButtonDown(evt: PointerEvent): void;
  35555. /**
  35556. * Called each time a new POINTERUP event occurs. Ie, for each button
  35557. * release.
  35558. * Override this method to provide functionality.
  35559. */
  35560. protected onButtonUp(evt: PointerEvent): void;
  35561. /**
  35562. * Called when window becomes inactive.
  35563. * Override this method to provide functionality.
  35564. */
  35565. protected onLostFocus(): void;
  35566. private _pointerInput;
  35567. private _observer;
  35568. private _onLostFocus;
  35569. private pointA;
  35570. private pointB;
  35571. }
  35572. }
  35573. declare module BABYLON {
  35574. /**
  35575. * Manage the pointers inputs to control an arc rotate camera.
  35576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35577. */
  35578. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35579. /**
  35580. * Defines the camera the input is attached to.
  35581. */
  35582. camera: ArcRotateCamera;
  35583. /**
  35584. * Gets the class name of the current input.
  35585. * @returns the class name
  35586. */
  35587. getClassName(): string;
  35588. /**
  35589. * Defines the buttons associated with the input to handle camera move.
  35590. */
  35591. buttons: number[];
  35592. /**
  35593. * Defines the pointer angular sensibility along the X axis or how fast is
  35594. * the camera rotating.
  35595. */
  35596. angularSensibilityX: number;
  35597. /**
  35598. * Defines the pointer angular sensibility along the Y axis or how fast is
  35599. * the camera rotating.
  35600. */
  35601. angularSensibilityY: number;
  35602. /**
  35603. * Defines the pointer pinch precision or how fast is the camera zooming.
  35604. */
  35605. pinchPrecision: number;
  35606. /**
  35607. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35608. * from 0.
  35609. * It defines the percentage of current camera.radius to use as delta when
  35610. * pinch zoom is used.
  35611. */
  35612. pinchDeltaPercentage: number;
  35613. /**
  35614. * Defines the pointer panning sensibility or how fast is the camera moving.
  35615. */
  35616. panningSensibility: number;
  35617. /**
  35618. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35619. */
  35620. multiTouchPanning: boolean;
  35621. /**
  35622. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35623. * zoom (pinch) through multitouch.
  35624. */
  35625. multiTouchPanAndZoom: boolean;
  35626. /**
  35627. * Revers pinch action direction.
  35628. */
  35629. pinchInwards: boolean;
  35630. private _isPanClick;
  35631. private _twoFingerActivityCount;
  35632. private _isPinching;
  35633. /**
  35634. * Called on pointer POINTERMOVE event if only a single touch is active.
  35635. */
  35636. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35637. /**
  35638. * Called on pointer POINTERDOUBLETAP event.
  35639. */
  35640. protected onDoubleTap(type: string): void;
  35641. /**
  35642. * Called on pointer POINTERMOVE event if multiple touches are active.
  35643. */
  35644. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35645. /**
  35646. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35647. * press.
  35648. */
  35649. protected onButtonDown(evt: PointerEvent): void;
  35650. /**
  35651. * Called each time a new POINTERUP event occurs. Ie, for each button
  35652. * release.
  35653. */
  35654. protected onButtonUp(evt: PointerEvent): void;
  35655. /**
  35656. * Called when window becomes inactive.
  35657. */
  35658. protected onLostFocus(): void;
  35659. }
  35660. }
  35661. declare module BABYLON {
  35662. /**
  35663. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35665. */
  35666. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35667. /**
  35668. * Defines the camera the input is attached to.
  35669. */
  35670. camera: ArcRotateCamera;
  35671. /**
  35672. * Defines the list of key codes associated with the up action (increase alpha)
  35673. */
  35674. keysUp: number[];
  35675. /**
  35676. * Defines the list of key codes associated with the down action (decrease alpha)
  35677. */
  35678. keysDown: number[];
  35679. /**
  35680. * Defines the list of key codes associated with the left action (increase beta)
  35681. */
  35682. keysLeft: number[];
  35683. /**
  35684. * Defines the list of key codes associated with the right action (decrease beta)
  35685. */
  35686. keysRight: number[];
  35687. /**
  35688. * Defines the list of key codes associated with the reset action.
  35689. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35690. */
  35691. keysReset: number[];
  35692. /**
  35693. * Defines the panning sensibility of the inputs.
  35694. * (How fast is the camera paning)
  35695. */
  35696. panningSensibility: number;
  35697. /**
  35698. * Defines the zooming sensibility of the inputs.
  35699. * (How fast is the camera zooming)
  35700. */
  35701. zoomingSensibility: number;
  35702. /**
  35703. * Defines wether maintaining the alt key down switch the movement mode from
  35704. * orientation to zoom.
  35705. */
  35706. useAltToZoom: boolean;
  35707. /**
  35708. * Rotation speed of the camera
  35709. */
  35710. angularSpeed: number;
  35711. private _keys;
  35712. private _ctrlPressed;
  35713. private _altPressed;
  35714. private _onCanvasBlurObserver;
  35715. private _onKeyboardObserver;
  35716. private _engine;
  35717. private _scene;
  35718. /**
  35719. * Attach the input controls to a specific dom element to get the input from.
  35720. * @param element Defines the element the controls should be listened from
  35721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35722. */
  35723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35724. /**
  35725. * Detach the current controls from the specified dom element.
  35726. * @param element Defines the element to stop listening the inputs from
  35727. */
  35728. detachControl(element: Nullable<HTMLElement>): void;
  35729. /**
  35730. * Update the current camera state depending on the inputs that have been used this frame.
  35731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35732. */
  35733. checkInputs(): void;
  35734. /**
  35735. * Gets the class name of the current intput.
  35736. * @returns the class name
  35737. */
  35738. getClassName(): string;
  35739. /**
  35740. * Get the friendly name associated with the input class.
  35741. * @returns the input friendly name
  35742. */
  35743. getSimpleName(): string;
  35744. }
  35745. }
  35746. declare module BABYLON {
  35747. /**
  35748. * Manage the mouse wheel inputs to control an arc rotate camera.
  35749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35750. */
  35751. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35752. /**
  35753. * Defines the camera the input is attached to.
  35754. */
  35755. camera: ArcRotateCamera;
  35756. /**
  35757. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35758. */
  35759. wheelPrecision: number;
  35760. /**
  35761. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35762. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35763. */
  35764. wheelDeltaPercentage: number;
  35765. private _wheel;
  35766. private _observer;
  35767. private computeDeltaFromMouseWheelLegacyEvent;
  35768. /**
  35769. * Attach the input controls to a specific dom element to get the input from.
  35770. * @param element Defines the element the controls should be listened from
  35771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35772. */
  35773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35774. /**
  35775. * Detach the current controls from the specified dom element.
  35776. * @param element Defines the element to stop listening the inputs from
  35777. */
  35778. detachControl(element: Nullable<HTMLElement>): void;
  35779. /**
  35780. * Gets the class name of the current intput.
  35781. * @returns the class name
  35782. */
  35783. getClassName(): string;
  35784. /**
  35785. * Get the friendly name associated with the input class.
  35786. * @returns the input friendly name
  35787. */
  35788. getSimpleName(): string;
  35789. }
  35790. }
  35791. declare module BABYLON {
  35792. /**
  35793. * Default Inputs manager for the ArcRotateCamera.
  35794. * It groups all the default supported inputs for ease of use.
  35795. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35796. */
  35797. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35798. /**
  35799. * Instantiates a new ArcRotateCameraInputsManager.
  35800. * @param camera Defines the camera the inputs belong to
  35801. */
  35802. constructor(camera: ArcRotateCamera);
  35803. /**
  35804. * Add mouse wheel input support to the input manager.
  35805. * @returns the current input manager
  35806. */
  35807. addMouseWheel(): ArcRotateCameraInputsManager;
  35808. /**
  35809. * Add pointers input support to the input manager.
  35810. * @returns the current input manager
  35811. */
  35812. addPointers(): ArcRotateCameraInputsManager;
  35813. /**
  35814. * Add keyboard input support to the input manager.
  35815. * @returns the current input manager
  35816. */
  35817. addKeyboard(): ArcRotateCameraInputsManager;
  35818. }
  35819. }
  35820. declare module BABYLON {
  35821. /**
  35822. * This represents an orbital type of camera.
  35823. *
  35824. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  35825. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  35826. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35827. */
  35828. export class ArcRotateCamera extends TargetCamera {
  35829. /**
  35830. * Defines the rotation angle of the camera along the longitudinal axis.
  35831. */
  35832. alpha: number;
  35833. /**
  35834. * Defines the rotation angle of the camera along the latitudinal axis.
  35835. */
  35836. beta: number;
  35837. /**
  35838. * Defines the radius of the camera from it s target point.
  35839. */
  35840. radius: number;
  35841. protected _target: Vector3;
  35842. protected _targetHost: Nullable<AbstractMesh>;
  35843. /**
  35844. * Defines the target point of the camera.
  35845. * The camera looks towards it form the radius distance.
  35846. */
  35847. target: Vector3;
  35848. /**
  35849. * Define the current local position of the camera in the scene
  35850. */
  35851. position: Vector3;
  35852. protected _upVector: Vector3;
  35853. protected _upToYMatrix: Matrix;
  35854. protected _YToUpMatrix: Matrix;
  35855. /**
  35856. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35857. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35858. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35859. */
  35860. upVector: Vector3;
  35861. /**
  35862. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35863. */
  35864. setMatUp(): void;
  35865. /**
  35866. * Current inertia value on the longitudinal axis.
  35867. * The bigger this number the longer it will take for the camera to stop.
  35868. */
  35869. inertialAlphaOffset: number;
  35870. /**
  35871. * Current inertia value on the latitudinal axis.
  35872. * The bigger this number the longer it will take for the camera to stop.
  35873. */
  35874. inertialBetaOffset: number;
  35875. /**
  35876. * Current inertia value on the radius axis.
  35877. * The bigger this number the longer it will take for the camera to stop.
  35878. */
  35879. inertialRadiusOffset: number;
  35880. /**
  35881. * Minimum allowed angle on the longitudinal axis.
  35882. * This can help limiting how the Camera is able to move in the scene.
  35883. */
  35884. lowerAlphaLimit: Nullable<number>;
  35885. /**
  35886. * Maximum allowed angle on the longitudinal axis.
  35887. * This can help limiting how the Camera is able to move in the scene.
  35888. */
  35889. upperAlphaLimit: Nullable<number>;
  35890. /**
  35891. * Minimum allowed angle on the latitudinal axis.
  35892. * This can help limiting how the Camera is able to move in the scene.
  35893. */
  35894. lowerBetaLimit: number;
  35895. /**
  35896. * Maximum allowed angle on the latitudinal axis.
  35897. * This can help limiting how the Camera is able to move in the scene.
  35898. */
  35899. upperBetaLimit: number;
  35900. /**
  35901. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35902. * This can help limiting how the Camera is able to move in the scene.
  35903. */
  35904. lowerRadiusLimit: Nullable<number>;
  35905. /**
  35906. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35907. * This can help limiting how the Camera is able to move in the scene.
  35908. */
  35909. upperRadiusLimit: Nullable<number>;
  35910. /**
  35911. * Defines the current inertia value used during panning of the camera along the X axis.
  35912. */
  35913. inertialPanningX: number;
  35914. /**
  35915. * Defines the current inertia value used during panning of the camera along the Y axis.
  35916. */
  35917. inertialPanningY: number;
  35918. /**
  35919. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35920. * Basically if your fingers moves away from more than this distance you will be considered
  35921. * in pinch mode.
  35922. */
  35923. pinchToPanMaxDistance: number;
  35924. /**
  35925. * Defines the maximum distance the camera can pan.
  35926. * This could help keeping the cammera always in your scene.
  35927. */
  35928. panningDistanceLimit: Nullable<number>;
  35929. /**
  35930. * Defines the target of the camera before paning.
  35931. */
  35932. panningOriginTarget: Vector3;
  35933. /**
  35934. * Defines the value of the inertia used during panning.
  35935. * 0 would mean stop inertia and one would mean no decelleration at all.
  35936. */
  35937. panningInertia: number;
  35938. /**
  35939. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35940. */
  35941. angularSensibilityX: number;
  35942. /**
  35943. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35944. */
  35945. angularSensibilityY: number;
  35946. /**
  35947. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35948. */
  35949. pinchPrecision: number;
  35950. /**
  35951. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35952. * It will be used instead of pinchDeltaPrecision if different from 0.
  35953. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35954. */
  35955. pinchDeltaPercentage: number;
  35956. /**
  35957. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35958. */
  35959. panningSensibility: number;
  35960. /**
  35961. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35962. */
  35963. keysUp: number[];
  35964. /**
  35965. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35966. */
  35967. keysDown: number[];
  35968. /**
  35969. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35970. */
  35971. keysLeft: number[];
  35972. /**
  35973. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35974. */
  35975. keysRight: number[];
  35976. /**
  35977. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35978. */
  35979. wheelPrecision: number;
  35980. /**
  35981. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35982. * It will be used instead of pinchDeltaPrecision if different from 0.
  35983. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35984. */
  35985. wheelDeltaPercentage: number;
  35986. /**
  35987. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35988. */
  35989. zoomOnFactor: number;
  35990. /**
  35991. * Defines a screen offset for the camera position.
  35992. */
  35993. targetScreenOffset: Vector2;
  35994. /**
  35995. * Allows the camera to be completely reversed.
  35996. * If false the camera can not arrive upside down.
  35997. */
  35998. allowUpsideDown: boolean;
  35999. /**
  36000. * Define if double tap/click is used to restore the previously saved state of the camera.
  36001. */
  36002. useInputToRestoreState: boolean;
  36003. /** @hidden */ private _viewMatrix: Matrix;
  36004. /** @hidden */ private _useCtrlForPanning: boolean;
  36005. /** @hidden */ private _panningMouseButton: number;
  36006. /**
  36007. * Defines the input associated to the camera.
  36008. */
  36009. inputs: ArcRotateCameraInputsManager;
  36010. /** @hidden */ private _reset: () => void;
  36011. /**
  36012. * Defines the allowed panning axis.
  36013. */
  36014. panningAxis: Vector3;
  36015. protected _localDirection: Vector3;
  36016. protected _transformedDirection: Vector3;
  36017. private _bouncingBehavior;
  36018. /**
  36019. * Gets the bouncing behavior of the camera if it has been enabled.
  36020. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36021. */
  36022. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36023. /**
  36024. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36025. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36026. */
  36027. useBouncingBehavior: boolean;
  36028. private _framingBehavior;
  36029. /**
  36030. * Gets the framing behavior of the camera if it has been enabled.
  36031. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36032. */
  36033. readonly framingBehavior: Nullable<FramingBehavior>;
  36034. /**
  36035. * Defines if the framing behavior of the camera is enabled on the camera.
  36036. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36037. */
  36038. useFramingBehavior: boolean;
  36039. private _autoRotationBehavior;
  36040. /**
  36041. * Gets the auto rotation behavior of the camera if it has been enabled.
  36042. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36043. */
  36044. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36045. /**
  36046. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36047. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36048. */
  36049. useAutoRotationBehavior: boolean;
  36050. /**
  36051. * Observable triggered when the mesh target has been changed on the camera.
  36052. */
  36053. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36054. /**
  36055. * Event raised when the camera is colliding with a mesh.
  36056. */
  36057. onCollide: (collidedMesh: AbstractMesh) => void;
  36058. /**
  36059. * Defines whether the camera should check collision with the objects oh the scene.
  36060. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36061. */
  36062. checkCollisions: boolean;
  36063. /**
  36064. * Defines the collision radius of the camera.
  36065. * This simulates a sphere around the camera.
  36066. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36067. */
  36068. collisionRadius: Vector3;
  36069. protected _collider: Collider;
  36070. protected _previousPosition: Vector3;
  36071. protected _collisionVelocity: Vector3;
  36072. protected _newPosition: Vector3;
  36073. protected _previousAlpha: number;
  36074. protected _previousBeta: number;
  36075. protected _previousRadius: number;
  36076. protected _collisionTriggered: boolean;
  36077. protected _targetBoundingCenter: Nullable<Vector3>;
  36078. private _computationVector;
  36079. /**
  36080. * Instantiates a new ArcRotateCamera in a given scene
  36081. * @param name Defines the name of the camera
  36082. * @param alpha Defines the camera rotation along the logitudinal axis
  36083. * @param beta Defines the camera rotation along the latitudinal axis
  36084. * @param radius Defines the camera distance from its target
  36085. * @param target Defines the camera target
  36086. * @param scene Defines the scene the camera belongs to
  36087. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36088. */
  36089. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36090. /** @hidden */ private _initCache(): void;
  36091. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  36092. protected _getTargetPosition(): Vector3;
  36093. private _storedAlpha;
  36094. private _storedBeta;
  36095. private _storedRadius;
  36096. private _storedTarget;
  36097. private _storedTargetScreenOffset;
  36098. /**
  36099. * Stores the current state of the camera (alpha, beta, radius and target)
  36100. * @returns the camera itself
  36101. */
  36102. storeState(): Camera;
  36103. /**
  36104. * @hidden
  36105. * Restored camera state. You must call storeState() first
  36106. */ private _restoreStateValues(): boolean;
  36107. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  36108. /**
  36109. * Attached controls to the current camera.
  36110. * @param element Defines the element the controls should be listened from
  36111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36112. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36113. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36114. */
  36115. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36116. /**
  36117. * Detach the current controls from the camera.
  36118. * The camera will stop reacting to inputs.
  36119. * @param element Defines the element to stop listening the inputs from
  36120. */
  36121. detachControl(element: HTMLElement): void;
  36122. /** @hidden */ private _checkInputs(): void;
  36123. protected _checkLimits(): void;
  36124. /**
  36125. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36126. */
  36127. rebuildAnglesAndRadius(): void;
  36128. /**
  36129. * Use a position to define the current camera related information like aplha, beta and radius
  36130. * @param position Defines the position to set the camera at
  36131. */
  36132. setPosition(position: Vector3): void;
  36133. /**
  36134. * Defines the target the camera should look at.
  36135. * This will automatically adapt alpha beta and radius to fit within the new target.
  36136. * @param target Defines the new target as a Vector or a mesh
  36137. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36138. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36139. */
  36140. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36141. /** @hidden */ private _getViewMatrix(): Matrix;
  36142. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36143. /**
  36144. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36145. * @param meshes Defines the mesh to zoom on
  36146. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  36147. */
  36148. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36149. /**
  36150. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36151. * The target will be changed but the radius
  36152. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36153. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  36154. */
  36155. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36156. min: Vector3;
  36157. max: Vector3;
  36158. distance: number;
  36159. }, doNotUpdateMaxZ?: boolean): void;
  36160. /**
  36161. * @override
  36162. * Override Camera.createRigCamera
  36163. */
  36164. createRigCamera(name: string, cameraIndex: number): Camera;
  36165. /**
  36166. * @hidden
  36167. * @override
  36168. * Override Camera._updateRigCameras
  36169. */ private _updateRigCameras(): void;
  36170. /**
  36171. * Destroy the camera and release the current resources hold by it.
  36172. */
  36173. dispose(): void;
  36174. /**
  36175. * Gets the current object class name.
  36176. * @return the class name
  36177. */
  36178. getClassName(): string;
  36179. }
  36180. }
  36181. declare module BABYLON {
  36182. /**
  36183. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36185. */
  36186. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36187. /**
  36188. * Gets the name of the behavior.
  36189. */
  36190. readonly name: string;
  36191. private _zoomStopsAnimation;
  36192. private _idleRotationSpeed;
  36193. private _idleRotationWaitTime;
  36194. private _idleRotationSpinupTime;
  36195. /**
  36196. * Sets the flag that indicates if user zooming should stop animation.
  36197. */
  36198. /**
  36199. * Gets the flag that indicates if user zooming should stop animation.
  36200. */
  36201. zoomStopsAnimation: boolean;
  36202. /**
  36203. * Sets the default speed at which the camera rotates around the model.
  36204. */
  36205. /**
  36206. * Gets the default speed at which the camera rotates around the model.
  36207. */
  36208. idleRotationSpeed: number;
  36209. /**
  36210. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36211. */
  36212. /**
  36213. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36214. */
  36215. idleRotationWaitTime: number;
  36216. /**
  36217. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36218. */
  36219. /**
  36220. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36221. */
  36222. idleRotationSpinupTime: number;
  36223. /**
  36224. * Gets a value indicating if the camera is currently rotating because of this behavior
  36225. */
  36226. readonly rotationInProgress: boolean;
  36227. private _onPrePointerObservableObserver;
  36228. private _onAfterCheckInputsObserver;
  36229. private _attachedCamera;
  36230. private _isPointerDown;
  36231. private _lastFrameTime;
  36232. private _lastInteractionTime;
  36233. private _cameraRotationSpeed;
  36234. /**
  36235. * Initializes the behavior.
  36236. */
  36237. init(): void;
  36238. /**
  36239. * Attaches the behavior to its arc rotate camera.
  36240. * @param camera Defines the camera to attach the behavior to
  36241. */
  36242. attach(camera: ArcRotateCamera): void;
  36243. /**
  36244. * Detaches the behavior from its current arc rotate camera.
  36245. */
  36246. detach(): void;
  36247. /**
  36248. * Returns true if user is scrolling.
  36249. * @return true if user is scrolling.
  36250. */
  36251. private _userIsZooming;
  36252. private _lastFrameRadius;
  36253. private _shouldAnimationStopForInteraction;
  36254. /**
  36255. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36256. */
  36257. private _applyUserInteraction;
  36258. private _userIsMoving;
  36259. }
  36260. }
  36261. declare module BABYLON {
  36262. /**
  36263. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36264. */
  36265. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36266. private ui;
  36267. /**
  36268. * The name of the behavior
  36269. */
  36270. name: string;
  36271. /**
  36272. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36273. */
  36274. distanceAwayFromFace: number;
  36275. /**
  36276. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36277. */
  36278. distanceAwayFromBottomOfFace: number;
  36279. private _faceVectors;
  36280. private _target;
  36281. private _scene;
  36282. private _onRenderObserver;
  36283. private _tmpMatrix;
  36284. private _tmpVector;
  36285. /**
  36286. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36287. * @param ui The transform node that should be attched to the mesh
  36288. */
  36289. constructor(ui: TransformNode);
  36290. /**
  36291. * Initializes the behavior
  36292. */
  36293. init(): void;
  36294. private _closestFace;
  36295. private _zeroVector;
  36296. private _lookAtTmpMatrix;
  36297. private _lookAtToRef;
  36298. /**
  36299. * Attaches the AttachToBoxBehavior to the passed in mesh
  36300. * @param target The mesh that the specified node will be attached to
  36301. */
  36302. attach(target: Mesh): void;
  36303. /**
  36304. * Detaches the behavior from the mesh
  36305. */
  36306. detach(): void;
  36307. }
  36308. }
  36309. declare module BABYLON {
  36310. /**
  36311. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36312. */
  36313. export class FadeInOutBehavior implements Behavior<Mesh> {
  36314. /**
  36315. * Time in milliseconds to delay before fading in (Default: 0)
  36316. */
  36317. delay: number;
  36318. /**
  36319. * Time in milliseconds for the mesh to fade in (Default: 300)
  36320. */
  36321. fadeInTime: number;
  36322. private _millisecondsPerFrame;
  36323. private _hovered;
  36324. private _hoverValue;
  36325. private _ownerNode;
  36326. /**
  36327. * Instatiates the FadeInOutBehavior
  36328. */
  36329. constructor();
  36330. /**
  36331. * The name of the behavior
  36332. */
  36333. readonly name: string;
  36334. /**
  36335. * Initializes the behavior
  36336. */
  36337. init(): void;
  36338. /**
  36339. * Attaches the fade behavior on the passed in mesh
  36340. * @param ownerNode The mesh that will be faded in/out once attached
  36341. */
  36342. attach(ownerNode: Mesh): void;
  36343. /**
  36344. * Detaches the behavior from the mesh
  36345. */
  36346. detach(): void;
  36347. /**
  36348. * Triggers the mesh to begin fading in or out
  36349. * @param value if the object should fade in or out (true to fade in)
  36350. */
  36351. fadeIn(value: boolean): void;
  36352. private _update;
  36353. private _setAllVisibility;
  36354. }
  36355. }
  36356. declare module BABYLON {
  36357. /**
  36358. * Class containing a set of static utilities functions for managing Pivots
  36359. * @hidden
  36360. */
  36361. export class PivotTools {
  36362. private static _PivotCached;
  36363. private static _OldPivotPoint;
  36364. private static _PivotTranslation;
  36365. private static _PivotTmpVector;
  36366. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36367. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  36368. }
  36369. }
  36370. declare module BABYLON {
  36371. /**
  36372. * Class containing static functions to help procedurally build meshes
  36373. */
  36374. export class PlaneBuilder {
  36375. /**
  36376. * Creates a plane mesh
  36377. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36378. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36379. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36383. * @param name defines the name of the mesh
  36384. * @param options defines the options used to create the mesh
  36385. * @param scene defines the hosting scene
  36386. * @returns the plane mesh
  36387. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36388. */
  36389. static CreatePlane(name: string, options: {
  36390. size?: number;
  36391. width?: number;
  36392. height?: number;
  36393. sideOrientation?: number;
  36394. frontUVs?: Vector4;
  36395. backUVs?: Vector4;
  36396. updatable?: boolean;
  36397. sourcePlane?: Plane;
  36398. }, scene?: Nullable<Scene>): Mesh;
  36399. }
  36400. }
  36401. declare module BABYLON {
  36402. /**
  36403. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36404. */
  36405. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36406. private static _AnyMouseID;
  36407. /**
  36408. * Abstract mesh the behavior is set on
  36409. */
  36410. attachedNode: AbstractMesh;
  36411. private _dragPlane;
  36412. private _scene;
  36413. private _pointerObserver;
  36414. private _beforeRenderObserver;
  36415. private static _planeScene;
  36416. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36417. /**
  36418. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  36419. */
  36420. maxDragAngle: number;
  36421. /**
  36422. * @hidden
  36423. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36424. /**
  36425. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36426. */
  36427. currentDraggingPointerID: number;
  36428. /**
  36429. * The last position where the pointer hit the drag plane in world space
  36430. */
  36431. lastDragPosition: Vector3;
  36432. /**
  36433. * If the behavior is currently in a dragging state
  36434. */
  36435. dragging: boolean;
  36436. /**
  36437. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  36438. */
  36439. dragDeltaRatio: number;
  36440. /**
  36441. * If the drag plane orientation should be updated during the dragging (Default: true)
  36442. */
  36443. updateDragPlane: boolean;
  36444. private _debugMode;
  36445. private _moving;
  36446. /**
  36447. * Fires each time the attached mesh is dragged with the pointer
  36448. * * delta between last drag position and current drag position in world space
  36449. * * dragDistance along the drag axis
  36450. * * dragPlaneNormal normal of the current drag plane used during the drag
  36451. * * dragPlanePoint in world space where the drag intersects the drag plane
  36452. */
  36453. onDragObservable: Observable<{
  36454. delta: Vector3;
  36455. dragPlanePoint: Vector3;
  36456. dragPlaneNormal: Vector3;
  36457. dragDistance: number;
  36458. pointerId: number;
  36459. }>;
  36460. /**
  36461. * Fires each time a drag begins (eg. mouse down on mesh)
  36462. */
  36463. onDragStartObservable: Observable<{
  36464. dragPlanePoint: Vector3;
  36465. pointerId: number;
  36466. }>;
  36467. /**
  36468. * Fires each time a drag ends (eg. mouse release after drag)
  36469. */
  36470. onDragEndObservable: Observable<{
  36471. dragPlanePoint: Vector3;
  36472. pointerId: number;
  36473. }>;
  36474. /**
  36475. * If the attached mesh should be moved when dragged
  36476. */
  36477. moveAttached: boolean;
  36478. /**
  36479. * If the drag behavior will react to drag events (Default: true)
  36480. */
  36481. enabled: boolean;
  36482. /**
  36483. * If pointer events should start and release the drag (Default: true)
  36484. */
  36485. startAndReleaseDragOnPointerEvents: boolean;
  36486. /**
  36487. * If camera controls should be detached during the drag
  36488. */
  36489. detachCameraControls: boolean;
  36490. /**
  36491. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36492. */
  36493. useObjectOrienationForDragging: boolean;
  36494. private _options;
  36495. /**
  36496. * Creates a pointer drag behavior that can be attached to a mesh
  36497. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  36498. */
  36499. constructor(options?: {
  36500. dragAxis?: Vector3;
  36501. dragPlaneNormal?: Vector3;
  36502. });
  36503. /**
  36504. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36505. */
  36506. validateDrag: (targetPosition: Vector3) => boolean;
  36507. /**
  36508. * The name of the behavior
  36509. */
  36510. readonly name: string;
  36511. /**
  36512. * Initializes the behavior
  36513. */
  36514. init(): void;
  36515. private _tmpVector;
  36516. private _alternatePickedPoint;
  36517. private _worldDragAxis;
  36518. private _targetPosition;
  36519. private _attachedElement;
  36520. /**
  36521. * Attaches the drag behavior the passed in mesh
  36522. * @param ownerNode The mesh that will be dragged around once attached
  36523. * @param predicate Predicate to use for pick filtering
  36524. */
  36525. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36526. /**
  36527. * Force relase the drag action by code.
  36528. */
  36529. releaseDrag(): void;
  36530. private _startDragRay;
  36531. private _lastPointerRay;
  36532. /**
  36533. * Simulates the start of a pointer drag event on the behavior
  36534. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36535. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36536. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36537. */
  36538. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36539. private _startDrag;
  36540. private _dragDelta;
  36541. private _moveDrag;
  36542. private _pickWithRayOnDragPlane;
  36543. private _pointA;
  36544. private _pointB;
  36545. private _pointC;
  36546. private _lineA;
  36547. private _lineB;
  36548. private _localAxis;
  36549. private _lookAt;
  36550. private _updateDragPlanePosition;
  36551. /**
  36552. * Detaches the behavior from the mesh
  36553. */
  36554. detach(): void;
  36555. }
  36556. }
  36557. declare module BABYLON {
  36558. /**
  36559. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36560. */
  36561. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36562. private _dragBehaviorA;
  36563. private _dragBehaviorB;
  36564. private _startDistance;
  36565. private _initialScale;
  36566. private _targetScale;
  36567. private _ownerNode;
  36568. private _sceneRenderObserver;
  36569. /**
  36570. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36571. */
  36572. constructor();
  36573. /**
  36574. * The name of the behavior
  36575. */
  36576. readonly name: string;
  36577. /**
  36578. * Initializes the behavior
  36579. */
  36580. init(): void;
  36581. private _getCurrentDistance;
  36582. /**
  36583. * Attaches the scale behavior the passed in mesh
  36584. * @param ownerNode The mesh that will be scaled around once attached
  36585. */
  36586. attach(ownerNode: Mesh): void;
  36587. /**
  36588. * Detaches the behavior from the mesh
  36589. */
  36590. detach(): void;
  36591. }
  36592. }
  36593. declare module BABYLON {
  36594. /**
  36595. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  36596. */
  36597. export class SixDofDragBehavior implements Behavior<Mesh> {
  36598. private static _virtualScene;
  36599. private _ownerNode;
  36600. private _sceneRenderObserver;
  36601. private _scene;
  36602. private _targetPosition;
  36603. private _virtualOriginMesh;
  36604. private _virtualDragMesh;
  36605. private _pointerObserver;
  36606. private _moving;
  36607. private _startingOrientation;
  36608. /**
  36609. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  36610. */
  36611. private zDragFactor;
  36612. /**
  36613. * If the object should rotate to face the drag origin
  36614. */
  36615. rotateDraggedObject: boolean;
  36616. /**
  36617. * If the behavior is currently in a dragging state
  36618. */
  36619. dragging: boolean;
  36620. /**
  36621. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  36622. */
  36623. dragDeltaRatio: number;
  36624. /**
  36625. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36626. */
  36627. currentDraggingPointerID: number;
  36628. /**
  36629. * If camera controls should be detached during the drag
  36630. */
  36631. detachCameraControls: boolean;
  36632. /**
  36633. * Fires each time a drag starts
  36634. */
  36635. onDragStartObservable: Observable<{}>;
  36636. /**
  36637. * Fires each time a drag ends (eg. mouse release after drag)
  36638. */
  36639. onDragEndObservable: Observable<{}>;
  36640. /**
  36641. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  36642. */
  36643. constructor();
  36644. /**
  36645. * The name of the behavior
  36646. */
  36647. readonly name: string;
  36648. /**
  36649. * Initializes the behavior
  36650. */
  36651. init(): void;
  36652. /**
  36653. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36654. */
  36655. private readonly _pointerCamera;
  36656. /**
  36657. * Attaches the scale behavior the passed in mesh
  36658. * @param ownerNode The mesh that will be scaled around once attached
  36659. */
  36660. attach(ownerNode: Mesh): void;
  36661. /**
  36662. * Detaches the behavior from the mesh
  36663. */
  36664. detach(): void;
  36665. }
  36666. }
  36667. declare module BABYLON {
  36668. /**
  36669. * Class used to apply inverse kinematics to bones
  36670. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36671. */
  36672. export class BoneIKController {
  36673. private static _tmpVecs;
  36674. private static _tmpQuat;
  36675. private static _tmpMats;
  36676. /**
  36677. * Gets or sets the target mesh
  36678. */
  36679. targetMesh: AbstractMesh;
  36680. /** Gets or sets the mesh used as pole */
  36681. poleTargetMesh: AbstractMesh;
  36682. /**
  36683. * Gets or sets the bone used as pole
  36684. */
  36685. poleTargetBone: Nullable<Bone>;
  36686. /**
  36687. * Gets or sets the target position
  36688. */
  36689. targetPosition: Vector3;
  36690. /**
  36691. * Gets or sets the pole target position
  36692. */
  36693. poleTargetPosition: Vector3;
  36694. /**
  36695. * Gets or sets the pole target local offset
  36696. */
  36697. poleTargetLocalOffset: Vector3;
  36698. /**
  36699. * Gets or sets the pole angle
  36700. */
  36701. poleAngle: number;
  36702. /**
  36703. * Gets or sets the mesh associated with the controller
  36704. */
  36705. mesh: AbstractMesh;
  36706. /**
  36707. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  36708. */
  36709. slerpAmount: number;
  36710. private _bone1Quat;
  36711. private _bone1Mat;
  36712. private _bone2Ang;
  36713. private _bone1;
  36714. private _bone2;
  36715. private _bone1Length;
  36716. private _bone2Length;
  36717. private _maxAngle;
  36718. private _maxReach;
  36719. private _rightHandedSystem;
  36720. private _bendAxis;
  36721. private _slerping;
  36722. private _adjustRoll;
  36723. /**
  36724. * Gets or sets maximum allowed angle
  36725. */
  36726. maxAngle: number;
  36727. /**
  36728. * Creates a new BoneIKController
  36729. * @param mesh defines the mesh to control
  36730. * @param bone defines the bone to control
  36731. * @param options defines options to set up the controller
  36732. */
  36733. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36734. targetMesh?: AbstractMesh;
  36735. poleTargetMesh?: AbstractMesh;
  36736. poleTargetBone?: Bone;
  36737. poleTargetLocalOffset?: Vector3;
  36738. poleAngle?: number;
  36739. bendAxis?: Vector3;
  36740. maxAngle?: number;
  36741. slerpAmount?: number;
  36742. });
  36743. private _setMaxAngle;
  36744. /**
  36745. * Force the controller to update the bones
  36746. */
  36747. update(): void;
  36748. }
  36749. }
  36750. declare module BABYLON {
  36751. /**
  36752. * Class used to make a bone look toward a point in space
  36753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36754. */
  36755. export class BoneLookController {
  36756. private static _tmpVecs;
  36757. private static _tmpQuat;
  36758. private static _tmpMats;
  36759. /**
  36760. * The target Vector3 that the bone will look at
  36761. */
  36762. target: Vector3;
  36763. /**
  36764. * The mesh that the bone is attached to
  36765. */
  36766. mesh: AbstractMesh;
  36767. /**
  36768. * The bone that will be looking to the target
  36769. */
  36770. bone: Bone;
  36771. /**
  36772. * The up axis of the coordinate system that is used when the bone is rotated
  36773. */
  36774. upAxis: Vector3;
  36775. /**
  36776. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36777. */
  36778. upAxisSpace: Space;
  36779. /**
  36780. * Used to make an adjustment to the yaw of the bone
  36781. */
  36782. adjustYaw: number;
  36783. /**
  36784. * Used to make an adjustment to the pitch of the bone
  36785. */
  36786. adjustPitch: number;
  36787. /**
  36788. * Used to make an adjustment to the roll of the bone
  36789. */
  36790. adjustRoll: number;
  36791. /**
  36792. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  36793. */
  36794. slerpAmount: number;
  36795. private _minYaw;
  36796. private _maxYaw;
  36797. private _minPitch;
  36798. private _maxPitch;
  36799. private _minYawSin;
  36800. private _minYawCos;
  36801. private _maxYawSin;
  36802. private _maxYawCos;
  36803. private _midYawConstraint;
  36804. private _minPitchTan;
  36805. private _maxPitchTan;
  36806. private _boneQuat;
  36807. private _slerping;
  36808. private _transformYawPitch;
  36809. private _transformYawPitchInv;
  36810. private _firstFrameSkipped;
  36811. private _yawRange;
  36812. private _fowardAxis;
  36813. /**
  36814. * Gets or sets the minimum yaw angle that the bone can look to
  36815. */
  36816. minYaw: number;
  36817. /**
  36818. * Gets or sets the maximum yaw angle that the bone can look to
  36819. */
  36820. maxYaw: number;
  36821. /**
  36822. * Gets or sets the minimum pitch angle that the bone can look to
  36823. */
  36824. minPitch: number;
  36825. /**
  36826. * Gets or sets the maximum pitch angle that the bone can look to
  36827. */
  36828. maxPitch: number;
  36829. /**
  36830. * Create a BoneLookController
  36831. * @param mesh the mesh that the bone belongs to
  36832. * @param bone the bone that will be looking to the target
  36833. * @param target the target Vector3 to look at
  36834. * @param options optional settings:
  36835. * * maxYaw: the maximum angle the bone will yaw to
  36836. * * minYaw: the minimum angle the bone will yaw to
  36837. * * maxPitch: the maximum angle the bone will pitch to
  36838. * * minPitch: the minimum angle the bone will yaw to
  36839. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36840. * * upAxis: the up axis of the coordinate system
  36841. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36842. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36843. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36844. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36845. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36846. * * adjustRoll: used to make an adjustment to the roll of the bone
  36847. **/
  36848. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36849. maxYaw?: number;
  36850. minYaw?: number;
  36851. maxPitch?: number;
  36852. minPitch?: number;
  36853. slerpAmount?: number;
  36854. upAxis?: Vector3;
  36855. upAxisSpace?: Space;
  36856. yawAxis?: Vector3;
  36857. pitchAxis?: Vector3;
  36858. adjustYaw?: number;
  36859. adjustPitch?: number;
  36860. adjustRoll?: number;
  36861. });
  36862. /**
  36863. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36864. */
  36865. update(): void;
  36866. private _getAngleDiff;
  36867. private _getAngleBetween;
  36868. private _isAngleBetween;
  36869. }
  36870. }
  36871. declare module BABYLON {
  36872. /**
  36873. * Manage the gamepad inputs to control an arc rotate camera.
  36874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36875. */
  36876. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36877. /**
  36878. * Defines the camera the input is attached to.
  36879. */
  36880. camera: ArcRotateCamera;
  36881. /**
  36882. * Defines the gamepad the input is gathering event from.
  36883. */
  36884. gamepad: Nullable<Gamepad>;
  36885. /**
  36886. * Defines the gamepad rotation sensiblity.
  36887. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36888. */
  36889. gamepadRotationSensibility: number;
  36890. /**
  36891. * Defines the gamepad move sensiblity.
  36892. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36893. */
  36894. gamepadMoveSensibility: number;
  36895. private _onGamepadConnectedObserver;
  36896. private _onGamepadDisconnectedObserver;
  36897. /**
  36898. * Attach the input controls to a specific dom element to get the input from.
  36899. * @param element Defines the element the controls should be listened from
  36900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36901. */
  36902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36903. /**
  36904. * Detach the current controls from the specified dom element.
  36905. * @param element Defines the element to stop listening the inputs from
  36906. */
  36907. detachControl(element: Nullable<HTMLElement>): void;
  36908. /**
  36909. * Update the current camera state depending on the inputs that have been used this frame.
  36910. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36911. */
  36912. checkInputs(): void;
  36913. /**
  36914. * Gets the class name of the current intput.
  36915. * @returns the class name
  36916. */
  36917. getClassName(): string;
  36918. /**
  36919. * Get the friendly name associated with the input class.
  36920. * @returns the input friendly name
  36921. */
  36922. getSimpleName(): string;
  36923. }
  36924. }
  36925. declare module BABYLON {
  36926. interface ArcRotateCameraInputsManager {
  36927. /**
  36928. * Add orientation input support to the input manager.
  36929. * @returns the current input manager
  36930. */
  36931. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36932. }
  36933. /**
  36934. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36936. */
  36937. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36938. /**
  36939. * Defines the camera the input is attached to.
  36940. */
  36941. camera: ArcRotateCamera;
  36942. /**
  36943. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36944. */
  36945. alphaCorrection: number;
  36946. /**
  36947. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36948. */
  36949. gammaCorrection: number;
  36950. private _alpha;
  36951. private _gamma;
  36952. private _dirty;
  36953. private _deviceOrientationHandler;
  36954. /**
  36955. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36956. */
  36957. constructor();
  36958. /**
  36959. * Attach the input controls to a specific dom element to get the input from.
  36960. * @param element Defines the element the controls should be listened from
  36961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36962. */
  36963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36964. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36965. /**
  36966. * Update the current camera state depending on the inputs that have been used this frame.
  36967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36968. */
  36969. checkInputs(): void;
  36970. /**
  36971. * Detach the current controls from the specified dom element.
  36972. * @param element Defines the element to stop listening the inputs from
  36973. */
  36974. detachControl(element: Nullable<HTMLElement>): void;
  36975. /**
  36976. * Gets the class name of the current intput.
  36977. * @returns the class name
  36978. */
  36979. getClassName(): string;
  36980. /**
  36981. * Get the friendly name associated with the input class.
  36982. * @returns the input friendly name
  36983. */
  36984. getSimpleName(): string;
  36985. }
  36986. }
  36987. declare module BABYLON {
  36988. /**
  36989. * Listen to mouse events to control the camera.
  36990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36991. */
  36992. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36993. /**
  36994. * Defines the camera the input is attached to.
  36995. */
  36996. camera: FlyCamera;
  36997. /**
  36998. * Defines if touch is enabled. (Default is true.)
  36999. */
  37000. touchEnabled: boolean;
  37001. /**
  37002. * Defines the buttons associated with the input to handle camera rotation.
  37003. */
  37004. buttons: number[];
  37005. /**
  37006. * Assign buttons for Yaw control.
  37007. */
  37008. buttonsYaw: number[];
  37009. /**
  37010. * Assign buttons for Pitch control.
  37011. */
  37012. buttonsPitch: number[];
  37013. /**
  37014. * Assign buttons for Roll control.
  37015. */
  37016. buttonsRoll: number[];
  37017. /**
  37018. * Detect if any button is being pressed while mouse is moved.
  37019. * -1 = Mouse locked.
  37020. * 0 = Left button.
  37021. * 1 = Middle Button.
  37022. * 2 = Right Button.
  37023. */
  37024. activeButton: number;
  37025. /**
  37026. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37027. * Higher values reduce its sensitivity.
  37028. */
  37029. angularSensibility: number;
  37030. private _mousemoveCallback;
  37031. private _observer;
  37032. private _rollObserver;
  37033. private previousPosition;
  37034. private noPreventDefault;
  37035. private element;
  37036. /**
  37037. * Listen to mouse events to control the camera.
  37038. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37040. */
  37041. constructor(touchEnabled?: boolean);
  37042. /**
  37043. * Attach the mouse control to the HTML DOM element.
  37044. * @param element Defines the element that listens to the input events.
  37045. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37046. */
  37047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37048. /**
  37049. * Detach the current controls from the specified dom element.
  37050. * @param element Defines the element to stop listening the inputs from
  37051. */
  37052. detachControl(element: Nullable<HTMLElement>): void;
  37053. /**
  37054. * Gets the class name of the current input.
  37055. * @returns the class name.
  37056. */
  37057. getClassName(): string;
  37058. /**
  37059. * Get the friendly name associated with the input class.
  37060. * @returns the input's friendly name.
  37061. */
  37062. getSimpleName(): string;
  37063. private _pointerInput;
  37064. private _onMouseMove;
  37065. /**
  37066. * Rotate camera by mouse offset.
  37067. */
  37068. private rotateCamera;
  37069. }
  37070. }
  37071. declare module BABYLON {
  37072. /**
  37073. * Default Inputs manager for the FlyCamera.
  37074. * It groups all the default supported inputs for ease of use.
  37075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37076. */
  37077. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37078. /**
  37079. * Instantiates a new FlyCameraInputsManager.
  37080. * @param camera Defines the camera the inputs belong to.
  37081. */
  37082. constructor(camera: FlyCamera);
  37083. /**
  37084. * Add keyboard input support to the input manager.
  37085. * @returns the new FlyCameraKeyboardMoveInput().
  37086. */
  37087. addKeyboard(): FlyCameraInputsManager;
  37088. /**
  37089. * Add mouse input support to the input manager.
  37090. * @param touchEnabled Enable touch screen support.
  37091. * @returns the new FlyCameraMouseInput().
  37092. */
  37093. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37094. }
  37095. }
  37096. declare module BABYLON {
  37097. /**
  37098. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37099. * such as in a 3D Space Shooter or a Flight Simulator.
  37100. */
  37101. export class FlyCamera extends TargetCamera {
  37102. /**
  37103. * Define the collision ellipsoid of the camera.
  37104. * This is helpful for simulating a camera body, like a player's body.
  37105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37106. */
  37107. ellipsoid: Vector3;
  37108. /**
  37109. * Define an offset for the position of the ellipsoid around the camera.
  37110. * This can be helpful if the camera is attached away from the player's body center,
  37111. * such as at its head.
  37112. */
  37113. ellipsoidOffset: Vector3;
  37114. /**
  37115. * Enable or disable collisions of the camera with the rest of the scene objects.
  37116. */
  37117. checkCollisions: boolean;
  37118. /**
  37119. * Enable or disable gravity on the camera.
  37120. */
  37121. applyGravity: boolean;
  37122. /**
  37123. * Define the current direction the camera is moving to.
  37124. */
  37125. cameraDirection: Vector3;
  37126. /**
  37127. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37128. * This overrides and empties cameraRotation.
  37129. */
  37130. rotationQuaternion: Quaternion;
  37131. /**
  37132. * Track Roll to maintain the wanted Rolling when looking around.
  37133. */ private _trackRoll: number;
  37134. /**
  37135. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37136. */
  37137. rollCorrect: number;
  37138. /**
  37139. * Mimic a banked turn, Rolling the camera when Yawing.
  37140. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37141. */
  37142. bankedTurn: boolean;
  37143. /**
  37144. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37145. */
  37146. bankedTurnLimit: number;
  37147. /**
  37148. * Value of 0 disables the banked Roll.
  37149. * Value of 1 is equal to the Yaw angle in radians.
  37150. */
  37151. bankedTurnMultiplier: number;
  37152. /**
  37153. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37154. */
  37155. inputs: FlyCameraInputsManager;
  37156. /**
  37157. * Gets the input sensibility for mouse input.
  37158. * Higher values reduce sensitivity.
  37159. */
  37160. /**
  37161. * Sets the input sensibility for a mouse input.
  37162. * Higher values reduce sensitivity.
  37163. */
  37164. angularSensibility: number;
  37165. /**
  37166. * Get the keys for camera movement forward.
  37167. */
  37168. /**
  37169. * Set the keys for camera movement forward.
  37170. */
  37171. keysForward: number[];
  37172. /**
  37173. * Get the keys for camera movement backward.
  37174. */
  37175. keysBackward: number[];
  37176. /**
  37177. * Get the keys for camera movement up.
  37178. */
  37179. /**
  37180. * Set the keys for camera movement up.
  37181. */
  37182. keysUp: number[];
  37183. /**
  37184. * Get the keys for camera movement down.
  37185. */
  37186. /**
  37187. * Set the keys for camera movement down.
  37188. */
  37189. keysDown: number[];
  37190. /**
  37191. * Get the keys for camera movement left.
  37192. */
  37193. /**
  37194. * Set the keys for camera movement left.
  37195. */
  37196. keysLeft: number[];
  37197. /**
  37198. * Set the keys for camera movement right.
  37199. */
  37200. /**
  37201. * Set the keys for camera movement right.
  37202. */
  37203. keysRight: number[];
  37204. /**
  37205. * Event raised when the camera collides with a mesh in the scene.
  37206. */
  37207. onCollide: (collidedMesh: AbstractMesh) => void;
  37208. private _collider;
  37209. private _needMoveForGravity;
  37210. private _oldPosition;
  37211. private _diffPosition;
  37212. private _newPosition;
  37213. /** @hidden */ private _localDirection: Vector3;
  37214. /** @hidden */ private _transformedDirection: Vector3;
  37215. /**
  37216. * Instantiates a FlyCamera.
  37217. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37218. * such as in a 3D Space Shooter or a Flight Simulator.
  37219. * @param name Define the name of the camera in the scene.
  37220. * @param position Define the starting position of the camera in the scene.
  37221. * @param scene Define the scene the camera belongs to.
  37222. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37223. */
  37224. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37225. /**
  37226. * Attach a control to the HTML DOM element.
  37227. * @param element Defines the element that listens to the input events.
  37228. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37229. */
  37230. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37231. /**
  37232. * Detach a control from the HTML DOM element.
  37233. * The camera will stop reacting to that input.
  37234. * @param element Defines the element that listens to the input events.
  37235. */
  37236. detachControl(element: HTMLElement): void;
  37237. private _collisionMask;
  37238. /**
  37239. * Get the mask that the camera ignores in collision events.
  37240. */
  37241. /**
  37242. * Set the mask that the camera ignores in collision events.
  37243. */
  37244. collisionMask: number;
  37245. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  37246. /** @hidden */
  37247. private _onCollisionPositionChange;
  37248. /** @hidden */ private _checkInputs(): void;
  37249. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  37250. /** @hidden */ private _updatePosition(): void;
  37251. /**
  37252. * Restore the Roll to its target value at the rate specified.
  37253. * @param rate - Higher means slower restoring.
  37254. * @hidden
  37255. */
  37256. restoreRoll(rate: number): void;
  37257. /**
  37258. * Destroy the camera and release the current resources held by it.
  37259. */
  37260. dispose(): void;
  37261. /**
  37262. * Get the current object class name.
  37263. * @returns the class name.
  37264. */
  37265. getClassName(): string;
  37266. }
  37267. }
  37268. declare module BABYLON {
  37269. /**
  37270. * Listen to keyboard events to control the camera.
  37271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37272. */
  37273. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37274. /**
  37275. * Defines the camera the input is attached to.
  37276. */
  37277. camera: FlyCamera;
  37278. /**
  37279. * The list of keyboard keys used to control the forward move of the camera.
  37280. */
  37281. keysForward: number[];
  37282. /**
  37283. * The list of keyboard keys used to control the backward move of the camera.
  37284. */
  37285. keysBackward: number[];
  37286. /**
  37287. * The list of keyboard keys used to control the forward move of the camera.
  37288. */
  37289. keysUp: number[];
  37290. /**
  37291. * The list of keyboard keys used to control the backward move of the camera.
  37292. */
  37293. keysDown: number[];
  37294. /**
  37295. * The list of keyboard keys used to control the right strafe move of the camera.
  37296. */
  37297. keysRight: number[];
  37298. /**
  37299. * The list of keyboard keys used to control the left strafe move of the camera.
  37300. */
  37301. keysLeft: number[];
  37302. private _keys;
  37303. private _onCanvasBlurObserver;
  37304. private _onKeyboardObserver;
  37305. private _engine;
  37306. private _scene;
  37307. /**
  37308. * Attach the input controls to a specific dom element to get the input from.
  37309. * @param element Defines the element the controls should be listened from
  37310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37311. */
  37312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37313. /**
  37314. * Detach the current controls from the specified dom element.
  37315. * @param element Defines the element to stop listening the inputs from
  37316. */
  37317. detachControl(element: Nullable<HTMLElement>): void;
  37318. /**
  37319. * Gets the class name of the current intput.
  37320. * @returns the class name
  37321. */
  37322. getClassName(): string;
  37323. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  37324. /**
  37325. * Get the friendly name associated with the input class.
  37326. * @returns the input friendly name
  37327. */
  37328. getSimpleName(): string;
  37329. /**
  37330. * Update the current camera state depending on the inputs that have been used this frame.
  37331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37332. */
  37333. checkInputs(): void;
  37334. }
  37335. }
  37336. declare module BABYLON {
  37337. /**
  37338. * Manage the mouse wheel inputs to control a follow camera.
  37339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37340. */
  37341. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37342. /**
  37343. * Defines the camera the input is attached to.
  37344. */
  37345. camera: FollowCamera;
  37346. /**
  37347. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37348. */
  37349. axisControlRadius: boolean;
  37350. /**
  37351. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37352. */
  37353. axisControlHeight: boolean;
  37354. /**
  37355. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37356. */
  37357. axisControlRotation: boolean;
  37358. /**
  37359. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37360. * relation to mouseWheel events.
  37361. */
  37362. wheelPrecision: number;
  37363. /**
  37364. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37365. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37366. */
  37367. wheelDeltaPercentage: number;
  37368. private _wheel;
  37369. private _observer;
  37370. /**
  37371. * Attach the input controls to a specific dom element to get the input from.
  37372. * @param element Defines the element the controls should be listened from
  37373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37374. */
  37375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37376. /**
  37377. * Detach the current controls from the specified dom element.
  37378. * @param element Defines the element to stop listening the inputs from
  37379. */
  37380. detachControl(element: Nullable<HTMLElement>): void;
  37381. /**
  37382. * Gets the class name of the current intput.
  37383. * @returns the class name
  37384. */
  37385. getClassName(): string;
  37386. /**
  37387. * Get the friendly name associated with the input class.
  37388. * @returns the input friendly name
  37389. */
  37390. getSimpleName(): string;
  37391. }
  37392. }
  37393. declare module BABYLON {
  37394. /**
  37395. * Manage the pointers inputs to control an follow camera.
  37396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37397. */
  37398. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37399. /**
  37400. * Defines the camera the input is attached to.
  37401. */
  37402. camera: FollowCamera;
  37403. /**
  37404. * Gets the class name of the current input.
  37405. * @returns the class name
  37406. */
  37407. getClassName(): string;
  37408. /**
  37409. * Defines the pointer angular sensibility along the X axis or how fast is
  37410. * the camera rotating.
  37411. * A negative number will reverse the axis direction.
  37412. */
  37413. angularSensibilityX: number;
  37414. /**
  37415. * Defines the pointer angular sensibility along the Y axis or how fast is
  37416. * the camera rotating.
  37417. * A negative number will reverse the axis direction.
  37418. */
  37419. angularSensibilityY: number;
  37420. /**
  37421. * Defines the pointer pinch precision or how fast is the camera zooming.
  37422. * A negative number will reverse the axis direction.
  37423. */
  37424. pinchPrecision: number;
  37425. /**
  37426. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37427. * from 0.
  37428. * It defines the percentage of current camera.radius to use as delta when
  37429. * pinch zoom is used.
  37430. */
  37431. pinchDeltaPercentage: number;
  37432. /**
  37433. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37434. */
  37435. axisXControlRadius: boolean;
  37436. /**
  37437. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37438. */
  37439. axisXControlHeight: boolean;
  37440. /**
  37441. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37442. */
  37443. axisXControlRotation: boolean;
  37444. /**
  37445. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37446. */
  37447. axisYControlRadius: boolean;
  37448. /**
  37449. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37450. */
  37451. axisYControlHeight: boolean;
  37452. /**
  37453. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37454. */
  37455. axisYControlRotation: boolean;
  37456. /**
  37457. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37458. */
  37459. axisPinchControlRadius: boolean;
  37460. /**
  37461. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37462. */
  37463. axisPinchControlHeight: boolean;
  37464. /**
  37465. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37466. */
  37467. axisPinchControlRotation: boolean;
  37468. /**
  37469. * Log error messages if basic misconfiguration has occurred.
  37470. */
  37471. warningEnable: boolean;
  37472. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37473. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37474. private _warningCounter;
  37475. private _warning;
  37476. }
  37477. }
  37478. declare module BABYLON {
  37479. /**
  37480. * Default Inputs manager for the FollowCamera.
  37481. * It groups all the default supported inputs for ease of use.
  37482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37483. */
  37484. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37485. /**
  37486. * Instantiates a new FollowCameraInputsManager.
  37487. * @param camera Defines the camera the inputs belong to
  37488. */
  37489. constructor(camera: FollowCamera);
  37490. /**
  37491. * Add keyboard input support to the input manager.
  37492. * @returns the current input manager
  37493. */
  37494. addKeyboard(): FollowCameraInputsManager;
  37495. /**
  37496. * Add mouse wheel input support to the input manager.
  37497. * @returns the current input manager
  37498. */
  37499. addMouseWheel(): FollowCameraInputsManager;
  37500. /**
  37501. * Add pointers input support to the input manager.
  37502. * @returns the current input manager
  37503. */
  37504. addPointers(): FollowCameraInputsManager;
  37505. /**
  37506. * Add orientation input support to the input manager.
  37507. * @returns the current input manager
  37508. */
  37509. addVRDeviceOrientation(): FollowCameraInputsManager;
  37510. }
  37511. }
  37512. declare module BABYLON {
  37513. /**
  37514. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37515. * an arc rotate version arcFollowCamera are available.
  37516. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37517. */
  37518. export class FollowCamera extends TargetCamera {
  37519. /**
  37520. * Distance the follow camera should follow an object at
  37521. */
  37522. radius: number;
  37523. /**
  37524. * Minimum allowed distance of the camera to the axis of rotation
  37525. * (The camera can not get closer).
  37526. * This can help limiting how the Camera is able to move in the scene.
  37527. */
  37528. lowerRadiusLimit: Nullable<number>;
  37529. /**
  37530. * Maximum allowed distance of the camera to the axis of rotation
  37531. * (The camera can not get further).
  37532. * This can help limiting how the Camera is able to move in the scene.
  37533. */
  37534. upperRadiusLimit: Nullable<number>;
  37535. /**
  37536. * Define a rotation offset between the camera and the object it follows
  37537. */
  37538. rotationOffset: number;
  37539. /**
  37540. * Minimum allowed angle to camera position relative to target object.
  37541. * This can help limiting how the Camera is able to move in the scene.
  37542. */
  37543. lowerRotationOffsetLimit: Nullable<number>;
  37544. /**
  37545. * Maximum allowed angle to camera position relative to target object.
  37546. * This can help limiting how the Camera is able to move in the scene.
  37547. */
  37548. upperRotationOffsetLimit: Nullable<number>;
  37549. /**
  37550. * Define a height offset between the camera and the object it follows.
  37551. * It can help following an object from the top (like a car chaing a plane)
  37552. */
  37553. heightOffset: number;
  37554. /**
  37555. * Minimum allowed height of camera position relative to target object.
  37556. * This can help limiting how the Camera is able to move in the scene.
  37557. */
  37558. lowerHeightOffsetLimit: Nullable<number>;
  37559. /**
  37560. * Maximum allowed height of camera position relative to target object.
  37561. * This can help limiting how the Camera is able to move in the scene.
  37562. */
  37563. upperHeightOffsetLimit: Nullable<number>;
  37564. /**
  37565. * Define how fast the camera can accelerate to follow it s target.
  37566. */
  37567. cameraAcceleration: number;
  37568. /**
  37569. * Define the speed limit of the camera following an object.
  37570. */
  37571. maxCameraSpeed: number;
  37572. /**
  37573. * Define the target of the camera.
  37574. */
  37575. lockedTarget: Nullable<AbstractMesh>;
  37576. /**
  37577. * Defines the input associated with the camera.
  37578. */
  37579. inputs: FollowCameraInputsManager;
  37580. /**
  37581. * Instantiates the follow camera.
  37582. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37583. * @param name Define the name of the camera in the scene
  37584. * @param position Define the position of the camera
  37585. * @param scene Define the scene the camera belong to
  37586. * @param lockedTarget Define the target of the camera
  37587. */
  37588. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37589. private _follow;
  37590. /**
  37591. * Attached controls to the current camera.
  37592. * @param element Defines the element the controls should be listened from
  37593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37594. */
  37595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37596. /**
  37597. * Detach the current controls from the camera.
  37598. * The camera will stop reacting to inputs.
  37599. * @param element Defines the element to stop listening the inputs from
  37600. */
  37601. detachControl(element: HTMLElement): void;
  37602. /** @hidden */ private _checkInputs(): void;
  37603. private _checkLimits;
  37604. /**
  37605. * Gets the camera class name.
  37606. * @returns the class name
  37607. */
  37608. getClassName(): string;
  37609. }
  37610. /**
  37611. * Arc Rotate version of the follow camera.
  37612. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37613. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37614. */
  37615. export class ArcFollowCamera extends TargetCamera {
  37616. /** The longitudinal angle of the camera */
  37617. alpha: number;
  37618. /** The latitudinal angle of the camera */
  37619. beta: number;
  37620. /** The radius of the camera from its target */
  37621. radius: number;
  37622. /** Define the camera target (the messh it should follow) */
  37623. target: Nullable<AbstractMesh>;
  37624. private _cartesianCoordinates;
  37625. /**
  37626. * Instantiates a new ArcFollowCamera
  37627. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37628. * @param name Define the name of the camera
  37629. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37630. * @param beta Define the rotation angle of the camera around the elevation axis
  37631. * @param radius Define the radius of the camera from its target point
  37632. * @param target Define the target of the camera
  37633. * @param scene Define the scene the camera belongs to
  37634. */
  37635. constructor(name: string,
  37636. /** The longitudinal angle of the camera */
  37637. alpha: number,
  37638. /** The latitudinal angle of the camera */
  37639. beta: number,
  37640. /** The radius of the camera from its target */
  37641. radius: number,
  37642. /** Define the camera target (the messh it should follow) */
  37643. target: Nullable<AbstractMesh>, scene: Scene);
  37644. private _follow;
  37645. /** @hidden */ private _checkInputs(): void;
  37646. /**
  37647. * Returns the class name of the object.
  37648. * It is mostly used internally for serialization purposes.
  37649. */
  37650. getClassName(): string;
  37651. }
  37652. }
  37653. declare module BABYLON {
  37654. /**
  37655. * Manage the keyboard inputs to control the movement of a follow camera.
  37656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37657. */
  37658. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37659. /**
  37660. * Defines the camera the input is attached to.
  37661. */
  37662. camera: FollowCamera;
  37663. /**
  37664. * Defines the list of key codes associated with the up action (increase heightOffset)
  37665. */
  37666. keysHeightOffsetIncr: number[];
  37667. /**
  37668. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37669. */
  37670. keysHeightOffsetDecr: number[];
  37671. /**
  37672. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37673. */
  37674. keysHeightOffsetModifierAlt: boolean;
  37675. /**
  37676. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37677. */
  37678. keysHeightOffsetModifierCtrl: boolean;
  37679. /**
  37680. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37681. */
  37682. keysHeightOffsetModifierShift: boolean;
  37683. /**
  37684. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37685. */
  37686. keysRotationOffsetIncr: number[];
  37687. /**
  37688. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37689. */
  37690. keysRotationOffsetDecr: number[];
  37691. /**
  37692. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37693. */
  37694. keysRotationOffsetModifierAlt: boolean;
  37695. /**
  37696. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37697. */
  37698. keysRotationOffsetModifierCtrl: boolean;
  37699. /**
  37700. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37701. */
  37702. keysRotationOffsetModifierShift: boolean;
  37703. /**
  37704. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37705. */
  37706. keysRadiusIncr: number[];
  37707. /**
  37708. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37709. */
  37710. keysRadiusDecr: number[];
  37711. /**
  37712. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37713. */
  37714. keysRadiusModifierAlt: boolean;
  37715. /**
  37716. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37717. */
  37718. keysRadiusModifierCtrl: boolean;
  37719. /**
  37720. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37721. */
  37722. keysRadiusModifierShift: boolean;
  37723. /**
  37724. * Defines the rate of change of heightOffset.
  37725. */
  37726. heightSensibility: number;
  37727. /**
  37728. * Defines the rate of change of rotationOffset.
  37729. */
  37730. rotationSensibility: number;
  37731. /**
  37732. * Defines the rate of change of radius.
  37733. */
  37734. radiusSensibility: number;
  37735. private _keys;
  37736. private _ctrlPressed;
  37737. private _altPressed;
  37738. private _shiftPressed;
  37739. private _onCanvasBlurObserver;
  37740. private _onKeyboardObserver;
  37741. private _engine;
  37742. private _scene;
  37743. /**
  37744. * Attach the input controls to a specific dom element to get the input from.
  37745. * @param element Defines the element the controls should be listened from
  37746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37747. */
  37748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37749. /**
  37750. * Detach the current controls from the specified dom element.
  37751. * @param element Defines the element to stop listening the inputs from
  37752. */
  37753. detachControl(element: Nullable<HTMLElement>): void;
  37754. /**
  37755. * Update the current camera state depending on the inputs that have been used this frame.
  37756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37757. */
  37758. checkInputs(): void;
  37759. /**
  37760. * Gets the class name of the current input.
  37761. * @returns the class name
  37762. */
  37763. getClassName(): string;
  37764. /**
  37765. * Get the friendly name associated with the input class.
  37766. * @returns the input friendly name
  37767. */
  37768. getSimpleName(): string;
  37769. /**
  37770. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37771. * allow modification of the heightOffset value.
  37772. */
  37773. private _modifierHeightOffset;
  37774. /**
  37775. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37776. * allow modification of the rotationOffset value.
  37777. */
  37778. private _modifierRotationOffset;
  37779. /**
  37780. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37781. * allow modification of the radius value.
  37782. */
  37783. private _modifierRadius;
  37784. }
  37785. }
  37786. declare module BABYLON {
  37787. interface FreeCameraInputsManager {
  37788. /**
  37789. * @hidden
  37790. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37791. /**
  37792. * Add orientation input support to the input manager.
  37793. * @returns the current input manager
  37794. */
  37795. addDeviceOrientation(): FreeCameraInputsManager;
  37796. }
  37797. /**
  37798. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37799. * Screen rotation is taken into account.
  37800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37801. */
  37802. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37803. private _camera;
  37804. private _screenOrientationAngle;
  37805. private _constantTranform;
  37806. private _screenQuaternion;
  37807. private _alpha;
  37808. private _beta;
  37809. private _gamma;
  37810. /**
  37811. * Can be used to detect if a device orientation sensor is availible on a device
  37812. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37813. * @returns a promise that will resolve on orientation change
  37814. */
  37815. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37816. /**
  37817. * @hidden
  37818. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37819. /**
  37820. * Instantiates a new input
  37821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37822. */
  37823. constructor();
  37824. /**
  37825. * Define the camera controlled by the input.
  37826. */
  37827. camera: FreeCamera;
  37828. /**
  37829. * Attach the input controls to a specific dom element to get the input from.
  37830. * @param element Defines the element the controls should be listened from
  37831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37832. */
  37833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37834. private _orientationChanged;
  37835. private _deviceOrientation;
  37836. /**
  37837. * Detach the current controls from the specified dom element.
  37838. * @param element Defines the element to stop listening the inputs from
  37839. */
  37840. detachControl(element: Nullable<HTMLElement>): void;
  37841. /**
  37842. * Update the current camera state depending on the inputs that have been used this frame.
  37843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37844. */
  37845. checkInputs(): void;
  37846. /**
  37847. * Gets the class name of the current intput.
  37848. * @returns the class name
  37849. */
  37850. getClassName(): string;
  37851. /**
  37852. * Get the friendly name associated with the input class.
  37853. * @returns the input friendly name
  37854. */
  37855. getSimpleName(): string;
  37856. }
  37857. }
  37858. declare module BABYLON {
  37859. /**
  37860. * Manage the gamepad inputs to control a free camera.
  37861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37862. */
  37863. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37864. /**
  37865. * Define the camera the input is attached to.
  37866. */
  37867. camera: FreeCamera;
  37868. /**
  37869. * Define the Gamepad controlling the input
  37870. */
  37871. gamepad: Nullable<Gamepad>;
  37872. /**
  37873. * Defines the gamepad rotation sensiblity.
  37874. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37875. */
  37876. gamepadAngularSensibility: number;
  37877. /**
  37878. * Defines the gamepad move sensiblity.
  37879. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37880. */
  37881. gamepadMoveSensibility: number;
  37882. private _onGamepadConnectedObserver;
  37883. private _onGamepadDisconnectedObserver;
  37884. private _cameraTransform;
  37885. private _deltaTransform;
  37886. private _vector3;
  37887. private _vector2;
  37888. /**
  37889. * Attach the input controls to a specific dom element to get the input from.
  37890. * @param element Defines the element the controls should be listened from
  37891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37892. */
  37893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37894. /**
  37895. * Detach the current controls from the specified dom element.
  37896. * @param element Defines the element to stop listening the inputs from
  37897. */
  37898. detachControl(element: Nullable<HTMLElement>): void;
  37899. /**
  37900. * Update the current camera state depending on the inputs that have been used this frame.
  37901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37902. */
  37903. checkInputs(): void;
  37904. /**
  37905. * Gets the class name of the current intput.
  37906. * @returns the class name
  37907. */
  37908. getClassName(): string;
  37909. /**
  37910. * Get the friendly name associated with the input class.
  37911. * @returns the input friendly name
  37912. */
  37913. getSimpleName(): string;
  37914. }
  37915. }
  37916. declare module BABYLON {
  37917. /**
  37918. * Defines the potential axis of a Joystick
  37919. */
  37920. export enum JoystickAxis {
  37921. /** X axis */
  37922. X = 0,
  37923. /** Y axis */
  37924. Y = 1,
  37925. /** Z axis */
  37926. Z = 2
  37927. }
  37928. /**
  37929. * Class used to define virtual joystick (used in touch mode)
  37930. */
  37931. export class VirtualJoystick {
  37932. /**
  37933. * Gets or sets a boolean indicating that left and right values must be inverted
  37934. */
  37935. reverseLeftRight: boolean;
  37936. /**
  37937. * Gets or sets a boolean indicating that up and down values must be inverted
  37938. */
  37939. reverseUpDown: boolean;
  37940. /**
  37941. * Gets the offset value for the position (ie. the change of the position value)
  37942. */
  37943. deltaPosition: Vector3;
  37944. /**
  37945. * Gets a boolean indicating if the virtual joystick was pressed
  37946. */
  37947. pressed: boolean;
  37948. /**
  37949. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37950. */
  37951. static Canvas: Nullable<HTMLCanvasElement>;
  37952. private static _globalJoystickIndex;
  37953. private static vjCanvasContext;
  37954. private static vjCanvasWidth;
  37955. private static vjCanvasHeight;
  37956. private static halfWidth;
  37957. private _action;
  37958. private _axisTargetedByLeftAndRight;
  37959. private _axisTargetedByUpAndDown;
  37960. private _joystickSensibility;
  37961. private _inversedSensibility;
  37962. private _joystickPointerID;
  37963. private _joystickColor;
  37964. private _joystickPointerPos;
  37965. private _joystickPreviousPointerPos;
  37966. private _joystickPointerStartPos;
  37967. private _deltaJoystickVector;
  37968. private _leftJoystick;
  37969. private _touches;
  37970. private _onPointerDownHandlerRef;
  37971. private _onPointerMoveHandlerRef;
  37972. private _onPointerUpHandlerRef;
  37973. private _onResize;
  37974. /**
  37975. * Creates a new virtual joystick
  37976. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37977. */
  37978. constructor(leftJoystick?: boolean);
  37979. /**
  37980. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37981. * @param newJoystickSensibility defines the new sensibility
  37982. */
  37983. setJoystickSensibility(newJoystickSensibility: number): void;
  37984. private _onPointerDown;
  37985. private _onPointerMove;
  37986. private _onPointerUp;
  37987. /**
  37988. * Change the color of the virtual joystick
  37989. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37990. */
  37991. setJoystickColor(newColor: string): void;
  37992. /**
  37993. * Defines a callback to call when the joystick is touched
  37994. * @param action defines the callback
  37995. */
  37996. setActionOnTouch(action: () => any): void;
  37997. /**
  37998. * Defines which axis you'd like to control for left & right
  37999. * @param axis defines the axis to use
  38000. */
  38001. setAxisForLeftRight(axis: JoystickAxis): void;
  38002. /**
  38003. * Defines which axis you'd like to control for up & down
  38004. * @param axis defines the axis to use
  38005. */
  38006. setAxisForUpDown(axis: JoystickAxis): void;
  38007. private _drawVirtualJoystick;
  38008. /**
  38009. * Release internal HTML canvas
  38010. */
  38011. releaseCanvas(): void;
  38012. }
  38013. }
  38014. declare module BABYLON {
  38015. interface FreeCameraInputsManager {
  38016. /**
  38017. * Add virtual joystick input support to the input manager.
  38018. * @returns the current input manager
  38019. */
  38020. addVirtualJoystick(): FreeCameraInputsManager;
  38021. }
  38022. /**
  38023. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38024. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38025. */
  38026. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38027. /**
  38028. * Defines the camera the input is attached to.
  38029. */
  38030. camera: FreeCamera;
  38031. private _leftjoystick;
  38032. private _rightjoystick;
  38033. /**
  38034. * Gets the left stick of the virtual joystick.
  38035. * @returns The virtual Joystick
  38036. */
  38037. getLeftJoystick(): VirtualJoystick;
  38038. /**
  38039. * Gets the right stick of the virtual joystick.
  38040. * @returns The virtual Joystick
  38041. */
  38042. getRightJoystick(): VirtualJoystick;
  38043. /**
  38044. * Update the current camera state depending on the inputs that have been used this frame.
  38045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38046. */
  38047. checkInputs(): void;
  38048. /**
  38049. * Attach the input controls to a specific dom element to get the input from.
  38050. * @param element Defines the element the controls should be listened from
  38051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38052. */
  38053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38054. /**
  38055. * Detach the current controls from the specified dom element.
  38056. * @param element Defines the element to stop listening the inputs from
  38057. */
  38058. detachControl(element: Nullable<HTMLElement>): void;
  38059. /**
  38060. * Gets the class name of the current intput.
  38061. * @returns the class name
  38062. */
  38063. getClassName(): string;
  38064. /**
  38065. * Get the friendly name associated with the input class.
  38066. * @returns the input friendly name
  38067. */
  38068. getSimpleName(): string;
  38069. }
  38070. }
  38071. declare module BABYLON {
  38072. /**
  38073. * This represents a FPS type of camera controlled by touch.
  38074. * This is like a universal camera minus the Gamepad controls.
  38075. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38076. */
  38077. export class TouchCamera extends FreeCamera {
  38078. /**
  38079. * Defines the touch sensibility for rotation.
  38080. * The higher the faster.
  38081. */
  38082. touchAngularSensibility: number;
  38083. /**
  38084. * Defines the touch sensibility for move.
  38085. * The higher the faster.
  38086. */
  38087. touchMoveSensibility: number;
  38088. /**
  38089. * Instantiates a new touch camera.
  38090. * This represents a FPS type of camera controlled by touch.
  38091. * This is like a universal camera minus the Gamepad controls.
  38092. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38093. * @param name Define the name of the camera in the scene
  38094. * @param position Define the start position of the camera in the scene
  38095. * @param scene Define the scene the camera belongs to
  38096. */
  38097. constructor(name: string, position: Vector3, scene: Scene);
  38098. /**
  38099. * Gets the current object class name.
  38100. * @return the class name
  38101. */
  38102. getClassName(): string;
  38103. /** @hidden */ private _setupInputs(): void;
  38104. }
  38105. }
  38106. declare module BABYLON {
  38107. /**
  38108. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38109. * being tilted forward or back and left or right.
  38110. */
  38111. export class DeviceOrientationCamera extends FreeCamera {
  38112. private _initialQuaternion;
  38113. private _quaternionCache;
  38114. private _tmpDragQuaternion;
  38115. private _disablePointerInputWhenUsingDeviceOrientation;
  38116. /**
  38117. * Creates a new device orientation camera
  38118. * @param name The name of the camera
  38119. * @param position The start position camera
  38120. * @param scene The scene the camera belongs to
  38121. */
  38122. constructor(name: string, position: Vector3, scene: Scene);
  38123. /**
  38124. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38125. */
  38126. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38127. private _dragFactor;
  38128. /**
  38129. * Enabled turning on the y axis when the orientation sensor is active
  38130. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38131. */
  38132. enableHorizontalDragging(dragFactor?: number): void;
  38133. /**
  38134. * Gets the current instance class name ("DeviceOrientationCamera").
  38135. * This helps avoiding instanceof at run time.
  38136. * @returns the class name
  38137. */
  38138. getClassName(): string;
  38139. /**
  38140. * @hidden
  38141. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38142. */ private _checkInputs(): void;
  38143. /**
  38144. * Reset the camera to its default orientation on the specified axis only.
  38145. * @param axis The axis to reset
  38146. */
  38147. resetToCurrentRotation(axis?: Axis): void;
  38148. }
  38149. }
  38150. declare module BABYLON {
  38151. /**
  38152. * Defines supported buttons for XBox360 compatible gamepads
  38153. */
  38154. export enum Xbox360Button {
  38155. /** A */
  38156. A = 0,
  38157. /** B */
  38158. B = 1,
  38159. /** X */
  38160. X = 2,
  38161. /** Y */
  38162. Y = 3,
  38163. /** Start */
  38164. Start = 4,
  38165. /** Back */
  38166. Back = 5,
  38167. /** Left button */
  38168. LB = 6,
  38169. /** Right button */
  38170. RB = 7,
  38171. /** Left stick */
  38172. LeftStick = 8,
  38173. /** Right stick */
  38174. RightStick = 9
  38175. }
  38176. /** Defines values for XBox360 DPad */
  38177. export enum Xbox360Dpad {
  38178. /** Up */
  38179. Up = 0,
  38180. /** Down */
  38181. Down = 1,
  38182. /** Left */
  38183. Left = 2,
  38184. /** Right */
  38185. Right = 3
  38186. }
  38187. /**
  38188. * Defines a XBox360 gamepad
  38189. */
  38190. export class Xbox360Pad extends Gamepad {
  38191. private _leftTrigger;
  38192. private _rightTrigger;
  38193. private _onlefttriggerchanged;
  38194. private _onrighttriggerchanged;
  38195. private _onbuttondown;
  38196. private _onbuttonup;
  38197. private _ondpaddown;
  38198. private _ondpadup;
  38199. /** Observable raised when a button is pressed */
  38200. onButtonDownObservable: Observable<Xbox360Button>;
  38201. /** Observable raised when a button is released */
  38202. onButtonUpObservable: Observable<Xbox360Button>;
  38203. /** Observable raised when a pad is pressed */
  38204. onPadDownObservable: Observable<Xbox360Dpad>;
  38205. /** Observable raised when a pad is released */
  38206. onPadUpObservable: Observable<Xbox360Dpad>;
  38207. private _buttonA;
  38208. private _buttonB;
  38209. private _buttonX;
  38210. private _buttonY;
  38211. private _buttonBack;
  38212. private _buttonStart;
  38213. private _buttonLB;
  38214. private _buttonRB;
  38215. private _buttonLeftStick;
  38216. private _buttonRightStick;
  38217. private _dPadUp;
  38218. private _dPadDown;
  38219. private _dPadLeft;
  38220. private _dPadRight;
  38221. private _isXboxOnePad;
  38222. /**
  38223. * Creates a new XBox360 gamepad object
  38224. * @param id defines the id of this gamepad
  38225. * @param index defines its index
  38226. * @param gamepad defines the internal HTML gamepad object
  38227. * @param xboxOne defines if it is a XBox One gamepad
  38228. */
  38229. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38230. /**
  38231. * Defines the callback to call when left trigger is pressed
  38232. * @param callback defines the callback to use
  38233. */
  38234. onlefttriggerchanged(callback: (value: number) => void): void;
  38235. /**
  38236. * Defines the callback to call when right trigger is pressed
  38237. * @param callback defines the callback to use
  38238. */
  38239. onrighttriggerchanged(callback: (value: number) => void): void;
  38240. /**
  38241. * Gets the left trigger value
  38242. */
  38243. /**
  38244. * Sets the left trigger value
  38245. */
  38246. leftTrigger: number;
  38247. /**
  38248. * Gets the right trigger value
  38249. */
  38250. /**
  38251. * Sets the right trigger value
  38252. */
  38253. rightTrigger: number;
  38254. /**
  38255. * Defines the callback to call when a button is pressed
  38256. * @param callback defines the callback to use
  38257. */
  38258. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38259. /**
  38260. * Defines the callback to call when a button is released
  38261. * @param callback defines the callback to use
  38262. */
  38263. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38264. /**
  38265. * Defines the callback to call when a pad is pressed
  38266. * @param callback defines the callback to use
  38267. */
  38268. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38269. /**
  38270. * Defines the callback to call when a pad is released
  38271. * @param callback defines the callback to use
  38272. */
  38273. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38274. private _setButtonValue;
  38275. private _setDPadValue;
  38276. /**
  38277. * Gets the value of the `A` button
  38278. */
  38279. /**
  38280. * Sets the value of the `A` button
  38281. */
  38282. buttonA: number;
  38283. /**
  38284. * Gets the value of the `B` button
  38285. */
  38286. /**
  38287. * Sets the value of the `B` button
  38288. */
  38289. buttonB: number;
  38290. /**
  38291. * Gets the value of the `X` button
  38292. */
  38293. /**
  38294. * Sets the value of the `X` button
  38295. */
  38296. buttonX: number;
  38297. /**
  38298. * Gets the value of the `Y` button
  38299. */
  38300. /**
  38301. * Sets the value of the `Y` button
  38302. */
  38303. buttonY: number;
  38304. /**
  38305. * Gets the value of the `Start` button
  38306. */
  38307. /**
  38308. * Sets the value of the `Start` button
  38309. */
  38310. buttonStart: number;
  38311. /**
  38312. * Gets the value of the `Back` button
  38313. */
  38314. /**
  38315. * Sets the value of the `Back` button
  38316. */
  38317. buttonBack: number;
  38318. /**
  38319. * Gets the value of the `Left` button
  38320. */
  38321. /**
  38322. * Sets the value of the `Left` button
  38323. */
  38324. buttonLB: number;
  38325. /**
  38326. * Gets the value of the `Right` button
  38327. */
  38328. /**
  38329. * Sets the value of the `Right` button
  38330. */
  38331. buttonRB: number;
  38332. /**
  38333. * Gets the value of the Left joystick
  38334. */
  38335. /**
  38336. * Sets the value of the Left joystick
  38337. */
  38338. buttonLeftStick: number;
  38339. /**
  38340. * Gets the value of the Right joystick
  38341. */
  38342. /**
  38343. * Sets the value of the Right joystick
  38344. */
  38345. buttonRightStick: number;
  38346. /**
  38347. * Gets the value of D-pad up
  38348. */
  38349. /**
  38350. * Sets the value of D-pad up
  38351. */
  38352. dPadUp: number;
  38353. /**
  38354. * Gets the value of D-pad down
  38355. */
  38356. /**
  38357. * Sets the value of D-pad down
  38358. */
  38359. dPadDown: number;
  38360. /**
  38361. * Gets the value of D-pad left
  38362. */
  38363. /**
  38364. * Sets the value of D-pad left
  38365. */
  38366. dPadLeft: number;
  38367. /**
  38368. * Gets the value of D-pad right
  38369. */
  38370. /**
  38371. * Sets the value of D-pad right
  38372. */
  38373. dPadRight: number;
  38374. /**
  38375. * Force the gamepad to synchronize with device values
  38376. */
  38377. update(): void;
  38378. /**
  38379. * Disposes the gamepad
  38380. */
  38381. dispose(): void;
  38382. }
  38383. }
  38384. declare module BABYLON {
  38385. /**
  38386. * Defines supported buttons for DualShock compatible gamepads
  38387. */
  38388. export enum DualShockButton {
  38389. /** Cross */
  38390. Cross = 0,
  38391. /** Circle */
  38392. Circle = 1,
  38393. /** Square */
  38394. Square = 2,
  38395. /** Triangle */
  38396. Triangle = 3,
  38397. /** Options */
  38398. Options = 4,
  38399. /** Share */
  38400. Share = 5,
  38401. /** L1 */
  38402. L1 = 6,
  38403. /** R1 */
  38404. R1 = 7,
  38405. /** Left stick */
  38406. LeftStick = 8,
  38407. /** Right stick */
  38408. RightStick = 9
  38409. }
  38410. /** Defines values for DualShock DPad */
  38411. export enum DualShockDpad {
  38412. /** Up */
  38413. Up = 0,
  38414. /** Down */
  38415. Down = 1,
  38416. /** Left */
  38417. Left = 2,
  38418. /** Right */
  38419. Right = 3
  38420. }
  38421. /**
  38422. * Defines a DualShock gamepad
  38423. */
  38424. export class DualShockPad extends Gamepad {
  38425. private _leftTrigger;
  38426. private _rightTrigger;
  38427. private _onlefttriggerchanged;
  38428. private _onrighttriggerchanged;
  38429. private _onbuttondown;
  38430. private _onbuttonup;
  38431. private _ondpaddown;
  38432. private _ondpadup;
  38433. /** Observable raised when a button is pressed */
  38434. onButtonDownObservable: Observable<DualShockButton>;
  38435. /** Observable raised when a button is released */
  38436. onButtonUpObservable: Observable<DualShockButton>;
  38437. /** Observable raised when a pad is pressed */
  38438. onPadDownObservable: Observable<DualShockDpad>;
  38439. /** Observable raised when a pad is released */
  38440. onPadUpObservable: Observable<DualShockDpad>;
  38441. private _buttonCross;
  38442. private _buttonCircle;
  38443. private _buttonSquare;
  38444. private _buttonTriangle;
  38445. private _buttonShare;
  38446. private _buttonOptions;
  38447. private _buttonL1;
  38448. private _buttonR1;
  38449. private _buttonLeftStick;
  38450. private _buttonRightStick;
  38451. private _dPadUp;
  38452. private _dPadDown;
  38453. private _dPadLeft;
  38454. private _dPadRight;
  38455. /**
  38456. * Creates a new DualShock gamepad object
  38457. * @param id defines the id of this gamepad
  38458. * @param index defines its index
  38459. * @param gamepad defines the internal HTML gamepad object
  38460. */
  38461. constructor(id: string, index: number, gamepad: any);
  38462. /**
  38463. * Defines the callback to call when left trigger is pressed
  38464. * @param callback defines the callback to use
  38465. */
  38466. onlefttriggerchanged(callback: (value: number) => void): void;
  38467. /**
  38468. * Defines the callback to call when right trigger is pressed
  38469. * @param callback defines the callback to use
  38470. */
  38471. onrighttriggerchanged(callback: (value: number) => void): void;
  38472. /**
  38473. * Gets the left trigger value
  38474. */
  38475. /**
  38476. * Sets the left trigger value
  38477. */
  38478. leftTrigger: number;
  38479. /**
  38480. * Gets the right trigger value
  38481. */
  38482. /**
  38483. * Sets the right trigger value
  38484. */
  38485. rightTrigger: number;
  38486. /**
  38487. * Defines the callback to call when a button is pressed
  38488. * @param callback defines the callback to use
  38489. */
  38490. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38491. /**
  38492. * Defines the callback to call when a button is released
  38493. * @param callback defines the callback to use
  38494. */
  38495. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38496. /**
  38497. * Defines the callback to call when a pad is pressed
  38498. * @param callback defines the callback to use
  38499. */
  38500. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38501. /**
  38502. * Defines the callback to call when a pad is released
  38503. * @param callback defines the callback to use
  38504. */
  38505. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38506. private _setButtonValue;
  38507. private _setDPadValue;
  38508. /**
  38509. * Gets the value of the `Cross` button
  38510. */
  38511. /**
  38512. * Sets the value of the `Cross` button
  38513. */
  38514. buttonCross: number;
  38515. /**
  38516. * Gets the value of the `Circle` button
  38517. */
  38518. /**
  38519. * Sets the value of the `Circle` button
  38520. */
  38521. buttonCircle: number;
  38522. /**
  38523. * Gets the value of the `Square` button
  38524. */
  38525. /**
  38526. * Sets the value of the `Square` button
  38527. */
  38528. buttonSquare: number;
  38529. /**
  38530. * Gets the value of the `Triangle` button
  38531. */
  38532. /**
  38533. * Sets the value of the `Triangle` button
  38534. */
  38535. buttonTriangle: number;
  38536. /**
  38537. * Gets the value of the `Options` button
  38538. */
  38539. /**
  38540. * Sets the value of the `Options` button
  38541. */
  38542. buttonOptions: number;
  38543. /**
  38544. * Gets the value of the `Share` button
  38545. */
  38546. /**
  38547. * Sets the value of the `Share` button
  38548. */
  38549. buttonShare: number;
  38550. /**
  38551. * Gets the value of the `L1` button
  38552. */
  38553. /**
  38554. * Sets the value of the `L1` button
  38555. */
  38556. buttonL1: number;
  38557. /**
  38558. * Gets the value of the `R1` button
  38559. */
  38560. /**
  38561. * Sets the value of the `R1` button
  38562. */
  38563. buttonR1: number;
  38564. /**
  38565. * Gets the value of the Left joystick
  38566. */
  38567. /**
  38568. * Sets the value of the Left joystick
  38569. */
  38570. buttonLeftStick: number;
  38571. /**
  38572. * Gets the value of the Right joystick
  38573. */
  38574. /**
  38575. * Sets the value of the Right joystick
  38576. */
  38577. buttonRightStick: number;
  38578. /**
  38579. * Gets the value of D-pad up
  38580. */
  38581. /**
  38582. * Sets the value of D-pad up
  38583. */
  38584. dPadUp: number;
  38585. /**
  38586. * Gets the value of D-pad down
  38587. */
  38588. /**
  38589. * Sets the value of D-pad down
  38590. */
  38591. dPadDown: number;
  38592. /**
  38593. * Gets the value of D-pad left
  38594. */
  38595. /**
  38596. * Sets the value of D-pad left
  38597. */
  38598. dPadLeft: number;
  38599. /**
  38600. * Gets the value of D-pad right
  38601. */
  38602. /**
  38603. * Sets the value of D-pad right
  38604. */
  38605. dPadRight: number;
  38606. /**
  38607. * Force the gamepad to synchronize with device values
  38608. */
  38609. update(): void;
  38610. /**
  38611. * Disposes the gamepad
  38612. */
  38613. dispose(): void;
  38614. }
  38615. }
  38616. declare module BABYLON {
  38617. /**
  38618. * Manager for handling gamepads
  38619. */
  38620. export class GamepadManager {
  38621. private _scene?;
  38622. private _babylonGamepads;
  38623. private _oneGamepadConnected;
  38624. /** @hidden */ private _isMonitoring: boolean;
  38625. private _gamepadEventSupported;
  38626. private _gamepadSupport;
  38627. /**
  38628. * observable to be triggered when the gamepad controller has been connected
  38629. */
  38630. onGamepadConnectedObservable: Observable<Gamepad>;
  38631. /**
  38632. * observable to be triggered when the gamepad controller has been disconnected
  38633. */
  38634. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38635. private _onGamepadConnectedEvent;
  38636. private _onGamepadDisconnectedEvent;
  38637. /**
  38638. * Initializes the gamepad manager
  38639. * @param _scene BabylonJS scene
  38640. */
  38641. constructor(_scene?: Scene | undefined);
  38642. /**
  38643. * The gamepads in the game pad manager
  38644. */
  38645. readonly gamepads: Gamepad[];
  38646. /**
  38647. * Get the gamepad controllers based on type
  38648. * @param type The type of gamepad controller
  38649. * @returns Nullable gamepad
  38650. */
  38651. getGamepadByType(type?: number): Nullable<Gamepad>;
  38652. /**
  38653. * Disposes the gamepad manager
  38654. */
  38655. dispose(): void;
  38656. private _addNewGamepad;
  38657. private _startMonitoringGamepads;
  38658. private _stopMonitoringGamepads;
  38659. /** @hidden */ private _checkGamepadsStatus(): void;
  38660. private _updateGamepadObjects;
  38661. }
  38662. }
  38663. declare module BABYLON {
  38664. interface Scene {
  38665. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38666. /**
  38667. * Gets the gamepad manager associated with the scene
  38668. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38669. */
  38670. gamepadManager: GamepadManager;
  38671. }
  38672. /**
  38673. * Interface representing a free camera inputs manager
  38674. */
  38675. interface FreeCameraInputsManager {
  38676. /**
  38677. * Adds gamepad input support to the FreeCameraInputsManager.
  38678. * @returns the FreeCameraInputsManager
  38679. */
  38680. addGamepad(): FreeCameraInputsManager;
  38681. }
  38682. /**
  38683. * Interface representing an arc rotate camera inputs manager
  38684. */
  38685. interface ArcRotateCameraInputsManager {
  38686. /**
  38687. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38688. * @returns the camera inputs manager
  38689. */
  38690. addGamepad(): ArcRotateCameraInputsManager;
  38691. }
  38692. /**
  38693. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38694. */
  38695. export class GamepadSystemSceneComponent implements ISceneComponent {
  38696. /**
  38697. * The component name helpfull to identify the component in the list of scene components.
  38698. */
  38699. readonly name: string;
  38700. /**
  38701. * The scene the component belongs to.
  38702. */
  38703. scene: Scene;
  38704. /**
  38705. * Creates a new instance of the component for the given scene
  38706. * @param scene Defines the scene to register the component in
  38707. */
  38708. constructor(scene: Scene);
  38709. /**
  38710. * Registers the component in a given scene
  38711. */
  38712. register(): void;
  38713. /**
  38714. * Rebuilds the elements related to this component in case of
  38715. * context lost for instance.
  38716. */
  38717. rebuild(): void;
  38718. /**
  38719. * Disposes the component and the associated ressources
  38720. */
  38721. dispose(): void;
  38722. private _beforeCameraUpdate;
  38723. }
  38724. }
  38725. declare module BABYLON {
  38726. /**
  38727. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  38728. * which still works and will still be found in many Playgrounds.
  38729. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38730. */
  38731. export class UniversalCamera extends TouchCamera {
  38732. /**
  38733. * Defines the gamepad rotation sensiblity.
  38734. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38735. */
  38736. gamepadAngularSensibility: number;
  38737. /**
  38738. * Defines the gamepad move sensiblity.
  38739. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38740. */
  38741. gamepadMoveSensibility: number;
  38742. /**
  38743. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  38744. * which still works and will still be found in many Playgrounds.
  38745. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38746. * @param name Define the name of the camera in the scene
  38747. * @param position Define the start position of the camera in the scene
  38748. * @param scene Define the scene the camera belongs to
  38749. */
  38750. constructor(name: string, position: Vector3, scene: Scene);
  38751. /**
  38752. * Gets the current object class name.
  38753. * @return the class name
  38754. */
  38755. getClassName(): string;
  38756. }
  38757. }
  38758. declare module BABYLON {
  38759. /**
  38760. * This represents a FPS type of camera. This is only here for back compat purpose.
  38761. * Please use the UniversalCamera instead as both are identical.
  38762. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38763. */
  38764. export class GamepadCamera extends UniversalCamera {
  38765. /**
  38766. * Instantiates a new Gamepad Camera
  38767. * This represents a FPS type of camera. This is only here for back compat purpose.
  38768. * Please use the UniversalCamera instead as both are identical.
  38769. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38770. * @param name Define the name of the camera in the scene
  38771. * @param position Define the start position of the camera in the scene
  38772. * @param scene Define the scene the camera belongs to
  38773. */
  38774. constructor(name: string, position: Vector3, scene: Scene);
  38775. /**
  38776. * Gets the current object class name.
  38777. * @return the class name
  38778. */
  38779. getClassName(): string;
  38780. }
  38781. }
  38782. declare module BABYLON {
  38783. /** @hidden */
  38784. export var passPixelShader: {
  38785. name: string;
  38786. shader: string;
  38787. };
  38788. }
  38789. declare module BABYLON {
  38790. /** @hidden */
  38791. export var passCubePixelShader: {
  38792. name: string;
  38793. shader: string;
  38794. };
  38795. }
  38796. declare module BABYLON {
  38797. /**
  38798. * PassPostProcess which produces an output the same as it's input
  38799. */
  38800. export class PassPostProcess extends PostProcess {
  38801. /**
  38802. * Creates the PassPostProcess
  38803. * @param name The name of the effect.
  38804. * @param options The required width/height ratio to downsize to before computing the render pass.
  38805. * @param camera The camera to apply the render pass to.
  38806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38807. * @param engine The engine which the post process will be applied. (default: current engine)
  38808. * @param reusable If the post process can be reused on the same frame. (default: false)
  38809. * @param textureType The type of texture to be used when performing the post processing.
  38810. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  38811. */
  38812. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38813. }
  38814. /**
  38815. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38816. */
  38817. export class PassCubePostProcess extends PostProcess {
  38818. private _face;
  38819. /**
  38820. * Gets or sets the cube face to display.
  38821. * * 0 is +X
  38822. * * 1 is -X
  38823. * * 2 is +Y
  38824. * * 3 is -Y
  38825. * * 4 is +Z
  38826. * * 5 is -Z
  38827. */
  38828. face: number;
  38829. /**
  38830. * Creates the PassCubePostProcess
  38831. * @param name The name of the effect.
  38832. * @param options The required width/height ratio to downsize to before computing the render pass.
  38833. * @param camera The camera to apply the render pass to.
  38834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38835. * @param engine The engine which the post process will be applied. (default: current engine)
  38836. * @param reusable If the post process can be reused on the same frame. (default: false)
  38837. * @param textureType The type of texture to be used when performing the post processing.
  38838. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  38839. */
  38840. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38841. }
  38842. }
  38843. declare module BABYLON {
  38844. /** @hidden */
  38845. export var anaglyphPixelShader: {
  38846. name: string;
  38847. shader: string;
  38848. };
  38849. }
  38850. declare module BABYLON {
  38851. /**
  38852. * Postprocess used to generate anaglyphic rendering
  38853. */
  38854. export class AnaglyphPostProcess extends PostProcess {
  38855. private _passedProcess;
  38856. /**
  38857. * Creates a new AnaglyphPostProcess
  38858. * @param name defines postprocess name
  38859. * @param options defines creation options or target ratio scale
  38860. * @param rigCameras defines cameras using this postprocess
  38861. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38862. * @param engine defines hosting engine
  38863. * @param reusable defines if the postprocess will be reused multiple times per frame
  38864. */
  38865. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38866. }
  38867. }
  38868. declare module BABYLON {
  38869. /**
  38870. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38871. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38872. */
  38873. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38874. /**
  38875. * Creates a new AnaglyphArcRotateCamera
  38876. * @param name defines camera name
  38877. * @param alpha defines alpha angle (in radians)
  38878. * @param beta defines beta angle (in radians)
  38879. * @param radius defines radius
  38880. * @param target defines camera target
  38881. * @param interaxialDistance defines distance between each color axis
  38882. * @param scene defines the hosting scene
  38883. */
  38884. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38885. /**
  38886. * Gets camera class name
  38887. * @returns AnaglyphArcRotateCamera
  38888. */
  38889. getClassName(): string;
  38890. }
  38891. }
  38892. declare module BABYLON {
  38893. /**
  38894. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38895. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38896. */
  38897. export class AnaglyphFreeCamera extends FreeCamera {
  38898. /**
  38899. * Creates a new AnaglyphFreeCamera
  38900. * @param name defines camera name
  38901. * @param position defines initial position
  38902. * @param interaxialDistance defines distance between each color axis
  38903. * @param scene defines the hosting scene
  38904. */
  38905. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38906. /**
  38907. * Gets camera class name
  38908. * @returns AnaglyphFreeCamera
  38909. */
  38910. getClassName(): string;
  38911. }
  38912. }
  38913. declare module BABYLON {
  38914. /**
  38915. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38916. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38917. */
  38918. export class AnaglyphGamepadCamera extends GamepadCamera {
  38919. /**
  38920. * Creates a new AnaglyphGamepadCamera
  38921. * @param name defines camera name
  38922. * @param position defines initial position
  38923. * @param interaxialDistance defines distance between each color axis
  38924. * @param scene defines the hosting scene
  38925. */
  38926. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38927. /**
  38928. * Gets camera class name
  38929. * @returns AnaglyphGamepadCamera
  38930. */
  38931. getClassName(): string;
  38932. }
  38933. }
  38934. declare module BABYLON {
  38935. /**
  38936. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38937. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38938. */
  38939. export class AnaglyphUniversalCamera extends UniversalCamera {
  38940. /**
  38941. * Creates a new AnaglyphUniversalCamera
  38942. * @param name defines camera name
  38943. * @param position defines initial position
  38944. * @param interaxialDistance defines distance between each color axis
  38945. * @param scene defines the hosting scene
  38946. */
  38947. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38948. /**
  38949. * Gets camera class name
  38950. * @returns AnaglyphUniversalCamera
  38951. */
  38952. getClassName(): string;
  38953. }
  38954. }
  38955. declare module BABYLON {
  38956. /** @hidden */
  38957. export var stereoscopicInterlacePixelShader: {
  38958. name: string;
  38959. shader: string;
  38960. };
  38961. }
  38962. declare module BABYLON {
  38963. /**
  38964. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38965. */
  38966. export class StereoscopicInterlacePostProcess extends PostProcess {
  38967. private _stepSize;
  38968. private _passedProcess;
  38969. /**
  38970. * Initializes a StereoscopicInterlacePostProcess
  38971. * @param name The name of the effect.
  38972. * @param rigCameras The rig cameras to be appled to the post process
  38973. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38975. * @param engine The engine which the post process will be applied. (default: current engine)
  38976. * @param reusable If the post process can be reused on the same frame. (default: false)
  38977. */
  38978. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38979. }
  38980. }
  38981. declare module BABYLON {
  38982. /**
  38983. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38984. * @see http://doc.babylonjs.com/features/cameras
  38985. */
  38986. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38987. /**
  38988. * Creates a new StereoscopicArcRotateCamera
  38989. * @param name defines camera name
  38990. * @param alpha defines alpha angle (in radians)
  38991. * @param beta defines beta angle (in radians)
  38992. * @param radius defines radius
  38993. * @param target defines camera target
  38994. * @param interaxialDistance defines distance between each color axis
  38995. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38996. * @param scene defines the hosting scene
  38997. */
  38998. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38999. /**
  39000. * Gets camera class name
  39001. * @returns StereoscopicArcRotateCamera
  39002. */
  39003. getClassName(): string;
  39004. }
  39005. }
  39006. declare module BABYLON {
  39007. /**
  39008. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39009. * @see http://doc.babylonjs.com/features/cameras
  39010. */
  39011. export class StereoscopicFreeCamera extends FreeCamera {
  39012. /**
  39013. * Creates a new StereoscopicFreeCamera
  39014. * @param name defines camera name
  39015. * @param position defines initial position
  39016. * @param interaxialDistance defines distance between each color axis
  39017. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39018. * @param scene defines the hosting scene
  39019. */
  39020. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39021. /**
  39022. * Gets camera class name
  39023. * @returns StereoscopicFreeCamera
  39024. */
  39025. getClassName(): string;
  39026. }
  39027. }
  39028. declare module BABYLON {
  39029. /**
  39030. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39031. * @see http://doc.babylonjs.com/features/cameras
  39032. */
  39033. export class StereoscopicGamepadCamera extends GamepadCamera {
  39034. /**
  39035. * Creates a new StereoscopicGamepadCamera
  39036. * @param name defines camera name
  39037. * @param position defines initial position
  39038. * @param interaxialDistance defines distance between each color axis
  39039. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39040. * @param scene defines the hosting scene
  39041. */
  39042. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39043. /**
  39044. * Gets camera class name
  39045. * @returns StereoscopicGamepadCamera
  39046. */
  39047. getClassName(): string;
  39048. }
  39049. }
  39050. declare module BABYLON {
  39051. /**
  39052. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39053. * @see http://doc.babylonjs.com/features/cameras
  39054. */
  39055. export class StereoscopicUniversalCamera extends UniversalCamera {
  39056. /**
  39057. * Creates a new StereoscopicUniversalCamera
  39058. * @param name defines camera name
  39059. * @param position defines initial position
  39060. * @param interaxialDistance defines distance between each color axis
  39061. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39062. * @param scene defines the hosting scene
  39063. */
  39064. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39065. /**
  39066. * Gets camera class name
  39067. * @returns StereoscopicUniversalCamera
  39068. */
  39069. getClassName(): string;
  39070. }
  39071. }
  39072. declare module BABYLON {
  39073. /**
  39074. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39075. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39076. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39077. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39078. */
  39079. export class VirtualJoysticksCamera extends FreeCamera {
  39080. /**
  39081. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39082. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39083. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39084. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39085. * @param name Define the name of the camera in the scene
  39086. * @param position Define the start position of the camera in the scene
  39087. * @param scene Define the scene the camera belongs to
  39088. */
  39089. constructor(name: string, position: Vector3, scene: Scene);
  39090. /**
  39091. * Gets the current object class name.
  39092. * @return the class name
  39093. */
  39094. getClassName(): string;
  39095. }
  39096. }
  39097. declare module BABYLON {
  39098. /**
  39099. * This represents all the required metrics to create a VR camera.
  39100. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39101. */
  39102. export class VRCameraMetrics {
  39103. /**
  39104. * Define the horizontal resolution off the screen.
  39105. */
  39106. hResolution: number;
  39107. /**
  39108. * Define the vertical resolution off the screen.
  39109. */
  39110. vResolution: number;
  39111. /**
  39112. * Define the horizontal screen size.
  39113. */
  39114. hScreenSize: number;
  39115. /**
  39116. * Define the vertical screen size.
  39117. */
  39118. vScreenSize: number;
  39119. /**
  39120. * Define the vertical screen center position.
  39121. */
  39122. vScreenCenter: number;
  39123. /**
  39124. * Define the distance of the eyes to the screen.
  39125. */
  39126. eyeToScreenDistance: number;
  39127. /**
  39128. * Define the distance between both lenses
  39129. */
  39130. lensSeparationDistance: number;
  39131. /**
  39132. * Define the distance between both viewer's eyes.
  39133. */
  39134. interpupillaryDistance: number;
  39135. /**
  39136. * Define the distortion factor of the VR postprocess.
  39137. * Please, touch with care.
  39138. */
  39139. distortionK: number[];
  39140. /**
  39141. * Define the chromatic aberration correction factors for the VR post process.
  39142. */
  39143. chromaAbCorrection: number[];
  39144. /**
  39145. * Define the scale factor of the post process.
  39146. * The smaller the better but the slower.
  39147. */
  39148. postProcessScaleFactor: number;
  39149. /**
  39150. * Define an offset for the lens center.
  39151. */
  39152. lensCenterOffset: number;
  39153. /**
  39154. * Define if the current vr camera should compensate the distortion of the lense or not.
  39155. */
  39156. compensateDistortion: boolean;
  39157. /**
  39158. * Defines if multiview should be enabled when rendering (Default: false)
  39159. */
  39160. multiviewEnabled: boolean;
  39161. /**
  39162. * Gets the rendering aspect ratio based on the provided resolutions.
  39163. */
  39164. readonly aspectRatio: number;
  39165. /**
  39166. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39167. */
  39168. readonly aspectRatioFov: number;
  39169. /**
  39170. * @hidden
  39171. */
  39172. readonly leftHMatrix: Matrix;
  39173. /**
  39174. * @hidden
  39175. */
  39176. readonly rightHMatrix: Matrix;
  39177. /**
  39178. * @hidden
  39179. */
  39180. readonly leftPreViewMatrix: Matrix;
  39181. /**
  39182. * @hidden
  39183. */
  39184. readonly rightPreViewMatrix: Matrix;
  39185. /**
  39186. * Get the default VRMetrics based on the most generic setup.
  39187. * @returns the default vr metrics
  39188. */
  39189. static GetDefault(): VRCameraMetrics;
  39190. }
  39191. }
  39192. declare module BABYLON {
  39193. /** @hidden */
  39194. export var vrDistortionCorrectionPixelShader: {
  39195. name: string;
  39196. shader: string;
  39197. };
  39198. }
  39199. declare module BABYLON {
  39200. /**
  39201. * VRDistortionCorrectionPostProcess used for mobile VR
  39202. */
  39203. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39204. private _isRightEye;
  39205. private _distortionFactors;
  39206. private _postProcessScaleFactor;
  39207. private _lensCenterOffset;
  39208. private _scaleIn;
  39209. private _scaleFactor;
  39210. private _lensCenter;
  39211. /**
  39212. * Initializes the VRDistortionCorrectionPostProcess
  39213. * @param name The name of the effect.
  39214. * @param camera The camera to apply the render pass to.
  39215. * @param isRightEye If this is for the right eye distortion
  39216. * @param vrMetrics All the required metrics for the VR camera
  39217. */
  39218. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39219. }
  39220. }
  39221. declare module BABYLON {
  39222. /**
  39223. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39224. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39225. */
  39226. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39227. /**
  39228. * Creates a new VRDeviceOrientationArcRotateCamera
  39229. * @param name defines camera name
  39230. * @param alpha defines the camera rotation along the logitudinal axis
  39231. * @param beta defines the camera rotation along the latitudinal axis
  39232. * @param radius defines the camera distance from its target
  39233. * @param target defines the camera target
  39234. * @param scene defines the scene the camera belongs to
  39235. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39236. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39237. */
  39238. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39239. /**
  39240. * Gets camera class name
  39241. * @returns VRDeviceOrientationArcRotateCamera
  39242. */
  39243. getClassName(): string;
  39244. }
  39245. }
  39246. declare module BABYLON {
  39247. /**
  39248. * Camera used to simulate VR rendering (based on FreeCamera)
  39249. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39250. */
  39251. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39252. /**
  39253. * Creates a new VRDeviceOrientationFreeCamera
  39254. * @param name defines camera name
  39255. * @param position defines the start position of the camera
  39256. * @param scene defines the scene the camera belongs to
  39257. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39258. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39259. */
  39260. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39261. /**
  39262. * Gets camera class name
  39263. * @returns VRDeviceOrientationFreeCamera
  39264. */
  39265. getClassName(): string;
  39266. }
  39267. }
  39268. declare module BABYLON {
  39269. /**
  39270. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39271. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39272. */
  39273. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39274. /**
  39275. * Creates a new VRDeviceOrientationGamepadCamera
  39276. * @param name defines camera name
  39277. * @param position defines the start position of the camera
  39278. * @param scene defines the scene the camera belongs to
  39279. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39280. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39281. */
  39282. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39283. /**
  39284. * Gets camera class name
  39285. * @returns VRDeviceOrientationGamepadCamera
  39286. */
  39287. getClassName(): string;
  39288. }
  39289. }
  39290. declare module BABYLON {
  39291. /**
  39292. * Base class of materials working in push mode in babylon JS
  39293. * @hidden
  39294. */
  39295. export class PushMaterial extends Material {
  39296. protected _activeEffect: Effect;
  39297. protected _normalMatrix: Matrix;
  39298. /**
  39299. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39300. * This means that the material can keep using a previous shader while a new one is being compiled.
  39301. * This is mostly used when shader parallel compilation is supported (true by default)
  39302. */
  39303. allowShaderHotSwapping: boolean;
  39304. constructor(name: string, scene: Scene);
  39305. getEffect(): Effect;
  39306. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39307. /**
  39308. * Binds the given world matrix to the active effect
  39309. *
  39310. * @param world the matrix to bind
  39311. */
  39312. bindOnlyWorldMatrix(world: Matrix): void;
  39313. /**
  39314. * Binds the given normal matrix to the active effect
  39315. *
  39316. * @param normalMatrix the matrix to bind
  39317. */
  39318. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39319. bind(world: Matrix, mesh?: Mesh): void;
  39320. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39321. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39322. }
  39323. }
  39324. declare module BABYLON {
  39325. /**
  39326. * This groups all the flags used to control the materials channel.
  39327. */
  39328. export class MaterialFlags {
  39329. private static _DiffuseTextureEnabled;
  39330. /**
  39331. * Are diffuse textures enabled in the application.
  39332. */
  39333. static DiffuseTextureEnabled: boolean;
  39334. private static _AmbientTextureEnabled;
  39335. /**
  39336. * Are ambient textures enabled in the application.
  39337. */
  39338. static AmbientTextureEnabled: boolean;
  39339. private static _OpacityTextureEnabled;
  39340. /**
  39341. * Are opacity textures enabled in the application.
  39342. */
  39343. static OpacityTextureEnabled: boolean;
  39344. private static _ReflectionTextureEnabled;
  39345. /**
  39346. * Are reflection textures enabled in the application.
  39347. */
  39348. static ReflectionTextureEnabled: boolean;
  39349. private static _EmissiveTextureEnabled;
  39350. /**
  39351. * Are emissive textures enabled in the application.
  39352. */
  39353. static EmissiveTextureEnabled: boolean;
  39354. private static _SpecularTextureEnabled;
  39355. /**
  39356. * Are specular textures enabled in the application.
  39357. */
  39358. static SpecularTextureEnabled: boolean;
  39359. private static _BumpTextureEnabled;
  39360. /**
  39361. * Are bump textures enabled in the application.
  39362. */
  39363. static BumpTextureEnabled: boolean;
  39364. private static _LightmapTextureEnabled;
  39365. /**
  39366. * Are lightmap textures enabled in the application.
  39367. */
  39368. static LightmapTextureEnabled: boolean;
  39369. private static _RefractionTextureEnabled;
  39370. /**
  39371. * Are refraction textures enabled in the application.
  39372. */
  39373. static RefractionTextureEnabled: boolean;
  39374. private static _ColorGradingTextureEnabled;
  39375. /**
  39376. * Are color grading textures enabled in the application.
  39377. */
  39378. static ColorGradingTextureEnabled: boolean;
  39379. private static _FresnelEnabled;
  39380. /**
  39381. * Are fresnels enabled in the application.
  39382. */
  39383. static FresnelEnabled: boolean;
  39384. private static _ClearCoatTextureEnabled;
  39385. /**
  39386. * Are clear coat textures enabled in the application.
  39387. */
  39388. static ClearCoatTextureEnabled: boolean;
  39389. private static _ClearCoatBumpTextureEnabled;
  39390. /**
  39391. * Are clear coat bump textures enabled in the application.
  39392. */
  39393. static ClearCoatBumpTextureEnabled: boolean;
  39394. private static _ClearCoatTintTextureEnabled;
  39395. /**
  39396. * Are clear coat tint textures enabled in the application.
  39397. */
  39398. static ClearCoatTintTextureEnabled: boolean;
  39399. private static _SheenTextureEnabled;
  39400. /**
  39401. * Are sheen textures enabled in the application.
  39402. */
  39403. static SheenTextureEnabled: boolean;
  39404. private static _AnisotropicTextureEnabled;
  39405. /**
  39406. * Are anisotropic textures enabled in the application.
  39407. */
  39408. static AnisotropicTextureEnabled: boolean;
  39409. private static _ThicknessTextureEnabled;
  39410. /**
  39411. * Are thickness textures enabled in the application.
  39412. */
  39413. static ThicknessTextureEnabled: boolean;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /** @hidden */
  39418. export var defaultFragmentDeclaration: {
  39419. name: string;
  39420. shader: string;
  39421. };
  39422. }
  39423. declare module BABYLON {
  39424. /** @hidden */
  39425. export var defaultUboDeclaration: {
  39426. name: string;
  39427. shader: string;
  39428. };
  39429. }
  39430. declare module BABYLON {
  39431. /** @hidden */
  39432. export var lightFragmentDeclaration: {
  39433. name: string;
  39434. shader: string;
  39435. };
  39436. }
  39437. declare module BABYLON {
  39438. /** @hidden */
  39439. export var lightUboDeclaration: {
  39440. name: string;
  39441. shader: string;
  39442. };
  39443. }
  39444. declare module BABYLON {
  39445. /** @hidden */
  39446. export var lightsFragmentFunctions: {
  39447. name: string;
  39448. shader: string;
  39449. };
  39450. }
  39451. declare module BABYLON {
  39452. /** @hidden */
  39453. export var shadowsFragmentFunctions: {
  39454. name: string;
  39455. shader: string;
  39456. };
  39457. }
  39458. declare module BABYLON {
  39459. /** @hidden */
  39460. export var fresnelFunction: {
  39461. name: string;
  39462. shader: string;
  39463. };
  39464. }
  39465. declare module BABYLON {
  39466. /** @hidden */
  39467. export var reflectionFunction: {
  39468. name: string;
  39469. shader: string;
  39470. };
  39471. }
  39472. declare module BABYLON {
  39473. /** @hidden */
  39474. export var bumpFragmentFunctions: {
  39475. name: string;
  39476. shader: string;
  39477. };
  39478. }
  39479. declare module BABYLON {
  39480. /** @hidden */
  39481. export var logDepthDeclaration: {
  39482. name: string;
  39483. shader: string;
  39484. };
  39485. }
  39486. declare module BABYLON {
  39487. /** @hidden */
  39488. export var bumpFragment: {
  39489. name: string;
  39490. shader: string;
  39491. };
  39492. }
  39493. declare module BABYLON {
  39494. /** @hidden */
  39495. export var depthPrePass: {
  39496. name: string;
  39497. shader: string;
  39498. };
  39499. }
  39500. declare module BABYLON {
  39501. /** @hidden */
  39502. export var lightFragment: {
  39503. name: string;
  39504. shader: string;
  39505. };
  39506. }
  39507. declare module BABYLON {
  39508. /** @hidden */
  39509. export var logDepthFragment: {
  39510. name: string;
  39511. shader: string;
  39512. };
  39513. }
  39514. declare module BABYLON {
  39515. /** @hidden */
  39516. export var defaultPixelShader: {
  39517. name: string;
  39518. shader: string;
  39519. };
  39520. }
  39521. declare module BABYLON {
  39522. /** @hidden */
  39523. export var defaultVertexDeclaration: {
  39524. name: string;
  39525. shader: string;
  39526. };
  39527. }
  39528. declare module BABYLON {
  39529. /** @hidden */
  39530. export var bumpVertexDeclaration: {
  39531. name: string;
  39532. shader: string;
  39533. };
  39534. }
  39535. declare module BABYLON {
  39536. /** @hidden */
  39537. export var bumpVertex: {
  39538. name: string;
  39539. shader: string;
  39540. };
  39541. }
  39542. declare module BABYLON {
  39543. /** @hidden */
  39544. export var fogVertex: {
  39545. name: string;
  39546. shader: string;
  39547. };
  39548. }
  39549. declare module BABYLON {
  39550. /** @hidden */
  39551. export var shadowsVertex: {
  39552. name: string;
  39553. shader: string;
  39554. };
  39555. }
  39556. declare module BABYLON {
  39557. /** @hidden */
  39558. export var pointCloudVertex: {
  39559. name: string;
  39560. shader: string;
  39561. };
  39562. }
  39563. declare module BABYLON {
  39564. /** @hidden */
  39565. export var logDepthVertex: {
  39566. name: string;
  39567. shader: string;
  39568. };
  39569. }
  39570. declare module BABYLON {
  39571. /** @hidden */
  39572. export var defaultVertexShader: {
  39573. name: string;
  39574. shader: string;
  39575. };
  39576. }
  39577. declare module BABYLON {
  39578. /** @hidden */
  39579. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39580. MAINUV1: boolean;
  39581. MAINUV2: boolean;
  39582. DIFFUSE: boolean;
  39583. DIFFUSEDIRECTUV: number;
  39584. AMBIENT: boolean;
  39585. AMBIENTDIRECTUV: number;
  39586. OPACITY: boolean;
  39587. OPACITYDIRECTUV: number;
  39588. OPACITYRGB: boolean;
  39589. REFLECTION: boolean;
  39590. EMISSIVE: boolean;
  39591. EMISSIVEDIRECTUV: number;
  39592. SPECULAR: boolean;
  39593. SPECULARDIRECTUV: number;
  39594. BUMP: boolean;
  39595. BUMPDIRECTUV: number;
  39596. PARALLAX: boolean;
  39597. PARALLAXOCCLUSION: boolean;
  39598. SPECULAROVERALPHA: boolean;
  39599. CLIPPLANE: boolean;
  39600. CLIPPLANE2: boolean;
  39601. CLIPPLANE3: boolean;
  39602. CLIPPLANE4: boolean;
  39603. ALPHATEST: boolean;
  39604. DEPTHPREPASS: boolean;
  39605. ALPHAFROMDIFFUSE: boolean;
  39606. POINTSIZE: boolean;
  39607. FOG: boolean;
  39608. SPECULARTERM: boolean;
  39609. DIFFUSEFRESNEL: boolean;
  39610. OPACITYFRESNEL: boolean;
  39611. REFLECTIONFRESNEL: boolean;
  39612. REFRACTIONFRESNEL: boolean;
  39613. EMISSIVEFRESNEL: boolean;
  39614. FRESNEL: boolean;
  39615. NORMAL: boolean;
  39616. UV1: boolean;
  39617. UV2: boolean;
  39618. VERTEXCOLOR: boolean;
  39619. VERTEXALPHA: boolean;
  39620. NUM_BONE_INFLUENCERS: number;
  39621. BonesPerMesh: number;
  39622. BONETEXTURE: boolean;
  39623. INSTANCES: boolean;
  39624. GLOSSINESS: boolean;
  39625. ROUGHNESS: boolean;
  39626. EMISSIVEASILLUMINATION: boolean;
  39627. LINKEMISSIVEWITHDIFFUSE: boolean;
  39628. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39629. LIGHTMAP: boolean;
  39630. LIGHTMAPDIRECTUV: number;
  39631. OBJECTSPACE_NORMALMAP: boolean;
  39632. USELIGHTMAPASSHADOWMAP: boolean;
  39633. REFLECTIONMAP_3D: boolean;
  39634. REFLECTIONMAP_SPHERICAL: boolean;
  39635. REFLECTIONMAP_PLANAR: boolean;
  39636. REFLECTIONMAP_CUBIC: boolean;
  39637. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39638. REFLECTIONMAP_PROJECTION: boolean;
  39639. REFLECTIONMAP_SKYBOX: boolean;
  39640. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39641. REFLECTIONMAP_EXPLICIT: boolean;
  39642. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39643. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39644. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39645. INVERTCUBICMAP: boolean;
  39646. LOGARITHMICDEPTH: boolean;
  39647. REFRACTION: boolean;
  39648. REFRACTIONMAP_3D: boolean;
  39649. REFLECTIONOVERALPHA: boolean;
  39650. TWOSIDEDLIGHTING: boolean;
  39651. SHADOWFLOAT: boolean;
  39652. MORPHTARGETS: boolean;
  39653. MORPHTARGETS_NORMAL: boolean;
  39654. MORPHTARGETS_TANGENT: boolean;
  39655. MORPHTARGETS_UV: boolean;
  39656. NUM_MORPH_INFLUENCERS: number;
  39657. NONUNIFORMSCALING: boolean;
  39658. PREMULTIPLYALPHA: boolean;
  39659. IMAGEPROCESSING: boolean;
  39660. VIGNETTE: boolean;
  39661. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39662. VIGNETTEBLENDMODEOPAQUE: boolean;
  39663. TONEMAPPING: boolean;
  39664. TONEMAPPING_ACES: boolean;
  39665. CONTRAST: boolean;
  39666. COLORCURVES: boolean;
  39667. COLORGRADING: boolean;
  39668. COLORGRADING3D: boolean;
  39669. SAMPLER3DGREENDEPTH: boolean;
  39670. SAMPLER3DBGRMAP: boolean;
  39671. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39672. MULTIVIEW: boolean;
  39673. /**
  39674. * If the reflection texture on this material is in linear color space
  39675. * @hidden
  39676. */
  39677. IS_REFLECTION_LINEAR: boolean;
  39678. /**
  39679. * If the refraction texture on this material is in linear color space
  39680. * @hidden
  39681. */
  39682. IS_REFRACTION_LINEAR: boolean;
  39683. EXPOSURE: boolean;
  39684. constructor();
  39685. setReflectionMode(modeToEnable: string): void;
  39686. }
  39687. /**
  39688. * This is the default material used in Babylon. It is the best trade off between quality
  39689. * and performances.
  39690. * @see http://doc.babylonjs.com/babylon101/materials
  39691. */
  39692. export class StandardMaterial extends PushMaterial {
  39693. private _diffuseTexture;
  39694. /**
  39695. * The basic texture of the material as viewed under a light.
  39696. */
  39697. diffuseTexture: Nullable<BaseTexture>;
  39698. private _ambientTexture;
  39699. /**
  39700. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39701. */
  39702. ambientTexture: Nullable<BaseTexture>;
  39703. private _opacityTexture;
  39704. /**
  39705. * Define the transparency of the material from a texture.
  39706. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39707. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39708. */
  39709. opacityTexture: Nullable<BaseTexture>;
  39710. private _reflectionTexture;
  39711. /**
  39712. * Define the texture used to display the reflection.
  39713. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39714. */
  39715. reflectionTexture: Nullable<BaseTexture>;
  39716. private _emissiveTexture;
  39717. /**
  39718. * Define texture of the material as if self lit.
  39719. * This will be mixed in the final result even in the absence of light.
  39720. */
  39721. emissiveTexture: Nullable<BaseTexture>;
  39722. private _specularTexture;
  39723. /**
  39724. * Define how the color and intensity of the highlight given by the light in the material.
  39725. */
  39726. specularTexture: Nullable<BaseTexture>;
  39727. private _bumpTexture;
  39728. /**
  39729. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39730. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  39731. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39732. */
  39733. bumpTexture: Nullable<BaseTexture>;
  39734. private _lightmapTexture;
  39735. /**
  39736. * Complex lighting can be computationally expensive to compute at runtime.
  39737. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39738. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39739. */
  39740. lightmapTexture: Nullable<BaseTexture>;
  39741. private _refractionTexture;
  39742. /**
  39743. * Define the texture used to display the refraction.
  39744. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39745. */
  39746. refractionTexture: Nullable<BaseTexture>;
  39747. /**
  39748. * The color of the material lit by the environmental background lighting.
  39749. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39750. */
  39751. ambientColor: Color3;
  39752. /**
  39753. * The basic color of the material as viewed under a light.
  39754. */
  39755. diffuseColor: Color3;
  39756. /**
  39757. * Define how the color and intensity of the highlight given by the light in the material.
  39758. */
  39759. specularColor: Color3;
  39760. /**
  39761. * Define the color of the material as if self lit.
  39762. * This will be mixed in the final result even in the absence of light.
  39763. */
  39764. emissiveColor: Color3;
  39765. /**
  39766. * Defines how sharp are the highlights in the material.
  39767. * The bigger the value the sharper giving a more glossy feeling to the result.
  39768. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39769. */
  39770. specularPower: number;
  39771. private _useAlphaFromDiffuseTexture;
  39772. /**
  39773. * Does the transparency come from the diffuse texture alpha channel.
  39774. */
  39775. useAlphaFromDiffuseTexture: boolean;
  39776. private _useEmissiveAsIllumination;
  39777. /**
  39778. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39779. */
  39780. useEmissiveAsIllumination: boolean;
  39781. private _linkEmissiveWithDiffuse;
  39782. /**
  39783. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39784. * the emissive level when the final color is close to one.
  39785. */
  39786. linkEmissiveWithDiffuse: boolean;
  39787. private _useSpecularOverAlpha;
  39788. /**
  39789. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39790. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39791. */
  39792. useSpecularOverAlpha: boolean;
  39793. private _useReflectionOverAlpha;
  39794. /**
  39795. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39796. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39797. */
  39798. useReflectionOverAlpha: boolean;
  39799. private _disableLighting;
  39800. /**
  39801. * Does lights from the scene impacts this material.
  39802. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39803. */
  39804. disableLighting: boolean;
  39805. private _useObjectSpaceNormalMap;
  39806. /**
  39807. * Allows using an object space normal map (instead of tangent space).
  39808. */
  39809. useObjectSpaceNormalMap: boolean;
  39810. private _useParallax;
  39811. /**
  39812. * Is parallax enabled or not.
  39813. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39814. */
  39815. useParallax: boolean;
  39816. private _useParallaxOcclusion;
  39817. /**
  39818. * Is parallax occlusion enabled or not.
  39819. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39820. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39821. */
  39822. useParallaxOcclusion: boolean;
  39823. /**
  39824. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  39825. */
  39826. parallaxScaleBias: number;
  39827. private _roughness;
  39828. /**
  39829. * Helps to define how blurry the reflections should appears in the material.
  39830. */
  39831. roughness: number;
  39832. /**
  39833. * In case of refraction, define the value of the index of refraction.
  39834. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39835. */
  39836. indexOfRefraction: number;
  39837. /**
  39838. * Invert the refraction texture alongside the y axis.
  39839. * It can be useful with procedural textures or probe for instance.
  39840. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39841. */
  39842. invertRefractionY: boolean;
  39843. /**
  39844. * Defines the alpha limits in alpha test mode.
  39845. */
  39846. alphaCutOff: number;
  39847. private _useLightmapAsShadowmap;
  39848. /**
  39849. * In case of light mapping, define whether the map contains light or shadow informations.
  39850. */
  39851. useLightmapAsShadowmap: boolean;
  39852. private _diffuseFresnelParameters;
  39853. /**
  39854. * Define the diffuse fresnel parameters of the material.
  39855. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39856. */
  39857. diffuseFresnelParameters: FresnelParameters;
  39858. private _opacityFresnelParameters;
  39859. /**
  39860. * Define the opacity fresnel parameters of the material.
  39861. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39862. */
  39863. opacityFresnelParameters: FresnelParameters;
  39864. private _reflectionFresnelParameters;
  39865. /**
  39866. * Define the reflection fresnel parameters of the material.
  39867. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39868. */
  39869. reflectionFresnelParameters: FresnelParameters;
  39870. private _refractionFresnelParameters;
  39871. /**
  39872. * Define the refraction fresnel parameters of the material.
  39873. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39874. */
  39875. refractionFresnelParameters: FresnelParameters;
  39876. private _emissiveFresnelParameters;
  39877. /**
  39878. * Define the emissive fresnel parameters of the material.
  39879. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39880. */
  39881. emissiveFresnelParameters: FresnelParameters;
  39882. private _useReflectionFresnelFromSpecular;
  39883. /**
  39884. * If true automatically deducts the fresnels values from the material specularity.
  39885. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39886. */
  39887. useReflectionFresnelFromSpecular: boolean;
  39888. private _useGlossinessFromSpecularMapAlpha;
  39889. /**
  39890. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39891. */
  39892. useGlossinessFromSpecularMapAlpha: boolean;
  39893. private _maxSimultaneousLights;
  39894. /**
  39895. * Defines the maximum number of lights that can be used in the material
  39896. */
  39897. maxSimultaneousLights: number;
  39898. private _invertNormalMapX;
  39899. /**
  39900. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39901. */
  39902. invertNormalMapX: boolean;
  39903. private _invertNormalMapY;
  39904. /**
  39905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39906. */
  39907. invertNormalMapY: boolean;
  39908. private _twoSidedLighting;
  39909. /**
  39910. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39911. */
  39912. twoSidedLighting: boolean;
  39913. /**
  39914. * Default configuration related to image processing available in the standard Material.
  39915. */
  39916. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39917. /**
  39918. * Gets the image processing configuration used either in this material.
  39919. */
  39920. /**
  39921. * Sets the Default image processing configuration used either in the this material.
  39922. *
  39923. * If sets to null, the scene one is in use.
  39924. */
  39925. imageProcessingConfiguration: ImageProcessingConfiguration;
  39926. /**
  39927. * Keep track of the image processing observer to allow dispose and replace.
  39928. */
  39929. private _imageProcessingObserver;
  39930. /**
  39931. * Attaches a new image processing configuration to the Standard Material.
  39932. * @param configuration
  39933. */
  39934. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39935. /**
  39936. * Gets wether the color curves effect is enabled.
  39937. */
  39938. /**
  39939. * Sets wether the color curves effect is enabled.
  39940. */
  39941. cameraColorCurvesEnabled: boolean;
  39942. /**
  39943. * Gets wether the color grading effect is enabled.
  39944. */
  39945. /**
  39946. * Gets wether the color grading effect is enabled.
  39947. */
  39948. cameraColorGradingEnabled: boolean;
  39949. /**
  39950. * Gets wether tonemapping is enabled or not.
  39951. */
  39952. /**
  39953. * Sets wether tonemapping is enabled or not
  39954. */
  39955. cameraToneMappingEnabled: boolean;
  39956. /**
  39957. * The camera exposure used on this material.
  39958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39959. * This corresponds to a photographic exposure.
  39960. */
  39961. /**
  39962. * The camera exposure used on this material.
  39963. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39964. * This corresponds to a photographic exposure.
  39965. */
  39966. cameraExposure: number;
  39967. /**
  39968. * Gets The camera contrast used on this material.
  39969. */
  39970. /**
  39971. * Sets The camera contrast used on this material.
  39972. */
  39973. cameraContrast: number;
  39974. /**
  39975. * Gets the Color Grading 2D Lookup Texture.
  39976. */
  39977. /**
  39978. * Sets the Color Grading 2D Lookup Texture.
  39979. */
  39980. cameraColorGradingTexture: Nullable<BaseTexture>;
  39981. /**
  39982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39984. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  39985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39986. */
  39987. /**
  39988. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39989. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39990. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  39991. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39992. */
  39993. cameraColorCurves: Nullable<ColorCurves>;
  39994. /**
  39995. * Custom callback helping to override the default shader used in the material.
  39996. */
  39997. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39998. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39999. protected _worldViewProjectionMatrix: Matrix;
  40000. protected _globalAmbientColor: Color3;
  40001. protected _useLogarithmicDepth: boolean;
  40002. protected _rebuildInParallel: boolean;
  40003. /**
  40004. * Instantiates a new standard material.
  40005. * This is the default material used in Babylon. It is the best trade off between quality
  40006. * and performances.
  40007. * @see http://doc.babylonjs.com/babylon101/materials
  40008. * @param name Define the name of the material in the scene
  40009. * @param scene Define the scene the material belong to
  40010. */
  40011. constructor(name: string, scene: Scene);
  40012. /**
  40013. * Gets a boolean indicating that current material needs to register RTT
  40014. */
  40015. readonly hasRenderTargetTextures: boolean;
  40016. /**
  40017. * Gets the current class name of the material e.g. "StandardMaterial"
  40018. * Mainly use in serialization.
  40019. * @returns the class name
  40020. */
  40021. getClassName(): string;
  40022. /**
  40023. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40024. * You can try switching to logarithmic depth.
  40025. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40026. */
  40027. useLogarithmicDepth: boolean;
  40028. /**
  40029. * Specifies if the material will require alpha blending
  40030. * @returns a boolean specifying if alpha blending is needed
  40031. */
  40032. needAlphaBlending(): boolean;
  40033. /**
  40034. * Specifies if this material should be rendered in alpha test mode
  40035. * @returns a boolean specifying if an alpha test is needed.
  40036. */
  40037. needAlphaTesting(): boolean;
  40038. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40039. /**
  40040. * Get the texture used for alpha test purpose.
  40041. * @returns the diffuse texture in case of the standard material.
  40042. */
  40043. getAlphaTestTexture(): Nullable<BaseTexture>;
  40044. /**
  40045. * Get if the submesh is ready to be used and all its information available.
  40046. * Child classes can use it to update shaders
  40047. * @param mesh defines the mesh to check
  40048. * @param subMesh defines which submesh to check
  40049. * @param useInstances specifies that instances should be used
  40050. * @returns a boolean indicating that the submesh is ready or not
  40051. */
  40052. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40053. /**
  40054. * Builds the material UBO layouts.
  40055. * Used internally during the effect preparation.
  40056. */
  40057. buildUniformLayout(): void;
  40058. /**
  40059. * Unbinds the material from the mesh
  40060. */
  40061. unbind(): void;
  40062. /**
  40063. * Binds the submesh to this material by preparing the effect and shader to draw
  40064. * @param world defines the world transformation matrix
  40065. * @param mesh defines the mesh containing the submesh
  40066. * @param subMesh defines the submesh to bind the material to
  40067. */
  40068. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40069. /**
  40070. * Get the list of animatables in the material.
  40071. * @returns the list of animatables object used in the material
  40072. */
  40073. getAnimatables(): IAnimatable[];
  40074. /**
  40075. * Gets the active textures from the material
  40076. * @returns an array of textures
  40077. */
  40078. getActiveTextures(): BaseTexture[];
  40079. /**
  40080. * Specifies if the material uses a texture
  40081. * @param texture defines the texture to check against the material
  40082. * @returns a boolean specifying if the material uses the texture
  40083. */
  40084. hasTexture(texture: BaseTexture): boolean;
  40085. /**
  40086. * Disposes the material
  40087. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40088. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40089. */
  40090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40091. /**
  40092. * Makes a duplicate of the material, and gives it a new name
  40093. * @param name defines the new name for the duplicated material
  40094. * @returns the cloned material
  40095. */
  40096. clone(name: string): StandardMaterial;
  40097. /**
  40098. * Serializes this material in a JSON representation
  40099. * @returns the serialized material object
  40100. */
  40101. serialize(): any;
  40102. /**
  40103. * Creates a standard material from parsed material data
  40104. * @param source defines the JSON representation of the material
  40105. * @param scene defines the hosting scene
  40106. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40107. * @returns a new standard material
  40108. */
  40109. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40110. /**
  40111. * Are diffuse textures enabled in the application.
  40112. */
  40113. static DiffuseTextureEnabled: boolean;
  40114. /**
  40115. * Are ambient textures enabled in the application.
  40116. */
  40117. static AmbientTextureEnabled: boolean;
  40118. /**
  40119. * Are opacity textures enabled in the application.
  40120. */
  40121. static OpacityTextureEnabled: boolean;
  40122. /**
  40123. * Are reflection textures enabled in the application.
  40124. */
  40125. static ReflectionTextureEnabled: boolean;
  40126. /**
  40127. * Are emissive textures enabled in the application.
  40128. */
  40129. static EmissiveTextureEnabled: boolean;
  40130. /**
  40131. * Are specular textures enabled in the application.
  40132. */
  40133. static SpecularTextureEnabled: boolean;
  40134. /**
  40135. * Are bump textures enabled in the application.
  40136. */
  40137. static BumpTextureEnabled: boolean;
  40138. /**
  40139. * Are lightmap textures enabled in the application.
  40140. */
  40141. static LightmapTextureEnabled: boolean;
  40142. /**
  40143. * Are refraction textures enabled in the application.
  40144. */
  40145. static RefractionTextureEnabled: boolean;
  40146. /**
  40147. * Are color grading textures enabled in the application.
  40148. */
  40149. static ColorGradingTextureEnabled: boolean;
  40150. /**
  40151. * Are fresnels enabled in the application.
  40152. */
  40153. static FresnelEnabled: boolean;
  40154. }
  40155. }
  40156. declare module BABYLON {
  40157. /**
  40158. * A class extending Texture allowing drawing on a texture
  40159. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40160. */
  40161. export class DynamicTexture extends Texture {
  40162. private _generateMipMaps;
  40163. private _canvas;
  40164. private _context;
  40165. private _engine;
  40166. /**
  40167. * Creates a DynamicTexture
  40168. * @param name defines the name of the texture
  40169. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  40170. * @param scene defines the scene where you want the texture
  40171. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40172. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40173. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40174. */
  40175. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40176. /**
  40177. * Get the current class name of the texture useful for serialization or dynamic coding.
  40178. * @returns "DynamicTexture"
  40179. */
  40180. getClassName(): string;
  40181. /**
  40182. * Gets the current state of canRescale
  40183. */
  40184. readonly canRescale: boolean;
  40185. private _recreate;
  40186. /**
  40187. * Scales the texture
  40188. * @param ratio the scale factor to apply to both width and height
  40189. */
  40190. scale(ratio: number): void;
  40191. /**
  40192. * Resizes the texture
  40193. * @param width the new width
  40194. * @param height the new height
  40195. */
  40196. scaleTo(width: number, height: number): void;
  40197. /**
  40198. * Gets the context of the canvas used by the texture
  40199. * @returns the canvas context of the dynamic texture
  40200. */
  40201. getContext(): CanvasRenderingContext2D;
  40202. /**
  40203. * Clears the texture
  40204. */
  40205. clear(): void;
  40206. /**
  40207. * Updates the texture
  40208. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40209. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40210. */
  40211. update(invertY?: boolean, premulAlpha?: boolean): void;
  40212. /**
  40213. * Draws text onto the texture
  40214. * @param text defines the text to be drawn
  40215. * @param x defines the placement of the text from the left
  40216. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40217. * @param font defines the font to be used with font-style, font-size, font-name
  40218. * @param color defines the color used for the text
  40219. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40220. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40221. * @param update defines whether texture is immediately update (default is true)
  40222. */
  40223. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40224. /**
  40225. * Clones the texture
  40226. * @returns the clone of the texture.
  40227. */
  40228. clone(): DynamicTexture;
  40229. /**
  40230. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40231. * @returns a serialized dynamic texture object
  40232. */
  40233. serialize(): any;
  40234. /** @hidden */ private _rebuild(): void;
  40235. }
  40236. }
  40237. declare module BABYLON {
  40238. /** @hidden */
  40239. export var imageProcessingPixelShader: {
  40240. name: string;
  40241. shader: string;
  40242. };
  40243. }
  40244. declare module BABYLON {
  40245. /**
  40246. * ImageProcessingPostProcess
  40247. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40248. */
  40249. export class ImageProcessingPostProcess extends PostProcess {
  40250. /**
  40251. * Default configuration related to image processing available in the PBR Material.
  40252. */
  40253. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40254. /**
  40255. * Gets the image processing configuration used either in this material.
  40256. */
  40257. /**
  40258. * Sets the Default image processing configuration used either in the this material.
  40259. *
  40260. * If sets to null, the scene one is in use.
  40261. */
  40262. imageProcessingConfiguration: ImageProcessingConfiguration;
  40263. /**
  40264. * Keep track of the image processing observer to allow dispose and replace.
  40265. */
  40266. private _imageProcessingObserver;
  40267. /**
  40268. * Attaches a new image processing configuration to the PBR Material.
  40269. * @param configuration
  40270. */
  40271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40272. /**
  40273. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40274. */
  40275. /**
  40276. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40277. */
  40278. colorCurves: Nullable<ColorCurves>;
  40279. /**
  40280. * Gets wether the color curves effect is enabled.
  40281. */
  40282. /**
  40283. * Sets wether the color curves effect is enabled.
  40284. */
  40285. colorCurvesEnabled: boolean;
  40286. /**
  40287. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40288. */
  40289. /**
  40290. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40291. */
  40292. colorGradingTexture: Nullable<BaseTexture>;
  40293. /**
  40294. * Gets wether the color grading effect is enabled.
  40295. */
  40296. /**
  40297. * Gets wether the color grading effect is enabled.
  40298. */
  40299. colorGradingEnabled: boolean;
  40300. /**
  40301. * Gets exposure used in the effect.
  40302. */
  40303. /**
  40304. * Sets exposure used in the effect.
  40305. */
  40306. exposure: number;
  40307. /**
  40308. * Gets wether tonemapping is enabled or not.
  40309. */
  40310. /**
  40311. * Sets wether tonemapping is enabled or not
  40312. */
  40313. toneMappingEnabled: boolean;
  40314. /**
  40315. * Gets the type of tone mapping effect.
  40316. */
  40317. /**
  40318. * Sets the type of tone mapping effect.
  40319. */
  40320. toneMappingType: number;
  40321. /**
  40322. * Gets contrast used in the effect.
  40323. */
  40324. /**
  40325. * Sets contrast used in the effect.
  40326. */
  40327. contrast: number;
  40328. /**
  40329. * Gets Vignette stretch size.
  40330. */
  40331. /**
  40332. * Sets Vignette stretch size.
  40333. */
  40334. vignetteStretch: number;
  40335. /**
  40336. * Gets Vignette centre X Offset.
  40337. */
  40338. /**
  40339. * Sets Vignette centre X Offset.
  40340. */
  40341. vignetteCentreX: number;
  40342. /**
  40343. * Gets Vignette centre Y Offset.
  40344. */
  40345. /**
  40346. * Sets Vignette centre Y Offset.
  40347. */
  40348. vignetteCentreY: number;
  40349. /**
  40350. * Gets Vignette weight or intensity of the vignette effect.
  40351. */
  40352. /**
  40353. * Sets Vignette weight or intensity of the vignette effect.
  40354. */
  40355. vignetteWeight: number;
  40356. /**
  40357. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40358. * if vignetteEnabled is set to true.
  40359. */
  40360. /**
  40361. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40362. * if vignetteEnabled is set to true.
  40363. */
  40364. vignetteColor: Color4;
  40365. /**
  40366. * Gets Camera field of view used by the Vignette effect.
  40367. */
  40368. /**
  40369. * Sets Camera field of view used by the Vignette effect.
  40370. */
  40371. vignetteCameraFov: number;
  40372. /**
  40373. * Gets the vignette blend mode allowing different kind of effect.
  40374. */
  40375. /**
  40376. * Sets the vignette blend mode allowing different kind of effect.
  40377. */
  40378. vignetteBlendMode: number;
  40379. /**
  40380. * Gets wether the vignette effect is enabled.
  40381. */
  40382. /**
  40383. * Sets wether the vignette effect is enabled.
  40384. */
  40385. vignetteEnabled: boolean;
  40386. private _fromLinearSpace;
  40387. /**
  40388. * Gets wether the input of the processing is in Gamma or Linear Space.
  40389. */
  40390. /**
  40391. * Sets wether the input of the processing is in Gamma or Linear Space.
  40392. */
  40393. fromLinearSpace: boolean;
  40394. /**
  40395. * Defines cache preventing GC.
  40396. */
  40397. private _defines;
  40398. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40399. /**
  40400. * "ImageProcessingPostProcess"
  40401. * @returns "ImageProcessingPostProcess"
  40402. */
  40403. getClassName(): string;
  40404. protected _updateParameters(): void;
  40405. dispose(camera?: Camera): void;
  40406. }
  40407. }
  40408. declare module BABYLON {
  40409. /**
  40410. * Class containing static functions to help procedurally build meshes
  40411. */
  40412. export class GroundBuilder {
  40413. /**
  40414. * Creates a ground mesh
  40415. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40416. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40418. * @param name defines the name of the mesh
  40419. * @param options defines the options used to create the mesh
  40420. * @param scene defines the hosting scene
  40421. * @returns the ground mesh
  40422. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40423. */
  40424. static CreateGround(name: string, options: {
  40425. width?: number;
  40426. height?: number;
  40427. subdivisions?: number;
  40428. subdivisionsX?: number;
  40429. subdivisionsY?: number;
  40430. updatable?: boolean;
  40431. }, scene: any): Mesh;
  40432. /**
  40433. * Creates a tiled ground mesh
  40434. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40435. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40436. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  40437. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  40438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40439. * @param name defines the name of the mesh
  40440. * @param options defines the options used to create the mesh
  40441. * @param scene defines the hosting scene
  40442. * @returns the tiled ground mesh
  40443. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40444. */
  40445. static CreateTiledGround(name: string, options: {
  40446. xmin: number;
  40447. zmin: number;
  40448. xmax: number;
  40449. zmax: number;
  40450. subdivisions?: {
  40451. w: number;
  40452. h: number;
  40453. };
  40454. precision?: {
  40455. w: number;
  40456. h: number;
  40457. };
  40458. updatable?: boolean;
  40459. }, scene?: Nullable<Scene>): Mesh;
  40460. /**
  40461. * Creates a ground mesh from a height map
  40462. * * The parameter `url` sets the URL of the height map image resource.
  40463. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40464. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40465. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40466. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40467. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  40468. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  40469. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40471. * @param name defines the name of the mesh
  40472. * @param url defines the url to the height map
  40473. * @param options defines the options used to create the mesh
  40474. * @param scene defines the hosting scene
  40475. * @returns the ground mesh
  40476. * @see https://doc.babylonjs.com/babylon101/height_map
  40477. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40478. */
  40479. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40480. width?: number;
  40481. height?: number;
  40482. subdivisions?: number;
  40483. minHeight?: number;
  40484. maxHeight?: number;
  40485. colorFilter?: Color3;
  40486. alphaFilter?: number;
  40487. updatable?: boolean;
  40488. onReady?: (mesh: GroundMesh) => void;
  40489. }, scene?: Nullable<Scene>): GroundMesh;
  40490. }
  40491. }
  40492. declare module BABYLON {
  40493. /**
  40494. * Class containing static functions to help procedurally build meshes
  40495. */
  40496. export class TorusBuilder {
  40497. /**
  40498. * Creates a torus mesh
  40499. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40500. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40501. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40505. * @param name defines the name of the mesh
  40506. * @param options defines the options used to create the mesh
  40507. * @param scene defines the hosting scene
  40508. * @returns the torus mesh
  40509. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40510. */
  40511. static CreateTorus(name: string, options: {
  40512. diameter?: number;
  40513. thickness?: number;
  40514. tessellation?: number;
  40515. updatable?: boolean;
  40516. sideOrientation?: number;
  40517. frontUVs?: Vector4;
  40518. backUVs?: Vector4;
  40519. }, scene: any): Mesh;
  40520. }
  40521. }
  40522. declare module BABYLON {
  40523. /**
  40524. * Class containing static functions to help procedurally build meshes
  40525. */
  40526. export class CylinderBuilder {
  40527. /**
  40528. * Creates a cylinder or a cone mesh
  40529. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40530. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40531. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  40532. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40533. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40534. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40535. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40536. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  40537. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40538. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  40539. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  40540. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40541. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  40542. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  40543. * * If `enclose` is false, a ring surface is one element.
  40544. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40545. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  40546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40549. * @param name defines the name of the mesh
  40550. * @param options defines the options used to create the mesh
  40551. * @param scene defines the hosting scene
  40552. * @returns the cylinder mesh
  40553. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40554. */
  40555. static CreateCylinder(name: string, options: {
  40556. height?: number;
  40557. diameterTop?: number;
  40558. diameterBottom?: number;
  40559. diameter?: number;
  40560. tessellation?: number;
  40561. subdivisions?: number;
  40562. arc?: number;
  40563. faceColors?: Color4[];
  40564. faceUV?: Vector4[];
  40565. updatable?: boolean;
  40566. hasRings?: boolean;
  40567. enclose?: boolean;
  40568. cap?: number;
  40569. sideOrientation?: number;
  40570. frontUVs?: Vector4;
  40571. backUVs?: Vector4;
  40572. }, scene: any): Mesh;
  40573. }
  40574. }
  40575. declare module BABYLON {
  40576. /**
  40577. * Options to modify the vr teleportation behavior.
  40578. */
  40579. export interface VRTeleportationOptions {
  40580. /**
  40581. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40582. */
  40583. floorMeshName?: string;
  40584. /**
  40585. * A list of meshes to be used as the teleportation floor. (default: empty)
  40586. */
  40587. floorMeshes?: Mesh[];
  40588. }
  40589. /**
  40590. * Options to modify the vr experience helper's behavior.
  40591. */
  40592. export interface VRExperienceHelperOptions extends WebVROptions {
  40593. /**
  40594. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40595. */
  40596. createDeviceOrientationCamera?: boolean;
  40597. /**
  40598. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40599. */
  40600. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40601. /**
  40602. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40603. */
  40604. laserToggle?: boolean;
  40605. /**
  40606. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40607. */
  40608. floorMeshes?: Mesh[];
  40609. /**
  40610. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40611. */
  40612. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40613. }
  40614. /**
  40615. * Event containing information after VR has been entered
  40616. */
  40617. export class OnAfterEnteringVRObservableEvent {
  40618. /**
  40619. * If entering vr was successful
  40620. */
  40621. success: boolean;
  40622. }
  40623. /**
  40624. * Helps to quickly add VR support to an existing scene.
  40625. * See http://doc.babylonjs.com/how_to/webvr_helper
  40626. */
  40627. export class VRExperienceHelper {
  40628. /** Options to modify the vr experience helper's behavior. */
  40629. webVROptions: VRExperienceHelperOptions;
  40630. private _scene;
  40631. private _position;
  40632. private _btnVR;
  40633. private _btnVRDisplayed;
  40634. private _webVRsupported;
  40635. private _webVRready;
  40636. private _webVRrequesting;
  40637. private _webVRpresenting;
  40638. private _hasEnteredVR;
  40639. private _fullscreenVRpresenting;
  40640. private _canvas;
  40641. private _webVRCamera;
  40642. private _vrDeviceOrientationCamera;
  40643. private _deviceOrientationCamera;
  40644. private _existingCamera;
  40645. private _onKeyDown;
  40646. private _onVrDisplayPresentChange;
  40647. private _onVRDisplayChanged;
  40648. private _onVRRequestPresentStart;
  40649. private _onVRRequestPresentComplete;
  40650. /**
  40651. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40652. */
  40653. enableGazeEvenWhenNoPointerLock: boolean;
  40654. /**
  40655. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40656. */
  40657. exitVROnDoubleTap: boolean;
  40658. /**
  40659. * Observable raised right before entering VR.
  40660. */
  40661. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40662. /**
  40663. * Observable raised when entering VR has completed.
  40664. */
  40665. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40666. /**
  40667. * Observable raised when exiting VR.
  40668. */
  40669. onExitingVRObservable: Observable<VRExperienceHelper>;
  40670. /**
  40671. * Observable raised when controller mesh is loaded.
  40672. */
  40673. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40674. /** Return this.onEnteringVRObservable
  40675. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40676. */
  40677. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40678. /** Return this.onExitingVRObservable
  40679. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40680. */
  40681. readonly onExitingVR: Observable<VRExperienceHelper>;
  40682. /** Return this.onControllerMeshLoadedObservable
  40683. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40684. */
  40685. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40686. private _rayLength;
  40687. private _useCustomVRButton;
  40688. private _teleportationRequested;
  40689. private _teleportActive;
  40690. private _floorMeshName;
  40691. private _floorMeshesCollection;
  40692. private _rotationAllowed;
  40693. private _teleportBackwardsVector;
  40694. private _teleportationTarget;
  40695. private _isDefaultTeleportationTarget;
  40696. private _postProcessMove;
  40697. private _teleportationFillColor;
  40698. private _teleportationBorderColor;
  40699. private _rotationAngle;
  40700. private _haloCenter;
  40701. private _cameraGazer;
  40702. private _padSensibilityUp;
  40703. private _padSensibilityDown;
  40704. private _leftController;
  40705. private _rightController;
  40706. /**
  40707. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40708. */
  40709. onNewMeshSelected: Observable<AbstractMesh>;
  40710. /**
  40711. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40712. * This observable will provide the mesh and the controller used to select the mesh
  40713. */
  40714. onMeshSelectedWithController: Observable<{
  40715. mesh: AbstractMesh;
  40716. controller: WebVRController;
  40717. }>;
  40718. /**
  40719. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40720. */
  40721. onNewMeshPicked: Observable<PickingInfo>;
  40722. private _circleEase;
  40723. /**
  40724. * Observable raised before camera teleportation
  40725. */
  40726. onBeforeCameraTeleport: Observable<Vector3>;
  40727. /**
  40728. * Observable raised after camera teleportation
  40729. */
  40730. onAfterCameraTeleport: Observable<Vector3>;
  40731. /**
  40732. * Observable raised when current selected mesh gets unselected
  40733. */
  40734. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40735. private _raySelectionPredicate;
  40736. /**
  40737. * To be optionaly changed by user to define custom ray selection
  40738. */
  40739. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40740. /**
  40741. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40742. */
  40743. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40744. /**
  40745. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40746. */
  40747. teleportationEnabled: boolean;
  40748. private _defaultHeight;
  40749. private _teleportationInitialized;
  40750. private _interactionsEnabled;
  40751. private _interactionsRequested;
  40752. private _displayGaze;
  40753. private _displayLaserPointer;
  40754. /**
  40755. * The mesh used to display where the user is going to teleport.
  40756. */
  40757. /**
  40758. * Sets the mesh to be used to display where the user is going to teleport.
  40759. */
  40760. teleportationTarget: Mesh;
  40761. /**
  40762. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  40763. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40764. * See http://doc.babylonjs.com/resources/baking_transformations
  40765. */
  40766. gazeTrackerMesh: Mesh;
  40767. /**
  40768. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40769. */
  40770. updateGazeTrackerScale: boolean;
  40771. /**
  40772. * If the gaze trackers color should be updated when selecting meshes
  40773. */
  40774. updateGazeTrackerColor: boolean;
  40775. /**
  40776. * The gaze tracking mesh corresponding to the left controller
  40777. */
  40778. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40779. /**
  40780. * The gaze tracking mesh corresponding to the right controller
  40781. */
  40782. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40783. /**
  40784. * If the ray of the gaze should be displayed.
  40785. */
  40786. /**
  40787. * Sets if the ray of the gaze should be displayed.
  40788. */
  40789. displayGaze: boolean;
  40790. /**
  40791. * If the ray of the LaserPointer should be displayed.
  40792. */
  40793. /**
  40794. * Sets if the ray of the LaserPointer should be displayed.
  40795. */
  40796. displayLaserPointer: boolean;
  40797. /**
  40798. * The deviceOrientationCamera used as the camera when not in VR.
  40799. */
  40800. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40801. /**
  40802. * Based on the current WebVR support, returns the current VR camera used.
  40803. */
  40804. readonly currentVRCamera: Nullable<Camera>;
  40805. /**
  40806. * The webVRCamera which is used when in VR.
  40807. */
  40808. readonly webVRCamera: WebVRFreeCamera;
  40809. /**
  40810. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40811. */
  40812. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40813. /**
  40814. * The html button that is used to trigger entering into VR.
  40815. */
  40816. readonly vrButton: Nullable<HTMLButtonElement>;
  40817. private readonly _teleportationRequestInitiated;
  40818. /**
  40819. * Defines wether or not Pointer lock should be requested when switching to
  40820. * full screen.
  40821. */
  40822. requestPointerLockOnFullScreen: boolean;
  40823. /**
  40824. * Instantiates a VRExperienceHelper.
  40825. * Helps to quickly add VR support to an existing scene.
  40826. * @param scene The scene the VRExperienceHelper belongs to.
  40827. * @param webVROptions Options to modify the vr experience helper's behavior.
  40828. */
  40829. constructor(scene: Scene,
  40830. /** Options to modify the vr experience helper's behavior. */
  40831. webVROptions?: VRExperienceHelperOptions);
  40832. private _onDefaultMeshLoaded;
  40833. private _onResize;
  40834. private _onFullscreenChange;
  40835. /**
  40836. * Gets a value indicating if we are currently in VR mode.
  40837. */
  40838. readonly isInVRMode: boolean;
  40839. private onVrDisplayPresentChange;
  40840. private onVRDisplayChanged;
  40841. private moveButtonToBottomRight;
  40842. private displayVRButton;
  40843. private updateButtonVisibility;
  40844. private _cachedAngularSensibility;
  40845. /**
  40846. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40847. * Otherwise, will use the fullscreen API.
  40848. */
  40849. enterVR(): void;
  40850. /**
  40851. * Attempt to exit VR, or fullscreen.
  40852. */
  40853. exitVR(): void;
  40854. /**
  40855. * The position of the vr experience helper.
  40856. */
  40857. /**
  40858. * Sets the position of the vr experience helper.
  40859. */
  40860. position: Vector3;
  40861. /**
  40862. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40863. */
  40864. enableInteractions(): void;
  40865. private readonly _noControllerIsActive;
  40866. private beforeRender;
  40867. private _isTeleportationFloor;
  40868. /**
  40869. * Adds a floor mesh to be used for teleportation.
  40870. * @param floorMesh the mesh to be used for teleportation.
  40871. */
  40872. addFloorMesh(floorMesh: Mesh): void;
  40873. /**
  40874. * Removes a floor mesh from being used for teleportation.
  40875. * @param floorMesh the mesh to be removed.
  40876. */
  40877. removeFloorMesh(floorMesh: Mesh): void;
  40878. /**
  40879. * Enables interactions and teleportation using the VR controllers and gaze.
  40880. * @param vrTeleportationOptions options to modify teleportation behavior.
  40881. */
  40882. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40883. private _onNewGamepadConnected;
  40884. private _tryEnableInteractionOnController;
  40885. private _onNewGamepadDisconnected;
  40886. private _enableInteractionOnController;
  40887. private _checkTeleportWithRay;
  40888. private _checkRotate;
  40889. private _checkTeleportBackwards;
  40890. private _enableTeleportationOnController;
  40891. private _createTeleportationCircles;
  40892. private _displayTeleportationTarget;
  40893. private _hideTeleportationTarget;
  40894. private _rotateCamera;
  40895. private _moveTeleportationSelectorTo;
  40896. private _workingVector;
  40897. private _workingQuaternion;
  40898. private _workingMatrix;
  40899. /**
  40900. * Teleports the users feet to the desired location
  40901. * @param location The location where the user's feet should be placed
  40902. */
  40903. teleportCamera(location: Vector3): void;
  40904. private _convertNormalToDirectionOfRay;
  40905. private _castRayAndSelectObject;
  40906. private _notifySelectedMeshUnselected;
  40907. /**
  40908. * Sets the color of the laser ray from the vr controllers.
  40909. * @param color new color for the ray.
  40910. */
  40911. changeLaserColor(color: Color3): void;
  40912. /**
  40913. * Sets the color of the ray from the vr headsets gaze.
  40914. * @param color new color for the ray.
  40915. */
  40916. changeGazeColor(color: Color3): void;
  40917. /**
  40918. * Exits VR and disposes of the vr experience helper
  40919. */
  40920. dispose(): void;
  40921. /**
  40922. * Gets the name of the VRExperienceHelper class
  40923. * @returns "VRExperienceHelper"
  40924. */
  40925. getClassName(): string;
  40926. }
  40927. }
  40928. declare module BABYLON {
  40929. /**
  40930. * Manages an XRSession to work with Babylon's engine
  40931. * @see https://doc.babylonjs.com/how_to/webxr
  40932. */
  40933. export class WebXRSessionManager implements IDisposable {
  40934. private scene;
  40935. /**
  40936. * Fires every time a new xrFrame arrives which can be used to update the camera
  40937. */
  40938. onXRFrameObservable: Observable<any>;
  40939. /**
  40940. * Fires when the xr session is ended either by the device or manually done
  40941. */
  40942. onXRSessionEnded: Observable<any>;
  40943. /**
  40944. * Underlying xr session
  40945. */
  40946. session: XRSession;
  40947. /**
  40948. * Type of reference space used when creating the session
  40949. */
  40950. referenceSpace: XRReferenceSpace;
  40951. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40952. /**
  40953. * Current XR frame
  40954. */
  40955. currentFrame: Nullable<XRFrame>;
  40956. private _xrNavigator;
  40957. private baseLayer;
  40958. /**
  40959. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40960. * @param scene The scene which the session should be created for
  40961. */
  40962. constructor(scene: Scene);
  40963. /**
  40964. * Initializes the manager
  40965. * After initialization enterXR can be called to start an XR session
  40966. * @returns Promise which resolves after it is initialized
  40967. */
  40968. initializeAsync(): Promise<void>;
  40969. /**
  40970. * Initializes an xr session
  40971. * @param xrSessionMode mode to initialize
  40972. * @returns a promise which will resolve once the session has been initialized
  40973. */
  40974. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40975. /**
  40976. * Sets the reference space on the xr session
  40977. * @param referenceSpace space to set
  40978. * @returns a promise that will resolve once the reference space has been set
  40979. */
  40980. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40981. /**
  40982. * Updates the render state of the session
  40983. * @param state state to set
  40984. * @returns a promise that resolves once the render state has been updated
  40985. */
  40986. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40987. /**
  40988. * Starts rendering to the xr layer
  40989. * @returns a promise that will resolve once rendering has started
  40990. */
  40991. startRenderingToXRAsync(): Promise<void>;
  40992. /**
  40993. * Stops the xrSession and restores the renderloop
  40994. * @returns Promise which resolves after it exits XR
  40995. */
  40996. exitXRAsync(): Promise<unknown>;
  40997. /**
  40998. * Checks if a session would be supported for the creation options specified
  40999. * @param sessionMode session mode to check if supported eg. immersive-vr
  41000. * @returns true if supported
  41001. */
  41002. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41003. /**
  41004. * @hidden
  41005. * Converts the render layer of xrSession to a render target
  41006. * @param session session to create render target for
  41007. * @param scene scene the new render target should be created for
  41008. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41009. /**
  41010. * Disposes of the session manager
  41011. */
  41012. dispose(): void;
  41013. }
  41014. }
  41015. declare module BABYLON {
  41016. /**
  41017. * WebXR Camera which holds the views for the xrSession
  41018. * @see https://doc.babylonjs.com/how_to/webxr
  41019. */
  41020. export class WebXRCamera extends FreeCamera {
  41021. private static _TmpMatrix;
  41022. /**
  41023. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41024. * @param name the name of the camera
  41025. * @param scene the scene to add the camera to
  41026. */
  41027. constructor(name: string, scene: Scene);
  41028. private _updateNumberOfRigCameras;
  41029. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  41030. /**
  41031. * Updates the cameras position from the current pose information of the XR session
  41032. * @param xrSessionManager the session containing pose information
  41033. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41034. */
  41035. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41036. }
  41037. }
  41038. declare module BABYLON {
  41039. /**
  41040. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41041. */
  41042. export class WebXRManagedOutputCanvas implements IDisposable {
  41043. private helper;
  41044. private _canvas;
  41045. /**
  41046. * xrpresent context of the canvas which can be used to display/mirror xr content
  41047. */
  41048. canvasContext: WebGLRenderingContext;
  41049. /**
  41050. * xr layer for the canvas
  41051. */
  41052. xrLayer: Nullable<XRWebGLLayer>;
  41053. /**
  41054. * Initializes the xr layer for the session
  41055. * @param xrSession xr session
  41056. * @returns a promise that will resolve once the XR Layer has been created
  41057. */
  41058. initializeXRLayerAsync(xrSession: any): any;
  41059. /**
  41060. * Initializes the canvas to be added/removed upon entering/exiting xr
  41061. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41062. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41063. */
  41064. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41065. /**
  41066. * Disposes of the object
  41067. */
  41068. dispose(): void;
  41069. private _setManagedOutputCanvas;
  41070. private _addCanvas;
  41071. private _removeCanvas;
  41072. }
  41073. }
  41074. declare module BABYLON {
  41075. /**
  41076. * States of the webXR experience
  41077. */
  41078. export enum WebXRState {
  41079. /**
  41080. * Transitioning to being in XR mode
  41081. */
  41082. ENTERING_XR = 0,
  41083. /**
  41084. * Transitioning to non XR mode
  41085. */
  41086. EXITING_XR = 1,
  41087. /**
  41088. * In XR mode and presenting
  41089. */
  41090. IN_XR = 2,
  41091. /**
  41092. * Not entered XR mode
  41093. */
  41094. NOT_IN_XR = 3
  41095. }
  41096. /**
  41097. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41098. * @see https://doc.babylonjs.com/how_to/webxr
  41099. */
  41100. export class WebXRExperienceHelper implements IDisposable {
  41101. private scene;
  41102. /**
  41103. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  41104. */
  41105. container: AbstractMesh;
  41106. /**
  41107. * Camera used to render xr content
  41108. */
  41109. camera: WebXRCamera;
  41110. /**
  41111. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41112. */
  41113. state: WebXRState;
  41114. private _setState;
  41115. private static _TmpVector;
  41116. /**
  41117. * Fires when the state of the experience helper has changed
  41118. */
  41119. onStateChangedObservable: Observable<WebXRState>;
  41120. /** Session manager used to keep track of xr session */
  41121. sessionManager: WebXRSessionManager;
  41122. private _nonVRCamera;
  41123. private _originalSceneAutoClear;
  41124. private _supported;
  41125. /**
  41126. * Creates the experience helper
  41127. * @param scene the scene to attach the experience helper to
  41128. * @returns a promise for the experience helper
  41129. */
  41130. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41131. /**
  41132. * Creates a WebXRExperienceHelper
  41133. * @param scene The scene the helper should be created in
  41134. */
  41135. private constructor();
  41136. /**
  41137. * Exits XR mode and returns the scene to its original state
  41138. * @returns promise that resolves after xr mode has exited
  41139. */
  41140. exitXRAsync(): Promise<unknown>;
  41141. /**
  41142. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41143. * @param sessionCreationOptions options for the XR session
  41144. * @param referenceSpaceType frame of reference of the XR session
  41145. * @param outputCanvas the output canvas that will be used to enter XR mode
  41146. * @returns promise that resolves after xr mode has entered
  41147. */
  41148. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41149. /**
  41150. * Updates the global position of the camera by moving the camera's container
  41151. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41152. * @param position The desired global position of the camera
  41153. */
  41154. setPositionOfCameraUsingContainer(position: Vector3): void;
  41155. /**
  41156. * Rotates the xr camera by rotating the camera's container around the camera's position
  41157. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41158. * @param rotation the desired quaternion rotation to apply to the camera
  41159. */
  41160. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41161. /**
  41162. * Disposes of the experience helper
  41163. */
  41164. dispose(): void;
  41165. }
  41166. }
  41167. declare module BABYLON {
  41168. /**
  41169. * Button which can be used to enter a different mode of XR
  41170. */
  41171. export class WebXREnterExitUIButton {
  41172. /** button element */
  41173. element: HTMLElement;
  41174. /** XR initialization options for the button */
  41175. sessionMode: XRSessionMode;
  41176. /** Reference space type */
  41177. referenceSpaceType: XRReferenceSpaceType;
  41178. /**
  41179. * Creates a WebXREnterExitUIButton
  41180. * @param element button element
  41181. * @param sessionMode XR initialization session mode
  41182. * @param referenceSpaceType the type of reference space to be used
  41183. */
  41184. constructor(
  41185. /** button element */
  41186. element: HTMLElement,
  41187. /** XR initialization options for the button */
  41188. sessionMode: XRSessionMode,
  41189. /** Reference space type */
  41190. referenceSpaceType: XRReferenceSpaceType);
  41191. /**
  41192. * Overwritable function which can be used to update the button's visuals when the state changes
  41193. * @param activeButton the current active button in the UI
  41194. */
  41195. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41196. }
  41197. /**
  41198. * Options to create the webXR UI
  41199. */
  41200. export class WebXREnterExitUIOptions {
  41201. /**
  41202. * Context to enter xr with
  41203. */
  41204. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41205. /**
  41206. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41207. */
  41208. customButtons?: Array<WebXREnterExitUIButton>;
  41209. }
  41210. /**
  41211. * UI to allow the user to enter/exit XR mode
  41212. */
  41213. export class WebXREnterExitUI implements IDisposable {
  41214. private scene;
  41215. private _overlay;
  41216. private _buttons;
  41217. private _activeButton;
  41218. /**
  41219. * Fired every time the active button is changed.
  41220. *
  41221. * When xr is entered via a button that launches xr that button will be the callback parameter
  41222. *
  41223. * When exiting xr the callback parameter will be null)
  41224. */
  41225. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41226. /**
  41227. * Creates UI to allow the user to enter/exit XR mode
  41228. * @param scene the scene to add the ui to
  41229. * @param helper the xr experience helper to enter/exit xr with
  41230. * @param options options to configure the UI
  41231. * @returns the created ui
  41232. */
  41233. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41234. private constructor();
  41235. private _updateButtons;
  41236. /**
  41237. * Disposes of the object
  41238. */
  41239. dispose(): void;
  41240. }
  41241. }
  41242. declare module BABYLON {
  41243. /**
  41244. * Represents an XR input
  41245. */
  41246. export class WebXRController {
  41247. private scene;
  41248. /** The underlying input source for the controller */
  41249. inputSource: XRInputSource;
  41250. private parentContainer;
  41251. /**
  41252. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  41253. */
  41254. grip?: AbstractMesh;
  41255. /**
  41256. * Pointer which can be used to select objects or attach a visible laser to
  41257. */
  41258. pointer: AbstractMesh;
  41259. /**
  41260. * Event that fires when the controller is removed/disposed
  41261. */
  41262. onDisposeObservable: Observable<{}>;
  41263. private _tmpMatrix;
  41264. private _tmpQuaternion;
  41265. private _tmpVector;
  41266. /**
  41267. * Creates the controller
  41268. * @see https://doc.babylonjs.com/how_to/webxr
  41269. * @param scene the scene which the controller should be associated to
  41270. * @param inputSource the underlying input source for the controller
  41271. * @param parentContainer parent that the controller meshes should be children of
  41272. */
  41273. constructor(scene: Scene,
  41274. /** The underlying input source for the controller */
  41275. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41276. /**
  41277. * Updates the controller pose based on the given XRFrame
  41278. * @param xrFrame xr frame to update the pose with
  41279. * @param referenceSpace reference space to use
  41280. */
  41281. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41282. /**
  41283. * Gets a world space ray coming from the controller
  41284. * @param result the resulting ray
  41285. */
  41286. getWorldPointerRayToRef(result: Ray): void;
  41287. /**
  41288. * Disposes of the object
  41289. */
  41290. dispose(): void;
  41291. }
  41292. }
  41293. declare module BABYLON {
  41294. /**
  41295. * XR input used to track XR inputs such as controllers/rays
  41296. */
  41297. export class WebXRInput implements IDisposable {
  41298. /**
  41299. * Base experience the input listens to
  41300. */
  41301. baseExperience: WebXRExperienceHelper;
  41302. /**
  41303. * XR controllers being tracked
  41304. */
  41305. controllers: Array<WebXRController>;
  41306. private _frameObserver;
  41307. private _stateObserver;
  41308. /**
  41309. * Event when a controller has been connected/added
  41310. */
  41311. onControllerAddedObservable: Observable<WebXRController>;
  41312. /**
  41313. * Event when a controller has been removed/disconnected
  41314. */
  41315. onControllerRemovedObservable: Observable<WebXRController>;
  41316. /**
  41317. * Initializes the WebXRInput
  41318. * @param baseExperience experience helper which the input should be created for
  41319. */
  41320. constructor(
  41321. /**
  41322. * Base experience the input listens to
  41323. */
  41324. baseExperience: WebXRExperienceHelper);
  41325. private _onInputSourcesChange;
  41326. private _addAndRemoveControllers;
  41327. /**
  41328. * Disposes of the object
  41329. */
  41330. dispose(): void;
  41331. }
  41332. }
  41333. declare module BABYLON {
  41334. /**
  41335. * Enables teleportation
  41336. */
  41337. export class WebXRControllerTeleportation {
  41338. private _teleportationFillColor;
  41339. private _teleportationBorderColor;
  41340. private _tmpRay;
  41341. private _tmpVector;
  41342. /**
  41343. * Creates a WebXRControllerTeleportation
  41344. * @param input input manager to add teleportation to
  41345. * @param floorMeshes floormeshes which can be teleported to
  41346. */
  41347. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41348. }
  41349. }
  41350. declare module BABYLON {
  41351. /**
  41352. * Handles pointer input automatically for the pointer of XR controllers
  41353. */
  41354. export class WebXRControllerPointerSelection {
  41355. private static _idCounter;
  41356. private _tmpRay;
  41357. /**
  41358. * Creates a WebXRControllerPointerSelection
  41359. * @param input input manager to setup pointer selection
  41360. */
  41361. constructor(input: WebXRInput);
  41362. private _convertNormalToDirectionOfRay;
  41363. private _updatePointerDistance;
  41364. }
  41365. }
  41366. declare module BABYLON {
  41367. /**
  41368. * Class used to represent data loading progression
  41369. */
  41370. export class SceneLoaderProgressEvent {
  41371. /** defines if data length to load can be evaluated */
  41372. readonly lengthComputable: boolean;
  41373. /** defines the loaded data length */
  41374. readonly loaded: number;
  41375. /** defines the data length to load */
  41376. readonly total: number;
  41377. /**
  41378. * Create a new progress event
  41379. * @param lengthComputable defines if data length to load can be evaluated
  41380. * @param loaded defines the loaded data length
  41381. * @param total defines the data length to load
  41382. */
  41383. constructor(
  41384. /** defines if data length to load can be evaluated */
  41385. lengthComputable: boolean,
  41386. /** defines the loaded data length */
  41387. loaded: number,
  41388. /** defines the data length to load */
  41389. total: number);
  41390. /**
  41391. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41392. * @param event defines the source event
  41393. * @returns a new SceneLoaderProgressEvent
  41394. */
  41395. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41396. }
  41397. /**
  41398. * Interface used by SceneLoader plugins to define supported file extensions
  41399. */
  41400. export interface ISceneLoaderPluginExtensions {
  41401. /**
  41402. * Defines the list of supported extensions
  41403. */
  41404. [extension: string]: {
  41405. isBinary: boolean;
  41406. };
  41407. }
  41408. /**
  41409. * Interface used by SceneLoader plugin factory
  41410. */
  41411. export interface ISceneLoaderPluginFactory {
  41412. /**
  41413. * Defines the name of the factory
  41414. */
  41415. name: string;
  41416. /**
  41417. * Function called to create a new plugin
  41418. * @return the new plugin
  41419. */
  41420. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41421. /**
  41422. * Boolean indicating if the plugin can direct load specific data
  41423. */
  41424. canDirectLoad?: (data: string) => boolean;
  41425. }
  41426. /**
  41427. * Interface used to define a SceneLoader plugin
  41428. */
  41429. export interface ISceneLoaderPlugin {
  41430. /**
  41431. * The friendly name of this plugin.
  41432. */
  41433. name: string;
  41434. /**
  41435. * The file extensions supported by this plugin.
  41436. */
  41437. extensions: string | ISceneLoaderPluginExtensions;
  41438. /**
  41439. * Import meshes into a scene.
  41440. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41441. * @param scene The scene to import into
  41442. * @param data The data to import
  41443. * @param rootUrl The root url for scene and resources
  41444. * @param meshes The meshes array to import into
  41445. * @param particleSystems The particle systems array to import into
  41446. * @param skeletons The skeletons array to import into
  41447. * @param onError The callback when import fails
  41448. * @returns True if successful or false otherwise
  41449. */
  41450. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41451. /**
  41452. * Load into a scene.
  41453. * @param scene The scene to load into
  41454. * @param data The data to import
  41455. * @param rootUrl The root url for scene and resources
  41456. * @param onError The callback when import fails
  41457. * @returns true if successful or false otherwise
  41458. */
  41459. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41460. /**
  41461. * The callback that returns true if the data can be directly loaded.
  41462. */
  41463. canDirectLoad?: (data: string) => boolean;
  41464. /**
  41465. * The callback that allows custom handling of the root url based on the response url.
  41466. */
  41467. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41468. /**
  41469. * Load into an asset container.
  41470. * @param scene The scene to load into
  41471. * @param data The data to import
  41472. * @param rootUrl The root url for scene and resources
  41473. * @param onError The callback when import fails
  41474. * @returns The loaded asset container
  41475. */
  41476. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41477. }
  41478. /**
  41479. * Interface used to define an async SceneLoader plugin
  41480. */
  41481. export interface ISceneLoaderPluginAsync {
  41482. /**
  41483. * The friendly name of this plugin.
  41484. */
  41485. name: string;
  41486. /**
  41487. * The file extensions supported by this plugin.
  41488. */
  41489. extensions: string | ISceneLoaderPluginExtensions;
  41490. /**
  41491. * Import meshes into a scene.
  41492. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41493. * @param scene The scene to import into
  41494. * @param data The data to import
  41495. * @param rootUrl The root url for scene and resources
  41496. * @param onProgress The callback when the load progresses
  41497. * @param fileName Defines the name of the file to load
  41498. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41499. */
  41500. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41501. meshes: AbstractMesh[];
  41502. particleSystems: IParticleSystem[];
  41503. skeletons: Skeleton[];
  41504. animationGroups: AnimationGroup[];
  41505. }>;
  41506. /**
  41507. * Load into a scene.
  41508. * @param scene The scene to load into
  41509. * @param data The data to import
  41510. * @param rootUrl The root url for scene and resources
  41511. * @param onProgress The callback when the load progresses
  41512. * @param fileName Defines the name of the file to load
  41513. * @returns Nothing
  41514. */
  41515. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41516. /**
  41517. * The callback that returns true if the data can be directly loaded.
  41518. */
  41519. canDirectLoad?: (data: string) => boolean;
  41520. /**
  41521. * The callback that allows custom handling of the root url based on the response url.
  41522. */
  41523. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41524. /**
  41525. * Load into an asset container.
  41526. * @param scene The scene to load into
  41527. * @param data The data to import
  41528. * @param rootUrl The root url for scene and resources
  41529. * @param onProgress The callback when the load progresses
  41530. * @param fileName Defines the name of the file to load
  41531. * @returns The loaded asset container
  41532. */
  41533. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41534. }
  41535. /**
  41536. * Class used to load scene from various file formats using registered plugins
  41537. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41538. */
  41539. export class SceneLoader {
  41540. /**
  41541. * No logging while loading
  41542. */
  41543. static readonly NO_LOGGING: number;
  41544. /**
  41545. * Minimal logging while loading
  41546. */
  41547. static readonly MINIMAL_LOGGING: number;
  41548. /**
  41549. * Summary logging while loading
  41550. */
  41551. static readonly SUMMARY_LOGGING: number;
  41552. /**
  41553. * Detailled logging while loading
  41554. */
  41555. static readonly DETAILED_LOGGING: number;
  41556. /**
  41557. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41558. */
  41559. static ForceFullSceneLoadingForIncremental: boolean;
  41560. /**
  41561. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41562. */
  41563. static ShowLoadingScreen: boolean;
  41564. /**
  41565. * Defines the current logging level (while loading the scene)
  41566. * @ignorenaming
  41567. */
  41568. static loggingLevel: number;
  41569. /**
  41570. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41571. */
  41572. static CleanBoneMatrixWeights: boolean;
  41573. /**
  41574. * Event raised when a plugin is used to load a scene
  41575. */
  41576. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41577. private static _registeredPlugins;
  41578. private static _getDefaultPlugin;
  41579. private static _getPluginForExtension;
  41580. private static _getPluginForDirectLoad;
  41581. private static _getPluginForFilename;
  41582. private static _getDirectLoad;
  41583. private static _loadData;
  41584. private static _getFileInfo;
  41585. /**
  41586. * Gets a plugin that can load the given extension
  41587. * @param extension defines the extension to load
  41588. * @returns a plugin or null if none works
  41589. */
  41590. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41591. /**
  41592. * Gets a boolean indicating that the given extension can be loaded
  41593. * @param extension defines the extension to load
  41594. * @returns true if the extension is supported
  41595. */
  41596. static IsPluginForExtensionAvailable(extension: string): boolean;
  41597. /**
  41598. * Adds a new plugin to the list of registered plugins
  41599. * @param plugin defines the plugin to add
  41600. */
  41601. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41602. /**
  41603. * Import meshes into a scene
  41604. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41605. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41606. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41607. * @param scene the instance of BABYLON.Scene to append to
  41608. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41609. * @param onProgress a callback with a progress event for each file being loaded
  41610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41611. * @param pluginExtension the extension used to determine the plugin
  41612. * @returns The loaded plugin
  41613. */
  41614. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41615. /**
  41616. * Import meshes into a scene
  41617. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41618. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41619. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41620. * @param scene the instance of BABYLON.Scene to append to
  41621. * @param onProgress a callback with a progress event for each file being loaded
  41622. * @param pluginExtension the extension used to determine the plugin
  41623. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41624. */
  41625. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41626. meshes: AbstractMesh[];
  41627. particleSystems: IParticleSystem[];
  41628. skeletons: Skeleton[];
  41629. animationGroups: AnimationGroup[];
  41630. }>;
  41631. /**
  41632. * Load a scene
  41633. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41634. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41635. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41636. * @param onSuccess a callback with the scene when import succeeds
  41637. * @param onProgress a callback with a progress event for each file being loaded
  41638. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41639. * @param pluginExtension the extension used to determine the plugin
  41640. * @returns The loaded plugin
  41641. */
  41642. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41643. /**
  41644. * Load a scene
  41645. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41646. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41647. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41648. * @param onProgress a callback with a progress event for each file being loaded
  41649. * @param pluginExtension the extension used to determine the plugin
  41650. * @returns The loaded scene
  41651. */
  41652. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41653. /**
  41654. * Append a scene
  41655. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41656. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41657. * @param scene is the instance of BABYLON.Scene to append to
  41658. * @param onSuccess a callback with the scene when import succeeds
  41659. * @param onProgress a callback with a progress event for each file being loaded
  41660. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41661. * @param pluginExtension the extension used to determine the plugin
  41662. * @returns The loaded plugin
  41663. */
  41664. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41665. /**
  41666. * Append a scene
  41667. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41668. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41669. * @param scene is the instance of BABYLON.Scene to append to
  41670. * @param onProgress a callback with a progress event for each file being loaded
  41671. * @param pluginExtension the extension used to determine the plugin
  41672. * @returns The given scene
  41673. */
  41674. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41675. /**
  41676. * Load a scene into an asset container
  41677. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41678. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41679. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41680. * @param onSuccess a callback with the scene when import succeeds
  41681. * @param onProgress a callback with a progress event for each file being loaded
  41682. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41683. * @param pluginExtension the extension used to determine the plugin
  41684. * @returns The loaded plugin
  41685. */
  41686. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41687. /**
  41688. * Load a scene into an asset container
  41689. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41690. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  41691. * @param scene is the instance of Scene to append to
  41692. * @param onProgress a callback with a progress event for each file being loaded
  41693. * @param pluginExtension the extension used to determine the plugin
  41694. * @returns The loaded asset container
  41695. */
  41696. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41697. }
  41698. }
  41699. declare module BABYLON {
  41700. /**
  41701. * Generic Controller
  41702. */
  41703. export class GenericController extends WebVRController {
  41704. /**
  41705. * Base Url for the controller model.
  41706. */
  41707. static readonly MODEL_BASE_URL: string;
  41708. /**
  41709. * File name for the controller model.
  41710. */
  41711. static readonly MODEL_FILENAME: string;
  41712. /**
  41713. * Creates a new GenericController from a gamepad
  41714. * @param vrGamepad the gamepad that the controller should be created from
  41715. */
  41716. constructor(vrGamepad: any);
  41717. /**
  41718. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41719. * @param scene scene in which to add meshes
  41720. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41721. */
  41722. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41723. /**
  41724. * Called once for each button that changed state since the last frame
  41725. * @param buttonIdx Which button index changed
  41726. * @param state New state of the button
  41727. * @param changes Which properties on the state changed since last frame
  41728. */
  41729. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41730. }
  41731. }
  41732. declare module BABYLON {
  41733. /**
  41734. * Defines the WindowsMotionController object that the state of the windows motion controller
  41735. */
  41736. export class WindowsMotionController extends WebVRController {
  41737. /**
  41738. * The base url used to load the left and right controller models
  41739. */
  41740. static MODEL_BASE_URL: string;
  41741. /**
  41742. * The name of the left controller model file
  41743. */
  41744. static MODEL_LEFT_FILENAME: string;
  41745. /**
  41746. * The name of the right controller model file
  41747. */
  41748. static MODEL_RIGHT_FILENAME: string;
  41749. /**
  41750. * The controller name prefix for this controller type
  41751. */
  41752. static readonly GAMEPAD_ID_PREFIX: string;
  41753. /**
  41754. * The controller id pattern for this controller type
  41755. */
  41756. private static readonly GAMEPAD_ID_PATTERN;
  41757. private _loadedMeshInfo;
  41758. private readonly _mapping;
  41759. /**
  41760. * Fired when the trackpad on this controller is clicked
  41761. */
  41762. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41763. /**
  41764. * Fired when the trackpad on this controller is modified
  41765. */
  41766. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41767. /**
  41768. * The current x and y values of this controller's trackpad
  41769. */
  41770. trackpad: StickValues;
  41771. /**
  41772. * Creates a new WindowsMotionController from a gamepad
  41773. * @param vrGamepad the gamepad that the controller should be created from
  41774. */
  41775. constructor(vrGamepad: any);
  41776. /**
  41777. * Fired when the trigger on this controller is modified
  41778. */
  41779. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41780. /**
  41781. * Fired when the menu button on this controller is modified
  41782. */
  41783. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41784. /**
  41785. * Fired when the grip button on this controller is modified
  41786. */
  41787. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41788. /**
  41789. * Fired when the thumbstick button on this controller is modified
  41790. */
  41791. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41792. /**
  41793. * Fired when the touchpad button on this controller is modified
  41794. */
  41795. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41796. /**
  41797. * Fired when the touchpad values on this controller are modified
  41798. */
  41799. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41800. private _updateTrackpad;
  41801. /**
  41802. * Called once per frame by the engine.
  41803. */
  41804. update(): void;
  41805. /**
  41806. * Called once for each button that changed state since the last frame
  41807. * @param buttonIdx Which button index changed
  41808. * @param state New state of the button
  41809. * @param changes Which properties on the state changed since last frame
  41810. */
  41811. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41812. /**
  41813. * Moves the buttons on the controller mesh based on their current state
  41814. * @param buttonName the name of the button to move
  41815. * @param buttonValue the value of the button which determines the buttons new position
  41816. */
  41817. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41818. /**
  41819. * Moves the axis on the controller mesh based on its current state
  41820. * @param axis the index of the axis
  41821. * @param axisValue the value of the axis which determines the meshes new position
  41822. * @hidden
  41823. */
  41824. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41825. /**
  41826. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41827. * @param scene scene in which to add meshes
  41828. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41829. */
  41830. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41831. /**
  41832. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41833. * can be transformed by button presses and axes values, based on this._mapping.
  41834. *
  41835. * @param scene scene in which the meshes exist
  41836. * @param meshes list of meshes that make up the controller model to process
  41837. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41838. */
  41839. private processModel;
  41840. private createMeshInfo;
  41841. /**
  41842. * Gets the ray of the controller in the direction the controller is pointing
  41843. * @param length the length the resulting ray should be
  41844. * @returns a ray in the direction the controller is pointing
  41845. */
  41846. getForwardRay(length?: number): Ray;
  41847. /**
  41848. * Disposes of the controller
  41849. */
  41850. dispose(): void;
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. /**
  41855. * Oculus Touch Controller
  41856. */
  41857. export class OculusTouchController extends WebVRController {
  41858. /**
  41859. * Base Url for the controller model.
  41860. */
  41861. static MODEL_BASE_URL: string;
  41862. /**
  41863. * File name for the left controller model.
  41864. */
  41865. static MODEL_LEFT_FILENAME: string;
  41866. /**
  41867. * File name for the right controller model.
  41868. */
  41869. static MODEL_RIGHT_FILENAME: string;
  41870. /**
  41871. * Base Url for the Quest controller model.
  41872. */
  41873. static QUEST_MODEL_BASE_URL: string;
  41874. /**
  41875. * @hidden
  41876. * If the controllers are running on a device that needs the updated Quest controller models
  41877. */ private static _IsQuest: boolean;
  41878. /**
  41879. * Fired when the secondary trigger on this controller is modified
  41880. */
  41881. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41882. /**
  41883. * Fired when the thumb rest on this controller is modified
  41884. */
  41885. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41886. /**
  41887. * Creates a new OculusTouchController from a gamepad
  41888. * @param vrGamepad the gamepad that the controller should be created from
  41889. */
  41890. constructor(vrGamepad: any);
  41891. /**
  41892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41893. * @param scene scene in which to add meshes
  41894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41895. */
  41896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41897. /**
  41898. * Fired when the A button on this controller is modified
  41899. */
  41900. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41901. /**
  41902. * Fired when the B button on this controller is modified
  41903. */
  41904. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41905. /**
  41906. * Fired when the X button on this controller is modified
  41907. */
  41908. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41909. /**
  41910. * Fired when the Y button on this controller is modified
  41911. */
  41912. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41913. /**
  41914. * Called once for each button that changed state since the last frame
  41915. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41916. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41917. * 2) secondary trigger (same)
  41918. * 3) A (right) X (left), touch, pressed = value
  41919. * 4) B / Y
  41920. * 5) thumb rest
  41921. * @param buttonIdx Which button index changed
  41922. * @param state New state of the button
  41923. * @param changes Which properties on the state changed since last frame
  41924. */
  41925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41926. }
  41927. }
  41928. declare module BABYLON {
  41929. /**
  41930. * Vive Controller
  41931. */
  41932. export class ViveController extends WebVRController {
  41933. /**
  41934. * Base Url for the controller model.
  41935. */
  41936. static MODEL_BASE_URL: string;
  41937. /**
  41938. * File name for the controller model.
  41939. */
  41940. static MODEL_FILENAME: string;
  41941. /**
  41942. * Creates a new ViveController from a gamepad
  41943. * @param vrGamepad the gamepad that the controller should be created from
  41944. */
  41945. constructor(vrGamepad: any);
  41946. /**
  41947. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41948. * @param scene scene in which to add meshes
  41949. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41950. */
  41951. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41952. /**
  41953. * Fired when the left button on this controller is modified
  41954. */
  41955. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41956. /**
  41957. * Fired when the right button on this controller is modified
  41958. */
  41959. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41960. /**
  41961. * Fired when the menu button on this controller is modified
  41962. */
  41963. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41964. /**
  41965. * Called once for each button that changed state since the last frame
  41966. * Vive mapping:
  41967. * 0: touchpad
  41968. * 1: trigger
  41969. * 2: left AND right buttons
  41970. * 3: menu button
  41971. * @param buttonIdx Which button index changed
  41972. * @param state New state of the button
  41973. * @param changes Which properties on the state changed since last frame
  41974. */
  41975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41976. }
  41977. }
  41978. declare module BABYLON {
  41979. /**
  41980. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41981. */
  41982. export class WebXRControllerModelLoader {
  41983. /**
  41984. * Creates the WebXRControllerModelLoader
  41985. * @param input xr input that creates the controllers
  41986. */
  41987. constructor(input: WebXRInput);
  41988. }
  41989. }
  41990. declare module BABYLON {
  41991. /**
  41992. * Contains an array of blocks representing the octree
  41993. */
  41994. export interface IOctreeContainer<T> {
  41995. /**
  41996. * Blocks within the octree
  41997. */
  41998. blocks: Array<OctreeBlock<T>>;
  41999. }
  42000. /**
  42001. * Class used to store a cell in an octree
  42002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42003. */
  42004. export class OctreeBlock<T> {
  42005. /**
  42006. * Gets the content of the current block
  42007. */
  42008. entries: T[];
  42009. /**
  42010. * Gets the list of block children
  42011. */
  42012. blocks: Array<OctreeBlock<T>>;
  42013. private _depth;
  42014. private _maxDepth;
  42015. private _capacity;
  42016. private _minPoint;
  42017. private _maxPoint;
  42018. private _boundingVectors;
  42019. private _creationFunc;
  42020. /**
  42021. * Creates a new block
  42022. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42023. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42024. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42025. * @param depth defines the current depth of this block in the octree
  42026. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42027. * @param creationFunc defines a callback to call when an element is added to the block
  42028. */
  42029. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42030. /**
  42031. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42032. */
  42033. readonly capacity: number;
  42034. /**
  42035. * Gets the minimum vector (in world space) of the block's bounding box
  42036. */
  42037. readonly minPoint: Vector3;
  42038. /**
  42039. * Gets the maximum vector (in world space) of the block's bounding box
  42040. */
  42041. readonly maxPoint: Vector3;
  42042. /**
  42043. * Add a new element to this block
  42044. * @param entry defines the element to add
  42045. */
  42046. addEntry(entry: T): void;
  42047. /**
  42048. * Remove an element from this block
  42049. * @param entry defines the element to remove
  42050. */
  42051. removeEntry(entry: T): void;
  42052. /**
  42053. * Add an array of elements to this block
  42054. * @param entries defines the array of elements to add
  42055. */
  42056. addEntries(entries: T[]): void;
  42057. /**
  42058. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42059. * @param frustumPlanes defines the frustum planes to test
  42060. * @param selection defines the array to store current content if selection is positive
  42061. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42062. */
  42063. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42064. /**
  42065. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42066. * @param sphereCenter defines the bounding sphere center
  42067. * @param sphereRadius defines the bounding sphere radius
  42068. * @param selection defines the array to store current content if selection is positive
  42069. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42070. */
  42071. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42072. /**
  42073. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42074. * @param ray defines the ray to test with
  42075. * @param selection defines the array to store current content if selection is positive
  42076. */
  42077. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42078. /**
  42079. * Subdivide the content into child blocks (this block will then be empty)
  42080. */
  42081. createInnerBlocks(): void;
  42082. /**
  42083. * @hidden
  42084. */ private static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  42085. }
  42086. }
  42087. declare module BABYLON {
  42088. /**
  42089. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42090. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42091. */
  42092. export class Octree<T> {
  42093. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  42094. maxDepth: number;
  42095. /**
  42096. * Blocks within the octree containing objects
  42097. */
  42098. blocks: Array<OctreeBlock<T>>;
  42099. /**
  42100. * Content stored in the octree
  42101. */
  42102. dynamicContent: T[];
  42103. private _maxBlockCapacity;
  42104. private _selectionContent;
  42105. private _creationFunc;
  42106. /**
  42107. * Creates a octree
  42108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42109. * @param creationFunc function to be used to instatiate the octree
  42110. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42111. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  42112. */
  42113. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42114. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  42115. maxDepth?: number);
  42116. /**
  42117. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42118. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  42119. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  42120. * @param entries meshes to be added to the octree blocks
  42121. */
  42122. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42123. /**
  42124. * Adds a mesh to the octree
  42125. * @param entry Mesh to add to the octree
  42126. */
  42127. addMesh(entry: T): void;
  42128. /**
  42129. * Remove an element from the octree
  42130. * @param entry defines the element to remove
  42131. */
  42132. removeMesh(entry: T): void;
  42133. /**
  42134. * Selects an array of meshes within the frustum
  42135. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42136. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42137. * @returns array of meshes within the frustum
  42138. */
  42139. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42140. /**
  42141. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42142. * @param sphereCenter defines the bounding sphere center
  42143. * @param sphereRadius defines the bounding sphere radius
  42144. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42145. * @returns an array of objects that intersect the sphere
  42146. */
  42147. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42148. /**
  42149. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42150. * @param ray defines the ray to test with
  42151. * @returns array of intersected objects
  42152. */
  42153. intersectsRay(ray: Ray): SmartArray<T>;
  42154. /**
  42155. * Adds a mesh into the octree block if it intersects the block
  42156. */
  42157. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42158. /**
  42159. * Adds a submesh into the octree block if it intersects the block
  42160. */
  42161. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42162. }
  42163. }
  42164. declare module BABYLON {
  42165. interface Scene {
  42166. /**
  42167. * @hidden
  42168. * Backing Filed
  42169. */ private _selectionOctree: Octree<AbstractMesh>;
  42170. /**
  42171. * Gets the octree used to boost mesh selection (picking)
  42172. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42173. */
  42174. selectionOctree: Octree<AbstractMesh>;
  42175. /**
  42176. * Creates or updates the octree used to boost selection (picking)
  42177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42178. * @param maxCapacity defines the maximum capacity per leaf
  42179. * @param maxDepth defines the maximum depth of the octree
  42180. * @returns an octree of AbstractMesh
  42181. */
  42182. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42183. }
  42184. interface AbstractMesh {
  42185. /**
  42186. * @hidden
  42187. * Backing Field
  42188. */ private _submeshesOctree: Octree<SubMesh>;
  42189. /**
  42190. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42191. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42192. * @param maxCapacity defines the maximum size of each block (64 by default)
  42193. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42194. * @returns the new octree
  42195. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42197. */
  42198. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42199. }
  42200. /**
  42201. * Defines the octree scene component responsible to manage any octrees
  42202. * in a given scene.
  42203. */
  42204. export class OctreeSceneComponent {
  42205. /**
  42206. * The component name help to identify the component in the list of scene components.
  42207. */
  42208. readonly name: string;
  42209. /**
  42210. * The scene the component belongs to.
  42211. */
  42212. scene: Scene;
  42213. /**
  42214. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42215. */
  42216. readonly checksIsEnabled: boolean;
  42217. /**
  42218. * Creates a new instance of the component for the given scene
  42219. * @param scene Defines the scene to register the component in
  42220. */
  42221. constructor(scene: Scene);
  42222. /**
  42223. * Registers the component in a given scene
  42224. */
  42225. register(): void;
  42226. /**
  42227. * Return the list of active meshes
  42228. * @returns the list of active meshes
  42229. */
  42230. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42231. /**
  42232. * Return the list of active sub meshes
  42233. * @param mesh The mesh to get the candidates sub meshes from
  42234. * @returns the list of active sub meshes
  42235. */
  42236. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42237. private _tempRay;
  42238. /**
  42239. * Return the list of sub meshes intersecting with a given local ray
  42240. * @param mesh defines the mesh to find the submesh for
  42241. * @param localRay defines the ray in local space
  42242. * @returns the list of intersecting sub meshes
  42243. */
  42244. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42245. /**
  42246. * Return the list of sub meshes colliding with a collider
  42247. * @param mesh defines the mesh to find the submesh for
  42248. * @param collider defines the collider to evaluate the collision against
  42249. * @returns the list of colliding sub meshes
  42250. */
  42251. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42252. /**
  42253. * Rebuilds the elements related to this component in case of
  42254. * context lost for instance.
  42255. */
  42256. rebuild(): void;
  42257. /**
  42258. * Disposes the component and the associated ressources.
  42259. */
  42260. dispose(): void;
  42261. }
  42262. }
  42263. declare module BABYLON {
  42264. /**
  42265. * Renders a layer on top of an existing scene
  42266. */
  42267. export class UtilityLayerRenderer implements IDisposable {
  42268. /** the original scene that will be rendered on top of */
  42269. originalScene: Scene;
  42270. private _pointerCaptures;
  42271. private _lastPointerEvents;
  42272. private static _DefaultUtilityLayer;
  42273. private static _DefaultKeepDepthUtilityLayer;
  42274. private _sharedGizmoLight;
  42275. private _renderCamera;
  42276. /**
  42277. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42278. * @returns the camera that is used when rendering the utility layer
  42279. */
  42280. getRenderCamera(): Nullable<Camera>;
  42281. /**
  42282. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42283. * @param cam the camera that should be used when rendering the utility layer
  42284. */
  42285. setRenderCamera(cam: Nullable<Camera>): void;
  42286. /**
  42287. * @hidden
  42288. * Light which used by gizmos to get light shading
  42289. */ private _getSharedGizmoLight(): HemisphericLight;
  42290. /**
  42291. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42292. */
  42293. pickUtilitySceneFirst: boolean;
  42294. /**
  42295. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  42296. */
  42297. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42298. /**
  42299. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  42300. */
  42301. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42302. /**
  42303. * The scene that is rendered on top of the original scene
  42304. */
  42305. utilityLayerScene: Scene;
  42306. /**
  42307. * If the utility layer should automatically be rendered on top of existing scene
  42308. */
  42309. shouldRender: boolean;
  42310. /**
  42311. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42312. */
  42313. onlyCheckPointerDownEvents: boolean;
  42314. /**
  42315. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42316. */
  42317. processAllEvents: boolean;
  42318. /**
  42319. * Observable raised when the pointer move from the utility layer scene to the main scene
  42320. */
  42321. onPointerOutObservable: Observable<number>;
  42322. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42323. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42324. private _afterRenderObserver;
  42325. private _sceneDisposeObserver;
  42326. private _originalPointerObserver;
  42327. /**
  42328. * Instantiates a UtilityLayerRenderer
  42329. * @param originalScene the original scene that will be rendered on top of
  42330. * @param handleEvents boolean indicating if the utility layer should handle events
  42331. */
  42332. constructor(
  42333. /** the original scene that will be rendered on top of */
  42334. originalScene: Scene, handleEvents?: boolean);
  42335. private _notifyObservers;
  42336. /**
  42337. * Renders the utility layers scene on top of the original scene
  42338. */
  42339. render(): void;
  42340. /**
  42341. * Disposes of the renderer
  42342. */
  42343. dispose(): void;
  42344. private _updateCamera;
  42345. }
  42346. }
  42347. declare module BABYLON {
  42348. /**
  42349. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42350. */
  42351. export class Gizmo implements IDisposable {
  42352. /** The utility layer the gizmo will be added to */
  42353. gizmoLayer: UtilityLayerRenderer;
  42354. /**
  42355. * The root mesh of the gizmo
  42356. */ private _rootMesh: Mesh;
  42357. private _attachedMesh;
  42358. /**
  42359. * Ratio for the scale of the gizmo (Default: 1)
  42360. */
  42361. scaleRatio: number;
  42362. /**
  42363. * If a custom mesh has been set (Default: false)
  42364. */
  42365. protected _customMeshSet: boolean;
  42366. /**
  42367. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42368. * * When set, interactions will be enabled
  42369. */
  42370. attachedMesh: Nullable<AbstractMesh>;
  42371. /**
  42372. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42373. * @param mesh The mesh to replace the default mesh of the gizmo
  42374. */
  42375. setCustomMesh(mesh: Mesh): void;
  42376. /**
  42377. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42378. */
  42379. updateGizmoRotationToMatchAttachedMesh: boolean;
  42380. /**
  42381. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42382. */
  42383. updateGizmoPositionToMatchAttachedMesh: boolean;
  42384. /**
  42385. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42386. */
  42387. updateScale: boolean;
  42388. protected _interactionsEnabled: boolean;
  42389. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42390. private _beforeRenderObserver;
  42391. private _tempVector;
  42392. /**
  42393. * Creates a gizmo
  42394. * @param gizmoLayer The utility layer the gizmo will be added to
  42395. */
  42396. constructor(
  42397. /** The utility layer the gizmo will be added to */
  42398. gizmoLayer?: UtilityLayerRenderer);
  42399. /**
  42400. * Updates the gizmo to match the attached mesh's position/rotation
  42401. */
  42402. protected _update(): void;
  42403. /**
  42404. * Disposes of the gizmo
  42405. */
  42406. dispose(): void;
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /**
  42411. * Single plane drag gizmo
  42412. */
  42413. export class PlaneDragGizmo extends Gizmo {
  42414. /**
  42415. * Drag behavior responsible for the gizmos dragging interactions
  42416. */
  42417. dragBehavior: PointerDragBehavior;
  42418. private _pointerObserver;
  42419. /**
  42420. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42421. */
  42422. snapDistance: number;
  42423. /**
  42424. * Event that fires each time the gizmo snaps to a new location.
  42425. * * snapDistance is the the change in distance
  42426. */
  42427. onSnapObservable: Observable<{
  42428. snapDistance: number;
  42429. }>;
  42430. private _plane;
  42431. private _coloredMaterial;
  42432. private _hoverMaterial;
  42433. private _isEnabled;
  42434. private _parent;
  42435. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42436. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42437. /**
  42438. * Creates a PlaneDragGizmo
  42439. * @param gizmoLayer The utility layer the gizmo will be added to
  42440. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42441. * @param color The color of the gizmo
  42442. */
  42443. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42444. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42445. /**
  42446. * If the gizmo is enabled
  42447. */
  42448. isEnabled: boolean;
  42449. /**
  42450. * Disposes of the gizmo
  42451. */
  42452. dispose(): void;
  42453. }
  42454. }
  42455. declare module BABYLON {
  42456. /**
  42457. * Gizmo that enables dragging a mesh along 3 axis
  42458. */
  42459. export class PositionGizmo extends Gizmo {
  42460. /**
  42461. * Internal gizmo used for interactions on the x axis
  42462. */
  42463. xGizmo: AxisDragGizmo;
  42464. /**
  42465. * Internal gizmo used for interactions on the y axis
  42466. */
  42467. yGizmo: AxisDragGizmo;
  42468. /**
  42469. * Internal gizmo used for interactions on the z axis
  42470. */
  42471. zGizmo: AxisDragGizmo;
  42472. /**
  42473. * Internal gizmo used for interactions on the yz plane
  42474. */
  42475. xPlaneGizmo: PlaneDragGizmo;
  42476. /**
  42477. * Internal gizmo used for interactions on the xz plane
  42478. */
  42479. yPlaneGizmo: PlaneDragGizmo;
  42480. /**
  42481. * Internal gizmo used for interactions on the xy plane
  42482. */
  42483. zPlaneGizmo: PlaneDragGizmo;
  42484. /**
  42485. * private variables
  42486. */
  42487. private _meshAttached;
  42488. private _updateGizmoRotationToMatchAttachedMesh;
  42489. private _snapDistance;
  42490. private _scaleRatio;
  42491. /** Fires an event when any of it's sub gizmos are dragged */
  42492. onDragStartObservable: Observable<unknown>;
  42493. /** Fires an event when any of it's sub gizmos are released from dragging */
  42494. onDragEndObservable: Observable<unknown>;
  42495. /**
  42496. * If set to true, planar drag is enabled
  42497. */
  42498. private _planarGizmoEnabled;
  42499. attachedMesh: Nullable<AbstractMesh>;
  42500. /**
  42501. * Creates a PositionGizmo
  42502. * @param gizmoLayer The utility layer the gizmo will be added to
  42503. */
  42504. constructor(gizmoLayer?: UtilityLayerRenderer);
  42505. /**
  42506. * If the planar drag gizmo is enabled
  42507. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42508. */
  42509. planarGizmoEnabled: boolean;
  42510. updateGizmoRotationToMatchAttachedMesh: boolean;
  42511. /**
  42512. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42513. */
  42514. snapDistance: number;
  42515. /**
  42516. * Ratio for the scale of the gizmo (Default: 1)
  42517. */
  42518. scaleRatio: number;
  42519. /**
  42520. * Disposes of the gizmo
  42521. */
  42522. dispose(): void;
  42523. /**
  42524. * CustomMeshes are not supported by this gizmo
  42525. * @param mesh The mesh to replace the default mesh of the gizmo
  42526. */
  42527. setCustomMesh(mesh: Mesh): void;
  42528. }
  42529. }
  42530. declare module BABYLON {
  42531. /**
  42532. * Single axis drag gizmo
  42533. */
  42534. export class AxisDragGizmo extends Gizmo {
  42535. /**
  42536. * Drag behavior responsible for the gizmos dragging interactions
  42537. */
  42538. dragBehavior: PointerDragBehavior;
  42539. private _pointerObserver;
  42540. /**
  42541. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42542. */
  42543. snapDistance: number;
  42544. /**
  42545. * Event that fires each time the gizmo snaps to a new location.
  42546. * * snapDistance is the the change in distance
  42547. */
  42548. onSnapObservable: Observable<{
  42549. snapDistance: number;
  42550. }>;
  42551. private _isEnabled;
  42552. private _parent;
  42553. private _arrow;
  42554. private _coloredMaterial;
  42555. private _hoverMaterial;
  42556. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42557. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42558. /**
  42559. * Creates an AxisDragGizmo
  42560. * @param gizmoLayer The utility layer the gizmo will be added to
  42561. * @param dragAxis The axis which the gizmo will be able to drag on
  42562. * @param color The color of the gizmo
  42563. */
  42564. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42565. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42566. /**
  42567. * If the gizmo is enabled
  42568. */
  42569. isEnabled: boolean;
  42570. /**
  42571. * Disposes of the gizmo
  42572. */
  42573. dispose(): void;
  42574. }
  42575. }
  42576. declare module BABYLON.Debug {
  42577. /**
  42578. * The Axes viewer will show 3 axes in a specific point in space
  42579. */
  42580. export class AxesViewer {
  42581. private _xAxis;
  42582. private _yAxis;
  42583. private _zAxis;
  42584. private _scaleLinesFactor;
  42585. private _instanced;
  42586. /**
  42587. * Gets the hosting scene
  42588. */
  42589. scene: Scene;
  42590. /**
  42591. * Gets or sets a number used to scale line length
  42592. */
  42593. scaleLines: number;
  42594. /** Gets the node hierarchy used to render x-axis */
  42595. readonly xAxis: TransformNode;
  42596. /** Gets the node hierarchy used to render y-axis */
  42597. readonly yAxis: TransformNode;
  42598. /** Gets the node hierarchy used to render z-axis */
  42599. readonly zAxis: TransformNode;
  42600. /**
  42601. * Creates a new AxesViewer
  42602. * @param scene defines the hosting scene
  42603. * @param scaleLines defines a number used to scale line length (1 by default)
  42604. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42605. * @param xAxis defines the node hierarchy used to render the x-axis
  42606. * @param yAxis defines the node hierarchy used to render the y-axis
  42607. * @param zAxis defines the node hierarchy used to render the z-axis
  42608. */
  42609. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42610. /**
  42611. * Force the viewer to update
  42612. * @param position defines the position of the viewer
  42613. * @param xaxis defines the x axis of the viewer
  42614. * @param yaxis defines the y axis of the viewer
  42615. * @param zaxis defines the z axis of the viewer
  42616. */
  42617. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42618. /**
  42619. * Creates an instance of this axes viewer.
  42620. * @returns a new axes viewer with instanced meshes
  42621. */
  42622. createInstance(): AxesViewer;
  42623. /** Releases resources */
  42624. dispose(): void;
  42625. private static _SetRenderingGroupId;
  42626. }
  42627. }
  42628. declare module BABYLON.Debug {
  42629. /**
  42630. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42631. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42632. */
  42633. export class BoneAxesViewer extends AxesViewer {
  42634. /**
  42635. * Gets or sets the target mesh where to display the axes viewer
  42636. */
  42637. mesh: Nullable<Mesh>;
  42638. /**
  42639. * Gets or sets the target bone where to display the axes viewer
  42640. */
  42641. bone: Nullable<Bone>;
  42642. /** Gets current position */
  42643. pos: Vector3;
  42644. /** Gets direction of X axis */
  42645. xaxis: Vector3;
  42646. /** Gets direction of Y axis */
  42647. yaxis: Vector3;
  42648. /** Gets direction of Z axis */
  42649. zaxis: Vector3;
  42650. /**
  42651. * Creates a new BoneAxesViewer
  42652. * @param scene defines the hosting scene
  42653. * @param bone defines the target bone
  42654. * @param mesh defines the target mesh
  42655. * @param scaleLines defines a scaling factor for line length (1 by default)
  42656. */
  42657. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42658. /**
  42659. * Force the viewer to update
  42660. */
  42661. update(): void;
  42662. /** Releases resources */
  42663. dispose(): void;
  42664. }
  42665. }
  42666. declare module BABYLON {
  42667. /**
  42668. * Interface used to define scene explorer extensibility option
  42669. */
  42670. export interface IExplorerExtensibilityOption {
  42671. /**
  42672. * Define the option label
  42673. */
  42674. label: string;
  42675. /**
  42676. * Defines the action to execute on click
  42677. */
  42678. action: (entity: any) => void;
  42679. }
  42680. /**
  42681. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42682. */
  42683. export interface IExplorerExtensibilityGroup {
  42684. /**
  42685. * Defines a predicate to test if a given type mut be extended
  42686. */
  42687. predicate: (entity: any) => boolean;
  42688. /**
  42689. * Gets the list of options added to a type
  42690. */
  42691. entries: IExplorerExtensibilityOption[];
  42692. }
  42693. /**
  42694. * Interface used to define the options to use to create the Inspector
  42695. */
  42696. export interface IInspectorOptions {
  42697. /**
  42698. * Display in overlay mode (default: false)
  42699. */
  42700. overlay?: boolean;
  42701. /**
  42702. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42703. */
  42704. globalRoot?: HTMLElement;
  42705. /**
  42706. * Display the Scene explorer
  42707. */
  42708. showExplorer?: boolean;
  42709. /**
  42710. * Display the property inspector
  42711. */
  42712. showInspector?: boolean;
  42713. /**
  42714. * Display in embed mode (both panes on the right)
  42715. */
  42716. embedMode?: boolean;
  42717. /**
  42718. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42719. */
  42720. handleResize?: boolean;
  42721. /**
  42722. * Allow the panes to popup (default: true)
  42723. */
  42724. enablePopup?: boolean;
  42725. /**
  42726. * Allow the panes to be closed by users (default: true)
  42727. */
  42728. enableClose?: boolean;
  42729. /**
  42730. * Optional list of extensibility entries
  42731. */
  42732. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42733. /**
  42734. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42735. */
  42736. inspectorURL?: string;
  42737. }
  42738. interface Scene {
  42739. /**
  42740. * @hidden
  42741. * Backing field
  42742. */ private _debugLayer: DebugLayer;
  42743. /**
  42744. * Gets the debug layer (aka Inspector) associated with the scene
  42745. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42746. */
  42747. debugLayer: DebugLayer;
  42748. }
  42749. /**
  42750. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42751. * what is happening in your scene
  42752. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42753. */
  42754. export class DebugLayer {
  42755. /**
  42756. * Define the url to get the inspector script from.
  42757. * By default it uses the babylonjs CDN.
  42758. * @ignoreNaming
  42759. */
  42760. static InspectorURL: string;
  42761. private _scene;
  42762. private BJSINSPECTOR;
  42763. private _onPropertyChangedObservable?;
  42764. /**
  42765. * Observable triggered when a property is changed through the inspector.
  42766. */
  42767. readonly onPropertyChangedObservable: any;
  42768. /**
  42769. * Instantiates a new debug layer.
  42770. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42771. * what is happening in your scene
  42772. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42773. * @param scene Defines the scene to inspect
  42774. */
  42775. constructor(scene: Scene);
  42776. /** Creates the inspector window. */
  42777. private _createInspector;
  42778. /**
  42779. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42780. * @param entity defines the entity to select
  42781. * @param lineContainerTitle defines the specific block to highlight
  42782. */
  42783. select(entity: any, lineContainerTitle?: string): void;
  42784. /** Get the inspector from bundle or global */
  42785. private _getGlobalInspector;
  42786. /**
  42787. * Get if the inspector is visible or not.
  42788. * @returns true if visible otherwise, false
  42789. */
  42790. isVisible(): boolean;
  42791. /**
  42792. * Hide the inspector and close its window.
  42793. */
  42794. hide(): void;
  42795. /**
  42796. * Launch the debugLayer.
  42797. * @param config Define the configuration of the inspector
  42798. * @return a promise fulfilled when the debug layer is visible
  42799. */
  42800. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42801. }
  42802. }
  42803. declare module BABYLON {
  42804. /**
  42805. * Class containing static functions to help procedurally build meshes
  42806. */
  42807. export class BoxBuilder {
  42808. /**
  42809. * Creates a box mesh
  42810. * * The parameter `size` sets the size (float) of each box side (default 1)
  42811. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42812. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  42813. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42817. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42818. * @param name defines the name of the mesh
  42819. * @param options defines the options used to create the mesh
  42820. * @param scene defines the hosting scene
  42821. * @returns the box mesh
  42822. */
  42823. static CreateBox(name: string, options: {
  42824. size?: number;
  42825. width?: number;
  42826. height?: number;
  42827. depth?: number;
  42828. faceUV?: Vector4[];
  42829. faceColors?: Color4[];
  42830. sideOrientation?: number;
  42831. frontUVs?: Vector4;
  42832. backUVs?: Vector4;
  42833. wrap?: boolean;
  42834. topBaseAt?: number;
  42835. bottomBaseAt?: number;
  42836. updatable?: boolean;
  42837. }, scene?: Nullable<Scene>): Mesh;
  42838. }
  42839. }
  42840. declare module BABYLON {
  42841. /**
  42842. * Class containing static functions to help procedurally build meshes
  42843. */
  42844. export class SphereBuilder {
  42845. /**
  42846. * Creates a sphere mesh
  42847. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42848. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  42849. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42850. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  42851. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  42852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42855. * @param name defines the name of the mesh
  42856. * @param options defines the options used to create the mesh
  42857. * @param scene defines the hosting scene
  42858. * @returns the sphere mesh
  42859. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42860. */
  42861. static CreateSphere(name: string, options: {
  42862. segments?: number;
  42863. diameter?: number;
  42864. diameterX?: number;
  42865. diameterY?: number;
  42866. diameterZ?: number;
  42867. arc?: number;
  42868. slice?: number;
  42869. sideOrientation?: number;
  42870. frontUVs?: Vector4;
  42871. backUVs?: Vector4;
  42872. updatable?: boolean;
  42873. }, scene?: Nullable<Scene>): Mesh;
  42874. }
  42875. }
  42876. declare module BABYLON.Debug {
  42877. /**
  42878. * Used to show the physics impostor around the specific mesh
  42879. */
  42880. export class PhysicsViewer {
  42881. /** @hidden */
  42882. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42883. /** @hidden */
  42884. protected _meshes: Array<Nullable<AbstractMesh>>;
  42885. /** @hidden */
  42886. protected _scene: Nullable<Scene>;
  42887. /** @hidden */
  42888. protected _numMeshes: number;
  42889. /** @hidden */
  42890. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42891. private _renderFunction;
  42892. private _utilityLayer;
  42893. private _debugBoxMesh;
  42894. private _debugSphereMesh;
  42895. private _debugCylinderMesh;
  42896. private _debugMaterial;
  42897. private _debugMeshMeshes;
  42898. /**
  42899. * Creates a new PhysicsViewer
  42900. * @param scene defines the hosting scene
  42901. */
  42902. constructor(scene: Scene);
  42903. /** @hidden */
  42904. protected _updateDebugMeshes(): void;
  42905. /**
  42906. * Renders a specified physic impostor
  42907. * @param impostor defines the impostor to render
  42908. * @param targetMesh defines the mesh represented by the impostor
  42909. * @returns the new debug mesh used to render the impostor
  42910. */
  42911. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42912. /**
  42913. * Hides a specified physic impostor
  42914. * @param impostor defines the impostor to hide
  42915. */
  42916. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42917. private _getDebugMaterial;
  42918. private _getDebugBoxMesh;
  42919. private _getDebugSphereMesh;
  42920. private _getDebugCylinderMesh;
  42921. private _getDebugMeshMesh;
  42922. private _getDebugMesh;
  42923. /** Releases all resources */
  42924. dispose(): void;
  42925. }
  42926. }
  42927. declare module BABYLON {
  42928. /**
  42929. * Class containing static functions to help procedurally build meshes
  42930. */
  42931. export class LinesBuilder {
  42932. /**
  42933. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42934. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  42935. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42936. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42937. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42938. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42939. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42940. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  42941. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42944. * @param name defines the name of the new line system
  42945. * @param options defines the options used to create the line system
  42946. * @param scene defines the hosting scene
  42947. * @returns a new line system mesh
  42948. */
  42949. static CreateLineSystem(name: string, options: {
  42950. lines: Vector3[][];
  42951. updatable?: boolean;
  42952. instance?: Nullable<LinesMesh>;
  42953. colors?: Nullable<Color4[][]>;
  42954. useVertexAlpha?: boolean;
  42955. }, scene: Nullable<Scene>): LinesMesh;
  42956. /**
  42957. * Creates a line mesh
  42958. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  42959. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42960. * * The parameter `points` is an array successive Vector3
  42961. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  42962. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42963. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42964. * * When updating an instance, remember that only point positions can change, not the number of points
  42965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42967. * @param name defines the name of the new line system
  42968. * @param options defines the options used to create the line system
  42969. * @param scene defines the hosting scene
  42970. * @returns a new line mesh
  42971. */
  42972. static CreateLines(name: string, options: {
  42973. points: Vector3[];
  42974. updatable?: boolean;
  42975. instance?: Nullable<LinesMesh>;
  42976. colors?: Color4[];
  42977. useVertexAlpha?: boolean;
  42978. }, scene?: Nullable<Scene>): LinesMesh;
  42979. /**
  42980. * Creates a dashed line mesh
  42981. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  42982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42983. * * The parameter `points` is an array successive Vector3
  42984. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42985. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42986. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42987. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  42988. * * When updating an instance, remember that only point positions can change, not the number of points
  42989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42990. * @param name defines the name of the mesh
  42991. * @param options defines the options used to create the mesh
  42992. * @param scene defines the hosting scene
  42993. * @returns the dashed line mesh
  42994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42995. */
  42996. static CreateDashedLines(name: string, options: {
  42997. points: Vector3[];
  42998. dashSize?: number;
  42999. gapSize?: number;
  43000. dashNb?: number;
  43001. updatable?: boolean;
  43002. instance?: LinesMesh;
  43003. }, scene?: Nullable<Scene>): LinesMesh;
  43004. }
  43005. }
  43006. declare module BABYLON {
  43007. /**
  43008. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43009. * in order to better appreciate the issue one might have.
  43010. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43011. */
  43012. export class RayHelper {
  43013. /**
  43014. * Defines the ray we are currently tryin to visualize.
  43015. */
  43016. ray: Nullable<Ray>;
  43017. private _renderPoints;
  43018. private _renderLine;
  43019. private _renderFunction;
  43020. private _scene;
  43021. private _updateToMeshFunction;
  43022. private _attachedToMesh;
  43023. private _meshSpaceDirection;
  43024. private _meshSpaceOrigin;
  43025. /**
  43026. * Helper function to create a colored helper in a scene in one line.
  43027. * @param ray Defines the ray we are currently tryin to visualize
  43028. * @param scene Defines the scene the ray is used in
  43029. * @param color Defines the color we want to see the ray in
  43030. * @returns The newly created ray helper.
  43031. */
  43032. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43033. /**
  43034. * Instantiate a new ray helper.
  43035. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43036. * in order to better appreciate the issue one might have.
  43037. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43038. * @param ray Defines the ray we are currently tryin to visualize
  43039. */
  43040. constructor(ray: Ray);
  43041. /**
  43042. * Shows the ray we are willing to debug.
  43043. * @param scene Defines the scene the ray needs to be rendered in
  43044. * @param color Defines the color the ray needs to be rendered in
  43045. */
  43046. show(scene: Scene, color?: Color3): void;
  43047. /**
  43048. * Hides the ray we are debugging.
  43049. */
  43050. hide(): void;
  43051. private _render;
  43052. /**
  43053. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43054. * @param mesh Defines the mesh we want the helper attached to
  43055. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43056. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43057. * @param length Defines the length of the ray
  43058. */
  43059. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43060. /**
  43061. * Detach the ray helper from the mesh it has previously been attached to.
  43062. */
  43063. detachFromMesh(): void;
  43064. private _updateToMesh;
  43065. /**
  43066. * Dispose the helper and release its associated resources.
  43067. */
  43068. dispose(): void;
  43069. }
  43070. }
  43071. declare module BABYLON.Debug {
  43072. /**
  43073. * Class used to render a debug view of a given skeleton
  43074. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43075. */
  43076. export class SkeletonViewer {
  43077. /** defines the skeleton to render */
  43078. skeleton: Skeleton;
  43079. /** defines the mesh attached to the skeleton */
  43080. mesh: AbstractMesh;
  43081. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43082. autoUpdateBonesMatrices: boolean;
  43083. /** defines the rendering group id to use with the viewer */
  43084. renderingGroupId: number;
  43085. /** Gets or sets the color used to render the skeleton */
  43086. color: Color3;
  43087. private _scene;
  43088. private _debugLines;
  43089. private _debugMesh;
  43090. private _isEnabled;
  43091. private _renderFunction;
  43092. private _utilityLayer;
  43093. /**
  43094. * Returns the mesh used to render the bones
  43095. */
  43096. readonly debugMesh: Nullable<LinesMesh>;
  43097. /**
  43098. * Creates a new SkeletonViewer
  43099. * @param skeleton defines the skeleton to render
  43100. * @param mesh defines the mesh attached to the skeleton
  43101. * @param scene defines the hosting scene
  43102. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43103. * @param renderingGroupId defines the rendering group id to use with the viewer
  43104. */
  43105. constructor(
  43106. /** defines the skeleton to render */
  43107. skeleton: Skeleton,
  43108. /** defines the mesh attached to the skeleton */
  43109. mesh: AbstractMesh, scene: Scene,
  43110. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43111. autoUpdateBonesMatrices?: boolean,
  43112. /** defines the rendering group id to use with the viewer */
  43113. renderingGroupId?: number);
  43114. /** Gets or sets a boolean indicating if the viewer is enabled */
  43115. isEnabled: boolean;
  43116. private _getBonePosition;
  43117. private _getLinesForBonesWithLength;
  43118. private _getLinesForBonesNoLength;
  43119. /** Update the viewer to sync with current skeleton state */
  43120. update(): void;
  43121. /** Release associated resources */
  43122. dispose(): void;
  43123. }
  43124. }
  43125. declare module BABYLON {
  43126. /**
  43127. * Options to create the null engine
  43128. */
  43129. export class NullEngineOptions {
  43130. /**
  43131. * Render width (Default: 512)
  43132. */
  43133. renderWidth: number;
  43134. /**
  43135. * Render height (Default: 256)
  43136. */
  43137. renderHeight: number;
  43138. /**
  43139. * Texture size (Default: 512)
  43140. */
  43141. textureSize: number;
  43142. /**
  43143. * If delta time between frames should be constant
  43144. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43145. */
  43146. deterministicLockstep: boolean;
  43147. /**
  43148. * Maximum about of steps between frames (Default: 4)
  43149. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43150. */
  43151. lockstepMaxSteps: number;
  43152. }
  43153. /**
  43154. * The null engine class provides support for headless version of babylon.js.
  43155. * This can be used in server side scenario or for testing purposes
  43156. */
  43157. export class NullEngine extends Engine {
  43158. private _options;
  43159. /**
  43160. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43161. */
  43162. isDeterministicLockStep(): boolean;
  43163. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43164. getLockstepMaxSteps(): number;
  43165. /**
  43166. * Sets hardware scaling, used to save performance if needed
  43167. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43168. */
  43169. getHardwareScalingLevel(): number;
  43170. constructor(options?: NullEngineOptions);
  43171. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43172. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43173. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43174. getRenderWidth(useScreen?: boolean): number;
  43175. getRenderHeight(useScreen?: boolean): number;
  43176. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43177. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43178. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43179. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43180. bindSamplers(effect: Effect): void;
  43181. enableEffect(effect: Effect): void;
  43182. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43183. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43184. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43185. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43186. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43187. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43188. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43189. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43190. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43191. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43192. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43193. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43194. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43195. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43196. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43197. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43198. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43199. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43200. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43201. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43202. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43203. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43204. bindBuffers(vertexBuffers: {
  43205. [key: string]: VertexBuffer;
  43206. }, indexBuffer: DataBuffer, effect: Effect): void;
  43207. wipeCaches(bruteForce?: boolean): void;
  43208. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43209. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43210. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43211. /** @hidden */ private _createTexture(): WebGLTexture;
  43212. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  43213. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  43214. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43215. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43216. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43217. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43218. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43219. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43220. areAllEffectsReady(): boolean;
  43221. /**
  43222. * @hidden
  43223. * Get the current error code of the webGL context
  43224. * @returns the error code
  43225. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43226. */
  43227. getError(): number;
  43228. /** @hidden */ private _getUnpackAlignement(): number;
  43229. /** @hidden */ private _unpackFlipY(value: boolean): void;
  43230. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43231. /**
  43232. * Updates a dynamic vertex buffer.
  43233. * @param vertexBuffer the vertex buffer to update
  43234. * @param data the data used to update the vertex buffer
  43235. * @param byteOffset the byte offset of the data (optional)
  43236. * @param byteLength the byte length of the data (optional)
  43237. */
  43238. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43239. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43240. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43241. releaseEffects(): void;
  43242. displayLoadingUI(): void;
  43243. hideLoadingUI(): void;
  43244. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43245. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43246. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43247. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43248. }
  43249. }
  43250. declare module BABYLON {
  43251. /** @hidden */
  43252. export class _OcclusionDataStorage {
  43253. /** @hidden */
  43254. occlusionInternalRetryCounter: number;
  43255. /** @hidden */
  43256. isOcclusionQueryInProgress: boolean;
  43257. /** @hidden */
  43258. isOccluded: boolean;
  43259. /** @hidden */
  43260. occlusionRetryCount: number;
  43261. /** @hidden */
  43262. occlusionType: number;
  43263. /** @hidden */
  43264. occlusionQueryAlgorithmType: number;
  43265. }
  43266. interface Engine {
  43267. /**
  43268. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43269. * @return the new query
  43270. */
  43271. createQuery(): WebGLQuery;
  43272. /**
  43273. * Delete and release a webGL query
  43274. * @param query defines the query to delete
  43275. * @return the current engine
  43276. */
  43277. deleteQuery(query: WebGLQuery): Engine;
  43278. /**
  43279. * Check if a given query has resolved and got its value
  43280. * @param query defines the query to check
  43281. * @returns true if the query got its value
  43282. */
  43283. isQueryResultAvailable(query: WebGLQuery): boolean;
  43284. /**
  43285. * Gets the value of a given query
  43286. * @param query defines the query to check
  43287. * @returns the value of the query
  43288. */
  43289. getQueryResult(query: WebGLQuery): number;
  43290. /**
  43291. * Initiates an occlusion query
  43292. * @param algorithmType defines the algorithm to use
  43293. * @param query defines the query to use
  43294. * @returns the current engine
  43295. * @see http://doc.babylonjs.com/features/occlusionquery
  43296. */
  43297. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43298. /**
  43299. * Ends an occlusion query
  43300. * @see http://doc.babylonjs.com/features/occlusionquery
  43301. * @param algorithmType defines the algorithm to use
  43302. * @returns the current engine
  43303. */
  43304. endOcclusionQuery(algorithmType: number): Engine;
  43305. /**
  43306. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43307. * Please note that only one query can be issued at a time
  43308. * @returns a time token used to track the time span
  43309. */
  43310. startTimeQuery(): Nullable<_TimeToken>;
  43311. /**
  43312. * Ends a time query
  43313. * @param token defines the token used to measure the time span
  43314. * @returns the time spent (in ns)
  43315. */
  43316. endTimeQuery(token: _TimeToken): int;
  43317. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  43318. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  43319. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  43320. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  43321. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  43322. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  43323. }
  43324. interface AbstractMesh {
  43325. /**
  43326. * Backing filed
  43327. * @hidden
  43328. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43329. /**
  43330. * Access property
  43331. * @hidden
  43332. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43333. /**
  43334. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  43335. * The default value is -1 which means don't break the query and wait till the result
  43336. * @see http://doc.babylonjs.com/features/occlusionquery
  43337. */
  43338. occlusionRetryCount: number;
  43339. /**
  43340. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  43341. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43342. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43343. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  43344. * @see http://doc.babylonjs.com/features/occlusionquery
  43345. */
  43346. occlusionType: number;
  43347. /**
  43348. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43349. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43350. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  43351. * @see http://doc.babylonjs.com/features/occlusionquery
  43352. */
  43353. occlusionQueryAlgorithmType: number;
  43354. /**
  43355. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  43356. * @see http://doc.babylonjs.com/features/occlusionquery
  43357. */
  43358. isOccluded: boolean;
  43359. /**
  43360. * Flag to check the progress status of the query
  43361. * @see http://doc.babylonjs.com/features/occlusionquery
  43362. */
  43363. isOcclusionQueryInProgress: boolean;
  43364. }
  43365. }
  43366. declare module BABYLON {
  43367. /** @hidden */
  43368. export var _forceTransformFeedbackToBundle: boolean;
  43369. interface Engine {
  43370. /**
  43371. * Creates a webGL transform feedback object
  43372. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43373. * @returns the webGL transform feedback object
  43374. */
  43375. createTransformFeedback(): WebGLTransformFeedback;
  43376. /**
  43377. * Delete a webGL transform feedback object
  43378. * @param value defines the webGL transform feedback object to delete
  43379. */
  43380. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43381. /**
  43382. * Bind a webGL transform feedback object to the webgl context
  43383. * @param value defines the webGL transform feedback object to bind
  43384. */
  43385. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43386. /**
  43387. * Begins a transform feedback operation
  43388. * @param usePoints defines if points or triangles must be used
  43389. */
  43390. beginTransformFeedback(usePoints: boolean): void;
  43391. /**
  43392. * Ends a transform feedback operation
  43393. */
  43394. endTransformFeedback(): void;
  43395. /**
  43396. * Specify the varyings to use with transform feedback
  43397. * @param program defines the associated webGL program
  43398. * @param value defines the list of strings representing the varying names
  43399. */
  43400. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43401. /**
  43402. * Bind a webGL buffer for a transform feedback operation
  43403. * @param value defines the webGL buffer to bind
  43404. */
  43405. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43406. }
  43407. }
  43408. declare module BABYLON {
  43409. /**
  43410. * Creation options of the multi render target texture.
  43411. */
  43412. export interface IMultiRenderTargetOptions {
  43413. /**
  43414. * Define if the texture needs to create mip maps after render.
  43415. */
  43416. generateMipMaps?: boolean;
  43417. /**
  43418. * Define the types of all the draw buffers we want to create
  43419. */
  43420. types?: number[];
  43421. /**
  43422. * Define the sampling modes of all the draw buffers we want to create
  43423. */
  43424. samplingModes?: number[];
  43425. /**
  43426. * Define if a depth buffer is required
  43427. */
  43428. generateDepthBuffer?: boolean;
  43429. /**
  43430. * Define if a stencil buffer is required
  43431. */
  43432. generateStencilBuffer?: boolean;
  43433. /**
  43434. * Define if a depth texture is required instead of a depth buffer
  43435. */
  43436. generateDepthTexture?: boolean;
  43437. /**
  43438. * Define the number of desired draw buffers
  43439. */
  43440. textureCount?: number;
  43441. /**
  43442. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43443. */
  43444. doNotChangeAspectRatio?: boolean;
  43445. /**
  43446. * Define the default type of the buffers we are creating
  43447. */
  43448. defaultType?: number;
  43449. }
  43450. /**
  43451. * A multi render target, like a render target provides the ability to render to a texture.
  43452. * Unlike the render target, it can render to several draw buffers in one draw.
  43453. * This is specially interesting in deferred rendering or for any effects requiring more than
  43454. * just one color from a single pass.
  43455. */
  43456. export class MultiRenderTarget extends RenderTargetTexture {
  43457. private _internalTextures;
  43458. private _textures;
  43459. private _multiRenderTargetOptions;
  43460. /**
  43461. * Get if draw buffers are currently supported by the used hardware and browser.
  43462. */
  43463. readonly isSupported: boolean;
  43464. /**
  43465. * Get the list of textures generated by the multi render target.
  43466. */
  43467. readonly textures: Texture[];
  43468. /**
  43469. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43470. */
  43471. readonly depthTexture: Texture;
  43472. /**
  43473. * Set the wrapping mode on U of all the textures we are rendering to.
  43474. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43475. */
  43476. wrapU: number;
  43477. /**
  43478. * Set the wrapping mode on V of all the textures we are rendering to.
  43479. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43480. */
  43481. wrapV: number;
  43482. /**
  43483. * Instantiate a new multi render target texture.
  43484. * A multi render target, like a render target provides the ability to render to a texture.
  43485. * Unlike the render target, it can render to several draw buffers in one draw.
  43486. * This is specially interesting in deferred rendering or for any effects requiring more than
  43487. * just one color from a single pass.
  43488. * @param name Define the name of the texture
  43489. * @param size Define the size of the buffers to render to
  43490. * @param count Define the number of target we are rendering into
  43491. * @param scene Define the scene the texture belongs to
  43492. * @param options Define the options used to create the multi render target
  43493. */
  43494. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43495. /** @hidden */ private _rebuild(): void;
  43496. private _createInternalTextures;
  43497. private _createTextures;
  43498. /**
  43499. * Define the number of samples used if MSAA is enabled.
  43500. */
  43501. samples: number;
  43502. /**
  43503. * Resize all the textures in the multi render target.
  43504. * Be carrefull as it will recreate all the data in the new texture.
  43505. * @param size Define the new size
  43506. */
  43507. resize(size: any): void;
  43508. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43509. /**
  43510. * Dispose the render targets and their associated resources
  43511. */
  43512. dispose(): void;
  43513. /**
  43514. * Release all the underlying texture used as draw buffers.
  43515. */
  43516. releaseInternalTextures(): void;
  43517. }
  43518. }
  43519. declare module BABYLON {
  43520. interface Engine {
  43521. /**
  43522. * Unbind a list of render target textures from the webGL context
  43523. * This is used only when drawBuffer extension or webGL2 are active
  43524. * @param textures defines the render target textures to unbind
  43525. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43526. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43527. */
  43528. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43529. /**
  43530. * Create a multi render target texture
  43531. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43532. * @param size defines the size of the texture
  43533. * @param options defines the creation options
  43534. * @returns the cube texture as an InternalTexture
  43535. */
  43536. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43537. /**
  43538. * Update the sample count for a given multiple render target texture
  43539. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43540. * @param textures defines the textures to update
  43541. * @param samples defines the sample count to set
  43542. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43543. */
  43544. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43545. }
  43546. }
  43547. declare module BABYLON {
  43548. /** @hidden */
  43549. export class WebGPUConstants {
  43550. static readonly GPUCullMode_none: GPUCullMode;
  43551. static readonly GPUCullMode_front: GPUCullMode;
  43552. static readonly GPUCullMode_back: GPUCullMode;
  43553. static readonly GPUFrontFace_ccw: GPUFrontFace;
  43554. static readonly GPUFrontFace_cw: GPUFrontFace;
  43555. static readonly GPUIndexFormat_uint16: GPUIndexFormat;
  43556. static readonly GPUIndexFormat_uint32: GPUIndexFormat;
  43557. static readonly GPULoadOp_load: GPULoadOp;
  43558. static readonly GPUStoreOp_store: GPUStoreOp;
  43559. static readonly GPUStoreOp_clear: GPUStoreOp;
  43560. static readonly GPUPrimitiveTopology_pointList: GPUPrimitiveTopology;
  43561. static readonly GPUPrimitiveTopology_lineList: GPUPrimitiveTopology;
  43562. static readonly GPUPrimitiveTopology_lineStrip: GPUPrimitiveTopology;
  43563. static readonly GPUPrimitiveTopology_triangleList: GPUPrimitiveTopology;
  43564. static readonly GPUPrimitiveTopology_triangleStrip: GPUPrimitiveTopology;
  43565. static readonly GPUTextureDimension_1d: GPUTextureDimension;
  43566. static readonly GPUTextureDimension_2d: GPUTextureDimension;
  43567. static readonly GPUTextureDimension_3d: GPUTextureDimension;
  43568. static readonly GPUTextureFormat_r8unorm: GPUTextureFormat;
  43569. static readonly GPUTextureFormat_r8snorm: GPUTextureFormat;
  43570. static readonly GPUTextureFormat_r8uint: GPUTextureFormat;
  43571. static readonly GPUTextureFormat_r8sint: GPUTextureFormat;
  43572. static readonly GPUTextureFormat_r16uint: GPUTextureFormat;
  43573. static readonly GPUTextureFormat_r16sint: GPUTextureFormat;
  43574. static readonly GPUTextureFormat_r16float: GPUTextureFormat;
  43575. static readonly GPUTextureFormat_rg8unorm: GPUTextureFormat;
  43576. static readonly GPUTextureFormat_rg8snorm: GPUTextureFormat;
  43577. static readonly GPUTextureFormat_rg8uint: GPUTextureFormat;
  43578. static readonly GPUTextureFormat_rg8sint: GPUTextureFormat;
  43579. static readonly GPUTextureFormat_r32uint: GPUTextureFormat;
  43580. static readonly GPUTextureFormat_r32sint: GPUTextureFormat;
  43581. static readonly GPUTextureFormat_r32float: GPUTextureFormat;
  43582. static readonly GPUTextureFormat_rg16uint: GPUTextureFormat;
  43583. static readonly GPUTextureFormat_rg16sint: GPUTextureFormat;
  43584. static readonly GPUTextureFormat_rg16float: GPUTextureFormat;
  43585. static readonly GPUTextureFormat_rgba8unorm: GPUTextureFormat;
  43586. static readonly GPUTextureFormat_rgba8unormSrgb: GPUTextureFormat;
  43587. static readonly GPUTextureFormat_rgba8snorm: GPUTextureFormat;
  43588. static readonly GPUTextureFormat_rgba8uint: GPUTextureFormat;
  43589. static readonly GPUTextureFormat_rgba8sint: GPUTextureFormat;
  43590. static readonly GPUTextureFormat_bgra8unorm: GPUTextureFormat;
  43591. static readonly GPUTextureFormat_bgra8unormSrgb: GPUTextureFormat;
  43592. static readonly GPUTextureFormat_rgb10a2unorm: GPUTextureFormat;
  43593. static readonly GPUTextureFormat_rg11b10float: GPUTextureFormat;
  43594. static readonly GPUTextureFormat_rg32uint: GPUTextureFormat;
  43595. static readonly GPUTextureFormat_rg32sint: GPUTextureFormat;
  43596. static readonly GPUTextureFormat_rg32float: GPUTextureFormat;
  43597. static readonly GPUTextureFormat_rgba16uint: GPUTextureFormat;
  43598. static readonly GPUTextureFormat_rgba16sint: GPUTextureFormat;
  43599. static readonly GPUTextureFormat_rgba16float: GPUTextureFormat;
  43600. static readonly GPUTextureFormat_rgba32uint: GPUTextureFormat;
  43601. static readonly GPUTextureFormat_rgba32sint: GPUTextureFormat;
  43602. static readonly GPUTextureFormat_rgba32float: GPUTextureFormat;
  43603. static readonly GPUTextureFormat_depth32float: GPUTextureFormat;
  43604. static readonly GPUTextureFormat_depth24plus: GPUTextureFormat;
  43605. static readonly GPUTextureFormat_depth24plusStencil8: GPUTextureFormat;
  43606. static readonly GPUTextureViewDimension_1d: GPUTextureViewDimension;
  43607. static readonly GPUTextureViewDimension_2d: GPUTextureViewDimension;
  43608. static readonly GPUTextureViewDimension_2dArray: GPUTextureViewDimension;
  43609. static readonly GPUTextureViewDimension_cube: GPUTextureViewDimension;
  43610. static readonly GPUTextureViewDimension_cubeArray: GPUTextureViewDimension;
  43611. static readonly GPUTextureViewDimension_3d: GPUTextureViewDimension;
  43612. static readonly GPUPowerPreference_lowPower: GPUPowerPreference;
  43613. static readonly GPUPowerPreference_highPerformance: GPUPowerPreference;
  43614. static readonly GPUVertexFormat_uchar2: GPUVertexFormat;
  43615. static readonly GPUVertexFormat_uchar4: GPUVertexFormat;
  43616. static readonly GPUVertexFormat_char2: GPUVertexFormat;
  43617. static readonly GPUVertexFormat_char4: GPUVertexFormat;
  43618. static readonly GPUVertexFormat_uchar2norm: GPUVertexFormat;
  43619. static readonly GPUVertexFormat_uchar4norm: GPUVertexFormat;
  43620. static readonly GPUVertexFormat_char2norm: GPUVertexFormat;
  43621. static readonly GPUVertexFormat_char4norm: GPUVertexFormat;
  43622. static readonly GPUVertexFormat_ushort2: GPUVertexFormat;
  43623. static readonly GPUVertexFormat_ushort4: GPUVertexFormat;
  43624. static readonly GPUVertexFormat_short2: GPUVertexFormat;
  43625. static readonly GPUVertexFormat_short4: GPUVertexFormat;
  43626. static readonly GPUVertexFormat_ushort2norm: GPUVertexFormat;
  43627. static readonly GPUVertexFormat_ushort4norm: GPUVertexFormat;
  43628. static readonly GPUVertexFormat_short2norm: GPUVertexFormat;
  43629. static readonly GPUVertexFormat_short4norm: GPUVertexFormat;
  43630. static readonly GPUVertexFormat_half2: GPUVertexFormat;
  43631. static readonly GPUVertexFormat_half4: GPUVertexFormat;
  43632. static readonly GPUVertexFormat_float: GPUVertexFormat;
  43633. static readonly GPUVertexFormat_float2: GPUVertexFormat;
  43634. static readonly GPUVertexFormat_float3: GPUVertexFormat;
  43635. static readonly GPUVertexFormat_float4: GPUVertexFormat;
  43636. static readonly GPUVertexFormat_uint: GPUVertexFormat;
  43637. static readonly GPUVertexFormat_uint2: GPUVertexFormat;
  43638. static readonly GPUVertexFormat_uint3: GPUVertexFormat;
  43639. static readonly GPUVertexFormat_uint4: GPUVertexFormat;
  43640. static readonly GPUVertexFormat_int: GPUVertexFormat;
  43641. static readonly GPUVertexFormat_int2: GPUVertexFormat;
  43642. static readonly GPUVertexFormat_int3: GPUVertexFormat;
  43643. static readonly GPUVertexFormat_int4: GPUVertexFormat;
  43644. static readonly GPUBufferUsage_NONE: number;
  43645. static readonly GPUBufferUsage_MAP_READ: number;
  43646. static readonly GPUBufferUsage_MAP_WRITE: number;
  43647. static readonly GPUBufferUsage_TRANSFER_SRC: number;
  43648. static readonly GPUBufferUsage_TRANSFER_DST: number;
  43649. static readonly GPUBufferUsage_INDEX: number;
  43650. static readonly GPUBufferUsage_VERTEX: number;
  43651. static readonly GPUBufferUsage_UNIFORM: number;
  43652. static readonly GPUBufferUsage_STORAGE: number;
  43653. static readonly GPUColorWriteBits_NONE: number;
  43654. static readonly GPUColorWriteBits_RED: number;
  43655. static readonly GPUColorWriteBits_GREEN: number;
  43656. static readonly GPUColorWriteBits_BLUE: number;
  43657. static readonly GPUColorWriteBits_ALPHA: number;
  43658. static readonly GPUColorWriteBits_ALL: number;
  43659. static readonly GPUShaderStageBit_NONE: number;
  43660. static readonly GPUShaderStageBit_VERTEX: number;
  43661. static readonly GPUShaderStageBit_FRAGMENT: number;
  43662. static readonly GPUShaderStageBit_COMPUTE: number;
  43663. static readonly GPUTextureAspect_all: GPUTextureAspect;
  43664. static readonly GPUTextureAspect_depthOnly: GPUTextureAspect;
  43665. static readonly GPUTextureAspect_stencilOnly: GPUTextureAspect;
  43666. static readonly GPUTextureUsage_NONE: number;
  43667. static readonly GPUTextureUsage_COPY_SRC: number;
  43668. static readonly GPUTextureUsage_COPY_DST: number;
  43669. static readonly GPUTextureUsage_SAMPLED: number;
  43670. static readonly GPUTextureUsage_STORAGE: number;
  43671. static readonly GPUTextureUsage_OUTPUT_ATTACHMENT: number;
  43672. static readonly GPUCompareFunction_never: GPUCompareFunction;
  43673. static readonly GPUCompareFunction_less: GPUCompareFunction;
  43674. static readonly GPUCompareFunction_equal: GPUCompareFunction;
  43675. static readonly GPUCompareFunction_lessEqual: GPUCompareFunction;
  43676. static readonly GPUCompareFunction_greater: GPUCompareFunction;
  43677. static readonly GPUCompareFunction_notEqual: GPUCompareFunction;
  43678. static readonly GPUCompareFunction_greaterEqual: GPUCompareFunction;
  43679. static readonly GPUCompareFunction_always: GPUCompareFunction;
  43680. static readonly GPUBindingType_uniformBuffer: GPUBindingType;
  43681. static readonly GPUBindingType_sampler: GPUBindingType;
  43682. static readonly GPUBindingType_sampledTexture: GPUBindingType;
  43683. static readonly GPUBindingType_storageBuffer: GPUBindingType;
  43684. static readonly GPUInputStepMode_vertex: GPUInputStepMode;
  43685. static readonly GPUInputStepMode_instance: GPUInputStepMode;
  43686. static readonly GPUStencilOperation_keep: GPUStencilOperation;
  43687. static readonly GPUStencilOperation_zero: GPUStencilOperation;
  43688. static readonly GPUStencilOperation_replace: GPUStencilOperation;
  43689. static readonly GPUStencilOperation_invert: GPUStencilOperation;
  43690. static readonly GPUStencilOperation_incrementClamp: GPUStencilOperation;
  43691. static readonly GPUStencilOperation_decrementClamp: GPUStencilOperation;
  43692. static readonly GPUStencilOperation_incrementWrap: GPUStencilOperation;
  43693. static readonly GPUStencilOperation_decrementWrap: GPUStencilOperation;
  43694. static readonly GPUFilterMode_nearest: GPUFilterMode;
  43695. static readonly GPUFilterMode_linear: GPUFilterMode;
  43696. static readonly GPUAddressMode_clampToEdge: GPUAddressMode;
  43697. static readonly GPUAddressMode_repeat: GPUAddressMode;
  43698. static readonly GPUAddressMode_mirrorRepeat: GPUAddressMode;
  43699. static readonly GPUBlendFactor_zero: GPUBlendFactor;
  43700. static readonly GPUBlendFactor_one: GPUBlendFactor;
  43701. static readonly GPUBlendFactor_srcColor: GPUBlendFactor;
  43702. static readonly GPUBlendFactor_oneMinusSrcColor: GPUBlendFactor;
  43703. static readonly GPUBlendFactor_srcAlpha: GPUBlendFactor;
  43704. static readonly GPUBlendFactor_oneMinusSrcAlpha: GPUBlendFactor;
  43705. static readonly GPUBlendFactor_dstColor: GPUBlendFactor;
  43706. static readonly GPUBlendFactor_oneMinusDstColor: GPUBlendFactor;
  43707. static readonly GPUBlendFactor_dstAlpha: GPUBlendFactor;
  43708. static readonly GPUBlendFactor_oneMinusDstAlpha: GPUBlendFactor;
  43709. static readonly GPUBlendFactor_srcAlphaSaturated: GPUBlendFactor;
  43710. static readonly GPUBlendFactor_blendColor: GPUBlendFactor;
  43711. static readonly GPUBlendFactor_oneMinusBlendColor: GPUBlendFactor;
  43712. static readonly GPUBlendOperation_add: GPUBlendOperation;
  43713. static readonly GPUBlendOperation_substract: GPUBlendOperation;
  43714. static readonly GPUBlendOperation_reverseSubtract: GPUBlendOperation;
  43715. static readonly GPUBlendOperation_min: GPUBlendOperation;
  43716. static readonly GPUBlendOperation_max: GPUBlendOperation;
  43717. }
  43718. }
  43719. declare module BABYLON {
  43720. /**
  43721. * Contains position and normal vectors for a vertex
  43722. */
  43723. export class PositionNormalVertex {
  43724. /** the position of the vertex (defaut: 0,0,0) */
  43725. position: Vector3;
  43726. /** the normal of the vertex (defaut: 0,1,0) */
  43727. normal: Vector3;
  43728. /**
  43729. * Creates a PositionNormalVertex
  43730. * @param position the position of the vertex (defaut: 0,0,0)
  43731. * @param normal the normal of the vertex (defaut: 0,1,0)
  43732. */
  43733. constructor(
  43734. /** the position of the vertex (defaut: 0,0,0) */
  43735. position?: Vector3,
  43736. /** the normal of the vertex (defaut: 0,1,0) */
  43737. normal?: Vector3);
  43738. /**
  43739. * Clones the PositionNormalVertex
  43740. * @returns the cloned PositionNormalVertex
  43741. */
  43742. clone(): PositionNormalVertex;
  43743. }
  43744. /**
  43745. * Contains position, normal and uv vectors for a vertex
  43746. */
  43747. export class PositionNormalTextureVertex {
  43748. /** the position of the vertex (defaut: 0,0,0) */
  43749. position: Vector3;
  43750. /** the normal of the vertex (defaut: 0,1,0) */
  43751. normal: Vector3;
  43752. /** the uv of the vertex (default: 0,0) */
  43753. uv: Vector2;
  43754. /**
  43755. * Creates a PositionNormalTextureVertex
  43756. * @param position the position of the vertex (defaut: 0,0,0)
  43757. * @param normal the normal of the vertex (defaut: 0,1,0)
  43758. * @param uv the uv of the vertex (default: 0,0)
  43759. */
  43760. constructor(
  43761. /** the position of the vertex (defaut: 0,0,0) */
  43762. position?: Vector3,
  43763. /** the normal of the vertex (defaut: 0,1,0) */
  43764. normal?: Vector3,
  43765. /** the uv of the vertex (default: 0,0) */
  43766. uv?: Vector2);
  43767. /**
  43768. * Clones the PositionNormalTextureVertex
  43769. * @returns the cloned PositionNormalTextureVertex
  43770. */
  43771. clone(): PositionNormalTextureVertex;
  43772. }
  43773. }
  43774. declare module BABYLON {
  43775. /**
  43776. * @hidden
  43777. */
  43778. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  43779. attributeNextLocation: number;
  43780. varyingNextLocation: number;
  43781. uboNextBindingIndex: number;
  43782. freeSetIndex: number;
  43783. freeBindingIndex: number;
  43784. availableVaryings: {
  43785. [key: string]: number;
  43786. };
  43787. availableAttributes: {
  43788. [key: string]: number;
  43789. };
  43790. availableUBOs: {
  43791. [key: string]: {
  43792. setIndex: number;
  43793. bindingIndex: number;
  43794. };
  43795. };
  43796. availableSamplers: {
  43797. [key: string]: {
  43798. setIndex: number;
  43799. bindingIndex: number;
  43800. };
  43801. };
  43802. leftOverUniforms: {
  43803. name: string;
  43804. type: string;
  43805. length: number;
  43806. }[];
  43807. orderedAttributes: string[];
  43808. orderedUBOsAndSamplers: {
  43809. name: string;
  43810. isSampler: boolean;
  43811. }[][];
  43812. constructor();
  43813. getNextFreeUBOBinding(): {
  43814. setIndex: number;
  43815. bindingIndex: number;
  43816. };
  43817. getNextFreeTextureBinding(): {
  43818. setIndex: number;
  43819. bindingIndex: number;
  43820. };
  43821. private _getNextFreeBinding;
  43822. }
  43823. }
  43824. declare module BABYLON {
  43825. /** @hidden */
  43826. export interface IWebGPUPipelineContextSamplerCache {
  43827. setIndex: number;
  43828. textureBinding: number;
  43829. samplerBinding: number;
  43830. texture: InternalTexture;
  43831. }
  43832. /** @hidden */
  43833. export interface IWebGPUPipelineContextVertexInputsCache {
  43834. indexBuffer: Nullable<GPUBuffer>;
  43835. indexOffset: number;
  43836. vertexStartSlot: number;
  43837. vertexBuffers: GPUBuffer[];
  43838. vertexOffsets: number[];
  43839. }
  43840. /** @hidden */
  43841. export class WebGPUPipelineContext implements IPipelineContext {
  43842. engine: WebGPUEngine;
  43843. availableAttributes: {
  43844. [key: string]: number;
  43845. };
  43846. availableUBOs: {
  43847. [key: string]: {
  43848. setIndex: number;
  43849. bindingIndex: number;
  43850. };
  43851. };
  43852. availableSamplers: {
  43853. [key: string]: {
  43854. setIndex: number;
  43855. bindingIndex: number;
  43856. };
  43857. };
  43858. orderedAttributes: string[];
  43859. orderedUBOsAndSamplers: {
  43860. name: string;
  43861. isSampler: boolean;
  43862. }[][];
  43863. leftOverUniforms: {
  43864. name: string;
  43865. type: string;
  43866. length: number;
  43867. }[];
  43868. leftOverUniformsByName: {
  43869. [name: string]: string;
  43870. };
  43871. sources: {
  43872. vertex: string;
  43873. fragment: string;
  43874. };
  43875. stages: Nullable<GPURenderPipelineStageDescriptor>;
  43876. samplers: {
  43877. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  43878. };
  43879. vertexInputs: IWebGPUPipelineContextVertexInputsCache;
  43880. bindGroupLayouts: (GPUBindGroupLayout | undefined)[];
  43881. bindGroups: GPUBindGroup[];
  43882. renderPipeline: GPURenderPipeline;
  43883. /**
  43884. * Stores the uniform buffer
  43885. */
  43886. uniformBuffer: Nullable<UniformBuffer>;
  43887. onCompiled?: () => void;
  43888. readonly isAsync: boolean;
  43889. readonly isReady: boolean;
  43890. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine); private _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void; private _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  43891. [key: string]: number;
  43892. }, uniformsNames: string[], uniforms: {
  43893. [key: string]: Nullable<WebGLUniformLocation>;
  43894. }, samplerList: string[], samplers: {
  43895. [key: string]: number;
  43896. }, attributesNames: string[], attributes: number[]): void;
  43897. /**
  43898. * Build the uniform buffer used in the material.
  43899. */
  43900. buildUniformLayout(): void;
  43901. /**
  43902. * Release all associated resources.
  43903. **/
  43904. dispose(): void;
  43905. /**
  43906. * Sets an interger value on a uniform variable.
  43907. * @param uniformName Name of the variable.
  43908. * @param value Value to be set.
  43909. */
  43910. setInt(uniformName: string, value: number): void;
  43911. /**
  43912. * Sets an int array on a uniform variable.
  43913. * @param uniformName Name of the variable.
  43914. * @param array array to be set.
  43915. */
  43916. setIntArray(uniformName: string, array: Int32Array): void;
  43917. /**
  43918. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  43919. * @param uniformName Name of the variable.
  43920. * @param array array to be set.
  43921. */
  43922. setIntArray2(uniformName: string, array: Int32Array): void;
  43923. /**
  43924. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  43925. * @param uniformName Name of the variable.
  43926. * @param array array to be set.
  43927. */
  43928. setIntArray3(uniformName: string, array: Int32Array): void;
  43929. /**
  43930. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  43931. * @param uniformName Name of the variable.
  43932. * @param array array to be set.
  43933. */
  43934. setIntArray4(uniformName: string, array: Int32Array): void;
  43935. /**
  43936. * Sets an float array on a uniform variable.
  43937. * @param uniformName Name of the variable.
  43938. * @param array array to be set.
  43939. */
  43940. setFloatArray(uniformName: string, array: Float32Array): void;
  43941. /**
  43942. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  43943. * @param uniformName Name of the variable.
  43944. * @param array array to be set.
  43945. */
  43946. setFloatArray2(uniformName: string, array: Float32Array): void;
  43947. /**
  43948. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  43949. * @param uniformName Name of the variable.
  43950. * @param array array to be set.
  43951. */
  43952. setFloatArray3(uniformName: string, array: Float32Array): void;
  43953. /**
  43954. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  43955. * @param uniformName Name of the variable.
  43956. * @param array array to be set.
  43957. */
  43958. setFloatArray4(uniformName: string, array: Float32Array): void;
  43959. /**
  43960. * Sets an array on a uniform variable.
  43961. * @param uniformName Name of the variable.
  43962. * @param array array to be set.
  43963. */
  43964. setArray(uniformName: string, array: number[]): void;
  43965. /**
  43966. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  43967. * @param uniformName Name of the variable.
  43968. * @param array array to be set.
  43969. */
  43970. setArray2(uniformName: string, array: number[]): void;
  43971. /**
  43972. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  43973. * @param uniformName Name of the variable.
  43974. * @param array array to be set.
  43975. * @returns this effect.
  43976. */
  43977. setArray3(uniformName: string, array: number[]): void;
  43978. /**
  43979. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  43980. * @param uniformName Name of the variable.
  43981. * @param array array to be set.
  43982. */
  43983. setArray4(uniformName: string, array: number[]): void;
  43984. /**
  43985. * Sets matrices on a uniform variable.
  43986. * @param uniformName Name of the variable.
  43987. * @param matrices matrices to be set.
  43988. */
  43989. setMatrices(uniformName: string, matrices: Float32Array): void;
  43990. /**
  43991. * Sets matrix on a uniform variable.
  43992. * @param uniformName Name of the variable.
  43993. * @param matrix matrix to be set.
  43994. */
  43995. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  43996. /**
  43997. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  43998. * @param uniformName Name of the variable.
  43999. * @param matrix matrix to be set.
  44000. */
  44001. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44002. /**
  44003. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44004. * @param uniformName Name of the variable.
  44005. * @param matrix matrix to be set.
  44006. */
  44007. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44008. /**
  44009. * Sets a float on a uniform variable.
  44010. * @param uniformName Name of the variable.
  44011. * @param value value to be set.
  44012. * @returns this effect.
  44013. */
  44014. setFloat(uniformName: string, value: number): void;
  44015. /**
  44016. * Sets a boolean on a uniform variable.
  44017. * @param uniformName Name of the variable.
  44018. * @param bool value to be set.
  44019. */
  44020. setBool(uniformName: string, bool: boolean): void;
  44021. /**
  44022. * Sets a Vector2 on a uniform variable.
  44023. * @param uniformName Name of the variable.
  44024. * @param vector2 vector2 to be set.
  44025. */
  44026. setVector2(uniformName: string, vector2: IVector2Like): void;
  44027. /**
  44028. * Sets a float2 on a uniform variable.
  44029. * @param uniformName Name of the variable.
  44030. * @param x First float in float2.
  44031. * @param y Second float in float2.
  44032. */
  44033. setFloat2(uniformName: string, x: number, y: number): void;
  44034. /**
  44035. * Sets a Vector3 on a uniform variable.
  44036. * @param uniformName Name of the variable.
  44037. * @param vector3 Value to be set.
  44038. */
  44039. setVector3(uniformName: string, vector3: IVector3Like): void;
  44040. /**
  44041. * Sets a float3 on a uniform variable.
  44042. * @param uniformName Name of the variable.
  44043. * @param x First float in float3.
  44044. * @param y Second float in float3.
  44045. * @param z Third float in float3.
  44046. */
  44047. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44048. /**
  44049. * Sets a Vector4 on a uniform variable.
  44050. * @param uniformName Name of the variable.
  44051. * @param vector4 Value to be set.
  44052. */
  44053. setVector4(uniformName: string, vector4: IVector4Like): void;
  44054. /**
  44055. * Sets a float4 on a uniform variable.
  44056. * @param uniformName Name of the variable.
  44057. * @param x First float in float4.
  44058. * @param y Second float in float4.
  44059. * @param z Third float in float4.
  44060. * @param w Fourth float in float4.
  44061. * @returns this effect.
  44062. */
  44063. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44064. /**
  44065. * Sets a Color3 on a uniform variable.
  44066. * @param uniformName Name of the variable.
  44067. * @param color3 Value to be set.
  44068. */
  44069. setColor3(uniformName: string, color3: IColor3Like): void;
  44070. /**
  44071. * Sets a Color4 on a uniform variable.
  44072. * @param uniformName Name of the variable.
  44073. * @param color3 Value to be set.
  44074. * @param alpha Alpha value to be set.
  44075. */
  44076. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44077. /**
  44078. * Sets a Color4 on a uniform variable
  44079. * @param uniformName defines the name of the variable
  44080. * @param color4 defines the value to be set
  44081. */
  44082. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44083. }
  44084. }
  44085. declare module BABYLON {
  44086. /** @hidden */
  44087. export class WebGPUDataBuffer extends DataBuffer {
  44088. private _buffer;
  44089. constructor(resource: GPUBuffer);
  44090. readonly underlyingResource: any;
  44091. }
  44092. }
  44093. declare module BABYLON {
  44094. /** @hidden */
  44095. export class WebGPUShaderProcessor implements IShaderProcessor {
  44096. varyingProcessor(varying: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44097. attributeProcessor(attribute: string, processingContext: Nullable<ShaderProcessingContext>): string;
  44098. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44099. [key: string]: string;
  44100. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44101. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44102. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44103. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44104. vertexCode: string;
  44105. fragmentCode: string;
  44106. };
  44107. }
  44108. }
  44109. declare module BABYLON {
  44110. /**
  44111. * Options to load the associated Shaderc library
  44112. */
  44113. export interface ShadercOptions {
  44114. /**
  44115. * Defines an existing instance of shaderC (usefull in modules who do not access the global instance).
  44116. */
  44117. shaderc?: any;
  44118. /**
  44119. * Defines the URL of the shaderc JS File.
  44120. */
  44121. jsPath?: string;
  44122. /**
  44123. * Defines the URL of the shaderc WASM File.
  44124. */
  44125. wasmPath?: string;
  44126. }
  44127. /**
  44128. * Options to create the WebGPU engine
  44129. */
  44130. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44131. /**
  44132. * If delta time between frames should be constant
  44133. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44134. */
  44135. deterministicLockstep?: boolean;
  44136. /**
  44137. * Maximum about of steps between frames (Default: 4)
  44138. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44139. */
  44140. lockstepMaxSteps?: number;
  44141. /**
  44142. * Defines that engine should ignore modifying touch action attribute and style
  44143. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44144. */
  44145. doNotHandleTouchAction?: boolean;
  44146. /**
  44147. * Defines if webaudio should be initialized as well
  44148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44149. */
  44150. audioEngine?: boolean;
  44151. /**
  44152. * Defines the category of adapter to use.
  44153. * Is it the discrete or integrated device.
  44154. */
  44155. powerPreference?: GPUPowerPreference;
  44156. /**
  44157. * Defines the device descriptor used to create a device.
  44158. */
  44159. deviceDescriptor?: GPUDeviceDescriptor;
  44160. /**
  44161. * Defines the requested Swap Chain Format.
  44162. */
  44163. swapChainFormat?: GPUTextureFormat;
  44164. /**
  44165. * Defines wether MSAA is enabled on the canvas.
  44166. */
  44167. antialiasing?: boolean;
  44168. }
  44169. /**
  44170. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44171. */
  44172. export class WebGPUEngine extends Engine {
  44173. private static readonly _shadercDefaultOptions;
  44174. private readonly _uploadEncoderDescriptor;
  44175. private readonly _renderEncoderDescriptor;
  44176. private readonly _clearDepthValue;
  44177. private readonly _clearStencilValue;
  44178. private readonly _defaultSampleCount;
  44179. private _canvas;
  44180. private _options;
  44181. private _shaderc;
  44182. private _adapter;
  44183. private _device;
  44184. private _context;
  44185. private _swapChain;
  44186. private _mainPassSampleCount;
  44187. private _mainTexture;
  44188. private _depthTexture;
  44189. private _mainColorAttachments;
  44190. private _mainTextureExtends;
  44191. private _mainDepthAttachment;
  44192. private _uploadEncoder;
  44193. private _renderEncoder;
  44194. private _commandBuffers;
  44195. private _currentRenderPass;
  44196. private _currentVertexBuffers;
  44197. private _currentIndexBuffer;
  44198. private __colorWrite;
  44199. private _uniformsBuffers;
  44200. private _compiledShaders;
  44201. private _decodeCanvas;
  44202. private _decodeEngine;
  44203. /**
  44204. * Gets a boolean indicating that the engine supports uniform buffers
  44205. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  44206. */
  44207. readonly supportsUniformBuffers: boolean;
  44208. /**
  44209. * Create a new instance of the gpu engine.
  44210. * @param canvas Defines the canvas to use to display the result
  44211. * @param options Defines the options passed to the engine to create the GPU context dependencies
  44212. */
  44213. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  44214. /**
  44215. * Initializes the WebGPU context and dependencies.
  44216. * @param shadercOptions Defines the ShaderC compiler options if necessary
  44217. * @returns a promise notifying the readiness of the engine.
  44218. */
  44219. initAsync(shadercOptions?: ShadercOptions): Promise<void>;
  44220. private _initShaderc;
  44221. private _initializeLimits;
  44222. private _initializeContextAndSwapChain;
  44223. private _initializeMainAttachments;
  44224. /**
  44225. * Gets a shader processor implementation fitting with the current engine type.
  44226. * @returns The shader processor implementation.
  44227. */
  44228. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  44229. /** @hidden */ private _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  44230. wipeCaches(bruteForce?: boolean): void;
  44231. setColorWrite(enable: boolean): void;
  44232. getColorWrite(): boolean; private _viewport(x: number, y: number, width: number, height: number): void;
  44233. enableScissor(x: number, y: number, width: number, height: number): void;
  44234. disableScissor(): void;
  44235. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44236. private _createBuffer;
  44237. private _setSubData;
  44238. createVertexBuffer(data: DataArray): DataBuffer;
  44239. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44240. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44241. createIndexBuffer(data: IndicesArray): DataBuffer;
  44242. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44243. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  44244. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  44245. bindBuffers(vertexBuffers: {
  44246. [key: string]: Nullable<VertexBuffer>;
  44247. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  44248. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  44249. createUniformBuffer(elements: FloatArray): DataBuffer;
  44250. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  44251. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  44252. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  44253. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  44254. private _compileRawShaderToSpirV;
  44255. private _compileShaderToSpirV;
  44256. private _createPipelineStageDescriptor;
  44257. private _compileRawPipelineStageDescriptor;
  44258. private _compilePipelineStageDescriptor;
  44259. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44260. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44261. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  44262. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  44263. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44264. enableEffect(effect: Effect): void; private _releaseEffect(effect: Effect): void;
  44265. /**
  44266. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  44267. */
  44268. releaseEffects(): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44269. /** @hidden */ private _createTexture(): WebGLTexture;
  44270. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  44271. private _uploadMipMapsFromWebglTexture;
  44272. private _uploadFromWebglTexture;
  44273. private _getSamplerFilterDescriptor;
  44274. private _getWrappingMode;
  44275. private _getSamplerWrappingDescriptor;
  44276. private _getSamplerDescriptor;
  44277. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  44278. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  44279. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44280. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44281. setTexture(channel: number, _: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  44282. bindSamplers(effect: Effect): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44283. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  44284. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44285. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44286. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44287. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44288. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44289. /**
  44290. * Begin a new frame
  44291. */
  44292. beginFrame(): void;
  44293. private _freezeCommands;
  44294. private _frozenCommands; private _shouldOnlyUpdateCameras(): boolean;
  44295. /**
  44296. * End the current frame
  44297. */
  44298. endFrame(): void;
  44299. /**
  44300. * Freezes the current list of commands to speed up rendering of sub sequent frames.
  44301. */
  44302. freezeCommands(): void;
  44303. /**
  44304. * Freezes the current list of commands to speed up rendering of sub sequent frames.
  44305. */
  44306. unFreezeCommands(): void;
  44307. private _startMainRenderPass;
  44308. private _endRenderPass;
  44309. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44310. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44311. private _getTopology;
  44312. private _getCompareFunction;
  44313. private _getOpFunction;
  44314. private _getDepthStencilStateDescriptor;
  44315. /**
  44316. * Set various states to the webGL context
  44317. * @param culling defines backface culling state
  44318. * @param zOffset defines the value to apply to zOffset (0 by default)
  44319. * @param force defines if states must be applied even if cache is up to date
  44320. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  44321. */
  44322. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44323. private _getFrontFace;
  44324. private _getCullMode;
  44325. private _getRasterizationStateDescriptor;
  44326. private _getWriteMask;
  44327. /**
  44328. * Sets the current alpha mode
  44329. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  44330. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44331. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44332. */
  44333. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44334. private _getAphaBlendOperation;
  44335. private _getAphaBlendFactor;
  44336. private _getAphaBlendState;
  44337. private _getColorBlendState;
  44338. private _getColorStateDescriptors;
  44339. private _getStages;
  44340. private _getVertexInputDescriptorFormat;
  44341. private _getVertexInputDescriptor;
  44342. private _getPipelineLayout;
  44343. private _getRenderPipeline;
  44344. private _getVertexInputsToRender;
  44345. private _getBindGroupsToRender;
  44346. private _bindVertexInputs;
  44347. private _setRenderBindGroups;
  44348. private _setRenderPipeline;
  44349. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44350. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44351. /**
  44352. * Force a specific size of the canvas
  44353. * @param width defines the new canvas' width
  44354. * @param height defines the new canvas' height
  44355. */
  44356. setSize(width: number, height: number): void;
  44357. /**
  44358. * Dispose and release all associated resources
  44359. */
  44360. dispose(): void;
  44361. getRenderWidth(useScreen?: boolean): number;
  44362. getRenderHeight(useScreen?: boolean): number;
  44363. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  44364. getError(): number;
  44365. areAllEffectsReady(): boolean; private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void; private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean; private _getUnpackAlignement(): number; private _unpackFlipY(value: boolean): void;
  44366. applyStates(): void;
  44367. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  44368. min: number;
  44369. mag: number;
  44370. };
  44371. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44372. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44373. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44374. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44375. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44376. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44377. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44378. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44379. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44380. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44381. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44382. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44383. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44384. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44385. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44386. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44387. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44388. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44389. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44390. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44391. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44392. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44393. }
  44394. }
  44395. declare module BABYLON {
  44396. /** @hidden */
  44397. export var rgbdEncodePixelShader: {
  44398. name: string;
  44399. shader: string;
  44400. };
  44401. }
  44402. declare module BABYLON {
  44403. /** @hidden */
  44404. export var rgbdDecodePixelShader: {
  44405. name: string;
  44406. shader: string;
  44407. };
  44408. }
  44409. declare module BABYLON {
  44410. /**
  44411. * Raw texture data and descriptor sufficient for WebGL texture upload
  44412. */
  44413. export interface EnvironmentTextureInfo {
  44414. /**
  44415. * Version of the environment map
  44416. */
  44417. version: number;
  44418. /**
  44419. * Width of image
  44420. */
  44421. width: number;
  44422. /**
  44423. * Irradiance information stored in the file.
  44424. */
  44425. irradiance: any;
  44426. /**
  44427. * Specular information stored in the file.
  44428. */
  44429. specular: any;
  44430. }
  44431. /**
  44432. * Defines One Image in the file. It requires only the position in the file
  44433. * as well as the length.
  44434. */
  44435. interface BufferImageData {
  44436. /**
  44437. * Length of the image data.
  44438. */
  44439. length: number;
  44440. /**
  44441. * Position of the data from the null terminator delimiting the end of the JSON.
  44442. */
  44443. position: number;
  44444. }
  44445. /**
  44446. * Defines the specular data enclosed in the file.
  44447. * This corresponds to the version 1 of the data.
  44448. */
  44449. export interface EnvironmentTextureSpecularInfoV1 {
  44450. /**
  44451. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44452. */
  44453. specularDataPosition?: number;
  44454. /**
  44455. * This contains all the images data needed to reconstruct the cubemap.
  44456. */
  44457. mipmaps: Array<BufferImageData>;
  44458. /**
  44459. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44460. */
  44461. lodGenerationScale: number;
  44462. }
  44463. /**
  44464. * Sets of helpers addressing the serialization and deserialization of environment texture
  44465. * stored in a BabylonJS env file.
  44466. * Those files are usually stored as .env files.
  44467. */
  44468. export class EnvironmentTextureTools {
  44469. /**
  44470. * Magic number identifying the env file.
  44471. */
  44472. private static _MagicBytes;
  44473. /**
  44474. * Gets the environment info from an env file.
  44475. * @param data The array buffer containing the .env bytes.
  44476. * @returns the environment file info (the json header) if successfully parsed.
  44477. */
  44478. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44479. /**
  44480. * Creates an environment texture from a loaded cube texture.
  44481. * @param texture defines the cube texture to convert in env file
  44482. * @return a promise containing the environment data if succesfull.
  44483. */
  44484. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44485. /**
  44486. * Creates a JSON representation of the spherical data.
  44487. * @param texture defines the texture containing the polynomials
  44488. * @return the JSON representation of the spherical info
  44489. */
  44490. private static _CreateEnvTextureIrradiance;
  44491. /**
  44492. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44493. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44494. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44495. * @return the views described by info providing access to the underlying buffer
  44496. */
  44497. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44498. /**
  44499. * Uploads the texture info contained in the env file to the GPU.
  44500. * @param texture defines the internal texture to upload to
  44501. * @param arrayBuffer defines the buffer cotaining the data to load
  44502. * @param info defines the texture info retrieved through the GetEnvInfo method
  44503. * @returns a promise
  44504. */
  44505. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44506. /**
  44507. * Uploads the levels of image data to the GPU.
  44508. * @param texture defines the internal texture to upload to
  44509. * @param imageData defines the array buffer views of image data [mipmap][face]
  44510. * @returns a promise
  44511. */
  44512. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44513. /**
  44514. * Uploads spherical polynomials information to the texture.
  44515. * @param texture defines the texture we are trying to upload the information to
  44516. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44517. */
  44518. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44519. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44520. }
  44521. }
  44522. declare module BABYLON {
  44523. /** @hidden */
  44524. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44525. private _genericAttributeLocation;
  44526. private _varyingLocationCount;
  44527. private _varyingLocationMap;
  44528. private _replacements;
  44529. private _textureCount;
  44530. private _uniforms;
  44531. lineProcessor(line: string): string;
  44532. attributeProcessor(attribute: string): string;
  44533. varyingProcessor(varying: string, isFragment: boolean): string;
  44534. uniformProcessor(uniform: string): string;
  44535. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44536. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44537. }
  44538. }
  44539. declare module BABYLON {
  44540. /**
  44541. * Container for accessors for natively-stored mesh data buffers.
  44542. */
  44543. class NativeDataBuffer extends DataBuffer {
  44544. /**
  44545. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44546. */
  44547. nativeIndexBuffer?: any;
  44548. /**
  44549. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44550. */
  44551. nativeVertexBuffer?: any;
  44552. }
  44553. /** @hidden */
  44554. export class NativeEngine extends Engine {
  44555. private readonly _native;
  44556. getHardwareScalingLevel(): number;
  44557. constructor();
  44558. /**
  44559. * Can be used to override the current requestAnimationFrame requester.
  44560. * @hidden
  44561. */
  44562. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44563. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44564. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44565. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44566. recordVertexArrayObject(vertexBuffers: {
  44567. [key: string]: VertexBuffer;
  44568. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44569. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44570. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44571. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44572. /**
  44573. * Draw a list of indexed primitives
  44574. * @param fillMode defines the primitive to use
  44575. * @param indexStart defines the starting index
  44576. * @param indexCount defines the number of index to draw
  44577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44578. */
  44579. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44580. /**
  44581. * Draw a list of unindexed primitives
  44582. * @param fillMode defines the primitive to use
  44583. * @param verticesStart defines the index of first vertex to draw
  44584. * @param verticesCount defines the count of vertices to draw
  44585. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44586. */
  44587. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44588. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44589. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44590. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44591. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44592. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44593. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44594. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44595. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44596. bindSamplers(effect: Effect): void;
  44597. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44598. getRenderWidth(useScreen?: boolean): number;
  44599. getRenderHeight(useScreen?: boolean): number;
  44600. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44601. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44602. /**
  44603. * Set the z offset to apply to current rendering
  44604. * @param value defines the offset to apply
  44605. */
  44606. setZOffset(value: number): void;
  44607. /**
  44608. * Gets the current value of the zOffset
  44609. * @returns the current zOffset state
  44610. */
  44611. getZOffset(): number;
  44612. /**
  44613. * Enable or disable depth buffering
  44614. * @param enable defines the state to set
  44615. */
  44616. setDepthBuffer(enable: boolean): void;
  44617. /**
  44618. * Gets a boolean indicating if depth writing is enabled
  44619. * @returns the current depth writing state
  44620. */
  44621. getDepthWrite(): boolean;
  44622. /**
  44623. * Enable or disable depth writing
  44624. * @param enable defines the state to set
  44625. */
  44626. setDepthWrite(enable: boolean): void;
  44627. /**
  44628. * Enable or disable color writing
  44629. * @param enable defines the state to set
  44630. */
  44631. setColorWrite(enable: boolean): void;
  44632. /**
  44633. * Gets a boolean indicating if color writing is enabled
  44634. * @returns the current color writing state
  44635. */
  44636. getColorWrite(): boolean;
  44637. /**
  44638. * Sets alpha constants used by some alpha blending modes
  44639. * @param r defines the red component
  44640. * @param g defines the green component
  44641. * @param b defines the blue component
  44642. * @param a defines the alpha component
  44643. */
  44644. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44645. /**
  44646. * Sets the current alpha mode
  44647. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  44648. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44649. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44650. */
  44651. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44652. /**
  44653. * Gets the current alpha mode
  44654. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44655. * @returns the current alpha mode
  44656. */
  44657. getAlphaMode(): number;
  44658. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44659. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44660. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44661. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44662. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44663. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44664. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44665. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44666. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44667. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44668. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44669. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44670. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44671. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44672. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44673. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44674. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44675. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44676. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44677. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44678. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44679. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44680. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  44681. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44682. /**
  44683. * Usually called from BABYLON.Texture.ts.
  44684. * Passed information to create a WebGLTexture
  44685. * @param urlArg defines a value which contains one of the following:
  44686. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44687. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44688. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44689. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44690. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44691. * @param scene needed for loading to the correct scene
  44692. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44693. * @param onLoad optional callback to be called upon successful completion
  44694. * @param onError optional callback to be called upon failure
  44695. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44696. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44697. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44698. * @param forcedExtension defines the extension to use to pick the right loader
  44699. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44700. */
  44701. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  44702. /**
  44703. * Creates a cube texture
  44704. * @param rootUrl defines the url where the files to load is located
  44705. * @param scene defines the current scene
  44706. * @param files defines the list of files to load (1 per face)
  44707. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44708. * @param onLoad defines an optional callback raised when the texture is loaded
  44709. * @param onError defines an optional callback raised if there is an issue to load the texture
  44710. * @param format defines the format of the data
  44711. * @param forcedExtension defines the extension to use to pick the right loader
  44712. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44713. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44714. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44715. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44716. * @returns the cube texture as an InternalTexture
  44717. */
  44718. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44719. private _getSamplingFilter;
  44720. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44721. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44722. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44723. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44724. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44725. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44726. /**
  44727. * Updates a dynamic vertex buffer.
  44728. * @param vertexBuffer the vertex buffer to update
  44729. * @param data the data used to update the vertex buffer
  44730. * @param byteOffset the byte offset of the data (optional)
  44731. * @param byteLength the byte length of the data (optional)
  44732. */
  44733. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44734. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44735. private _updateAnisotropicLevel;
  44736. private _getAddressMode;
  44737. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  44738. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44739. releaseEffects(): void;
  44740. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44741. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44742. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44743. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44744. }
  44745. }
  44746. declare module BABYLON {
  44747. /**
  44748. * Gather the list of clipboard event types as constants.
  44749. */
  44750. export class ClipboardEventTypes {
  44751. /**
  44752. * The clipboard event is fired when a copy command is active (pressed).
  44753. */
  44754. static readonly COPY: number;
  44755. /**
  44756. * The clipboard event is fired when a cut command is active (pressed).
  44757. */
  44758. static readonly CUT: number;
  44759. /**
  44760. * The clipboard event is fired when a paste command is active (pressed).
  44761. */
  44762. static readonly PASTE: number;
  44763. }
  44764. /**
  44765. * This class is used to store clipboard related info for the onClipboardObservable event.
  44766. */
  44767. export class ClipboardInfo {
  44768. /**
  44769. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44770. */
  44771. type: number;
  44772. /**
  44773. * Defines the related dom event
  44774. */
  44775. event: ClipboardEvent;
  44776. /**
  44777. *Creates an instance of ClipboardInfo.
  44778. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44779. * @param event Defines the related dom event
  44780. */
  44781. constructor(
  44782. /**
  44783. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44784. */
  44785. type: number,
  44786. /**
  44787. * Defines the related dom event
  44788. */
  44789. event: ClipboardEvent);
  44790. /**
  44791. * Get the clipboard event's type from the keycode.
  44792. * @param keyCode Defines the keyCode for the current keyboard event.
  44793. * @return {number}
  44794. */
  44795. static GetTypeFromCharacter(keyCode: number): number;
  44796. }
  44797. }
  44798. declare module BABYLON {
  44799. /**
  44800. * Google Daydream controller
  44801. */
  44802. export class DaydreamController extends WebVRController {
  44803. /**
  44804. * Base Url for the controller model.
  44805. */
  44806. static MODEL_BASE_URL: string;
  44807. /**
  44808. * File name for the controller model.
  44809. */
  44810. static MODEL_FILENAME: string;
  44811. /**
  44812. * Gamepad Id prefix used to identify Daydream Controller.
  44813. */
  44814. static readonly GAMEPAD_ID_PREFIX: string;
  44815. /**
  44816. * Creates a new DaydreamController from a gamepad
  44817. * @param vrGamepad the gamepad that the controller should be created from
  44818. */
  44819. constructor(vrGamepad: any);
  44820. /**
  44821. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44822. * @param scene scene in which to add meshes
  44823. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44824. */
  44825. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44826. /**
  44827. * Called once for each button that changed state since the last frame
  44828. * @param buttonIdx Which button index changed
  44829. * @param state New state of the button
  44830. * @param changes Which properties on the state changed since last frame
  44831. */
  44832. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44833. }
  44834. }
  44835. declare module BABYLON {
  44836. /**
  44837. * Gear VR Controller
  44838. */
  44839. export class GearVRController extends WebVRController {
  44840. /**
  44841. * Base Url for the controller model.
  44842. */
  44843. static MODEL_BASE_URL: string;
  44844. /**
  44845. * File name for the controller model.
  44846. */
  44847. static MODEL_FILENAME: string;
  44848. /**
  44849. * Gamepad Id prefix used to identify this controller.
  44850. */
  44851. static readonly GAMEPAD_ID_PREFIX: string;
  44852. private readonly _buttonIndexToObservableNameMap;
  44853. /**
  44854. * Creates a new GearVRController from a gamepad
  44855. * @param vrGamepad the gamepad that the controller should be created from
  44856. */
  44857. constructor(vrGamepad: any);
  44858. /**
  44859. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44860. * @param scene scene in which to add meshes
  44861. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44862. */
  44863. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44864. /**
  44865. * Called once for each button that changed state since the last frame
  44866. * @param buttonIdx Which button index changed
  44867. * @param state New state of the button
  44868. * @param changes Which properties on the state changed since last frame
  44869. */
  44870. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44871. }
  44872. }
  44873. declare module BABYLON {
  44874. /**
  44875. * Class containing static functions to help procedurally build meshes
  44876. */
  44877. export class PolyhedronBuilder {
  44878. /**
  44879. * Creates a polyhedron mesh
  44880. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  44881. * * The parameter `size` (positive float, default 1) sets the polygon size
  44882. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44883. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  44884. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  44885. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  44886. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44887. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  44888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44891. * @param name defines the name of the mesh
  44892. * @param options defines the options used to create the mesh
  44893. * @param scene defines the hosting scene
  44894. * @returns the polyhedron mesh
  44895. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44896. */
  44897. static CreatePolyhedron(name: string, options: {
  44898. type?: number;
  44899. size?: number;
  44900. sizeX?: number;
  44901. sizeY?: number;
  44902. sizeZ?: number;
  44903. custom?: any;
  44904. faceUV?: Vector4[];
  44905. faceColors?: Color4[];
  44906. flat?: boolean;
  44907. updatable?: boolean;
  44908. sideOrientation?: number;
  44909. frontUVs?: Vector4;
  44910. backUVs?: Vector4;
  44911. }, scene?: Nullable<Scene>): Mesh;
  44912. }
  44913. }
  44914. declare module BABYLON {
  44915. /**
  44916. * Gizmo that enables scaling a mesh along 3 axis
  44917. */
  44918. export class ScaleGizmo extends Gizmo {
  44919. /**
  44920. * Internal gizmo used for interactions on the x axis
  44921. */
  44922. xGizmo: AxisScaleGizmo;
  44923. /**
  44924. * Internal gizmo used for interactions on the y axis
  44925. */
  44926. yGizmo: AxisScaleGizmo;
  44927. /**
  44928. * Internal gizmo used for interactions on the z axis
  44929. */
  44930. zGizmo: AxisScaleGizmo;
  44931. /**
  44932. * Internal gizmo used to scale all axis equally
  44933. */
  44934. uniformScaleGizmo: AxisScaleGizmo;
  44935. private _meshAttached;
  44936. private _updateGizmoRotationToMatchAttachedMesh;
  44937. private _snapDistance;
  44938. private _scaleRatio;
  44939. private _uniformScalingMesh;
  44940. private _octahedron;
  44941. /** Fires an event when any of it's sub gizmos are dragged */
  44942. onDragStartObservable: Observable<unknown>;
  44943. /** Fires an event when any of it's sub gizmos are released from dragging */
  44944. onDragEndObservable: Observable<unknown>;
  44945. attachedMesh: Nullable<AbstractMesh>;
  44946. /**
  44947. * Creates a ScaleGizmo
  44948. * @param gizmoLayer The utility layer the gizmo will be added to
  44949. */
  44950. constructor(gizmoLayer?: UtilityLayerRenderer);
  44951. updateGizmoRotationToMatchAttachedMesh: boolean;
  44952. /**
  44953. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44954. */
  44955. snapDistance: number;
  44956. /**
  44957. * Ratio for the scale of the gizmo (Default: 1)
  44958. */
  44959. scaleRatio: number;
  44960. /**
  44961. * Disposes of the gizmo
  44962. */
  44963. dispose(): void;
  44964. }
  44965. }
  44966. declare module BABYLON {
  44967. /**
  44968. * Single axis scale gizmo
  44969. */
  44970. export class AxisScaleGizmo extends Gizmo {
  44971. /**
  44972. * Drag behavior responsible for the gizmos dragging interactions
  44973. */
  44974. dragBehavior: PointerDragBehavior;
  44975. private _pointerObserver;
  44976. /**
  44977. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44978. */
  44979. snapDistance: number;
  44980. /**
  44981. * Event that fires each time the gizmo snaps to a new location.
  44982. * * snapDistance is the the change in distance
  44983. */
  44984. onSnapObservable: Observable<{
  44985. snapDistance: number;
  44986. }>;
  44987. /**
  44988. * If the scaling operation should be done on all axis (default: false)
  44989. */
  44990. uniformScaling: boolean;
  44991. private _isEnabled;
  44992. private _parent;
  44993. private _arrow;
  44994. private _coloredMaterial;
  44995. private _hoverMaterial;
  44996. /**
  44997. * Creates an AxisScaleGizmo
  44998. * @param gizmoLayer The utility layer the gizmo will be added to
  44999. * @param dragAxis The axis which the gizmo will be able to scale on
  45000. * @param color The color of the gizmo
  45001. */
  45002. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45003. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45004. /**
  45005. * If the gizmo is enabled
  45006. */
  45007. isEnabled: boolean;
  45008. /**
  45009. * Disposes of the gizmo
  45010. */
  45011. dispose(): void;
  45012. /**
  45013. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45014. * @param mesh The mesh to replace the default mesh of the gizmo
  45015. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45016. */
  45017. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45018. }
  45019. }
  45020. declare module BABYLON {
  45021. /**
  45022. * Bounding box gizmo
  45023. */
  45024. export class BoundingBoxGizmo extends Gizmo {
  45025. private _lineBoundingBox;
  45026. private _rotateSpheresParent;
  45027. private _scaleBoxesParent;
  45028. private _boundingDimensions;
  45029. private _renderObserver;
  45030. private _pointerObserver;
  45031. private _scaleDragSpeed;
  45032. private _tmpQuaternion;
  45033. private _tmpVector;
  45034. private _tmpRotationMatrix;
  45035. /**
  45036. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  45037. */
  45038. ignoreChildren: boolean;
  45039. /**
  45040. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  45041. */
  45042. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45043. /**
  45044. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45045. */
  45046. rotationSphereSize: number;
  45047. /**
  45048. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45049. */
  45050. scaleBoxSize: number;
  45051. /**
  45052. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  45053. */
  45054. fixedDragMeshScreenSize: boolean;
  45055. /**
  45056. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45057. */
  45058. fixedDragMeshScreenSizeDistanceFactor: number;
  45059. /**
  45060. * Fired when a rotation sphere or scale box is dragged
  45061. */
  45062. onDragStartObservable: Observable<{}>;
  45063. /**
  45064. * Fired when a scale box is dragged
  45065. */
  45066. onScaleBoxDragObservable: Observable<{}>;
  45067. /**
  45068. * Fired when a scale box drag is ended
  45069. */
  45070. onScaleBoxDragEndObservable: Observable<{}>;
  45071. /**
  45072. * Fired when a rotation sphere is dragged
  45073. */
  45074. onRotationSphereDragObservable: Observable<{}>;
  45075. /**
  45076. * Fired when a rotation sphere drag is ended
  45077. */
  45078. onRotationSphereDragEndObservable: Observable<{}>;
  45079. /**
  45080. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  45081. */
  45082. scalePivot: Nullable<Vector3>;
  45083. /**
  45084. * Mesh used as a pivot to rotate the attached mesh
  45085. */
  45086. private _anchorMesh;
  45087. private _existingMeshScale;
  45088. private _dragMesh;
  45089. private pointerDragBehavior;
  45090. private coloredMaterial;
  45091. private hoverColoredMaterial;
  45092. /**
  45093. * Sets the color of the bounding box gizmo
  45094. * @param color the color to set
  45095. */
  45096. setColor(color: Color3): void;
  45097. /**
  45098. * Creates an BoundingBoxGizmo
  45099. * @param gizmoLayer The utility layer the gizmo will be added to
  45100. * @param color The color of the gizmo
  45101. */
  45102. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45103. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45104. private _selectNode;
  45105. /**
  45106. * Updates the bounding box information for the Gizmo
  45107. */
  45108. updateBoundingBox(): void;
  45109. private _updateRotationSpheres;
  45110. private _updateScaleBoxes;
  45111. /**
  45112. * Enables rotation on the specified axis and disables rotation on the others
  45113. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45114. */
  45115. setEnabledRotationAxis(axis: string): void;
  45116. /**
  45117. * Enables/disables scaling
  45118. * @param enable if scaling should be enabled
  45119. */
  45120. setEnabledScaling(enable: boolean): void;
  45121. private _updateDummy;
  45122. /**
  45123. * Enables a pointer drag behavior on the bounding box of the gizmo
  45124. */
  45125. enableDragBehavior(): void;
  45126. /**
  45127. * Disposes of the gizmo
  45128. */
  45129. dispose(): void;
  45130. /**
  45131. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  45132. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45133. * @returns the bounding box mesh with the passed in mesh as a child
  45134. */
  45135. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45136. /**
  45137. * CustomMeshes are not supported by this gizmo
  45138. * @param mesh The mesh to replace the default mesh of the gizmo
  45139. */
  45140. setCustomMesh(mesh: Mesh): void;
  45141. }
  45142. }
  45143. declare module BABYLON {
  45144. /**
  45145. * Single plane rotation gizmo
  45146. */
  45147. export class PlaneRotationGizmo extends Gizmo {
  45148. /**
  45149. * Drag behavior responsible for the gizmos dragging interactions
  45150. */
  45151. dragBehavior: PointerDragBehavior;
  45152. private _pointerObserver;
  45153. /**
  45154. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45155. */
  45156. snapDistance: number;
  45157. /**
  45158. * Event that fires each time the gizmo snaps to a new location.
  45159. * * snapDistance is the the change in distance
  45160. */
  45161. onSnapObservable: Observable<{
  45162. snapDistance: number;
  45163. }>;
  45164. private _isEnabled;
  45165. private _parent;
  45166. /**
  45167. * Creates a PlaneRotationGizmo
  45168. * @param gizmoLayer The utility layer the gizmo will be added to
  45169. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45170. * @param color The color of the gizmo
  45171. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45172. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45173. */
  45174. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45175. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45176. /**
  45177. * If the gizmo is enabled
  45178. */
  45179. isEnabled: boolean;
  45180. /**
  45181. * Disposes of the gizmo
  45182. */
  45183. dispose(): void;
  45184. }
  45185. }
  45186. declare module BABYLON {
  45187. /**
  45188. * Gizmo that enables rotating a mesh along 3 axis
  45189. */
  45190. export class RotationGizmo extends Gizmo {
  45191. /**
  45192. * Internal gizmo used for interactions on the x axis
  45193. */
  45194. xGizmo: PlaneRotationGizmo;
  45195. /**
  45196. * Internal gizmo used for interactions on the y axis
  45197. */
  45198. yGizmo: PlaneRotationGizmo;
  45199. /**
  45200. * Internal gizmo used for interactions on the z axis
  45201. */
  45202. zGizmo: PlaneRotationGizmo;
  45203. /** Fires an event when any of it's sub gizmos are dragged */
  45204. onDragStartObservable: Observable<unknown>;
  45205. /** Fires an event when any of it's sub gizmos are released from dragging */
  45206. onDragEndObservable: Observable<unknown>;
  45207. private _meshAttached;
  45208. attachedMesh: Nullable<AbstractMesh>;
  45209. /**
  45210. * Creates a RotationGizmo
  45211. * @param gizmoLayer The utility layer the gizmo will be added to
  45212. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45213. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45214. */
  45215. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45216. updateGizmoRotationToMatchAttachedMesh: boolean;
  45217. /**
  45218. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45219. */
  45220. snapDistance: number;
  45221. /**
  45222. * Ratio for the scale of the gizmo (Default: 1)
  45223. */
  45224. scaleRatio: number;
  45225. /**
  45226. * Disposes of the gizmo
  45227. */
  45228. dispose(): void;
  45229. /**
  45230. * CustomMeshes are not supported by this gizmo
  45231. * @param mesh The mesh to replace the default mesh of the gizmo
  45232. */
  45233. setCustomMesh(mesh: Mesh): void;
  45234. }
  45235. }
  45236. declare module BABYLON {
  45237. /**
  45238. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45239. */
  45240. export class GizmoManager implements IDisposable {
  45241. private scene;
  45242. /**
  45243. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45244. */
  45245. gizmos: {
  45246. positionGizmo: Nullable<PositionGizmo>;
  45247. rotationGizmo: Nullable<RotationGizmo>;
  45248. scaleGizmo: Nullable<ScaleGizmo>;
  45249. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45250. };
  45251. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45252. clearGizmoOnEmptyPointerEvent: boolean;
  45253. /** Fires an event when the manager is attached to a mesh */
  45254. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45255. private _gizmosEnabled;
  45256. private _pointerObserver;
  45257. private _attachedMesh;
  45258. private _boundingBoxColor;
  45259. private _defaultUtilityLayer;
  45260. private _defaultKeepDepthUtilityLayer;
  45261. /**
  45262. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45263. */
  45264. boundingBoxDragBehavior: SixDofDragBehavior;
  45265. /**
  45266. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45267. */
  45268. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45269. /**
  45270. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45271. */
  45272. usePointerToAttachGizmos: boolean;
  45273. /**
  45274. * Utility layer that the bounding box gizmo belongs to
  45275. */
  45276. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45277. /**
  45278. * Utility layer that all gizmos besides bounding box belong to
  45279. */
  45280. readonly utilityLayer: UtilityLayerRenderer;
  45281. /**
  45282. * Instatiates a gizmo manager
  45283. * @param scene the scene to overlay the gizmos on top of
  45284. */
  45285. constructor(scene: Scene);
  45286. /**
  45287. * Attaches a set of gizmos to the specified mesh
  45288. * @param mesh The mesh the gizmo's should be attached to
  45289. */
  45290. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45291. /**
  45292. * If the position gizmo is enabled
  45293. */
  45294. positionGizmoEnabled: boolean;
  45295. /**
  45296. * If the rotation gizmo is enabled
  45297. */
  45298. rotationGizmoEnabled: boolean;
  45299. /**
  45300. * If the scale gizmo is enabled
  45301. */
  45302. scaleGizmoEnabled: boolean;
  45303. /**
  45304. * If the boundingBox gizmo is enabled
  45305. */
  45306. boundingBoxGizmoEnabled: boolean;
  45307. /**
  45308. * Disposes of the gizmo manager
  45309. */
  45310. dispose(): void;
  45311. }
  45312. }
  45313. declare module BABYLON {
  45314. /**
  45315. * A directional light is defined by a direction (what a surprise!).
  45316. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45317. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  45318. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45319. */
  45320. export class DirectionalLight extends ShadowLight {
  45321. private _shadowFrustumSize;
  45322. /**
  45323. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45324. */
  45325. /**
  45326. * Specifies a fix frustum size for the shadow generation.
  45327. */
  45328. shadowFrustumSize: number;
  45329. private _shadowOrthoScale;
  45330. /**
  45331. * Gets the shadow projection scale against the optimal computed one.
  45332. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45333. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45334. */
  45335. /**
  45336. * Sets the shadow projection scale against the optimal computed one.
  45337. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45338. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45339. */
  45340. shadowOrthoScale: number;
  45341. /**
  45342. * Automatically compute the projection matrix to best fit (including all the casters)
  45343. * on each frame.
  45344. */
  45345. autoUpdateExtends: boolean;
  45346. private _orthoLeft;
  45347. private _orthoRight;
  45348. private _orthoTop;
  45349. private _orthoBottom;
  45350. /**
  45351. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45352. * The directional light is emitted from everywhere in the given direction.
  45353. * It can cast shadows.
  45354. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45355. * @param name The friendly name of the light
  45356. * @param direction The direction of the light
  45357. * @param scene The scene the light belongs to
  45358. */
  45359. constructor(name: string, direction: Vector3, scene: Scene);
  45360. /**
  45361. * Returns the string "DirectionalLight".
  45362. * @return The class name
  45363. */
  45364. getClassName(): string;
  45365. /**
  45366. * Returns the integer 1.
  45367. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45368. */
  45369. getTypeID(): number;
  45370. /**
  45371. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45372. * Returns the DirectionalLight Shadow projection matrix.
  45373. */
  45374. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45375. /**
  45376. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45377. * Returns the DirectionalLight Shadow projection matrix.
  45378. */
  45379. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45380. /**
  45381. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45382. * Returns the DirectionalLight Shadow projection matrix.
  45383. */
  45384. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45385. protected _buildUniformLayout(): void;
  45386. /**
  45387. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45388. * @param effect The effect to update
  45389. * @param lightIndex The index of the light in the effect to update
  45390. * @returns The directional light
  45391. */
  45392. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45393. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45394. /**
  45395. * Gets the minZ used for shadow according to both the scene and the light.
  45396. *
  45397. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45398. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45399. * @param activeCamera The camera we are returning the min for
  45400. * @returns the depth min z
  45401. */
  45402. getDepthMinZ(activeCamera: Camera): number;
  45403. /**
  45404. * Gets the maxZ used for shadow according to both the scene and the light.
  45405. *
  45406. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45407. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45408. * @param activeCamera The camera we are returning the max for
  45409. * @returns the depth max z
  45410. */
  45411. getDepthMaxZ(activeCamera: Camera): number;
  45412. /**
  45413. * Prepares the list of defines specific to the light type.
  45414. * @param defines the list of defines
  45415. * @param lightIndex defines the index of the light for the effect
  45416. */
  45417. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45418. }
  45419. }
  45420. declare module BABYLON {
  45421. /**
  45422. * Class containing static functions to help procedurally build meshes
  45423. */
  45424. export class HemisphereBuilder {
  45425. /**
  45426. * Creates a hemisphere mesh
  45427. * @param name defines the name of the mesh
  45428. * @param options defines the options used to create the mesh
  45429. * @param scene defines the hosting scene
  45430. * @returns the hemisphere mesh
  45431. */
  45432. static CreateHemisphere(name: string, options: {
  45433. segments?: number;
  45434. diameter?: number;
  45435. sideOrientation?: number;
  45436. }, scene: any): Mesh;
  45437. }
  45438. }
  45439. declare module BABYLON {
  45440. /**
  45441. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45442. * These values define a cone of light starting from the position, emitting toward the direction.
  45443. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45444. * and the exponent defines the speed of the decay of the light with distance (reach).
  45445. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45446. */
  45447. export class SpotLight extends ShadowLight {
  45448. private _angle;
  45449. private _innerAngle;
  45450. private _cosHalfAngle;
  45451. private _lightAngleScale;
  45452. private _lightAngleOffset;
  45453. /**
  45454. * Gets the cone angle of the spot light in Radians.
  45455. */
  45456. /**
  45457. * Sets the cone angle of the spot light in Radians.
  45458. */
  45459. angle: number;
  45460. /**
  45461. * Only used in gltf falloff mode, this defines the angle where
  45462. * the directional falloff will start before cutting at angle which could be seen
  45463. * as outer angle.
  45464. */
  45465. /**
  45466. * Only used in gltf falloff mode, this defines the angle where
  45467. * the directional falloff will start before cutting at angle which could be seen
  45468. * as outer angle.
  45469. */
  45470. innerAngle: number;
  45471. private _shadowAngleScale;
  45472. /**
  45473. * Allows scaling the angle of the light for shadow generation only.
  45474. */
  45475. /**
  45476. * Allows scaling the angle of the light for shadow generation only.
  45477. */
  45478. shadowAngleScale: number;
  45479. /**
  45480. * The light decay speed with the distance from the emission spot.
  45481. */
  45482. exponent: number;
  45483. private _projectionTextureMatrix;
  45484. /**
  45485. * Allows reading the projecton texture
  45486. */
  45487. readonly projectionTextureMatrix: Matrix;
  45488. protected _projectionTextureLightNear: number;
  45489. /**
  45490. * Gets the near clip of the Spotlight for texture projection.
  45491. */
  45492. /**
  45493. * Sets the near clip of the Spotlight for texture projection.
  45494. */
  45495. projectionTextureLightNear: number;
  45496. protected _projectionTextureLightFar: number;
  45497. /**
  45498. * Gets the far clip of the Spotlight for texture projection.
  45499. */
  45500. /**
  45501. * Sets the far clip of the Spotlight for texture projection.
  45502. */
  45503. projectionTextureLightFar: number;
  45504. protected _projectionTextureUpDirection: Vector3;
  45505. /**
  45506. * Gets the Up vector of the Spotlight for texture projection.
  45507. */
  45508. /**
  45509. * Sets the Up vector of the Spotlight for texture projection.
  45510. */
  45511. projectionTextureUpDirection: Vector3;
  45512. private _projectionTexture;
  45513. /**
  45514. * Gets the projection texture of the light.
  45515. */
  45516. /**
  45517. * Sets the projection texture of the light.
  45518. */
  45519. projectionTexture: Nullable<BaseTexture>;
  45520. private _projectionTextureViewLightDirty;
  45521. private _projectionTextureProjectionLightDirty;
  45522. private _projectionTextureDirty;
  45523. private _projectionTextureViewTargetVector;
  45524. private _projectionTextureViewLightMatrix;
  45525. private _projectionTextureProjectionLightMatrix;
  45526. private _projectionTextureScalingMatrix;
  45527. /**
  45528. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45529. * It can cast shadows.
  45530. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45531. * @param name The light friendly name
  45532. * @param position The position of the spot light in the scene
  45533. * @param direction The direction of the light in the scene
  45534. * @param angle The cone angle of the light in Radians
  45535. * @param exponent The light decay speed with the distance from the emission spot
  45536. * @param scene The scene the lights belongs to
  45537. */
  45538. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45539. /**
  45540. * Returns the string "SpotLight".
  45541. * @returns the class name
  45542. */
  45543. getClassName(): string;
  45544. /**
  45545. * Returns the integer 2.
  45546. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45547. */
  45548. getTypeID(): number;
  45549. /**
  45550. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45551. */
  45552. protected _setDirection(value: Vector3): void;
  45553. /**
  45554. * Overrides the position setter to recompute the projection texture view light Matrix.
  45555. */
  45556. protected _setPosition(value: Vector3): void;
  45557. /**
  45558. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  45559. * Returns the SpotLight.
  45560. */
  45561. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45562. protected _computeProjectionTextureViewLightMatrix(): void;
  45563. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45564. /**
  45565. * Main function for light texture projection matrix computing.
  45566. */
  45567. protected _computeProjectionTextureMatrix(): void;
  45568. protected _buildUniformLayout(): void;
  45569. private _computeAngleValues;
  45570. /**
  45571. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45572. * @param effect The effect to update
  45573. * @param lightIndex The index of the light in the effect to update
  45574. * @returns The spot light
  45575. */
  45576. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45577. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45578. /**
  45579. * Disposes the light and the associated resources.
  45580. */
  45581. dispose(): void;
  45582. /**
  45583. * Prepares the list of defines specific to the light type.
  45584. * @param defines the list of defines
  45585. * @param lightIndex defines the index of the light for the effect
  45586. */
  45587. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45588. }
  45589. }
  45590. declare module BABYLON {
  45591. /**
  45592. * Gizmo that enables viewing a light
  45593. */
  45594. export class LightGizmo extends Gizmo {
  45595. private _lightMesh;
  45596. private _material;
  45597. private cachedPosition;
  45598. private cachedForward;
  45599. /**
  45600. * Creates a LightGizmo
  45601. * @param gizmoLayer The utility layer the gizmo will be added to
  45602. */
  45603. constructor(gizmoLayer?: UtilityLayerRenderer);
  45604. private _light;
  45605. /**
  45606. * The light that the gizmo is attached to
  45607. */
  45608. light: Nullable<Light>;
  45609. /**
  45610. * Gets the material used to render the light gizmo
  45611. */
  45612. readonly material: StandardMaterial;
  45613. /**
  45614. * @hidden
  45615. * Updates the gizmo to match the attached mesh's position/rotation
  45616. */
  45617. protected _update(): void;
  45618. private static _Scale;
  45619. /**
  45620. * Creates the lines for a light mesh
  45621. */
  45622. private static _createLightLines;
  45623. /**
  45624. * Disposes of the light gizmo
  45625. */
  45626. dispose(): void;
  45627. private static _CreateHemisphericLightMesh;
  45628. private static _CreatePointLightMesh;
  45629. private static _CreateSpotLightMesh;
  45630. private static _CreateDirectionalLightMesh;
  45631. }
  45632. }
  45633. declare module BABYLON {
  45634. /** @hidden */
  45635. export var backgroundFragmentDeclaration: {
  45636. name: string;
  45637. shader: string;
  45638. };
  45639. }
  45640. declare module BABYLON {
  45641. /** @hidden */
  45642. export var backgroundUboDeclaration: {
  45643. name: string;
  45644. shader: string;
  45645. };
  45646. }
  45647. declare module BABYLON {
  45648. /** @hidden */
  45649. export var backgroundPixelShader: {
  45650. name: string;
  45651. shader: string;
  45652. };
  45653. }
  45654. declare module BABYLON {
  45655. /** @hidden */
  45656. export var backgroundVertexDeclaration: {
  45657. name: string;
  45658. shader: string;
  45659. };
  45660. }
  45661. declare module BABYLON {
  45662. /** @hidden */
  45663. export var backgroundVertexShader: {
  45664. name: string;
  45665. shader: string;
  45666. };
  45667. }
  45668. declare module BABYLON {
  45669. /**
  45670. * Background material used to create an efficient environement around your scene.
  45671. */
  45672. export class BackgroundMaterial extends PushMaterial {
  45673. /**
  45674. * Standard reflectance value at parallel view angle.
  45675. */
  45676. static StandardReflectance0: number;
  45677. /**
  45678. * Standard reflectance value at grazing angle.
  45679. */
  45680. static StandardReflectance90: number;
  45681. protected _primaryColor: Color3;
  45682. /**
  45683. * Key light Color (multiply against the environement texture)
  45684. */
  45685. primaryColor: Color3;
  45686. protected __perceptualColor: Nullable<Color3>;
  45687. /**
  45688. * Experimental Internal Use Only.
  45689. *
  45690. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45691. * This acts as a helper to set the primary color to a more "human friendly" value.
  45692. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45693. * output color as close as possible from the chosen value.
  45694. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45695. * part of lighting setup.)
  45696. */ private _perceptualColor: Nullable<Color3>;
  45697. protected _primaryColorShadowLevel: float;
  45698. /**
  45699. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45700. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45701. */
  45702. primaryColorShadowLevel: float;
  45703. protected _primaryColorHighlightLevel: float;
  45704. /**
  45705. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45706. * The primary color is used at the level chosen to define what the white area would look.
  45707. */
  45708. primaryColorHighlightLevel: float;
  45709. protected _reflectionTexture: Nullable<BaseTexture>;
  45710. /**
  45711. * Reflection Texture used in the material.
  45712. * Should be author in a specific way for the best result (refer to the documentation).
  45713. */
  45714. reflectionTexture: Nullable<BaseTexture>;
  45715. protected _reflectionBlur: float;
  45716. /**
  45717. * Reflection Texture level of blur.
  45718. *
  45719. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45720. * texture twice.
  45721. */
  45722. reflectionBlur: float;
  45723. protected _diffuseTexture: Nullable<BaseTexture>;
  45724. /**
  45725. * Diffuse Texture used in the material.
  45726. * Should be author in a specific way for the best result (refer to the documentation).
  45727. */
  45728. diffuseTexture: Nullable<BaseTexture>;
  45729. protected _shadowLights: Nullable<IShadowLight[]>;
  45730. /**
  45731. * Specify the list of lights casting shadow on the material.
  45732. * All scene shadow lights will be included if null.
  45733. */
  45734. shadowLights: Nullable<IShadowLight[]>;
  45735. protected _shadowLevel: float;
  45736. /**
  45737. * Helps adjusting the shadow to a softer level if required.
  45738. * 0 means black shadows and 1 means no shadows.
  45739. */
  45740. shadowLevel: float;
  45741. protected _sceneCenter: Vector3;
  45742. /**
  45743. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45744. * It is usually zero but might be interesting to modify according to your setup.
  45745. */
  45746. sceneCenter: Vector3;
  45747. protected _opacityFresnel: boolean;
  45748. /**
  45749. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45750. * This helps ensuring a nice transition when the camera goes under the ground.
  45751. */
  45752. opacityFresnel: boolean;
  45753. protected _reflectionFresnel: boolean;
  45754. /**
  45755. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45756. * This helps adding a mirror texture on the ground.
  45757. */
  45758. reflectionFresnel: boolean;
  45759. protected _reflectionFalloffDistance: number;
  45760. /**
  45761. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45762. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45763. */
  45764. reflectionFalloffDistance: number;
  45765. protected _reflectionAmount: number;
  45766. /**
  45767. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45768. */
  45769. reflectionAmount: number;
  45770. protected _reflectionReflectance0: number;
  45771. /**
  45772. * This specifies the weight of the reflection at grazing angle.
  45773. */
  45774. reflectionReflectance0: number;
  45775. protected _reflectionReflectance90: number;
  45776. /**
  45777. * This specifies the weight of the reflection at a perpendicular point of view.
  45778. */
  45779. reflectionReflectance90: number;
  45780. /**
  45781. * Sets the reflection reflectance fresnel values according to the default standard
  45782. * empirically know to work well :-)
  45783. */
  45784. reflectionStandardFresnelWeight: number;
  45785. protected _useRGBColor: boolean;
  45786. /**
  45787. * Helps to directly use the maps channels instead of their level.
  45788. */
  45789. useRGBColor: boolean;
  45790. protected _enableNoise: boolean;
  45791. /**
  45792. * This helps reducing the banding effect that could occur on the background.
  45793. */
  45794. enableNoise: boolean;
  45795. /**
  45796. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45797. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45798. * Recommended to be keep at 1.0 except for special cases.
  45799. */
  45800. fovMultiplier: number;
  45801. private _fovMultiplier;
  45802. /**
  45803. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45804. */
  45805. useEquirectangularFOV: boolean;
  45806. private _maxSimultaneousLights;
  45807. /**
  45808. * Number of Simultaneous lights allowed on the material.
  45809. */
  45810. maxSimultaneousLights: int;
  45811. /**
  45812. * Default configuration related to image processing available in the Background Material.
  45813. */
  45814. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45815. /**
  45816. * Keep track of the image processing observer to allow dispose and replace.
  45817. */
  45818. private _imageProcessingObserver;
  45819. /**
  45820. * Attaches a new image processing configuration to the PBR Material.
  45821. * @param configuration (if null the scene configuration will be use)
  45822. */
  45823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45824. /**
  45825. * Gets the image processing configuration used either in this material.
  45826. */
  45827. /**
  45828. * Sets the Default image processing configuration used either in the this material.
  45829. *
  45830. * If sets to null, the scene one is in use.
  45831. */
  45832. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45833. /**
  45834. * Gets wether the color curves effect is enabled.
  45835. */
  45836. /**
  45837. * Sets wether the color curves effect is enabled.
  45838. */
  45839. cameraColorCurvesEnabled: boolean;
  45840. /**
  45841. * Gets wether the color grading effect is enabled.
  45842. */
  45843. /**
  45844. * Gets wether the color grading effect is enabled.
  45845. */
  45846. cameraColorGradingEnabled: boolean;
  45847. /**
  45848. * Gets wether tonemapping is enabled or not.
  45849. */
  45850. /**
  45851. * Sets wether tonemapping is enabled or not
  45852. */
  45853. cameraToneMappingEnabled: boolean;
  45854. /**
  45855. * The camera exposure used on this material.
  45856. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45857. * This corresponds to a photographic exposure.
  45858. */
  45859. /**
  45860. * The camera exposure used on this material.
  45861. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45862. * This corresponds to a photographic exposure.
  45863. */
  45864. cameraExposure: float;
  45865. /**
  45866. * Gets The camera contrast used on this material.
  45867. */
  45868. /**
  45869. * Sets The camera contrast used on this material.
  45870. */
  45871. cameraContrast: float;
  45872. /**
  45873. * Gets the Color Grading 2D Lookup Texture.
  45874. */
  45875. /**
  45876. * Sets the Color Grading 2D Lookup Texture.
  45877. */
  45878. cameraColorGradingTexture: Nullable<BaseTexture>;
  45879. /**
  45880. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45881. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45882. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  45883. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45884. */
  45885. /**
  45886. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45887. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45888. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  45889. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45890. */
  45891. cameraColorCurves: Nullable<ColorCurves>;
  45892. /**
  45893. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45894. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45895. */
  45896. switchToBGR: boolean;
  45897. private _renderTargets;
  45898. private _reflectionControls;
  45899. private _white;
  45900. private _primaryShadowColor;
  45901. private _primaryHighlightColor;
  45902. /**
  45903. * Instantiates a Background Material in the given scene
  45904. * @param name The friendly name of the material
  45905. * @param scene The scene to add the material to
  45906. */
  45907. constructor(name: string, scene: Scene);
  45908. /**
  45909. * Gets a boolean indicating that current material needs to register RTT
  45910. */
  45911. readonly hasRenderTargetTextures: boolean;
  45912. /**
  45913. * The entire material has been created in order to prevent overdraw.
  45914. * @returns false
  45915. */
  45916. needAlphaTesting(): boolean;
  45917. /**
  45918. * The entire material has been created in order to prevent overdraw.
  45919. * @returns true if blending is enable
  45920. */
  45921. needAlphaBlending(): boolean;
  45922. /**
  45923. * Checks wether the material is ready to be rendered for a given mesh.
  45924. * @param mesh The mesh to render
  45925. * @param subMesh The submesh to check against
  45926. * @param useInstances Specify wether or not the material is used with instances
  45927. * @returns true if all the dependencies are ready (Textures, Effects...)
  45928. */
  45929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45930. /**
  45931. * Compute the primary color according to the chosen perceptual color.
  45932. */
  45933. private _computePrimaryColorFromPerceptualColor;
  45934. /**
  45935. * Compute the highlights and shadow colors according to their chosen levels.
  45936. */
  45937. private _computePrimaryColors;
  45938. /**
  45939. * Build the uniform buffer used in the material.
  45940. */
  45941. buildUniformLayout(): void;
  45942. /**
  45943. * Unbind the material.
  45944. */
  45945. unbind(): void;
  45946. /**
  45947. * Bind only the world matrix to the material.
  45948. * @param world The world matrix to bind.
  45949. */
  45950. bindOnlyWorldMatrix(world: Matrix): void;
  45951. /**
  45952. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45953. * @param world The world matrix to bind.
  45954. * @param subMesh The submesh to bind for.
  45955. */
  45956. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45957. /**
  45958. * Checks to see if a texture is used in the material.
  45959. * @param texture - Base texture to use.
  45960. * @returns - Boolean specifying if a texture is used in the material.
  45961. */
  45962. hasTexture(texture: BaseTexture): boolean;
  45963. /**
  45964. * Dispose the material.
  45965. * @param forceDisposeEffect Force disposal of the associated effect.
  45966. * @param forceDisposeTextures Force disposal of the associated textures.
  45967. */
  45968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45969. /**
  45970. * Clones the material.
  45971. * @param name The cloned name.
  45972. * @returns The cloned material.
  45973. */
  45974. clone(name: string): BackgroundMaterial;
  45975. /**
  45976. * Serializes the current material to its JSON representation.
  45977. * @returns The JSON representation.
  45978. */
  45979. serialize(): any;
  45980. /**
  45981. * Gets the class name of the material
  45982. * @returns "BackgroundMaterial"
  45983. */
  45984. getClassName(): string;
  45985. /**
  45986. * Parse a JSON input to create back a background material.
  45987. * @param source The JSON data to parse
  45988. * @param scene The scene to create the parsed material in
  45989. * @param rootUrl The root url of the assets the material depends upon
  45990. * @returns the instantiated BackgroundMaterial.
  45991. */
  45992. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45993. }
  45994. }
  45995. declare module BABYLON {
  45996. /**
  45997. * Represents the different options available during the creation of
  45998. * a Environment helper.
  45999. *
  46000. * This can control the default ground, skybox and image processing setup of your scene.
  46001. */
  46002. export interface IEnvironmentHelperOptions {
  46003. /**
  46004. * Specifies wether or not to create a ground.
  46005. * True by default.
  46006. */
  46007. createGround: boolean;
  46008. /**
  46009. * Specifies the ground size.
  46010. * 15 by default.
  46011. */
  46012. groundSize: number;
  46013. /**
  46014. * The texture used on the ground for the main color.
  46015. * Comes from the BabylonJS CDN by default.
  46016. *
  46017. * Remarks: Can be either a texture or a url.
  46018. */
  46019. groundTexture: string | BaseTexture;
  46020. /**
  46021. * The color mixed in the ground texture by default.
  46022. * BabylonJS clearColor by default.
  46023. */
  46024. groundColor: Color3;
  46025. /**
  46026. * Specifies the ground opacity.
  46027. * 1 by default.
  46028. */
  46029. groundOpacity: number;
  46030. /**
  46031. * Enables the ground to receive shadows.
  46032. * True by default.
  46033. */
  46034. enableGroundShadow: boolean;
  46035. /**
  46036. * Helps preventing the shadow to be fully black on the ground.
  46037. * 0.5 by default.
  46038. */
  46039. groundShadowLevel: number;
  46040. /**
  46041. * Creates a mirror texture attach to the ground.
  46042. * false by default.
  46043. */
  46044. enableGroundMirror: boolean;
  46045. /**
  46046. * Specifies the ground mirror size ratio.
  46047. * 0.3 by default as the default kernel is 64.
  46048. */
  46049. groundMirrorSizeRatio: number;
  46050. /**
  46051. * Specifies the ground mirror blur kernel size.
  46052. * 64 by default.
  46053. */
  46054. groundMirrorBlurKernel: number;
  46055. /**
  46056. * Specifies the ground mirror visibility amount.
  46057. * 1 by default
  46058. */
  46059. groundMirrorAmount: number;
  46060. /**
  46061. * Specifies the ground mirror reflectance weight.
  46062. * This uses the standard weight of the background material to setup the fresnel effect
  46063. * of the mirror.
  46064. * 1 by default.
  46065. */
  46066. groundMirrorFresnelWeight: number;
  46067. /**
  46068. * Specifies the ground mirror Falloff distance.
  46069. * This can helps reducing the size of the reflection.
  46070. * 0 by Default.
  46071. */
  46072. groundMirrorFallOffDistance: number;
  46073. /**
  46074. * Specifies the ground mirror texture type.
  46075. * Unsigned Int by Default.
  46076. */
  46077. groundMirrorTextureType: number;
  46078. /**
  46079. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46080. * the shown objects.
  46081. */
  46082. groundYBias: number;
  46083. /**
  46084. * Specifies wether or not to create a skybox.
  46085. * True by default.
  46086. */
  46087. createSkybox: boolean;
  46088. /**
  46089. * Specifies the skybox size.
  46090. * 20 by default.
  46091. */
  46092. skyboxSize: number;
  46093. /**
  46094. * The texture used on the skybox for the main color.
  46095. * Comes from the BabylonJS CDN by default.
  46096. *
  46097. * Remarks: Can be either a texture or a url.
  46098. */
  46099. skyboxTexture: string | BaseTexture;
  46100. /**
  46101. * The color mixed in the skybox texture by default.
  46102. * BabylonJS clearColor by default.
  46103. */
  46104. skyboxColor: Color3;
  46105. /**
  46106. * The background rotation around the Y axis of the scene.
  46107. * This helps aligning the key lights of your scene with the background.
  46108. * 0 by default.
  46109. */
  46110. backgroundYRotation: number;
  46111. /**
  46112. * Compute automatically the size of the elements to best fit with the scene.
  46113. */
  46114. sizeAuto: boolean;
  46115. /**
  46116. * Default position of the rootMesh if autoSize is not true.
  46117. */
  46118. rootPosition: Vector3;
  46119. /**
  46120. * Sets up the image processing in the scene.
  46121. * true by default.
  46122. */
  46123. setupImageProcessing: boolean;
  46124. /**
  46125. * The texture used as your environment texture in the scene.
  46126. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46127. *
  46128. * Remarks: Can be either a texture or a url.
  46129. */
  46130. environmentTexture: string | BaseTexture;
  46131. /**
  46132. * The value of the exposure to apply to the scene.
  46133. * 0.6 by default if setupImageProcessing is true.
  46134. */
  46135. cameraExposure: number;
  46136. /**
  46137. * The value of the contrast to apply to the scene.
  46138. * 1.6 by default if setupImageProcessing is true.
  46139. */
  46140. cameraContrast: number;
  46141. /**
  46142. * Specifies wether or not tonemapping should be enabled in the scene.
  46143. * true by default if setupImageProcessing is true.
  46144. */
  46145. toneMappingEnabled: boolean;
  46146. }
  46147. /**
  46148. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46149. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46150. * It also helps with the default setup of your imageProcessing configuration.
  46151. */
  46152. export class EnvironmentHelper {
  46153. /**
  46154. * Default ground texture URL.
  46155. */
  46156. private static _groundTextureCDNUrl;
  46157. /**
  46158. * Default skybox texture URL.
  46159. */
  46160. private static _skyboxTextureCDNUrl;
  46161. /**
  46162. * Default environment texture URL.
  46163. */
  46164. private static _environmentTextureCDNUrl;
  46165. /**
  46166. * Creates the default options for the helper.
  46167. */
  46168. private static _getDefaultOptions;
  46169. private _rootMesh;
  46170. /**
  46171. * Gets the root mesh created by the helper.
  46172. */
  46173. readonly rootMesh: Mesh;
  46174. private _skybox;
  46175. /**
  46176. * Gets the skybox created by the helper.
  46177. */
  46178. readonly skybox: Nullable<Mesh>;
  46179. private _skyboxTexture;
  46180. /**
  46181. * Gets the skybox texture created by the helper.
  46182. */
  46183. readonly skyboxTexture: Nullable<BaseTexture>;
  46184. private _skyboxMaterial;
  46185. /**
  46186. * Gets the skybox material created by the helper.
  46187. */
  46188. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46189. private _ground;
  46190. /**
  46191. * Gets the ground mesh created by the helper.
  46192. */
  46193. readonly ground: Nullable<Mesh>;
  46194. private _groundTexture;
  46195. /**
  46196. * Gets the ground texture created by the helper.
  46197. */
  46198. readonly groundTexture: Nullable<BaseTexture>;
  46199. private _groundMirror;
  46200. /**
  46201. * Gets the ground mirror created by the helper.
  46202. */
  46203. readonly groundMirror: Nullable<MirrorTexture>;
  46204. /**
  46205. * Gets the ground mirror render list to helps pushing the meshes
  46206. * you wish in the ground reflection.
  46207. */
  46208. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46209. private _groundMaterial;
  46210. /**
  46211. * Gets the ground material created by the helper.
  46212. */
  46213. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46214. /**
  46215. * Stores the creation options.
  46216. */
  46217. private readonly _scene;
  46218. private _options;
  46219. /**
  46220. * This observable will be notified with any error during the creation of the environment,
  46221. * mainly texture creation errors.
  46222. */
  46223. onErrorObservable: Observable<{
  46224. message?: string;
  46225. exception?: any;
  46226. }>;
  46227. /**
  46228. * constructor
  46229. * @param options Defines the options we want to customize the helper
  46230. * @param scene The scene to add the material to
  46231. */
  46232. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46233. /**
  46234. * Updates the background according to the new options
  46235. * @param options
  46236. */
  46237. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46238. /**
  46239. * Sets the primary color of all the available elements.
  46240. * @param color the main color to affect to the ground and the background
  46241. */
  46242. setMainColor(color: Color3): void;
  46243. /**
  46244. * Setup the image processing according to the specified options.
  46245. */
  46246. private _setupImageProcessing;
  46247. /**
  46248. * Setup the environment texture according to the specified options.
  46249. */
  46250. private _setupEnvironmentTexture;
  46251. /**
  46252. * Setup the background according to the specified options.
  46253. */
  46254. private _setupBackground;
  46255. /**
  46256. * Get the scene sizes according to the setup.
  46257. */
  46258. private _getSceneSize;
  46259. /**
  46260. * Setup the ground according to the specified options.
  46261. */
  46262. private _setupGround;
  46263. /**
  46264. * Setup the ground material according to the specified options.
  46265. */
  46266. private _setupGroundMaterial;
  46267. /**
  46268. * Setup the ground diffuse texture according to the specified options.
  46269. */
  46270. private _setupGroundDiffuseTexture;
  46271. /**
  46272. * Setup the ground mirror texture according to the specified options.
  46273. */
  46274. private _setupGroundMirrorTexture;
  46275. /**
  46276. * Setup the ground to receive the mirror texture.
  46277. */
  46278. private _setupMirrorInGroundMaterial;
  46279. /**
  46280. * Setup the skybox according to the specified options.
  46281. */
  46282. private _setupSkybox;
  46283. /**
  46284. * Setup the skybox material according to the specified options.
  46285. */
  46286. private _setupSkyboxMaterial;
  46287. /**
  46288. * Setup the skybox reflection texture according to the specified options.
  46289. */
  46290. private _setupSkyboxReflectionTexture;
  46291. private _errorHandler;
  46292. /**
  46293. * Dispose all the elements created by the Helper.
  46294. */
  46295. dispose(): void;
  46296. }
  46297. }
  46298. declare module BABYLON {
  46299. /**
  46300. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46301. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46302. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46303. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46304. */
  46305. export class PhotoDome extends TransformNode {
  46306. /**
  46307. * Define the image as a Monoscopic panoramic 360 image.
  46308. */
  46309. static readonly MODE_MONOSCOPIC: number;
  46310. /**
  46311. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46312. */
  46313. static readonly MODE_TOPBOTTOM: number;
  46314. /**
  46315. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46316. */
  46317. static readonly MODE_SIDEBYSIDE: number;
  46318. private _useDirectMapping;
  46319. /**
  46320. * The texture being displayed on the sphere
  46321. */
  46322. protected _photoTexture: Texture;
  46323. /**
  46324. * Gets or sets the texture being displayed on the sphere
  46325. */
  46326. photoTexture: Texture;
  46327. /**
  46328. * Observable raised when an error occured while loading the 360 image
  46329. */
  46330. onLoadErrorObservable: Observable<string>;
  46331. /**
  46332. * The skybox material
  46333. */
  46334. protected _material: BackgroundMaterial;
  46335. /**
  46336. * The surface used for the skybox
  46337. */
  46338. protected _mesh: Mesh;
  46339. /**
  46340. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46341. * Also see the options.resolution property.
  46342. */
  46343. fovMultiplier: number;
  46344. private _imageMode;
  46345. /**
  46346. * Gets or set the current video mode for the video. It can be:
  46347. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46348. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46349. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46350. */
  46351. imageMode: number;
  46352. /**
  46353. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46354. * @param name Element's name, child elements will append suffixes for their own names.
  46355. * @param urlsOfPhoto defines the url of the photo to display
  46356. * @param options defines an object containing optional or exposed sub element properties
  46357. * @param onError defines a callback called when an error occured while loading the texture
  46358. */
  46359. constructor(name: string, urlOfPhoto: string, options: {
  46360. resolution?: number;
  46361. size?: number;
  46362. useDirectMapping?: boolean;
  46363. faceForward?: boolean;
  46364. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46365. private _onBeforeCameraRenderObserver;
  46366. private _changeImageMode;
  46367. /**
  46368. * Releases resources associated with this node.
  46369. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46370. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46371. */
  46372. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46373. }
  46374. }
  46375. declare module BABYLON {
  46376. /**
  46377. * Class used to host RGBD texture specific utilities
  46378. */
  46379. export class RGBDTextureTools {
  46380. /**
  46381. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46382. * @param texture the texture to expand.
  46383. */
  46384. static ExpandRGBDTexture(texture: Texture): void;
  46385. }
  46386. }
  46387. declare module BABYLON {
  46388. /**
  46389. * Class used to host texture specific utilities
  46390. */
  46391. export class BRDFTextureTools {
  46392. /**
  46393. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46394. * @param scene defines the hosting scene
  46395. * @returns the environment BRDF texture
  46396. */
  46397. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46398. private static _environmentBRDFBase64Texture;
  46399. }
  46400. }
  46401. declare module BABYLON {
  46402. /**
  46403. * @hidden
  46404. */
  46405. export interface IMaterialClearCoatDefines {
  46406. CLEARCOAT: boolean;
  46407. CLEARCOAT_DEFAULTIOR: boolean;
  46408. CLEARCOAT_TEXTURE: boolean;
  46409. CLEARCOAT_TEXTUREDIRECTUV: number;
  46410. CLEARCOAT_BUMP: boolean;
  46411. CLEARCOAT_BUMPDIRECTUV: number;
  46412. CLEARCOAT_TINT: boolean;
  46413. CLEARCOAT_TINT_TEXTURE: boolean;
  46414. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46415. /** @hidden */ private _areTexturesDirty: boolean;
  46416. }
  46417. /**
  46418. * Define the code related to the clear coat parameters of the pbr material.
  46419. */
  46420. export class PBRClearCoatConfiguration {
  46421. /**
  46422. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46423. * The default fits with a polyurethane material.
  46424. */
  46425. private static readonly _DefaultIndexOfRefraction;
  46426. private _isEnabled;
  46427. /**
  46428. * Defines if the clear coat is enabled in the material.
  46429. */
  46430. isEnabled: boolean;
  46431. /**
  46432. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46433. */
  46434. intensity: number;
  46435. /**
  46436. * Defines the clear coat layer roughness.
  46437. */
  46438. roughness: number;
  46439. private _indexOfRefraction;
  46440. /**
  46441. * Defines the index of refraction of the clear coat.
  46442. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46443. * The default fits with a polyurethane material.
  46444. * Changing the default value is more performance intensive.
  46445. */
  46446. indexOfRefraction: number;
  46447. private _texture;
  46448. /**
  46449. * Stores the clear coat values in a texture.
  46450. */
  46451. texture: Nullable<BaseTexture>;
  46452. private _bumpTexture;
  46453. /**
  46454. * Define the clear coat specific bump texture.
  46455. */
  46456. bumpTexture: Nullable<BaseTexture>;
  46457. private _isTintEnabled;
  46458. /**
  46459. * Defines if the clear coat tint is enabled in the material.
  46460. */
  46461. isTintEnabled: boolean;
  46462. /**
  46463. * Defines the clear coat tint of the material.
  46464. * This is only use if tint is enabled
  46465. */
  46466. tintColor: Color3;
  46467. /**
  46468. * Defines the distance at which the tint color should be found in the
  46469. * clear coat media.
  46470. * This is only use if tint is enabled
  46471. */
  46472. tintColorAtDistance: number;
  46473. /**
  46474. * Defines the clear coat layer thickness.
  46475. * This is only use if tint is enabled
  46476. */
  46477. tintThickness: number;
  46478. private _tintTexture;
  46479. /**
  46480. * Stores the clear tint values in a texture.
  46481. * rgb is tint
  46482. * a is a thickness factor
  46483. */
  46484. tintTexture: Nullable<BaseTexture>;
  46485. /** @hidden */
  46486. private _internalMarkAllSubMeshesAsTexturesDirty;
  46487. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46488. /**
  46489. * Instantiate a new istance of clear coat configuration.
  46490. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46491. */
  46492. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46493. /**
  46494. * Gets wehter the submesh is ready to be used or not.
  46495. * @param defines the list of "defines" to update.
  46496. * @param scene defines the scene the material belongs to.
  46497. * @param engine defines the engine the material belongs to.
  46498. * @param disableBumpMap defines wether the material disables bump or not.
  46499. * @returns - boolean indicating that the submesh is ready or not.
  46500. */
  46501. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46502. /**
  46503. * Checks to see if a texture is used in the material.
  46504. * @param defines the list of "defines" to update.
  46505. * @param scene defines the scene to the material belongs to.
  46506. */
  46507. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46508. /**
  46509. * Binds the material data.
  46510. * @param uniformBuffer defines the Uniform buffer to fill in.
  46511. * @param scene defines the scene the material belongs to.
  46512. * @param engine defines the engine the material belongs to.
  46513. * @param disableBumpMap defines wether the material disables bump or not.
  46514. * @param isFrozen defines wether the material is frozen or not.
  46515. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46516. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46517. */
  46518. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46519. /**
  46520. * Checks to see if a texture is used in the material.
  46521. * @param texture - Base texture to use.
  46522. * @returns - Boolean specifying if a texture is used in the material.
  46523. */
  46524. hasTexture(texture: BaseTexture): boolean;
  46525. /**
  46526. * Returns an array of the actively used textures.
  46527. * @param activeTextures Array of BaseTextures
  46528. */
  46529. getActiveTextures(activeTextures: BaseTexture[]): void;
  46530. /**
  46531. * Returns the animatable textures.
  46532. * @param animatables Array of animatable textures.
  46533. */
  46534. getAnimatables(animatables: IAnimatable[]): void;
  46535. /**
  46536. * Disposes the resources of the material.
  46537. * @param forceDisposeTextures - Forces the disposal of all textures.
  46538. */
  46539. dispose(forceDisposeTextures?: boolean): void;
  46540. /**
  46541. * Get the current class name of the texture useful for serialization or dynamic coding.
  46542. * @returns "PBRClearCoatConfiguration"
  46543. */
  46544. getClassName(): string;
  46545. /**
  46546. * Add fallbacks to the effect fallbacks list.
  46547. * @param defines defines the Base texture to use.
  46548. * @param fallbacks defines the current fallback list.
  46549. * @param currentRank defines the current fallback rank.
  46550. * @returns the new fallback rank.
  46551. */
  46552. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46553. /**
  46554. * Add the required uniforms to the current list.
  46555. * @param uniforms defines the current uniform list.
  46556. */
  46557. static AddUniforms(uniforms: string[]): void;
  46558. /**
  46559. * Add the required samplers to the current list.
  46560. * @param samplers defines the current sampler list.
  46561. */
  46562. static AddSamplers(samplers: string[]): void;
  46563. /**
  46564. * Add the required uniforms to the current buffer.
  46565. * @param uniformBuffer defines the current uniform buffer.
  46566. */
  46567. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46568. /**
  46569. * Makes a duplicate of the current configuration into another one.
  46570. * @param clearCoatConfiguration define the config where to copy the info
  46571. */
  46572. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46573. /**
  46574. * Serializes this clear coat configuration.
  46575. * @returns - An object with the serialized config.
  46576. */
  46577. serialize(): any;
  46578. /**
  46579. * Parses a anisotropy Configuration from a serialized object.
  46580. * @param source - Serialized object.
  46581. * @param scene Defines the scene we are parsing for
  46582. * @param rootUrl Defines the rootUrl to load from
  46583. */
  46584. parse(source: any, scene: Scene, rootUrl: string): void;
  46585. }
  46586. }
  46587. declare module BABYLON {
  46588. /**
  46589. * @hidden
  46590. */
  46591. export interface IMaterialAnisotropicDefines {
  46592. ANISOTROPIC: boolean;
  46593. ANISOTROPIC_TEXTURE: boolean;
  46594. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46595. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  46596. }
  46597. /**
  46598. * Define the code related to the anisotropic parameters of the pbr material.
  46599. */
  46600. export class PBRAnisotropicConfiguration {
  46601. private _isEnabled;
  46602. /**
  46603. * Defines if the anisotropy is enabled in the material.
  46604. */
  46605. isEnabled: boolean;
  46606. /**
  46607. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46608. */
  46609. intensity: number;
  46610. /**
  46611. * Defines if the effect is along the tangents, bitangents or in between.
  46612. * By default, the effect is "strectching" the highlights along the tangents.
  46613. */
  46614. direction: Vector2;
  46615. private _texture;
  46616. /**
  46617. * Stores the anisotropy values in a texture.
  46618. * rg is direction (like normal from -1 to 1)
  46619. * b is a intensity
  46620. */
  46621. texture: Nullable<BaseTexture>;
  46622. /** @hidden */
  46623. private _internalMarkAllSubMeshesAsTexturesDirty;
  46624. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46625. /**
  46626. * Instantiate a new istance of anisotropy configuration.
  46627. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46628. */
  46629. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46630. /**
  46631. * Specifies that the submesh is ready to be used.
  46632. * @param defines the list of "defines" to update.
  46633. * @param scene defines the scene the material belongs to.
  46634. * @returns - boolean indicating that the submesh is ready or not.
  46635. */
  46636. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46637. /**
  46638. * Checks to see if a texture is used in the material.
  46639. * @param defines the list of "defines" to update.
  46640. * @param mesh the mesh we are preparing the defines for.
  46641. * @param scene defines the scene the material belongs to.
  46642. */
  46643. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46644. /**
  46645. * Binds the material data.
  46646. * @param uniformBuffer defines the Uniform buffer to fill in.
  46647. * @param scene defines the scene the material belongs to.
  46648. * @param isFrozen defines wether the material is frozen or not.
  46649. */
  46650. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46651. /**
  46652. * Checks to see if a texture is used in the material.
  46653. * @param texture - Base texture to use.
  46654. * @returns - Boolean specifying if a texture is used in the material.
  46655. */
  46656. hasTexture(texture: BaseTexture): boolean;
  46657. /**
  46658. * Returns an array of the actively used textures.
  46659. * @param activeTextures Array of BaseTextures
  46660. */
  46661. getActiveTextures(activeTextures: BaseTexture[]): void;
  46662. /**
  46663. * Returns the animatable textures.
  46664. * @param animatables Array of animatable textures.
  46665. */
  46666. getAnimatables(animatables: IAnimatable[]): void;
  46667. /**
  46668. * Disposes the resources of the material.
  46669. * @param forceDisposeTextures - Forces the disposal of all textures.
  46670. */
  46671. dispose(forceDisposeTextures?: boolean): void;
  46672. /**
  46673. * Get the current class name of the texture useful for serialization or dynamic coding.
  46674. * @returns "PBRAnisotropicConfiguration"
  46675. */
  46676. getClassName(): string;
  46677. /**
  46678. * Add fallbacks to the effect fallbacks list.
  46679. * @param defines defines the Base texture to use.
  46680. * @param fallbacks defines the current fallback list.
  46681. * @param currentRank defines the current fallback rank.
  46682. * @returns the new fallback rank.
  46683. */
  46684. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46685. /**
  46686. * Add the required uniforms to the current list.
  46687. * @param uniforms defines the current uniform list.
  46688. */
  46689. static AddUniforms(uniforms: string[]): void;
  46690. /**
  46691. * Add the required uniforms to the current buffer.
  46692. * @param uniformBuffer defines the current uniform buffer.
  46693. */
  46694. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46695. /**
  46696. * Add the required samplers to the current list.
  46697. * @param samplers defines the current sampler list.
  46698. */
  46699. static AddSamplers(samplers: string[]): void;
  46700. /**
  46701. * Makes a duplicate of the current configuration into another one.
  46702. * @param anisotropicConfiguration define the config where to copy the info
  46703. */
  46704. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46705. /**
  46706. * Serializes this anisotropy configuration.
  46707. * @returns - An object with the serialized config.
  46708. */
  46709. serialize(): any;
  46710. /**
  46711. * Parses a anisotropy Configuration from a serialized object.
  46712. * @param source - Serialized object.
  46713. * @param scene Defines the scene we are parsing for
  46714. * @param rootUrl Defines the rootUrl to load from
  46715. */
  46716. parse(source: any, scene: Scene, rootUrl: string): void;
  46717. }
  46718. }
  46719. declare module BABYLON {
  46720. /**
  46721. * @hidden
  46722. */
  46723. export interface IMaterialBRDFDefines {
  46724. BRDF_V_HEIGHT_CORRELATED: boolean;
  46725. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46726. SPHERICAL_HARMONICS: boolean;
  46727. /** @hidden */ private _areMiscDirty: boolean;
  46728. }
  46729. /**
  46730. * Define the code related to the BRDF parameters of the pbr material.
  46731. */
  46732. export class PBRBRDFConfiguration {
  46733. /**
  46734. * Default value used for the energy conservation.
  46735. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46736. */
  46737. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46738. /**
  46739. * Default value used for the Smith Visibility Height Correlated mode.
  46740. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46741. */
  46742. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46743. /**
  46744. * Default value used for the IBL diffuse part.
  46745. * This can help switching back to the polynomials mode globally which is a tiny bit
  46746. * less GPU intensive at the drawback of a lower quality.
  46747. */
  46748. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46749. private _useEnergyConservation;
  46750. /**
  46751. * Defines if the material uses energy conservation.
  46752. */
  46753. useEnergyConservation: boolean;
  46754. private _useSmithVisibilityHeightCorrelated;
  46755. /**
  46756. * LEGACY Mode set to false
  46757. * Defines if the material uses height smith correlated visibility term.
  46758. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46759. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46760. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46761. * Not relying on height correlated will also disable energy conservation.
  46762. */
  46763. useSmithVisibilityHeightCorrelated: boolean;
  46764. private _useSphericalHarmonics;
  46765. /**
  46766. * LEGACY Mode set to false
  46767. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46768. * diffuse part of the IBL.
  46769. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46770. * to the ground truth.
  46771. */
  46772. useSphericalHarmonics: boolean;
  46773. /** @hidden */
  46774. private _internalMarkAllSubMeshesAsMiscDirty;
  46775. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  46776. /**
  46777. * Instantiate a new istance of clear coat configuration.
  46778. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46779. */
  46780. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46781. /**
  46782. * Checks to see if a texture is used in the material.
  46783. * @param defines the list of "defines" to update.
  46784. */
  46785. prepareDefines(defines: IMaterialBRDFDefines): void;
  46786. /**
  46787. * Get the current class name of the texture useful for serialization or dynamic coding.
  46788. * @returns "PBRClearCoatConfiguration"
  46789. */
  46790. getClassName(): string;
  46791. /**
  46792. * Makes a duplicate of the current configuration into another one.
  46793. * @param brdfConfiguration define the config where to copy the info
  46794. */
  46795. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46796. /**
  46797. * Serializes this BRDF configuration.
  46798. * @returns - An object with the serialized config.
  46799. */
  46800. serialize(): any;
  46801. /**
  46802. * Parses a anisotropy Configuration from a serialized object.
  46803. * @param source - Serialized object.
  46804. * @param scene Defines the scene we are parsing for
  46805. * @param rootUrl Defines the rootUrl to load from
  46806. */
  46807. parse(source: any, scene: Scene, rootUrl: string): void;
  46808. }
  46809. }
  46810. declare module BABYLON {
  46811. /**
  46812. * @hidden
  46813. */
  46814. export interface IMaterialSheenDefines {
  46815. SHEEN: boolean;
  46816. SHEEN_TEXTURE: boolean;
  46817. SHEEN_TEXTUREDIRECTUV: number;
  46818. SHEEN_LINKWITHALBEDO: boolean;
  46819. /** @hidden */ private _areTexturesDirty: boolean;
  46820. }
  46821. /**
  46822. * Define the code related to the Sheen parameters of the pbr material.
  46823. */
  46824. export class PBRSheenConfiguration {
  46825. private _isEnabled;
  46826. /**
  46827. * Defines if the material uses sheen.
  46828. */
  46829. isEnabled: boolean;
  46830. private _linkSheenWithAlbedo;
  46831. /**
  46832. * Defines if the sheen is linked to the sheen color.
  46833. */
  46834. linkSheenWithAlbedo: boolean;
  46835. /**
  46836. * Defines the sheen intensity.
  46837. */
  46838. intensity: number;
  46839. /**
  46840. * Defines the sheen color.
  46841. */
  46842. color: Color3;
  46843. private _texture;
  46844. /**
  46845. * Stores the sheen tint values in a texture.
  46846. * rgb is tint
  46847. * a is a intensity
  46848. */
  46849. texture: Nullable<BaseTexture>;
  46850. /** @hidden */
  46851. private _internalMarkAllSubMeshesAsTexturesDirty;
  46852. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46853. /**
  46854. * Instantiate a new istance of clear coat configuration.
  46855. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46856. */
  46857. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46858. /**
  46859. * Specifies that the submesh is ready to be used.
  46860. * @param defines the list of "defines" to update.
  46861. * @param scene defines the scene the material belongs to.
  46862. * @returns - boolean indicating that the submesh is ready or not.
  46863. */
  46864. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46865. /**
  46866. * Checks to see if a texture is used in the material.
  46867. * @param defines the list of "defines" to update.
  46868. * @param scene defines the scene the material belongs to.
  46869. */
  46870. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46871. /**
  46872. * Binds the material data.
  46873. * @param uniformBuffer defines the Uniform buffer to fill in.
  46874. * @param scene defines the scene the material belongs to.
  46875. * @param isFrozen defines wether the material is frozen or not.
  46876. */
  46877. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46878. /**
  46879. * Checks to see if a texture is used in the material.
  46880. * @param texture - Base texture to use.
  46881. * @returns - Boolean specifying if a texture is used in the material.
  46882. */
  46883. hasTexture(texture: BaseTexture): boolean;
  46884. /**
  46885. * Returns an array of the actively used textures.
  46886. * @param activeTextures Array of BaseTextures
  46887. */
  46888. getActiveTextures(activeTextures: BaseTexture[]): void;
  46889. /**
  46890. * Returns the animatable textures.
  46891. * @param animatables Array of animatable textures.
  46892. */
  46893. getAnimatables(animatables: IAnimatable[]): void;
  46894. /**
  46895. * Disposes the resources of the material.
  46896. * @param forceDisposeTextures - Forces the disposal of all textures.
  46897. */
  46898. dispose(forceDisposeTextures?: boolean): void;
  46899. /**
  46900. * Get the current class name of the texture useful for serialization or dynamic coding.
  46901. * @returns "PBRSheenConfiguration"
  46902. */
  46903. getClassName(): string;
  46904. /**
  46905. * Add fallbacks to the effect fallbacks list.
  46906. * @param defines defines the Base texture to use.
  46907. * @param fallbacks defines the current fallback list.
  46908. * @param currentRank defines the current fallback rank.
  46909. * @returns the new fallback rank.
  46910. */
  46911. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46912. /**
  46913. * Add the required uniforms to the current list.
  46914. * @param uniforms defines the current uniform list.
  46915. */
  46916. static AddUniforms(uniforms: string[]): void;
  46917. /**
  46918. * Add the required uniforms to the current buffer.
  46919. * @param uniformBuffer defines the current uniform buffer.
  46920. */
  46921. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46922. /**
  46923. * Add the required samplers to the current list.
  46924. * @param samplers defines the current sampler list.
  46925. */
  46926. static AddSamplers(samplers: string[]): void;
  46927. /**
  46928. * Makes a duplicate of the current configuration into another one.
  46929. * @param sheenConfiguration define the config where to copy the info
  46930. */
  46931. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46932. /**
  46933. * Serializes this BRDF configuration.
  46934. * @returns - An object with the serialized config.
  46935. */
  46936. serialize(): any;
  46937. /**
  46938. * Parses a anisotropy Configuration from a serialized object.
  46939. * @param source - Serialized object.
  46940. * @param scene Defines the scene we are parsing for
  46941. * @param rootUrl Defines the rootUrl to load from
  46942. */
  46943. parse(source: any, scene: Scene, rootUrl: string): void;
  46944. }
  46945. }
  46946. declare module BABYLON {
  46947. /**
  46948. * @hidden
  46949. */
  46950. export interface IMaterialSubSurfaceDefines {
  46951. SUBSURFACE: boolean;
  46952. SS_REFRACTION: boolean;
  46953. SS_TRANSLUCENCY: boolean;
  46954. SS_SCATERRING: boolean;
  46955. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46956. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46957. SS_REFRACTIONMAP_3D: boolean;
  46958. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46959. SS_LODINREFRACTIONALPHA: boolean;
  46960. SS_GAMMAREFRACTION: boolean;
  46961. SS_RGBDREFRACTION: boolean;
  46962. SS_LINEARSPECULARREFRACTION: boolean;
  46963. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46964. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46965. /** @hidden */ private _areTexturesDirty: boolean;
  46966. }
  46967. /**
  46968. * Define the code related to the sub surface parameters of the pbr material.
  46969. */
  46970. export class PBRSubSurfaceConfiguration {
  46971. private _isRefractionEnabled;
  46972. /**
  46973. * Defines if the refraction is enabled in the material.
  46974. */
  46975. isRefractionEnabled: boolean;
  46976. private _isTranslucencyEnabled;
  46977. /**
  46978. * Defines if the translucency is enabled in the material.
  46979. */
  46980. isTranslucencyEnabled: boolean;
  46981. private _isScatteringEnabled;
  46982. /**
  46983. * Defines the refraction intensity of the material.
  46984. * The refraction when enabled replaces the Diffuse part of the material.
  46985. * The intensity helps transitionning between diffuse and refraction.
  46986. */
  46987. refractionIntensity: number;
  46988. /**
  46989. * Defines the translucency intensity of the material.
  46990. * When translucency has been enabled, this defines how much of the "translucency"
  46991. * is addded to the diffuse part of the material.
  46992. */
  46993. translucencyIntensity: number;
  46994. /**
  46995. * Defines the scattering intensity of the material.
  46996. * When scattering has been enabled, this defines how much of the "scattered light"
  46997. * is addded to the diffuse part of the material.
  46998. */
  46999. scatteringIntensity: number;
  47000. private _thicknessTexture;
  47001. /**
  47002. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47003. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47004. * 0 would mean minimumThickness
  47005. * 1 would mean maximumThickness
  47006. * The other channels might be use as a mask to vary the different effects intensity.
  47007. */
  47008. thicknessTexture: Nullable<BaseTexture>;
  47009. private _refractionTexture;
  47010. /**
  47011. * Defines the texture to use for refraction.
  47012. */
  47013. refractionTexture: Nullable<BaseTexture>;
  47014. private _indexOfRefraction;
  47015. /**
  47016. * Defines the index of refraction used in the material.
  47017. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47018. */
  47019. indexOfRefraction: number;
  47020. private _invertRefractionY;
  47021. /**
  47022. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47023. */
  47024. invertRefractionY: boolean;
  47025. private _linkRefractionWithTransparency;
  47026. /**
  47027. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47028. * Materials half opaque for instance using refraction could benefit from this control.
  47029. */
  47030. linkRefractionWithTransparency: boolean;
  47031. /**
  47032. * Defines the minimum thickness stored in the thickness map.
  47033. * If no thickness map is defined, this value will be used to simulate thickness.
  47034. */
  47035. minimumThickness: number;
  47036. /**
  47037. * Defines the maximum thickness stored in the thickness map.
  47038. */
  47039. maximumThickness: number;
  47040. /**
  47041. * Defines the volume tint of the material.
  47042. * This is used for both translucency and scattering.
  47043. */
  47044. tintColor: Color3;
  47045. /**
  47046. * Defines the distance at which the tint color should be found in the media.
  47047. * This is used for refraction only.
  47048. */
  47049. tintColorAtDistance: number;
  47050. /**
  47051. * Defines how far each channel transmit through the media.
  47052. * It is defined as a color to simplify it selection.
  47053. */
  47054. diffusionDistance: Color3;
  47055. private _useMaskFromThicknessTexture;
  47056. /**
  47057. * Stores the intensity of the different subsurface effects in the thickness texture.
  47058. * * the green channel is the translucency intensity.
  47059. * * the blue channel is the scattering intensity.
  47060. * * the alpha channel is the refraction intensity.
  47061. */
  47062. useMaskFromThicknessTexture: boolean;
  47063. /** @hidden */
  47064. private _internalMarkAllSubMeshesAsTexturesDirty;
  47065. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  47066. /**
  47067. * Instantiate a new istance of sub surface configuration.
  47068. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47069. */
  47070. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47071. /**
  47072. * Gets wehter the submesh is ready to be used or not.
  47073. * @param defines the list of "defines" to update.
  47074. * @param scene defines the scene the material belongs to.
  47075. * @returns - boolean indicating that the submesh is ready or not.
  47076. */
  47077. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47078. /**
  47079. * Checks to see if a texture is used in the material.
  47080. * @param defines the list of "defines" to update.
  47081. * @param scene defines the scene to the material belongs to.
  47082. */
  47083. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47084. /**
  47085. * Binds the material data.
  47086. * @param uniformBuffer defines the Uniform buffer to fill in.
  47087. * @param scene defines the scene the material belongs to.
  47088. * @param engine defines the engine the material belongs to.
  47089. * @param isFrozen defines wether the material is frozen or not.
  47090. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47091. */
  47092. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47093. /**
  47094. * Unbinds the material from the mesh.
  47095. * @param activeEffect defines the effect that should be unbound from.
  47096. * @returns true if unbound, otherwise false
  47097. */
  47098. unbind(activeEffect: Effect): boolean;
  47099. /**
  47100. * Returns the texture used for refraction or null if none is used.
  47101. * @param scene defines the scene the material belongs to.
  47102. * @returns - Refraction texture if present. If no refraction texture and refraction
  47103. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47104. */
  47105. private _getRefractionTexture;
  47106. /**
  47107. * Returns true if alpha blending should be disabled.
  47108. */
  47109. readonly disableAlphaBlending: boolean;
  47110. /**
  47111. * Fills the list of render target textures.
  47112. * @param renderTargets the list of render targets to update
  47113. */
  47114. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47115. /**
  47116. * Checks to see if a texture is used in the material.
  47117. * @param texture - Base texture to use.
  47118. * @returns - Boolean specifying if a texture is used in the material.
  47119. */
  47120. hasTexture(texture: BaseTexture): boolean;
  47121. /**
  47122. * Gets a boolean indicating that current material needs to register RTT
  47123. * @returns true if this uses a render target otherwise false.
  47124. */
  47125. hasRenderTargetTextures(): boolean;
  47126. /**
  47127. * Returns an array of the actively used textures.
  47128. * @param activeTextures Array of BaseTextures
  47129. */
  47130. getActiveTextures(activeTextures: BaseTexture[]): void;
  47131. /**
  47132. * Returns the animatable textures.
  47133. * @param animatables Array of animatable textures.
  47134. */
  47135. getAnimatables(animatables: IAnimatable[]): void;
  47136. /**
  47137. * Disposes the resources of the material.
  47138. * @param forceDisposeTextures - Forces the disposal of all textures.
  47139. */
  47140. dispose(forceDisposeTextures?: boolean): void;
  47141. /**
  47142. * Get the current class name of the texture useful for serialization or dynamic coding.
  47143. * @returns "PBRSubSurfaceConfiguration"
  47144. */
  47145. getClassName(): string;
  47146. /**
  47147. * Add fallbacks to the effect fallbacks list.
  47148. * @param defines defines the Base texture to use.
  47149. * @param fallbacks defines the current fallback list.
  47150. * @param currentRank defines the current fallback rank.
  47151. * @returns the new fallback rank.
  47152. */
  47153. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47154. /**
  47155. * Add the required uniforms to the current list.
  47156. * @param uniforms defines the current uniform list.
  47157. */
  47158. static AddUniforms(uniforms: string[]): void;
  47159. /**
  47160. * Add the required samplers to the current list.
  47161. * @param samplers defines the current sampler list.
  47162. */
  47163. static AddSamplers(samplers: string[]): void;
  47164. /**
  47165. * Add the required uniforms to the current buffer.
  47166. * @param uniformBuffer defines the current uniform buffer.
  47167. */
  47168. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47169. /**
  47170. * Makes a duplicate of the current configuration into another one.
  47171. * @param configuration define the config where to copy the info
  47172. */
  47173. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47174. /**
  47175. * Serializes this Sub Surface configuration.
  47176. * @returns - An object with the serialized config.
  47177. */
  47178. serialize(): any;
  47179. /**
  47180. * Parses a anisotropy Configuration from a serialized object.
  47181. * @param source - Serialized object.
  47182. * @param scene Defines the scene we are parsing for
  47183. * @param rootUrl Defines the rootUrl to load from
  47184. */
  47185. parse(source: any, scene: Scene, rootUrl: string): void;
  47186. }
  47187. }
  47188. declare module BABYLON {
  47189. /** @hidden */
  47190. export var pbrFragmentDeclaration: {
  47191. name: string;
  47192. shader: string;
  47193. };
  47194. }
  47195. declare module BABYLON {
  47196. /** @hidden */
  47197. export var pbrUboDeclaration: {
  47198. name: string;
  47199. shader: string;
  47200. };
  47201. }
  47202. declare module BABYLON {
  47203. /** @hidden */
  47204. export var pbrFragmentExtraDeclaration: {
  47205. name: string;
  47206. shader: string;
  47207. };
  47208. }
  47209. declare module BABYLON {
  47210. /** @hidden */
  47211. export var pbrFragmentSamplersDeclaration: {
  47212. name: string;
  47213. shader: string;
  47214. };
  47215. }
  47216. declare module BABYLON {
  47217. /** @hidden */
  47218. export var pbrHelperFunctions: {
  47219. name: string;
  47220. shader: string;
  47221. };
  47222. }
  47223. declare module BABYLON {
  47224. /** @hidden */
  47225. export var harmonicsFunctions: {
  47226. name: string;
  47227. shader: string;
  47228. };
  47229. }
  47230. declare module BABYLON {
  47231. /** @hidden */
  47232. export var pbrDirectLightingSetupFunctions: {
  47233. name: string;
  47234. shader: string;
  47235. };
  47236. }
  47237. declare module BABYLON {
  47238. /** @hidden */
  47239. export var pbrDirectLightingFalloffFunctions: {
  47240. name: string;
  47241. shader: string;
  47242. };
  47243. }
  47244. declare module BABYLON {
  47245. /** @hidden */
  47246. export var pbrBRDFFunctions: {
  47247. name: string;
  47248. shader: string;
  47249. };
  47250. }
  47251. declare module BABYLON {
  47252. /** @hidden */
  47253. export var pbrDirectLightingFunctions: {
  47254. name: string;
  47255. shader: string;
  47256. };
  47257. }
  47258. declare module BABYLON {
  47259. /** @hidden */
  47260. export var pbrIBLFunctions: {
  47261. name: string;
  47262. shader: string;
  47263. };
  47264. }
  47265. declare module BABYLON {
  47266. /** @hidden */
  47267. export var pbrDebug: {
  47268. name: string;
  47269. shader: string;
  47270. };
  47271. }
  47272. declare module BABYLON {
  47273. /** @hidden */
  47274. export var pbrPixelShader: {
  47275. name: string;
  47276. shader: string;
  47277. };
  47278. }
  47279. declare module BABYLON {
  47280. /** @hidden */
  47281. export var pbrVertexDeclaration: {
  47282. name: string;
  47283. shader: string;
  47284. };
  47285. }
  47286. declare module BABYLON {
  47287. /** @hidden */
  47288. export var pbrVertexShader: {
  47289. name: string;
  47290. shader: string;
  47291. };
  47292. }
  47293. declare module BABYLON {
  47294. /**
  47295. * Manages the defines for the PBR Material.
  47296. * @hidden
  47297. */
  47298. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47299. PBR: boolean;
  47300. MAINUV1: boolean;
  47301. MAINUV2: boolean;
  47302. UV1: boolean;
  47303. UV2: boolean;
  47304. ALBEDO: boolean;
  47305. ALBEDODIRECTUV: number;
  47306. VERTEXCOLOR: boolean;
  47307. AMBIENT: boolean;
  47308. AMBIENTDIRECTUV: number;
  47309. AMBIENTINGRAYSCALE: boolean;
  47310. OPACITY: boolean;
  47311. VERTEXALPHA: boolean;
  47312. OPACITYDIRECTUV: number;
  47313. OPACITYRGB: boolean;
  47314. ALPHATEST: boolean;
  47315. DEPTHPREPASS: boolean;
  47316. ALPHABLEND: boolean;
  47317. ALPHAFROMALBEDO: boolean;
  47318. ALPHATESTVALUE: string;
  47319. SPECULAROVERALPHA: boolean;
  47320. RADIANCEOVERALPHA: boolean;
  47321. ALPHAFRESNEL: boolean;
  47322. LINEARALPHAFRESNEL: boolean;
  47323. PREMULTIPLYALPHA: boolean;
  47324. EMISSIVE: boolean;
  47325. EMISSIVEDIRECTUV: number;
  47326. REFLECTIVITY: boolean;
  47327. REFLECTIVITYDIRECTUV: number;
  47328. SPECULARTERM: boolean;
  47329. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47330. MICROSURFACEAUTOMATIC: boolean;
  47331. LODBASEDMICROSFURACE: boolean;
  47332. MICROSURFACEMAP: boolean;
  47333. MICROSURFACEMAPDIRECTUV: number;
  47334. METALLICWORKFLOW: boolean;
  47335. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47336. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47337. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47338. AOSTOREINMETALMAPRED: boolean;
  47339. ENVIRONMENTBRDF: boolean;
  47340. ENVIRONMENTBRDF_RGBD: boolean;
  47341. NORMAL: boolean;
  47342. TANGENT: boolean;
  47343. BUMP: boolean;
  47344. BUMPDIRECTUV: number;
  47345. OBJECTSPACE_NORMALMAP: boolean;
  47346. PARALLAX: boolean;
  47347. PARALLAXOCCLUSION: boolean;
  47348. NORMALXYSCALE: boolean;
  47349. LIGHTMAP: boolean;
  47350. LIGHTMAPDIRECTUV: number;
  47351. USELIGHTMAPASSHADOWMAP: boolean;
  47352. GAMMALIGHTMAP: boolean;
  47353. RGBDLIGHTMAP: boolean;
  47354. REFLECTION: boolean;
  47355. REFLECTIONMAP_3D: boolean;
  47356. REFLECTIONMAP_SPHERICAL: boolean;
  47357. REFLECTIONMAP_PLANAR: boolean;
  47358. REFLECTIONMAP_CUBIC: boolean;
  47359. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47360. REFLECTIONMAP_PROJECTION: boolean;
  47361. REFLECTIONMAP_SKYBOX: boolean;
  47362. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47363. REFLECTIONMAP_EXPLICIT: boolean;
  47364. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47365. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47366. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47367. INVERTCUBICMAP: boolean;
  47368. USESPHERICALFROMREFLECTIONMAP: boolean;
  47369. USEIRRADIANCEMAP: boolean;
  47370. SPHERICAL_HARMONICS: boolean;
  47371. USESPHERICALINVERTEX: boolean;
  47372. REFLECTIONMAP_OPPOSITEZ: boolean;
  47373. LODINREFLECTIONALPHA: boolean;
  47374. GAMMAREFLECTION: boolean;
  47375. RGBDREFLECTION: boolean;
  47376. LINEARSPECULARREFLECTION: boolean;
  47377. RADIANCEOCCLUSION: boolean;
  47378. HORIZONOCCLUSION: boolean;
  47379. INSTANCES: boolean;
  47380. NUM_BONE_INFLUENCERS: number;
  47381. BonesPerMesh: number;
  47382. BONETEXTURE: boolean;
  47383. NONUNIFORMSCALING: boolean;
  47384. MORPHTARGETS: boolean;
  47385. MORPHTARGETS_NORMAL: boolean;
  47386. MORPHTARGETS_TANGENT: boolean;
  47387. MORPHTARGETS_UV: boolean;
  47388. NUM_MORPH_INFLUENCERS: number;
  47389. IMAGEPROCESSING: boolean;
  47390. VIGNETTE: boolean;
  47391. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47392. VIGNETTEBLENDMODEOPAQUE: boolean;
  47393. TONEMAPPING: boolean;
  47394. TONEMAPPING_ACES: boolean;
  47395. CONTRAST: boolean;
  47396. COLORCURVES: boolean;
  47397. COLORGRADING: boolean;
  47398. COLORGRADING3D: boolean;
  47399. SAMPLER3DGREENDEPTH: boolean;
  47400. SAMPLER3DBGRMAP: boolean;
  47401. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47402. EXPOSURE: boolean;
  47403. MULTIVIEW: boolean;
  47404. USEPHYSICALLIGHTFALLOFF: boolean;
  47405. USEGLTFLIGHTFALLOFF: boolean;
  47406. TWOSIDEDLIGHTING: boolean;
  47407. SHADOWFLOAT: boolean;
  47408. CLIPPLANE: boolean;
  47409. CLIPPLANE2: boolean;
  47410. CLIPPLANE3: boolean;
  47411. CLIPPLANE4: boolean;
  47412. POINTSIZE: boolean;
  47413. FOG: boolean;
  47414. LOGARITHMICDEPTH: boolean;
  47415. FORCENORMALFORWARD: boolean;
  47416. SPECULARAA: boolean;
  47417. CLEARCOAT: boolean;
  47418. CLEARCOAT_DEFAULTIOR: boolean;
  47419. CLEARCOAT_TEXTURE: boolean;
  47420. CLEARCOAT_TEXTUREDIRECTUV: number;
  47421. CLEARCOAT_BUMP: boolean;
  47422. CLEARCOAT_BUMPDIRECTUV: number;
  47423. CLEARCOAT_TINT: boolean;
  47424. CLEARCOAT_TINT_TEXTURE: boolean;
  47425. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47426. ANISOTROPIC: boolean;
  47427. ANISOTROPIC_TEXTURE: boolean;
  47428. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47429. BRDF_V_HEIGHT_CORRELATED: boolean;
  47430. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47431. SHEEN: boolean;
  47432. SHEEN_TEXTURE: boolean;
  47433. SHEEN_TEXTUREDIRECTUV: number;
  47434. SHEEN_LINKWITHALBEDO: boolean;
  47435. SUBSURFACE: boolean;
  47436. SS_REFRACTION: boolean;
  47437. SS_TRANSLUCENCY: boolean;
  47438. SS_SCATERRING: boolean;
  47439. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47440. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47441. SS_REFRACTIONMAP_3D: boolean;
  47442. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47443. SS_LODINREFRACTIONALPHA: boolean;
  47444. SS_GAMMAREFRACTION: boolean;
  47445. SS_RGBDREFRACTION: boolean;
  47446. SS_LINEARSPECULARREFRACTION: boolean;
  47447. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47448. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47449. UNLIT: boolean;
  47450. DEBUGMODE: number;
  47451. /**
  47452. * Initializes the PBR Material defines.
  47453. */
  47454. constructor();
  47455. /**
  47456. * Resets the PBR Material defines.
  47457. */
  47458. reset(): void;
  47459. }
  47460. /**
  47461. * The Physically based material base class of BJS.
  47462. *
  47463. * This offers the main features of a standard PBR material.
  47464. * For more information, please refer to the documentation :
  47465. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47466. */
  47467. export abstract class PBRBaseMaterial extends PushMaterial {
  47468. /**
  47469. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47470. */
  47471. static readonly PBRMATERIAL_OPAQUE: number;
  47472. /**
  47473. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47474. */
  47475. static readonly PBRMATERIAL_ALPHATEST: number;
  47476. /**
  47477. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47478. */
  47479. static readonly PBRMATERIAL_ALPHABLEND: number;
  47480. /**
  47481. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47482. * They are also discarded below the alpha cutoff threshold to improve performances.
  47483. */
  47484. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47485. /**
  47486. * Defines the default value of how much AO map is occluding the analytical lights
  47487. * (point spot...).
  47488. */
  47489. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47490. /**
  47491. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47492. */
  47493. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47494. /**
  47495. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47496. * to enhance interoperability with other engines.
  47497. */
  47498. static readonly LIGHTFALLOFF_GLTF: number;
  47499. /**
  47500. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47501. * to enhance interoperability with other materials.
  47502. */
  47503. static readonly LIGHTFALLOFF_STANDARD: number;
  47504. /**
  47505. * Intensity of the direct lights e.g. the four lights available in your scene.
  47506. * This impacts both the direct diffuse and specular highlights.
  47507. */
  47508. protected _directIntensity: number;
  47509. /**
  47510. * Intensity of the emissive part of the material.
  47511. * This helps controlling the emissive effect without modifying the emissive color.
  47512. */
  47513. protected _emissiveIntensity: number;
  47514. /**
  47515. * Intensity of the environment e.g. how much the environment will light the object
  47516. * either through harmonics for rough material or through the refelction for shiny ones.
  47517. */
  47518. protected _environmentIntensity: number;
  47519. /**
  47520. * This is a special control allowing the reduction of the specular highlights coming from the
  47521. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47522. */
  47523. protected _specularIntensity: number;
  47524. /**
  47525. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47526. */
  47527. private _lightingInfos;
  47528. /**
  47529. * Debug Control allowing disabling the bump map on this material.
  47530. */
  47531. protected _disableBumpMap: boolean;
  47532. /**
  47533. * AKA Diffuse Texture in standard nomenclature.
  47534. */
  47535. protected _albedoTexture: Nullable<BaseTexture>;
  47536. /**
  47537. * AKA Occlusion Texture in other nomenclature.
  47538. */
  47539. protected _ambientTexture: Nullable<BaseTexture>;
  47540. /**
  47541. * AKA Occlusion Texture Intensity in other nomenclature.
  47542. */
  47543. protected _ambientTextureStrength: number;
  47544. /**
  47545. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47546. * 1 means it completely occludes it
  47547. * 0 mean it has no impact
  47548. */
  47549. protected _ambientTextureImpactOnAnalyticalLights: number;
  47550. /**
  47551. * Stores the alpha values in a texture.
  47552. */
  47553. protected _opacityTexture: Nullable<BaseTexture>;
  47554. /**
  47555. * Stores the reflection values in a texture.
  47556. */
  47557. protected _reflectionTexture: Nullable<BaseTexture>;
  47558. /**
  47559. * Stores the emissive values in a texture.
  47560. */
  47561. protected _emissiveTexture: Nullable<BaseTexture>;
  47562. /**
  47563. * AKA Specular texture in other nomenclature.
  47564. */
  47565. protected _reflectivityTexture: Nullable<BaseTexture>;
  47566. /**
  47567. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47568. */
  47569. protected _metallicTexture: Nullable<BaseTexture>;
  47570. /**
  47571. * Specifies the metallic scalar of the metallic/roughness workflow.
  47572. * Can also be used to scale the metalness values of the metallic texture.
  47573. */
  47574. protected _metallic: Nullable<number>;
  47575. /**
  47576. * Specifies the roughness scalar of the metallic/roughness workflow.
  47577. * Can also be used to scale the roughness values of the metallic texture.
  47578. */
  47579. protected _roughness: Nullable<number>;
  47580. /**
  47581. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47582. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47583. */
  47584. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47585. /**
  47586. * Stores surface normal data used to displace a mesh in a texture.
  47587. */
  47588. protected _bumpTexture: Nullable<BaseTexture>;
  47589. /**
  47590. * Stores the pre-calculated light information of a mesh in a texture.
  47591. */
  47592. protected _lightmapTexture: Nullable<BaseTexture>;
  47593. /**
  47594. * The color of a material in ambient lighting.
  47595. */
  47596. protected _ambientColor: Color3;
  47597. /**
  47598. * AKA Diffuse Color in other nomenclature.
  47599. */
  47600. protected _albedoColor: Color3;
  47601. /**
  47602. * AKA Specular Color in other nomenclature.
  47603. */
  47604. protected _reflectivityColor: Color3;
  47605. /**
  47606. * The color applied when light is reflected from a material.
  47607. */
  47608. protected _reflectionColor: Color3;
  47609. /**
  47610. * The color applied when light is emitted from a material.
  47611. */
  47612. protected _emissiveColor: Color3;
  47613. /**
  47614. * AKA Glossiness in other nomenclature.
  47615. */
  47616. protected _microSurface: number;
  47617. /**
  47618. * Specifies that the material will use the light map as a show map.
  47619. */
  47620. protected _useLightmapAsShadowmap: boolean;
  47621. /**
  47622. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47623. * makes the reflect vector face the model (under horizon).
  47624. */
  47625. protected _useHorizonOcclusion: boolean;
  47626. /**
  47627. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47628. * too much the area relying on ambient texture to define their ambient occlusion.
  47629. */
  47630. protected _useRadianceOcclusion: boolean;
  47631. /**
  47632. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47633. */
  47634. protected _useAlphaFromAlbedoTexture: boolean;
  47635. /**
  47636. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47637. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47638. */
  47639. protected _useSpecularOverAlpha: boolean;
  47640. /**
  47641. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47642. */
  47643. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47644. /**
  47645. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47646. */
  47647. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47648. /**
  47649. * Specifies if the metallic texture contains the roughness information in its green channel.
  47650. */
  47651. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47652. /**
  47653. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47654. */
  47655. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47656. /**
  47657. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47658. */
  47659. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47660. /**
  47661. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47662. */
  47663. protected _useAmbientInGrayScale: boolean;
  47664. /**
  47665. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47666. * The material will try to infer what glossiness each pixel should be.
  47667. */
  47668. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47669. /**
  47670. * Defines the falloff type used in this material.
  47671. * It by default is Physical.
  47672. */
  47673. protected _lightFalloff: number;
  47674. /**
  47675. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47676. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47677. */
  47678. protected _useRadianceOverAlpha: boolean;
  47679. /**
  47680. * Allows using an object space normal map (instead of tangent space).
  47681. */
  47682. protected _useObjectSpaceNormalMap: boolean;
  47683. /**
  47684. * Allows using the bump map in parallax mode.
  47685. */
  47686. protected _useParallax: boolean;
  47687. /**
  47688. * Allows using the bump map in parallax occlusion mode.
  47689. */
  47690. protected _useParallaxOcclusion: boolean;
  47691. /**
  47692. * Controls the scale bias of the parallax mode.
  47693. */
  47694. protected _parallaxScaleBias: number;
  47695. /**
  47696. * If sets to true, disables all the lights affecting the material.
  47697. */
  47698. protected _disableLighting: boolean;
  47699. /**
  47700. * Number of Simultaneous lights allowed on the material.
  47701. */
  47702. protected _maxSimultaneousLights: number;
  47703. /**
  47704. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47705. */
  47706. protected _invertNormalMapX: boolean;
  47707. /**
  47708. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47709. */
  47710. protected _invertNormalMapY: boolean;
  47711. /**
  47712. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47713. */
  47714. protected _twoSidedLighting: boolean;
  47715. /**
  47716. * Defines the alpha limits in alpha test mode.
  47717. */
  47718. protected _alphaCutOff: number;
  47719. /**
  47720. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47721. */
  47722. protected _forceAlphaTest: boolean;
  47723. /**
  47724. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47725. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47726. */
  47727. protected _useAlphaFresnel: boolean;
  47728. /**
  47729. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47730. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47731. */
  47732. protected _useLinearAlphaFresnel: boolean;
  47733. /**
  47734. * The transparency mode of the material.
  47735. */
  47736. protected _transparencyMode: Nullable<number>;
  47737. /**
  47738. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47739. * from cos thetav and roughness:
  47740. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47741. */
  47742. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47743. /**
  47744. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47745. */
  47746. protected _forceIrradianceInFragment: boolean;
  47747. /**
  47748. * Force normal to face away from face.
  47749. */
  47750. protected _forceNormalForward: boolean;
  47751. /**
  47752. * Enables specular anti aliasing in the PBR shader.
  47753. * It will both interacts on the Geometry for analytical and IBL lighting.
  47754. * It also prefilter the roughness map based on the bump values.
  47755. */
  47756. protected _enableSpecularAntiAliasing: boolean;
  47757. /**
  47758. * Default configuration related to image processing available in the PBR Material.
  47759. */
  47760. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47761. /**
  47762. * Keep track of the image processing observer to allow dispose and replace.
  47763. */
  47764. private _imageProcessingObserver;
  47765. /**
  47766. * Attaches a new image processing configuration to the PBR Material.
  47767. * @param configuration
  47768. */
  47769. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47770. /**
  47771. * Stores the available render targets.
  47772. */
  47773. private _renderTargets;
  47774. /**
  47775. * Sets the global ambient color for the material used in lighting calculations.
  47776. */
  47777. private _globalAmbientColor;
  47778. /**
  47779. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47780. */
  47781. private _useLogarithmicDepth;
  47782. /**
  47783. * If set to true, no lighting calculations will be applied.
  47784. */
  47785. private _unlit;
  47786. private _debugMode;
  47787. /**
  47788. * @hidden
  47789. * This is reserved for the inspector.
  47790. * Defines the material debug mode.
  47791. * It helps seeing only some components of the material while troubleshooting.
  47792. */
  47793. debugMode: number;
  47794. /**
  47795. * @hidden
  47796. * This is reserved for the inspector.
  47797. * Specify from where on screen the debug mode should start.
  47798. * The value goes from -1 (full screen) to 1 (not visible)
  47799. * It helps with side by side comparison against the final render
  47800. * This defaults to -1
  47801. */
  47802. private debugLimit;
  47803. /**
  47804. * @hidden
  47805. * This is reserved for the inspector.
  47806. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47807. * You can use the factor to better multiply the final value.
  47808. */
  47809. private debugFactor;
  47810. /**
  47811. * Defines the clear coat layer parameters for the material.
  47812. */
  47813. readonly clearCoat: PBRClearCoatConfiguration;
  47814. /**
  47815. * Defines the anisotropic parameters for the material.
  47816. */
  47817. readonly anisotropy: PBRAnisotropicConfiguration;
  47818. /**
  47819. * Defines the BRDF parameters for the material.
  47820. */
  47821. readonly brdf: PBRBRDFConfiguration;
  47822. /**
  47823. * Defines the Sheen parameters for the material.
  47824. */
  47825. readonly sheen: PBRSheenConfiguration;
  47826. /**
  47827. * Defines the SubSurface parameters for the material.
  47828. */
  47829. readonly subSurface: PBRSubSurfaceConfiguration;
  47830. /**
  47831. * Custom callback helping to override the default shader used in the material.
  47832. */
  47833. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47834. protected _rebuildInParallel: boolean;
  47835. /**
  47836. * Instantiates a new PBRMaterial instance.
  47837. *
  47838. * @param name The material name
  47839. * @param scene The scene the material will be use in.
  47840. */
  47841. constructor(name: string, scene: Scene);
  47842. /**
  47843. * Gets a boolean indicating that current material needs to register RTT
  47844. */
  47845. readonly hasRenderTargetTextures: boolean;
  47846. /**
  47847. * Gets the name of the material class.
  47848. */
  47849. getClassName(): string;
  47850. /**
  47851. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47852. */
  47853. /**
  47854. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47855. */
  47856. useLogarithmicDepth: boolean;
  47857. /**
  47858. * Gets the current transparency mode.
  47859. */
  47860. /**
  47861. * Sets the transparency mode of the material.
  47862. *
  47863. * | Value | Type | Description |
  47864. * | ----- | ----------------------------------- | ----------- |
  47865. * | 0 | OPAQUE | |
  47866. * | 1 | ALPHATEST | |
  47867. * | 2 | ALPHABLEND | |
  47868. * | 3 | ALPHATESTANDBLEND | |
  47869. *
  47870. */
  47871. transparencyMode: Nullable<number>;
  47872. /**
  47873. * Returns true if alpha blending should be disabled.
  47874. */
  47875. private readonly _disableAlphaBlending;
  47876. /**
  47877. * Specifies whether or not this material should be rendered in alpha blend mode.
  47878. */
  47879. needAlphaBlending(): boolean;
  47880. /**
  47881. * Specifies if the mesh will require alpha blending.
  47882. * @param mesh - BJS mesh.
  47883. */
  47884. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47885. /**
  47886. * Specifies whether or not this material should be rendered in alpha test mode.
  47887. */
  47888. needAlphaTesting(): boolean;
  47889. /**
  47890. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47891. */
  47892. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47893. /**
  47894. * Gets the texture used for the alpha test.
  47895. */
  47896. getAlphaTestTexture(): Nullable<BaseTexture>;
  47897. /**
  47898. * Specifies that the submesh is ready to be used.
  47899. * @param mesh - BJS mesh.
  47900. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47901. * @param useInstances - Specifies that instances should be used.
  47902. * @returns - boolean indicating that the submesh is ready or not.
  47903. */
  47904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47905. /**
  47906. * Specifies if the material uses metallic roughness workflow.
  47907. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47908. */
  47909. isMetallicWorkflow(): boolean;
  47910. private _prepareEffect;
  47911. private _prepareDefines;
  47912. /**
  47913. * Force shader compilation
  47914. */
  47915. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47916. clipPlane: boolean;
  47917. }>): void;
  47918. /**
  47919. * Initializes the uniform buffer layout for the shader.
  47920. */
  47921. buildUniformLayout(): void;
  47922. /**
  47923. * Unbinds the material from the mesh
  47924. */
  47925. unbind(): void;
  47926. /**
  47927. * Binds the submesh data.
  47928. * @param world - The world matrix.
  47929. * @param mesh - The BJS mesh.
  47930. * @param subMesh - A submesh of the BJS mesh.
  47931. */
  47932. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47933. /**
  47934. * Returns the animatable textures.
  47935. * @returns - Array of animatable textures.
  47936. */
  47937. getAnimatables(): IAnimatable[];
  47938. /**
  47939. * Returns the texture used for reflections.
  47940. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47941. */
  47942. private _getReflectionTexture;
  47943. /**
  47944. * Returns an array of the actively used textures.
  47945. * @returns - Array of BaseTextures
  47946. */
  47947. getActiveTextures(): BaseTexture[];
  47948. /**
  47949. * Checks to see if a texture is used in the material.
  47950. * @param texture - Base texture to use.
  47951. * @returns - Boolean specifying if a texture is used in the material.
  47952. */
  47953. hasTexture(texture: BaseTexture): boolean;
  47954. /**
  47955. * Disposes the resources of the material.
  47956. * @param forceDisposeEffect - Forces the disposal of effects.
  47957. * @param forceDisposeTextures - Forces the disposal of all textures.
  47958. */
  47959. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47960. }
  47961. }
  47962. declare module BABYLON {
  47963. /**
  47964. * The Physically based material of BJS.
  47965. *
  47966. * This offers the main features of a standard PBR material.
  47967. * For more information, please refer to the documentation :
  47968. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47969. */
  47970. export class PBRMaterial extends PBRBaseMaterial {
  47971. /**
  47972. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47973. */
  47974. static readonly PBRMATERIAL_OPAQUE: number;
  47975. /**
  47976. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47977. */
  47978. static readonly PBRMATERIAL_ALPHATEST: number;
  47979. /**
  47980. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47981. */
  47982. static readonly PBRMATERIAL_ALPHABLEND: number;
  47983. /**
  47984. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47985. * They are also discarded below the alpha cutoff threshold to improve performances.
  47986. */
  47987. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47988. /**
  47989. * Defines the default value of how much AO map is occluding the analytical lights
  47990. * (point spot...).
  47991. */
  47992. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47993. /**
  47994. * Intensity of the direct lights e.g. the four lights available in your scene.
  47995. * This impacts both the direct diffuse and specular highlights.
  47996. */
  47997. directIntensity: number;
  47998. /**
  47999. * Intensity of the emissive part of the material.
  48000. * This helps controlling the emissive effect without modifying the emissive color.
  48001. */
  48002. emissiveIntensity: number;
  48003. /**
  48004. * Intensity of the environment e.g. how much the environment will light the object
  48005. * either through harmonics for rough material or through the refelction for shiny ones.
  48006. */
  48007. environmentIntensity: number;
  48008. /**
  48009. * This is a special control allowing the reduction of the specular highlights coming from the
  48010. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48011. */
  48012. specularIntensity: number;
  48013. /**
  48014. * Debug Control allowing disabling the bump map on this material.
  48015. */
  48016. disableBumpMap: boolean;
  48017. /**
  48018. * AKA Diffuse Texture in standard nomenclature.
  48019. */
  48020. albedoTexture: BaseTexture;
  48021. /**
  48022. * AKA Occlusion Texture in other nomenclature.
  48023. */
  48024. ambientTexture: BaseTexture;
  48025. /**
  48026. * AKA Occlusion Texture Intensity in other nomenclature.
  48027. */
  48028. ambientTextureStrength: number;
  48029. /**
  48030. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48031. * 1 means it completely occludes it
  48032. * 0 mean it has no impact
  48033. */
  48034. ambientTextureImpactOnAnalyticalLights: number;
  48035. /**
  48036. * Stores the alpha values in a texture.
  48037. */
  48038. opacityTexture: BaseTexture;
  48039. /**
  48040. * Stores the reflection values in a texture.
  48041. */
  48042. reflectionTexture: Nullable<BaseTexture>;
  48043. /**
  48044. * Stores the emissive values in a texture.
  48045. */
  48046. emissiveTexture: BaseTexture;
  48047. /**
  48048. * AKA Specular texture in other nomenclature.
  48049. */
  48050. reflectivityTexture: BaseTexture;
  48051. /**
  48052. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48053. */
  48054. metallicTexture: BaseTexture;
  48055. /**
  48056. * Specifies the metallic scalar of the metallic/roughness workflow.
  48057. * Can also be used to scale the metalness values of the metallic texture.
  48058. */
  48059. metallic: Nullable<number>;
  48060. /**
  48061. * Specifies the roughness scalar of the metallic/roughness workflow.
  48062. * Can also be used to scale the roughness values of the metallic texture.
  48063. */
  48064. roughness: Nullable<number>;
  48065. /**
  48066. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48067. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48068. */
  48069. microSurfaceTexture: BaseTexture;
  48070. /**
  48071. * Stores surface normal data used to displace a mesh in a texture.
  48072. */
  48073. bumpTexture: BaseTexture;
  48074. /**
  48075. * Stores the pre-calculated light information of a mesh in a texture.
  48076. */
  48077. lightmapTexture: BaseTexture;
  48078. /**
  48079. * Stores the refracted light information in a texture.
  48080. */
  48081. refractionTexture: Nullable<BaseTexture>;
  48082. /**
  48083. * The color of a material in ambient lighting.
  48084. */
  48085. ambientColor: Color3;
  48086. /**
  48087. * AKA Diffuse Color in other nomenclature.
  48088. */
  48089. albedoColor: Color3;
  48090. /**
  48091. * AKA Specular Color in other nomenclature.
  48092. */
  48093. reflectivityColor: Color3;
  48094. /**
  48095. * The color reflected from the material.
  48096. */
  48097. reflectionColor: Color3;
  48098. /**
  48099. * The color emitted from the material.
  48100. */
  48101. emissiveColor: Color3;
  48102. /**
  48103. * AKA Glossiness in other nomenclature.
  48104. */
  48105. microSurface: number;
  48106. /**
  48107. * source material index of refraction (IOR)' / 'destination material IOR.
  48108. */
  48109. indexOfRefraction: number;
  48110. /**
  48111. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48112. */
  48113. invertRefractionY: boolean;
  48114. /**
  48115. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48116. * Materials half opaque for instance using refraction could benefit from this control.
  48117. */
  48118. linkRefractionWithTransparency: boolean;
  48119. /**
  48120. * If true, the light map contains occlusion information instead of lighting info.
  48121. */
  48122. useLightmapAsShadowmap: boolean;
  48123. /**
  48124. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48125. */
  48126. useAlphaFromAlbedoTexture: boolean;
  48127. /**
  48128. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48129. */
  48130. forceAlphaTest: boolean;
  48131. /**
  48132. * Defines the alpha limits in alpha test mode.
  48133. */
  48134. alphaCutOff: number;
  48135. /**
  48136. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48137. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48138. */
  48139. useSpecularOverAlpha: boolean;
  48140. /**
  48141. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48142. */
  48143. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48144. /**
  48145. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48146. */
  48147. useRoughnessFromMetallicTextureAlpha: boolean;
  48148. /**
  48149. * Specifies if the metallic texture contains the roughness information in its green channel.
  48150. */
  48151. useRoughnessFromMetallicTextureGreen: boolean;
  48152. /**
  48153. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48154. */
  48155. useMetallnessFromMetallicTextureBlue: boolean;
  48156. /**
  48157. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48158. */
  48159. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48160. /**
  48161. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48162. */
  48163. useAmbientInGrayScale: boolean;
  48164. /**
  48165. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48166. * The material will try to infer what glossiness each pixel should be.
  48167. */
  48168. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48169. /**
  48170. * BJS is using an harcoded light falloff based on a manually sets up range.
  48171. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48172. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48173. */
  48174. /**
  48175. * BJS is using an harcoded light falloff based on a manually sets up range.
  48176. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48177. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48178. */
  48179. usePhysicalLightFalloff: boolean;
  48180. /**
  48181. * In order to support the falloff compatibility with gltf, a special mode has been added
  48182. * to reproduce the gltf light falloff.
  48183. */
  48184. /**
  48185. * In order to support the falloff compatibility with gltf, a special mode has been added
  48186. * to reproduce the gltf light falloff.
  48187. */
  48188. useGLTFLightFalloff: boolean;
  48189. /**
  48190. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48191. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48192. */
  48193. useRadianceOverAlpha: boolean;
  48194. /**
  48195. * Allows using an object space normal map (instead of tangent space).
  48196. */
  48197. useObjectSpaceNormalMap: boolean;
  48198. /**
  48199. * Allows using the bump map in parallax mode.
  48200. */
  48201. useParallax: boolean;
  48202. /**
  48203. * Allows using the bump map in parallax occlusion mode.
  48204. */
  48205. useParallaxOcclusion: boolean;
  48206. /**
  48207. * Controls the scale bias of the parallax mode.
  48208. */
  48209. parallaxScaleBias: number;
  48210. /**
  48211. * If sets to true, disables all the lights affecting the material.
  48212. */
  48213. disableLighting: boolean;
  48214. /**
  48215. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48216. */
  48217. forceIrradianceInFragment: boolean;
  48218. /**
  48219. * Number of Simultaneous lights allowed on the material.
  48220. */
  48221. maxSimultaneousLights: number;
  48222. /**
  48223. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48224. */
  48225. invertNormalMapX: boolean;
  48226. /**
  48227. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48228. */
  48229. invertNormalMapY: boolean;
  48230. /**
  48231. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48232. */
  48233. twoSidedLighting: boolean;
  48234. /**
  48235. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48236. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48237. */
  48238. useAlphaFresnel: boolean;
  48239. /**
  48240. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48241. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48242. */
  48243. useLinearAlphaFresnel: boolean;
  48244. /**
  48245. * Let user defines the brdf lookup texture used for IBL.
  48246. * A default 8bit version is embedded but you could point at :
  48247. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48248. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48249. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48250. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48251. */
  48252. environmentBRDFTexture: Nullable<BaseTexture>;
  48253. /**
  48254. * Force normal to face away from face.
  48255. */
  48256. forceNormalForward: boolean;
  48257. /**
  48258. * Enables specular anti aliasing in the PBR shader.
  48259. * It will both interacts on the Geometry for analytical and IBL lighting.
  48260. * It also prefilter the roughness map based on the bump values.
  48261. */
  48262. enableSpecularAntiAliasing: boolean;
  48263. /**
  48264. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48265. * makes the reflect vector face the model (under horizon).
  48266. */
  48267. useHorizonOcclusion: boolean;
  48268. /**
  48269. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48270. * too much the area relying on ambient texture to define their ambient occlusion.
  48271. */
  48272. useRadianceOcclusion: boolean;
  48273. /**
  48274. * If set to true, no lighting calculations will be applied.
  48275. */
  48276. unlit: boolean;
  48277. /**
  48278. * Gets the image processing configuration used either in this material.
  48279. */
  48280. /**
  48281. * Sets the Default image processing configuration used either in the this material.
  48282. *
  48283. * If sets to null, the scene one is in use.
  48284. */
  48285. imageProcessingConfiguration: ImageProcessingConfiguration;
  48286. /**
  48287. * Gets wether the color curves effect is enabled.
  48288. */
  48289. /**
  48290. * Sets wether the color curves effect is enabled.
  48291. */
  48292. cameraColorCurvesEnabled: boolean;
  48293. /**
  48294. * Gets wether the color grading effect is enabled.
  48295. */
  48296. /**
  48297. * Gets wether the color grading effect is enabled.
  48298. */
  48299. cameraColorGradingEnabled: boolean;
  48300. /**
  48301. * Gets wether tonemapping is enabled or not.
  48302. */
  48303. /**
  48304. * Sets wether tonemapping is enabled or not
  48305. */
  48306. cameraToneMappingEnabled: boolean;
  48307. /**
  48308. * The camera exposure used on this material.
  48309. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48310. * This corresponds to a photographic exposure.
  48311. */
  48312. /**
  48313. * The camera exposure used on this material.
  48314. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48315. * This corresponds to a photographic exposure.
  48316. */
  48317. cameraExposure: number;
  48318. /**
  48319. * Gets The camera contrast used on this material.
  48320. */
  48321. /**
  48322. * Sets The camera contrast used on this material.
  48323. */
  48324. cameraContrast: number;
  48325. /**
  48326. * Gets the Color Grading 2D Lookup Texture.
  48327. */
  48328. /**
  48329. * Sets the Color Grading 2D Lookup Texture.
  48330. */
  48331. cameraColorGradingTexture: Nullable<BaseTexture>;
  48332. /**
  48333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48335. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  48336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48337. */
  48338. /**
  48339. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48340. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48341. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  48342. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48343. */
  48344. cameraColorCurves: Nullable<ColorCurves>;
  48345. /**
  48346. * Instantiates a new PBRMaterial instance.
  48347. *
  48348. * @param name The material name
  48349. * @param scene The scene the material will be use in.
  48350. */
  48351. constructor(name: string, scene: Scene);
  48352. /**
  48353. * Returns the name of this material class.
  48354. */
  48355. getClassName(): string;
  48356. /**
  48357. * Makes a duplicate of the current material.
  48358. * @param name - name to use for the new material.
  48359. */
  48360. clone(name: string): PBRMaterial;
  48361. /**
  48362. * Serializes this PBR Material.
  48363. * @returns - An object with the serialized material.
  48364. */
  48365. serialize(): any;
  48366. /**
  48367. * Parses a PBR Material from a serialized object.
  48368. * @param source - Serialized object.
  48369. * @param scene - BJS scene instance.
  48370. * @param rootUrl - url for the scene object
  48371. * @returns - PBRMaterial
  48372. */
  48373. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48374. }
  48375. }
  48376. declare module BABYLON {
  48377. /**
  48378. * Direct draw surface info
  48379. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48380. */
  48381. export interface DDSInfo {
  48382. /**
  48383. * Width of the texture
  48384. */
  48385. width: number;
  48386. /**
  48387. * Width of the texture
  48388. */
  48389. height: number;
  48390. /**
  48391. * Number of Mipmaps for the texture
  48392. * @see https://en.wikipedia.org/wiki/Mipmap
  48393. */
  48394. mipmapCount: number;
  48395. /**
  48396. * If the textures format is a known fourCC format
  48397. * @see https://www.fourcc.org/
  48398. */
  48399. isFourCC: boolean;
  48400. /**
  48401. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48402. */
  48403. isRGB: boolean;
  48404. /**
  48405. * If the texture is a lumincance format
  48406. */
  48407. isLuminance: boolean;
  48408. /**
  48409. * If this is a cube texture
  48410. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48411. */
  48412. isCube: boolean;
  48413. /**
  48414. * If the texture is a compressed format eg. FOURCC_DXT1
  48415. */
  48416. isCompressed: boolean;
  48417. /**
  48418. * The dxgiFormat of the texture
  48419. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48420. */
  48421. dxgiFormat: number;
  48422. /**
  48423. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48424. */
  48425. textureType: number;
  48426. /**
  48427. * Sphericle polynomial created for the dds texture
  48428. */
  48429. sphericalPolynomial?: SphericalPolynomial;
  48430. }
  48431. /**
  48432. * Class used to provide DDS decompression tools
  48433. */
  48434. export class DDSTools {
  48435. /**
  48436. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48437. */
  48438. static StoreLODInAlphaChannel: boolean;
  48439. /**
  48440. * Gets DDS information from an array buffer
  48441. * @param arrayBuffer defines the array buffer to read data from
  48442. * @returns the DDS information
  48443. */
  48444. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48445. private static _FloatView;
  48446. private static _Int32View;
  48447. private static _ToHalfFloat;
  48448. private static _FromHalfFloat;
  48449. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48450. private static _GetHalfFloatRGBAArrayBuffer;
  48451. private static _GetFloatRGBAArrayBuffer;
  48452. private static _GetFloatAsUIntRGBAArrayBuffer;
  48453. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48454. private static _GetRGBAArrayBuffer;
  48455. private static _ExtractLongWordOrder;
  48456. private static _GetRGBArrayBuffer;
  48457. private static _GetLuminanceArrayBuffer;
  48458. /**
  48459. * Uploads DDS Levels to a Babylon Texture
  48460. * @hidden
  48461. */
  48462. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48463. }
  48464. interface Engine {
  48465. /**
  48466. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48467. * @param rootUrl defines the url where the file to load is located
  48468. * @param scene defines the current scene
  48469. * @param lodScale defines scale to apply to the mip map selection
  48470. * @param lodOffset defines offset to apply to the mip map selection
  48471. * @param onLoad defines an optional callback raised when the texture is loaded
  48472. * @param onError defines an optional callback raised if there is an issue to load the texture
  48473. * @param format defines the format of the data
  48474. * @param forcedExtension defines the extension to use to pick the right loader
  48475. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48476. * @returns the cube texture as an InternalTexture
  48477. */
  48478. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  48479. }
  48480. }
  48481. declare module BABYLON {
  48482. /**
  48483. * Implementation of the DDS Texture Loader.
  48484. * @hidden
  48485. */
  48486. export class _DDSTextureLoader implements IInternalTextureLoader {
  48487. /**
  48488. * Defines wether the loader supports cascade loading the different faces.
  48489. */
  48490. readonly supportCascades: boolean;
  48491. /**
  48492. * This returns if the loader support the current file information.
  48493. * @param extension defines the file extension of the file being loaded
  48494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48495. * @param fallback defines the fallback internal texture if any
  48496. * @param isBase64 defines whether the texture is encoded as a base64
  48497. * @param isBuffer defines whether the texture data are stored as a buffer
  48498. * @returns true if the loader can load the specified file
  48499. */
  48500. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48501. /**
  48502. * Transform the url before loading if required.
  48503. * @param rootUrl the url of the texture
  48504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48505. * @returns the transformed texture
  48506. */
  48507. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48508. /**
  48509. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48510. * @param rootUrl the url of the texture
  48511. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48512. * @returns the fallback texture
  48513. */
  48514. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48515. /**
  48516. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48517. * @param data contains the texture data
  48518. * @param texture defines the BabylonJS internal texture
  48519. * @param createPolynomials will be true if polynomials have been requested
  48520. * @param onLoad defines the callback to trigger once the texture is ready
  48521. * @param onError defines the callback to trigger in case of error
  48522. */
  48523. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48524. /**
  48525. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48526. * @param data contains the texture data
  48527. * @param texture defines the BabylonJS internal texture
  48528. * @param callback defines the method to call once ready to upload
  48529. */
  48530. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48531. }
  48532. }
  48533. declare module BABYLON {
  48534. /**
  48535. * Implementation of the ENV Texture Loader.
  48536. * @hidden
  48537. */
  48538. export class _ENVTextureLoader implements IInternalTextureLoader {
  48539. /**
  48540. * Defines wether the loader supports cascade loading the different faces.
  48541. */
  48542. readonly supportCascades: boolean;
  48543. /**
  48544. * This returns if the loader support the current file information.
  48545. * @param extension defines the file extension of the file being loaded
  48546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48547. * @param fallback defines the fallback internal texture if any
  48548. * @param isBase64 defines whether the texture is encoded as a base64
  48549. * @param isBuffer defines whether the texture data are stored as a buffer
  48550. * @returns true if the loader can load the specified file
  48551. */
  48552. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48553. /**
  48554. * Transform the url before loading if required.
  48555. * @param rootUrl the url of the texture
  48556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48557. * @returns the transformed texture
  48558. */
  48559. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48560. /**
  48561. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48562. * @param rootUrl the url of the texture
  48563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48564. * @returns the fallback texture
  48565. */
  48566. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48567. /**
  48568. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48569. * @param data contains the texture data
  48570. * @param texture defines the BabylonJS internal texture
  48571. * @param createPolynomials will be true if polynomials have been requested
  48572. * @param onLoad defines the callback to trigger once the texture is ready
  48573. * @param onError defines the callback to trigger in case of error
  48574. */
  48575. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48576. /**
  48577. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48578. * @param data contains the texture data
  48579. * @param texture defines the BabylonJS internal texture
  48580. * @param callback defines the method to call once ready to upload
  48581. */
  48582. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48583. }
  48584. }
  48585. declare module BABYLON {
  48586. /**
  48587. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48588. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48589. */
  48590. export class KhronosTextureContainer {
  48591. /** contents of the KTX container file */
  48592. arrayBuffer: any;
  48593. private static HEADER_LEN;
  48594. private static COMPRESSED_2D;
  48595. private static COMPRESSED_3D;
  48596. private static TEX_2D;
  48597. private static TEX_3D;
  48598. /**
  48599. * Gets the openGL type
  48600. */
  48601. glType: number;
  48602. /**
  48603. * Gets the openGL type size
  48604. */
  48605. glTypeSize: number;
  48606. /**
  48607. * Gets the openGL format
  48608. */
  48609. glFormat: number;
  48610. /**
  48611. * Gets the openGL internal format
  48612. */
  48613. glInternalFormat: number;
  48614. /**
  48615. * Gets the base internal format
  48616. */
  48617. glBaseInternalFormat: number;
  48618. /**
  48619. * Gets image width in pixel
  48620. */
  48621. pixelWidth: number;
  48622. /**
  48623. * Gets image height in pixel
  48624. */
  48625. pixelHeight: number;
  48626. /**
  48627. * Gets image depth in pixels
  48628. */
  48629. pixelDepth: number;
  48630. /**
  48631. * Gets the number of array elements
  48632. */
  48633. numberOfArrayElements: number;
  48634. /**
  48635. * Gets the number of faces
  48636. */
  48637. numberOfFaces: number;
  48638. /**
  48639. * Gets the number of mipmap levels
  48640. */
  48641. numberOfMipmapLevels: number;
  48642. /**
  48643. * Gets the bytes of key value data
  48644. */
  48645. bytesOfKeyValueData: number;
  48646. /**
  48647. * Gets the load type
  48648. */
  48649. loadType: number;
  48650. /**
  48651. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48652. */
  48653. isInvalid: boolean;
  48654. /**
  48655. * Creates a new KhronosTextureContainer
  48656. * @param arrayBuffer contents of the KTX container file
  48657. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48658. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48659. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48660. */
  48661. constructor(
  48662. /** contents of the KTX container file */
  48663. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48664. /**
  48665. * Uploads KTX content to a Babylon Texture.
  48666. * It is assumed that the texture has already been created & is currently bound
  48667. * @hidden
  48668. */
  48669. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48670. private _upload2DCompressedLevels;
  48671. }
  48672. }
  48673. declare module BABYLON {
  48674. /**
  48675. * Implementation of the KTX Texture Loader.
  48676. * @hidden
  48677. */
  48678. export class _KTXTextureLoader implements IInternalTextureLoader {
  48679. /**
  48680. * Defines wether the loader supports cascade loading the different faces.
  48681. */
  48682. readonly supportCascades: boolean;
  48683. /**
  48684. * This returns if the loader support the current file information.
  48685. * @param extension defines the file extension of the file being loaded
  48686. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48687. * @param fallback defines the fallback internal texture if any
  48688. * @param isBase64 defines whether the texture is encoded as a base64
  48689. * @param isBuffer defines whether the texture data are stored as a buffer
  48690. * @returns true if the loader can load the specified file
  48691. */
  48692. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48693. /**
  48694. * Transform the url before loading if required.
  48695. * @param rootUrl the url of the texture
  48696. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48697. * @returns the transformed texture
  48698. */
  48699. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48700. /**
  48701. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48702. * @param rootUrl the url of the texture
  48703. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48704. * @returns the fallback texture
  48705. */
  48706. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48707. /**
  48708. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48709. * @param data contains the texture data
  48710. * @param texture defines the BabylonJS internal texture
  48711. * @param createPolynomials will be true if polynomials have been requested
  48712. * @param onLoad defines the callback to trigger once the texture is ready
  48713. * @param onError defines the callback to trigger in case of error
  48714. */
  48715. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48716. /**
  48717. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48718. * @param data contains the texture data
  48719. * @param texture defines the BabylonJS internal texture
  48720. * @param callback defines the method to call once ready to upload
  48721. */
  48722. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48723. }
  48724. }
  48725. declare module BABYLON {
  48726. /**
  48727. * Options for the default xr helper
  48728. */
  48729. export class WebXRDefaultExperienceOptions {
  48730. /**
  48731. * Floor meshes that should be used for teleporting
  48732. */
  48733. floorMeshes: Array<AbstractMesh>;
  48734. }
  48735. /**
  48736. * Default experience which provides a similar setup to the previous webVRExperience
  48737. */
  48738. export class WebXRDefaultExperience {
  48739. /**
  48740. * Base experience
  48741. */
  48742. baseExperience: WebXRExperienceHelper;
  48743. /**
  48744. * Input experience extension
  48745. */
  48746. input: WebXRInput;
  48747. /**
  48748. * Loads the controller models
  48749. */
  48750. controllerModelLoader: WebXRControllerModelLoader;
  48751. /**
  48752. * Enables laser pointer and selection
  48753. */
  48754. pointerSelection: WebXRControllerPointerSelection;
  48755. /**
  48756. * Enables teleportation
  48757. */
  48758. teleportation: WebXRControllerTeleportation;
  48759. /**
  48760. * Enables ui for enetering/exiting xr
  48761. */
  48762. enterExitUI: WebXREnterExitUI;
  48763. /**
  48764. * Default output canvas xr should render to
  48765. */
  48766. outputCanvas: WebXRManagedOutputCanvas;
  48767. /**
  48768. * Creates the default xr experience
  48769. * @param scene scene
  48770. * @param options options for basic configuration
  48771. * @returns resulting WebXRDefaultExperience
  48772. */
  48773. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48774. private constructor();
  48775. /**
  48776. * DIsposes of the experience helper
  48777. */
  48778. dispose(): void;
  48779. }
  48780. }
  48781. declare module BABYLON {
  48782. /** @hidden */
  48783. export var _forceSceneHelpersToBundle: boolean;
  48784. interface Scene {
  48785. /**
  48786. * Creates a default light for the scene.
  48787. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48788. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48789. */
  48790. createDefaultLight(replace?: boolean): void;
  48791. /**
  48792. * Creates a default camera for the scene.
  48793. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48794. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48795. * @param replace has default false, when true replaces the active camera in the scene
  48796. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48797. */
  48798. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48799. /**
  48800. * Creates a default camera and a default light.
  48801. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48802. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48803. * @param replace has the default false, when true replaces the active camera/light in the scene
  48804. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48805. */
  48806. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48807. /**
  48808. * Creates a new sky box
  48809. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48810. * @param environmentTexture defines the texture to use as environment texture
  48811. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48812. * @param scale defines the overall scale of the skybox
  48813. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48814. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48815. * @returns a new mesh holding the sky box
  48816. */
  48817. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48818. /**
  48819. * Creates a new environment
  48820. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48821. * @param options defines the options you can use to configure the environment
  48822. * @returns the new EnvironmentHelper
  48823. */
  48824. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48825. /**
  48826. * Creates a new VREXperienceHelper
  48827. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48828. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48829. * @returns a new VREXperienceHelper
  48830. */
  48831. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48832. /**
  48833. * Creates a new WebXRDefaultExperience
  48834. * @see http://doc.babylonjs.com/how_to/webxr
  48835. * @param options experience options
  48836. * @returns a promise for a new WebXRDefaultExperience
  48837. */
  48838. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48839. }
  48840. }
  48841. declare module BABYLON {
  48842. /**
  48843. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48844. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48845. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48846. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48847. */
  48848. export class VideoDome extends TransformNode {
  48849. /**
  48850. * Define the video source as a Monoscopic panoramic 360 video.
  48851. */
  48852. static readonly MODE_MONOSCOPIC: number;
  48853. /**
  48854. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48855. */
  48856. static readonly MODE_TOPBOTTOM: number;
  48857. /**
  48858. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48859. */
  48860. static readonly MODE_SIDEBYSIDE: number;
  48861. private _halfDome;
  48862. private _useDirectMapping;
  48863. /**
  48864. * The video texture being displayed on the sphere
  48865. */
  48866. protected _videoTexture: VideoTexture;
  48867. /**
  48868. * Gets the video texture being displayed on the sphere
  48869. */
  48870. readonly videoTexture: VideoTexture;
  48871. /**
  48872. * The skybox material
  48873. */
  48874. protected _material: BackgroundMaterial;
  48875. /**
  48876. * The surface used for the skybox
  48877. */
  48878. protected _mesh: Mesh;
  48879. /**
  48880. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48881. */
  48882. private _halfDomeMask;
  48883. /**
  48884. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48885. * Also see the options.resolution property.
  48886. */
  48887. fovMultiplier: number;
  48888. private _videoMode;
  48889. /**
  48890. * Gets or set the current video mode for the video. It can be:
  48891. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48892. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48893. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48894. */
  48895. videoMode: number;
  48896. /**
  48897. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48898. *
  48899. */
  48900. /**
  48901. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48902. */
  48903. halfDome: boolean;
  48904. /**
  48905. * Oberserver used in Stereoscopic VR Mode.
  48906. */
  48907. private _onBeforeCameraRenderObserver;
  48908. /**
  48909. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48910. * @param name Element's name, child elements will append suffixes for their own names.
  48911. * @param urlsOrVideo defines the url(s) or the video element to use
  48912. * @param options An object containing optional or exposed sub element properties
  48913. */
  48914. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48915. resolution?: number;
  48916. clickToPlay?: boolean;
  48917. autoPlay?: boolean;
  48918. loop?: boolean;
  48919. size?: number;
  48920. poster?: string;
  48921. faceForward?: boolean;
  48922. useDirectMapping?: boolean;
  48923. halfDomeMode?: boolean;
  48924. }, scene: Scene);
  48925. private _changeVideoMode;
  48926. /**
  48927. * Releases resources associated with this node.
  48928. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48929. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48930. */
  48931. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48932. }
  48933. }
  48934. declare module BABYLON {
  48935. /**
  48936. * This class can be used to get instrumentation data from a Babylon engine
  48937. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48938. */
  48939. export class EngineInstrumentation implements IDisposable {
  48940. /**
  48941. * Define the instrumented engine.
  48942. */
  48943. engine: Engine;
  48944. private _captureGPUFrameTime;
  48945. private _gpuFrameTimeToken;
  48946. private _gpuFrameTime;
  48947. private _captureShaderCompilationTime;
  48948. private _shaderCompilationTime;
  48949. private _onBeginFrameObserver;
  48950. private _onEndFrameObserver;
  48951. private _onBeforeShaderCompilationObserver;
  48952. private _onAfterShaderCompilationObserver;
  48953. /**
  48954. * Gets the perf counter used for GPU frame time
  48955. */
  48956. readonly gpuFrameTimeCounter: PerfCounter;
  48957. /**
  48958. * Gets the GPU frame time capture status
  48959. */
  48960. /**
  48961. * Enable or disable the GPU frame time capture
  48962. */
  48963. captureGPUFrameTime: boolean;
  48964. /**
  48965. * Gets the perf counter used for shader compilation time
  48966. */
  48967. readonly shaderCompilationTimeCounter: PerfCounter;
  48968. /**
  48969. * Gets the shader compilation time capture status
  48970. */
  48971. /**
  48972. * Enable or disable the shader compilation time capture
  48973. */
  48974. captureShaderCompilationTime: boolean;
  48975. /**
  48976. * Instantiates a new engine instrumentation.
  48977. * This class can be used to get instrumentation data from a Babylon engine
  48978. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48979. * @param engine Defines the engine to instrument
  48980. */
  48981. constructor(
  48982. /**
  48983. * Define the instrumented engine.
  48984. */
  48985. engine: Engine);
  48986. /**
  48987. * Dispose and release associated resources.
  48988. */
  48989. dispose(): void;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /**
  48994. * This class can be used to get instrumentation data from a Babylon engine
  48995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48996. */
  48997. export class SceneInstrumentation implements IDisposable {
  48998. /**
  48999. * Defines the scene to instrument
  49000. */
  49001. scene: Scene;
  49002. private _captureActiveMeshesEvaluationTime;
  49003. private _activeMeshesEvaluationTime;
  49004. private _captureRenderTargetsRenderTime;
  49005. private _renderTargetsRenderTime;
  49006. private _captureFrameTime;
  49007. private _frameTime;
  49008. private _captureRenderTime;
  49009. private _renderTime;
  49010. private _captureInterFrameTime;
  49011. private _interFrameTime;
  49012. private _captureParticlesRenderTime;
  49013. private _particlesRenderTime;
  49014. private _captureSpritesRenderTime;
  49015. private _spritesRenderTime;
  49016. private _capturePhysicsTime;
  49017. private _physicsTime;
  49018. private _captureAnimationsTime;
  49019. private _animationsTime;
  49020. private _captureCameraRenderTime;
  49021. private _cameraRenderTime;
  49022. private _onBeforeActiveMeshesEvaluationObserver;
  49023. private _onAfterActiveMeshesEvaluationObserver;
  49024. private _onBeforeRenderTargetsRenderObserver;
  49025. private _onAfterRenderTargetsRenderObserver;
  49026. private _onAfterRenderObserver;
  49027. private _onBeforeDrawPhaseObserver;
  49028. private _onAfterDrawPhaseObserver;
  49029. private _onBeforeAnimationsObserver;
  49030. private _onBeforeParticlesRenderingObserver;
  49031. private _onAfterParticlesRenderingObserver;
  49032. private _onBeforeSpritesRenderingObserver;
  49033. private _onAfterSpritesRenderingObserver;
  49034. private _onBeforePhysicsObserver;
  49035. private _onAfterPhysicsObserver;
  49036. private _onAfterAnimationsObserver;
  49037. private _onBeforeCameraRenderObserver;
  49038. private _onAfterCameraRenderObserver;
  49039. /**
  49040. * Gets the perf counter used for active meshes evaluation time
  49041. */
  49042. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49043. /**
  49044. * Gets the active meshes evaluation time capture status
  49045. */
  49046. /**
  49047. * Enable or disable the active meshes evaluation time capture
  49048. */
  49049. captureActiveMeshesEvaluationTime: boolean;
  49050. /**
  49051. * Gets the perf counter used for render targets render time
  49052. */
  49053. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49054. /**
  49055. * Gets the render targets render time capture status
  49056. */
  49057. /**
  49058. * Enable or disable the render targets render time capture
  49059. */
  49060. captureRenderTargetsRenderTime: boolean;
  49061. /**
  49062. * Gets the perf counter used for particles render time
  49063. */
  49064. readonly particlesRenderTimeCounter: PerfCounter;
  49065. /**
  49066. * Gets the particles render time capture status
  49067. */
  49068. /**
  49069. * Enable or disable the particles render time capture
  49070. */
  49071. captureParticlesRenderTime: boolean;
  49072. /**
  49073. * Gets the perf counter used for sprites render time
  49074. */
  49075. readonly spritesRenderTimeCounter: PerfCounter;
  49076. /**
  49077. * Gets the sprites render time capture status
  49078. */
  49079. /**
  49080. * Enable or disable the sprites render time capture
  49081. */
  49082. captureSpritesRenderTime: boolean;
  49083. /**
  49084. * Gets the perf counter used for physics time
  49085. */
  49086. readonly physicsTimeCounter: PerfCounter;
  49087. /**
  49088. * Gets the physics time capture status
  49089. */
  49090. /**
  49091. * Enable or disable the physics time capture
  49092. */
  49093. capturePhysicsTime: boolean;
  49094. /**
  49095. * Gets the perf counter used for animations time
  49096. */
  49097. readonly animationsTimeCounter: PerfCounter;
  49098. /**
  49099. * Gets the animations time capture status
  49100. */
  49101. /**
  49102. * Enable or disable the animations time capture
  49103. */
  49104. captureAnimationsTime: boolean;
  49105. /**
  49106. * Gets the perf counter used for frame time capture
  49107. */
  49108. readonly frameTimeCounter: PerfCounter;
  49109. /**
  49110. * Gets the frame time capture status
  49111. */
  49112. /**
  49113. * Enable or disable the frame time capture
  49114. */
  49115. captureFrameTime: boolean;
  49116. /**
  49117. * Gets the perf counter used for inter-frames time capture
  49118. */
  49119. readonly interFrameTimeCounter: PerfCounter;
  49120. /**
  49121. * Gets the inter-frames time capture status
  49122. */
  49123. /**
  49124. * Enable or disable the inter-frames time capture
  49125. */
  49126. captureInterFrameTime: boolean;
  49127. /**
  49128. * Gets the perf counter used for render time capture
  49129. */
  49130. readonly renderTimeCounter: PerfCounter;
  49131. /**
  49132. * Gets the render time capture status
  49133. */
  49134. /**
  49135. * Enable or disable the render time capture
  49136. */
  49137. captureRenderTime: boolean;
  49138. /**
  49139. * Gets the perf counter used for camera render time capture
  49140. */
  49141. readonly cameraRenderTimeCounter: PerfCounter;
  49142. /**
  49143. * Gets the camera render time capture status
  49144. */
  49145. /**
  49146. * Enable or disable the camera render time capture
  49147. */
  49148. captureCameraRenderTime: boolean;
  49149. /**
  49150. * Gets the perf counter used for draw calls
  49151. */
  49152. readonly drawCallsCounter: PerfCounter;
  49153. /**
  49154. * Instantiates a new scene instrumentation.
  49155. * This class can be used to get instrumentation data from a Babylon engine
  49156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49157. * @param scene Defines the scene to instrument
  49158. */
  49159. constructor(
  49160. /**
  49161. * Defines the scene to instrument
  49162. */
  49163. scene: Scene);
  49164. /**
  49165. * Dispose and release associated resources.
  49166. */
  49167. dispose(): void;
  49168. }
  49169. }
  49170. declare module BABYLON {
  49171. /** @hidden */
  49172. export var glowMapGenerationPixelShader: {
  49173. name: string;
  49174. shader: string;
  49175. };
  49176. }
  49177. declare module BABYLON {
  49178. /** @hidden */
  49179. export var glowMapGenerationVertexShader: {
  49180. name: string;
  49181. shader: string;
  49182. };
  49183. }
  49184. declare module BABYLON {
  49185. /**
  49186. * Effect layer options. This helps customizing the behaviour
  49187. * of the effect layer.
  49188. */
  49189. export interface IEffectLayerOptions {
  49190. /**
  49191. * Multiplication factor apply to the canvas size to compute the render target size
  49192. * used to generated the objects (the smaller the faster).
  49193. */
  49194. mainTextureRatio: number;
  49195. /**
  49196. * Enforces a fixed size texture to ensure effect stability across devices.
  49197. */
  49198. mainTextureFixedSize?: number;
  49199. /**
  49200. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49201. */
  49202. alphaBlendingMode: number;
  49203. /**
  49204. * The camera attached to the layer.
  49205. */
  49206. camera: Nullable<Camera>;
  49207. /**
  49208. * The rendering group to draw the layer in.
  49209. */
  49210. renderingGroupId: number;
  49211. }
  49212. /**
  49213. * The effect layer Helps adding post process effect blended with the main pass.
  49214. *
  49215. * This can be for instance use to generate glow or higlight effects on the scene.
  49216. *
  49217. * The effect layer class can not be used directly and is intented to inherited from to be
  49218. * customized per effects.
  49219. */
  49220. export abstract class EffectLayer {
  49221. private _vertexBuffers;
  49222. private _indexBuffer;
  49223. private _cachedDefines;
  49224. private _effectLayerMapGenerationEffect;
  49225. private _effectLayerOptions;
  49226. private _mergeEffect;
  49227. protected _scene: Scene;
  49228. protected _engine: Engine;
  49229. protected _maxSize: number;
  49230. protected _mainTextureDesiredSize: ISize;
  49231. protected _mainTexture: RenderTargetTexture;
  49232. protected _shouldRender: boolean;
  49233. protected _postProcesses: PostProcess[];
  49234. protected _textures: BaseTexture[];
  49235. protected _emissiveTextureAndColor: {
  49236. texture: Nullable<BaseTexture>;
  49237. color: Color4;
  49238. };
  49239. /**
  49240. * The name of the layer
  49241. */
  49242. name: string;
  49243. /**
  49244. * The clear color of the texture used to generate the glow map.
  49245. */
  49246. neutralColor: Color4;
  49247. /**
  49248. * Specifies wether the highlight layer is enabled or not.
  49249. */
  49250. isEnabled: boolean;
  49251. /**
  49252. * Gets the camera attached to the layer.
  49253. */
  49254. readonly camera: Nullable<Camera>;
  49255. /**
  49256. * Gets the rendering group id the layer should render in.
  49257. */
  49258. renderingGroupId: number;
  49259. /**
  49260. * An event triggered when the effect layer has been disposed.
  49261. */
  49262. onDisposeObservable: Observable<EffectLayer>;
  49263. /**
  49264. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49265. */
  49266. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49267. /**
  49268. * An event triggered when the generated texture is being merged in the scene.
  49269. */
  49270. onBeforeComposeObservable: Observable<EffectLayer>;
  49271. /**
  49272. * An event triggered when the generated texture has been merged in the scene.
  49273. */
  49274. onAfterComposeObservable: Observable<EffectLayer>;
  49275. /**
  49276. * An event triggered when the efffect layer changes its size.
  49277. */
  49278. onSizeChangedObservable: Observable<EffectLayer>;
  49279. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49280. /**
  49281. * Instantiates a new effect Layer and references it in the scene.
  49282. * @param name The name of the layer
  49283. * @param scene The scene to use the layer in
  49284. */
  49285. constructor(
  49286. /** The Friendly of the effect in the scene */
  49287. name: string, scene: Scene);
  49288. /**
  49289. * Get the effect name of the layer.
  49290. * @return The effect name
  49291. */
  49292. abstract getEffectName(): string;
  49293. /**
  49294. * Checks for the readiness of the element composing the layer.
  49295. * @param subMesh the mesh to check for
  49296. * @param useInstances specify wether or not to use instances to render the mesh
  49297. * @return true if ready otherwise, false
  49298. */
  49299. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49300. /**
  49301. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49302. * @returns true if the effect requires stencil during the main canvas render pass.
  49303. */
  49304. abstract needStencil(): boolean;
  49305. /**
  49306. * Create the merge effect. This is the shader use to blit the information back
  49307. * to the main canvas at the end of the scene rendering.
  49308. * @returns The effect containing the shader used to merge the effect on the main canvas
  49309. */
  49310. protected abstract _createMergeEffect(): Effect;
  49311. /**
  49312. * Creates the render target textures and post processes used in the effect layer.
  49313. */
  49314. protected abstract _createTextureAndPostProcesses(): void;
  49315. /**
  49316. * Implementation specific of rendering the generating effect on the main canvas.
  49317. * @param effect The effect used to render through
  49318. */
  49319. protected abstract _internalRender(effect: Effect): void;
  49320. /**
  49321. * Sets the required values for both the emissive texture and and the main color.
  49322. */
  49323. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49324. /**
  49325. * Free any resources and references associated to a mesh.
  49326. * Internal use
  49327. * @param mesh The mesh to free.
  49328. */
  49329. abstract _disposeMesh(mesh: Mesh): void;
  49330. /**
  49331. * Serializes this layer (Glow or Highlight for example)
  49332. * @returns a serialized layer object
  49333. */
  49334. abstract serialize?(): any;
  49335. /**
  49336. * Initializes the effect layer with the required options.
  49337. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49338. */
  49339. protected _init(options: Partial<IEffectLayerOptions>): void;
  49340. /**
  49341. * Generates the index buffer of the full screen quad blending to the main canvas.
  49342. */
  49343. private _generateIndexBuffer;
  49344. /**
  49345. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49346. */
  49347. private _generateVertexBuffer;
  49348. /**
  49349. * Sets the main texture desired size which is the closest power of two
  49350. * of the engine canvas size.
  49351. */
  49352. private _setMainTextureSize;
  49353. /**
  49354. * Creates the main texture for the effect layer.
  49355. */
  49356. protected _createMainTexture(): void;
  49357. /**
  49358. * Adds specific effects defines.
  49359. * @param defines The defines to add specifics to.
  49360. */
  49361. protected _addCustomEffectDefines(defines: string[]): void;
  49362. /**
  49363. * Checks for the readiness of the element composing the layer.
  49364. * @param subMesh the mesh to check for
  49365. * @param useInstances specify wether or not to use instances to render the mesh
  49366. * @param emissiveTexture the associated emissive texture used to generate the glow
  49367. * @return true if ready otherwise, false
  49368. */
  49369. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49370. /**
  49371. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49372. */
  49373. render(): void;
  49374. /**
  49375. * Determine if a given mesh will be used in the current effect.
  49376. * @param mesh mesh to test
  49377. * @returns true if the mesh will be used
  49378. */
  49379. hasMesh(mesh: AbstractMesh): boolean;
  49380. /**
  49381. * Returns true if the layer contains information to display, otherwise false.
  49382. * @returns true if the glow layer should be rendered
  49383. */
  49384. shouldRender(): boolean;
  49385. /**
  49386. * Returns true if the mesh should render, otherwise false.
  49387. * @param mesh The mesh to render
  49388. * @returns true if it should render otherwise false
  49389. */
  49390. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49391. /**
  49392. * Returns true if the mesh can be rendered, otherwise false.
  49393. * @param mesh The mesh to render
  49394. * @param material The material used on the mesh
  49395. * @returns true if it can be rendered otherwise false
  49396. */
  49397. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49398. /**
  49399. * Returns true if the mesh should render, otherwise false.
  49400. * @param mesh The mesh to render
  49401. * @returns true if it should render otherwise false
  49402. */
  49403. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49404. /**
  49405. * Renders the submesh passed in parameter to the generation map.
  49406. */
  49407. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49408. /**
  49409. * Rebuild the required buffers.
  49410. * @hidden Internal use only.
  49411. */ private _rebuild(): void;
  49412. /**
  49413. * Dispose only the render target textures and post process.
  49414. */
  49415. private _disposeTextureAndPostProcesses;
  49416. /**
  49417. * Dispose the highlight layer and free resources.
  49418. */
  49419. dispose(): void;
  49420. /**
  49421. * Gets the class name of the effect layer
  49422. * @returns the string with the class name of the effect layer
  49423. */
  49424. getClassName(): string;
  49425. /**
  49426. * Creates an effect layer from parsed effect layer data
  49427. * @param parsedEffectLayer defines effect layer data
  49428. * @param scene defines the current scene
  49429. * @param rootUrl defines the root URL containing the effect layer information
  49430. * @returns a parsed effect Layer
  49431. */
  49432. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49433. }
  49434. }
  49435. declare module BABYLON {
  49436. interface AbstractScene {
  49437. /**
  49438. * The list of effect layers (highlights/glow) added to the scene
  49439. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49440. * @see http://doc.babylonjs.com/how_to/glow_layer
  49441. */
  49442. effectLayers: Array<EffectLayer>;
  49443. /**
  49444. * Removes the given effect layer from this scene.
  49445. * @param toRemove defines the effect layer to remove
  49446. * @returns the index of the removed effect layer
  49447. */
  49448. removeEffectLayer(toRemove: EffectLayer): number;
  49449. /**
  49450. * Adds the given effect layer to this scene
  49451. * @param newEffectLayer defines the effect layer to add
  49452. */
  49453. addEffectLayer(newEffectLayer: EffectLayer): void;
  49454. }
  49455. /**
  49456. * Defines the layer scene component responsible to manage any effect layers
  49457. * in a given scene.
  49458. */
  49459. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49460. /**
  49461. * The component name helpfull to identify the component in the list of scene components.
  49462. */
  49463. readonly name: string;
  49464. /**
  49465. * The scene the component belongs to.
  49466. */
  49467. scene: Scene;
  49468. private _engine;
  49469. private _renderEffects;
  49470. private _needStencil;
  49471. private _previousStencilState;
  49472. /**
  49473. * Creates a new instance of the component for the given scene
  49474. * @param scene Defines the scene to register the component in
  49475. */
  49476. constructor(scene: Scene);
  49477. /**
  49478. * Registers the component in a given scene
  49479. */
  49480. register(): void;
  49481. /**
  49482. * Rebuilds the elements related to this component in case of
  49483. * context lost for instance.
  49484. */
  49485. rebuild(): void;
  49486. /**
  49487. * Serializes the component data to the specified json object
  49488. * @param serializationObject The object to serialize to
  49489. */
  49490. serialize(serializationObject: any): void;
  49491. /**
  49492. * Adds all the elements from the container to the scene
  49493. * @param container the container holding the elements
  49494. */
  49495. addFromContainer(container: AbstractScene): void;
  49496. /**
  49497. * Removes all the elements in the container from the scene
  49498. * @param container contains the elements to remove
  49499. * @param dispose if the removed element should be disposed (default: false)
  49500. */
  49501. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49502. /**
  49503. * Disposes the component and the associated ressources.
  49504. */
  49505. dispose(): void;
  49506. private _isReadyForMesh;
  49507. private _renderMainTexture;
  49508. private _setStencil;
  49509. private _setStencilBack;
  49510. private _draw;
  49511. private _drawCamera;
  49512. private _drawRenderingGroup;
  49513. }
  49514. }
  49515. declare module BABYLON {
  49516. /** @hidden */
  49517. export var glowMapMergePixelShader: {
  49518. name: string;
  49519. shader: string;
  49520. };
  49521. }
  49522. declare module BABYLON {
  49523. /** @hidden */
  49524. export var glowMapMergeVertexShader: {
  49525. name: string;
  49526. shader: string;
  49527. };
  49528. }
  49529. declare module BABYLON {
  49530. interface AbstractScene {
  49531. /**
  49532. * Return a the first highlight layer of the scene with a given name.
  49533. * @param name The name of the highlight layer to look for.
  49534. * @return The highlight layer if found otherwise null.
  49535. */
  49536. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49537. }
  49538. /**
  49539. * Glow layer options. This helps customizing the behaviour
  49540. * of the glow layer.
  49541. */
  49542. export interface IGlowLayerOptions {
  49543. /**
  49544. * Multiplication factor apply to the canvas size to compute the render target size
  49545. * used to generated the glowing objects (the smaller the faster).
  49546. */
  49547. mainTextureRatio: number;
  49548. /**
  49549. * Enforces a fixed size texture to ensure resize independant blur.
  49550. */
  49551. mainTextureFixedSize?: number;
  49552. /**
  49553. * How big is the kernel of the blur texture.
  49554. */
  49555. blurKernelSize: number;
  49556. /**
  49557. * The camera attached to the layer.
  49558. */
  49559. camera: Nullable<Camera>;
  49560. /**
  49561. * Enable MSAA by chosing the number of samples.
  49562. */
  49563. mainTextureSamples?: number;
  49564. /**
  49565. * The rendering group to draw the layer in.
  49566. */
  49567. renderingGroupId: number;
  49568. }
  49569. /**
  49570. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49571. *
  49572. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49573. * glowy meshes to your scene.
  49574. *
  49575. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49576. */
  49577. export class GlowLayer extends EffectLayer {
  49578. /**
  49579. * Effect Name of the layer.
  49580. */
  49581. static readonly EffectName: string;
  49582. /**
  49583. * The default blur kernel size used for the glow.
  49584. */
  49585. static DefaultBlurKernelSize: number;
  49586. /**
  49587. * The default texture size ratio used for the glow.
  49588. */
  49589. static DefaultTextureRatio: number;
  49590. /**
  49591. * Sets the kernel size of the blur.
  49592. */
  49593. /**
  49594. * Gets the kernel size of the blur.
  49595. */
  49596. blurKernelSize: number;
  49597. /**
  49598. * Sets the glow intensity.
  49599. */
  49600. /**
  49601. * Gets the glow intensity.
  49602. */
  49603. intensity: number;
  49604. private _options;
  49605. private _intensity;
  49606. private _horizontalBlurPostprocess1;
  49607. private _verticalBlurPostprocess1;
  49608. private _horizontalBlurPostprocess2;
  49609. private _verticalBlurPostprocess2;
  49610. private _blurTexture1;
  49611. private _blurTexture2;
  49612. private _postProcesses1;
  49613. private _postProcesses2;
  49614. private _includedOnlyMeshes;
  49615. private _excludedMeshes;
  49616. /**
  49617. * Callback used to let the user override the color selection on a per mesh basis
  49618. */
  49619. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49620. /**
  49621. * Callback used to let the user override the texture selection on a per mesh basis
  49622. */
  49623. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49624. /**
  49625. * Instantiates a new glow Layer and references it to the scene.
  49626. * @param name The name of the layer
  49627. * @param scene The scene to use the layer in
  49628. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49629. */
  49630. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49631. /**
  49632. * Get the effect name of the layer.
  49633. * @return The effect name
  49634. */
  49635. getEffectName(): string;
  49636. /**
  49637. * Create the merge effect. This is the shader use to blit the information back
  49638. * to the main canvas at the end of the scene rendering.
  49639. */
  49640. protected _createMergeEffect(): Effect;
  49641. /**
  49642. * Creates the render target textures and post processes used in the glow layer.
  49643. */
  49644. protected _createTextureAndPostProcesses(): void;
  49645. /**
  49646. * Checks for the readiness of the element composing the layer.
  49647. * @param subMesh the mesh to check for
  49648. * @param useInstances specify wether or not to use instances to render the mesh
  49649. * @param emissiveTexture the associated emissive texture used to generate the glow
  49650. * @return true if ready otherwise, false
  49651. */
  49652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49653. /**
  49654. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49655. */
  49656. needStencil(): boolean;
  49657. /**
  49658. * Returns true if the mesh can be rendered, otherwise false.
  49659. * @param mesh The mesh to render
  49660. * @param material The material used on the mesh
  49661. * @returns true if it can be rendered otherwise false
  49662. */
  49663. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49664. /**
  49665. * Implementation specific of rendering the generating effect on the main canvas.
  49666. * @param effect The effect used to render through
  49667. */
  49668. protected _internalRender(effect: Effect): void;
  49669. /**
  49670. * Sets the required values for both the emissive texture and and the main color.
  49671. */
  49672. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49673. /**
  49674. * Returns true if the mesh should render, otherwise false.
  49675. * @param mesh The mesh to render
  49676. * @returns true if it should render otherwise false
  49677. */
  49678. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49679. /**
  49680. * Adds specific effects defines.
  49681. * @param defines The defines to add specifics to.
  49682. */
  49683. protected _addCustomEffectDefines(defines: string[]): void;
  49684. /**
  49685. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49686. * @param mesh The mesh to exclude from the glow layer
  49687. */
  49688. addExcludedMesh(mesh: Mesh): void;
  49689. /**
  49690. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49691. * @param mesh The mesh to remove
  49692. */
  49693. removeExcludedMesh(mesh: Mesh): void;
  49694. /**
  49695. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49696. * @param mesh The mesh to include in the glow layer
  49697. */
  49698. addIncludedOnlyMesh(mesh: Mesh): void;
  49699. /**
  49700. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49701. * @param mesh The mesh to remove
  49702. */
  49703. removeIncludedOnlyMesh(mesh: Mesh): void;
  49704. /**
  49705. * Determine if a given mesh will be used in the glow layer
  49706. * @param mesh The mesh to test
  49707. * @returns true if the mesh will be highlighted by the current glow layer
  49708. */
  49709. hasMesh(mesh: AbstractMesh): boolean;
  49710. /**
  49711. * Free any resources and references associated to a mesh.
  49712. * Internal use
  49713. * @param mesh The mesh to free.
  49714. * @hidden
  49715. */ private _disposeMesh(mesh: Mesh): void;
  49716. /**
  49717. * Gets the class name of the effect layer
  49718. * @returns the string with the class name of the effect layer
  49719. */
  49720. getClassName(): string;
  49721. /**
  49722. * Serializes this glow layer
  49723. * @returns a serialized glow layer object
  49724. */
  49725. serialize(): any;
  49726. /**
  49727. * Creates a Glow Layer from parsed glow layer data
  49728. * @param parsedGlowLayer defines glow layer data
  49729. * @param scene defines the current scene
  49730. * @param rootUrl defines the root URL containing the glow layer information
  49731. * @returns a parsed Glow Layer
  49732. */
  49733. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49734. }
  49735. }
  49736. declare module BABYLON {
  49737. /** @hidden */
  49738. export var glowBlurPostProcessPixelShader: {
  49739. name: string;
  49740. shader: string;
  49741. };
  49742. }
  49743. declare module BABYLON {
  49744. interface AbstractScene {
  49745. /**
  49746. * Return a the first highlight layer of the scene with a given name.
  49747. * @param name The name of the highlight layer to look for.
  49748. * @return The highlight layer if found otherwise null.
  49749. */
  49750. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49751. }
  49752. /**
  49753. * Highlight layer options. This helps customizing the behaviour
  49754. * of the highlight layer.
  49755. */
  49756. export interface IHighlightLayerOptions {
  49757. /**
  49758. * Multiplication factor apply to the canvas size to compute the render target size
  49759. * used to generated the glowing objects (the smaller the faster).
  49760. */
  49761. mainTextureRatio: number;
  49762. /**
  49763. * Enforces a fixed size texture to ensure resize independant blur.
  49764. */
  49765. mainTextureFixedSize?: number;
  49766. /**
  49767. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49768. * of the picture to blur (the smaller the faster).
  49769. */
  49770. blurTextureSizeRatio: number;
  49771. /**
  49772. * How big in texel of the blur texture is the vertical blur.
  49773. */
  49774. blurVerticalSize: number;
  49775. /**
  49776. * How big in texel of the blur texture is the horizontal blur.
  49777. */
  49778. blurHorizontalSize: number;
  49779. /**
  49780. * Alpha blending mode used to apply the blur. Default is combine.
  49781. */
  49782. alphaBlendingMode: number;
  49783. /**
  49784. * The camera attached to the layer.
  49785. */
  49786. camera: Nullable<Camera>;
  49787. /**
  49788. * Should we display highlight as a solid stroke?
  49789. */
  49790. isStroke?: boolean;
  49791. /**
  49792. * The rendering group to draw the layer in.
  49793. */
  49794. renderingGroupId: number;
  49795. }
  49796. /**
  49797. * The highlight layer Helps adding a glow effect around a mesh.
  49798. *
  49799. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49800. * glowy meshes to your scene.
  49801. *
  49802. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49803. */
  49804. export class HighlightLayer extends EffectLayer {
  49805. name: string;
  49806. /**
  49807. * Effect Name of the highlight layer.
  49808. */
  49809. static readonly EffectName: string;
  49810. /**
  49811. * The neutral color used during the preparation of the glow effect.
  49812. * This is black by default as the blend operation is a blend operation.
  49813. */
  49814. static NeutralColor: Color4;
  49815. /**
  49816. * Stencil value used for glowing meshes.
  49817. */
  49818. static GlowingMeshStencilReference: number;
  49819. /**
  49820. * Stencil value used for the other meshes in the scene.
  49821. */
  49822. static NormalMeshStencilReference: number;
  49823. /**
  49824. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49825. */
  49826. innerGlow: boolean;
  49827. /**
  49828. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49829. */
  49830. outerGlow: boolean;
  49831. /**
  49832. * Specifies the horizontal size of the blur.
  49833. */
  49834. /**
  49835. * Gets the horizontal size of the blur.
  49836. */
  49837. blurHorizontalSize: number;
  49838. /**
  49839. * Specifies the vertical size of the blur.
  49840. */
  49841. /**
  49842. * Gets the vertical size of the blur.
  49843. */
  49844. blurVerticalSize: number;
  49845. /**
  49846. * An event triggered when the highlight layer is being blurred.
  49847. */
  49848. onBeforeBlurObservable: Observable<HighlightLayer>;
  49849. /**
  49850. * An event triggered when the highlight layer has been blurred.
  49851. */
  49852. onAfterBlurObservable: Observable<HighlightLayer>;
  49853. private _instanceGlowingMeshStencilReference;
  49854. private _options;
  49855. private _downSamplePostprocess;
  49856. private _horizontalBlurPostprocess;
  49857. private _verticalBlurPostprocess;
  49858. private _blurTexture;
  49859. private _meshes;
  49860. private _excludedMeshes;
  49861. /**
  49862. * Instantiates a new highlight Layer and references it to the scene..
  49863. * @param name The name of the layer
  49864. * @param scene The scene to use the layer in
  49865. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49866. */
  49867. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49868. /**
  49869. * Get the effect name of the layer.
  49870. * @return The effect name
  49871. */
  49872. getEffectName(): string;
  49873. /**
  49874. * Create the merge effect. This is the shader use to blit the information back
  49875. * to the main canvas at the end of the scene rendering.
  49876. */
  49877. protected _createMergeEffect(): Effect;
  49878. /**
  49879. * Creates the render target textures and post processes used in the highlight layer.
  49880. */
  49881. protected _createTextureAndPostProcesses(): void;
  49882. /**
  49883. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49884. */
  49885. needStencil(): boolean;
  49886. /**
  49887. * Checks for the readiness of the element composing the layer.
  49888. * @param subMesh the mesh to check for
  49889. * @param useInstances specify wether or not to use instances to render the mesh
  49890. * @param emissiveTexture the associated emissive texture used to generate the glow
  49891. * @return true if ready otherwise, false
  49892. */
  49893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49894. /**
  49895. * Implementation specific of rendering the generating effect on the main canvas.
  49896. * @param effect The effect used to render through
  49897. */
  49898. protected _internalRender(effect: Effect): void;
  49899. /**
  49900. * Returns true if the layer contains information to display, otherwise false.
  49901. */
  49902. shouldRender(): boolean;
  49903. /**
  49904. * Returns true if the mesh should render, otherwise false.
  49905. * @param mesh The mesh to render
  49906. * @returns true if it should render otherwise false
  49907. */
  49908. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49909. /**
  49910. * Sets the required values for both the emissive texture and and the main color.
  49911. */
  49912. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49913. /**
  49914. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49915. * @param mesh The mesh to exclude from the highlight layer
  49916. */
  49917. addExcludedMesh(mesh: Mesh): void;
  49918. /**
  49919. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49920. * @param mesh The mesh to highlight
  49921. */
  49922. removeExcludedMesh(mesh: Mesh): void;
  49923. /**
  49924. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49925. * @param mesh mesh to test
  49926. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49927. */
  49928. hasMesh(mesh: AbstractMesh): boolean;
  49929. /**
  49930. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49931. * @param mesh The mesh to highlight
  49932. * @param color The color of the highlight
  49933. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49934. */
  49935. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49936. /**
  49937. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49938. * @param mesh The mesh to highlight
  49939. */
  49940. removeMesh(mesh: Mesh): void;
  49941. /**
  49942. * Force the stencil to the normal expected value for none glowing parts
  49943. */
  49944. private _defaultStencilReference;
  49945. /**
  49946. * Free any resources and references associated to a mesh.
  49947. * Internal use
  49948. * @param mesh The mesh to free.
  49949. * @hidden
  49950. */ private _disposeMesh(mesh: Mesh): void;
  49951. /**
  49952. * Dispose the highlight layer and free resources.
  49953. */
  49954. dispose(): void;
  49955. /**
  49956. * Gets the class name of the effect layer
  49957. * @returns the string with the class name of the effect layer
  49958. */
  49959. getClassName(): string;
  49960. /**
  49961. * Serializes this Highlight layer
  49962. * @returns a serialized Highlight layer object
  49963. */
  49964. serialize(): any;
  49965. /**
  49966. * Creates a Highlight layer from parsed Highlight layer data
  49967. * @param parsedHightlightLayer defines the Highlight layer data
  49968. * @param scene defines the current scene
  49969. * @param rootUrl defines the root URL containing the Highlight layer information
  49970. * @returns a parsed Highlight layer
  49971. */
  49972. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49973. }
  49974. }
  49975. declare module BABYLON {
  49976. interface AbstractScene {
  49977. /**
  49978. * The list of layers (background and foreground) of the scene
  49979. */
  49980. layers: Array<Layer>;
  49981. }
  49982. /**
  49983. * Defines the layer scene component responsible to manage any layers
  49984. * in a given scene.
  49985. */
  49986. export class LayerSceneComponent implements ISceneComponent {
  49987. /**
  49988. * The component name helpfull to identify the component in the list of scene components.
  49989. */
  49990. readonly name: string;
  49991. /**
  49992. * The scene the component belongs to.
  49993. */
  49994. scene: Scene;
  49995. private _engine;
  49996. /**
  49997. * Creates a new instance of the component for the given scene
  49998. * @param scene Defines the scene to register the component in
  49999. */
  50000. constructor(scene: Scene);
  50001. /**
  50002. * Registers the component in a given scene
  50003. */
  50004. register(): void;
  50005. /**
  50006. * Rebuilds the elements related to this component in case of
  50007. * context lost for instance.
  50008. */
  50009. rebuild(): void;
  50010. /**
  50011. * Disposes the component and the associated ressources.
  50012. */
  50013. dispose(): void;
  50014. private _draw;
  50015. private _drawCameraPredicate;
  50016. private _drawCameraBackground;
  50017. private _drawCameraForeground;
  50018. private _drawRenderTargetPredicate;
  50019. private _drawRenderTargetBackground;
  50020. private _drawRenderTargetForeground;
  50021. /**
  50022. * Adds all the elements from the container to the scene
  50023. * @param container the container holding the elements
  50024. */
  50025. addFromContainer(container: AbstractScene): void;
  50026. /**
  50027. * Removes all the elements in the container from the scene
  50028. * @param container contains the elements to remove
  50029. * @param dispose if the removed element should be disposed (default: false)
  50030. */
  50031. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50032. }
  50033. }
  50034. declare module BABYLON {
  50035. /** @hidden */
  50036. export var layerPixelShader: {
  50037. name: string;
  50038. shader: string;
  50039. };
  50040. }
  50041. declare module BABYLON {
  50042. /** @hidden */
  50043. export var layerVertexShader: {
  50044. name: string;
  50045. shader: string;
  50046. };
  50047. }
  50048. declare module BABYLON {
  50049. /**
  50050. * This represents a full screen 2d layer.
  50051. * This can be useful to display a picture in the background of your scene for instance.
  50052. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50053. */
  50054. export class Layer {
  50055. /**
  50056. * Define the name of the layer.
  50057. */
  50058. name: string;
  50059. /**
  50060. * Define the texture the layer should display.
  50061. */
  50062. texture: Nullable<Texture>;
  50063. /**
  50064. * Is the layer in background or foreground.
  50065. */
  50066. isBackground: boolean;
  50067. /**
  50068. * Define the color of the layer (instead of texture).
  50069. */
  50070. color: Color4;
  50071. /**
  50072. * Define the scale of the layer in order to zoom in out of the texture.
  50073. */
  50074. scale: Vector2;
  50075. /**
  50076. * Define an offset for the layer in order to shift the texture.
  50077. */
  50078. offset: Vector2;
  50079. /**
  50080. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50081. */
  50082. alphaBlendingMode: number;
  50083. /**
  50084. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50085. * Alpha test will not mix with the background color in case of transparency.
  50086. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50087. */
  50088. alphaTest: boolean;
  50089. /**
  50090. * Define a mask to restrict the layer to only some of the scene cameras.
  50091. */
  50092. layerMask: number;
  50093. /**
  50094. * Define the list of render target the layer is visible into.
  50095. */
  50096. renderTargetTextures: RenderTargetTexture[];
  50097. /**
  50098. * Define if the layer is only used in renderTarget or if it also
  50099. * renders in the main frame buffer of the canvas.
  50100. */
  50101. renderOnlyInRenderTargetTextures: boolean;
  50102. private _scene;
  50103. private _vertexBuffers;
  50104. private _indexBuffer;
  50105. private _effect;
  50106. private _alphaTestEffect;
  50107. /**
  50108. * An event triggered when the layer is disposed.
  50109. */
  50110. onDisposeObservable: Observable<Layer>;
  50111. private _onDisposeObserver;
  50112. /**
  50113. * Back compatibility with callback before the onDisposeObservable existed.
  50114. * The set callback will be triggered when the layer has been disposed.
  50115. */
  50116. onDispose: () => void;
  50117. /**
  50118. * An event triggered before rendering the scene
  50119. */
  50120. onBeforeRenderObservable: Observable<Layer>;
  50121. private _onBeforeRenderObserver;
  50122. /**
  50123. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50124. * The set callback will be triggered just before rendering the layer.
  50125. */
  50126. onBeforeRender: () => void;
  50127. /**
  50128. * An event triggered after rendering the scene
  50129. */
  50130. onAfterRenderObservable: Observable<Layer>;
  50131. private _onAfterRenderObserver;
  50132. /**
  50133. * Back compatibility with callback before the onAfterRenderObservable existed.
  50134. * The set callback will be triggered just after rendering the layer.
  50135. */
  50136. onAfterRender: () => void;
  50137. /**
  50138. * Instantiates a new layer.
  50139. * This represents a full screen 2d layer.
  50140. * This can be useful to display a picture in the background of your scene for instance.
  50141. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50142. * @param name Define the name of the layer in the scene
  50143. * @param imgUrl Define the url of the texture to display in the layer
  50144. * @param scene Define the scene the layer belongs to
  50145. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50146. * @param color Defines a color for the layer
  50147. */
  50148. constructor(
  50149. /**
  50150. * Define the name of the layer.
  50151. */
  50152. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50153. private _createIndexBuffer;
  50154. /** @hidden */ private _rebuild(): void;
  50155. /**
  50156. * Renders the layer in the scene.
  50157. */
  50158. render(): void;
  50159. /**
  50160. * Disposes and releases the associated ressources.
  50161. */
  50162. dispose(): void;
  50163. }
  50164. }
  50165. declare module BABYLON {
  50166. /** @hidden */
  50167. export var lensFlarePixelShader: {
  50168. name: string;
  50169. shader: string;
  50170. };
  50171. }
  50172. declare module BABYLON {
  50173. /** @hidden */
  50174. export var lensFlareVertexShader: {
  50175. name: string;
  50176. shader: string;
  50177. };
  50178. }
  50179. declare module BABYLON {
  50180. /**
  50181. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50182. * It is usually composed of several `lensFlare`.
  50183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50184. */
  50185. export class LensFlareSystem {
  50186. /**
  50187. * Define the name of the lens flare system
  50188. */
  50189. name: string;
  50190. /**
  50191. * List of lens flares used in this system.
  50192. */
  50193. lensFlares: LensFlare[];
  50194. /**
  50195. * Define a limit from the border the lens flare can be visible.
  50196. */
  50197. borderLimit: number;
  50198. /**
  50199. * Define a viewport border we do not want to see the lens flare in.
  50200. */
  50201. viewportBorder: number;
  50202. /**
  50203. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50204. */
  50205. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50206. /**
  50207. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50208. */
  50209. layerMask: number;
  50210. /**
  50211. * Define the id of the lens flare system in the scene.
  50212. * (equal to name by default)
  50213. */
  50214. id: string;
  50215. private _scene;
  50216. private _emitter;
  50217. private _vertexBuffers;
  50218. private _indexBuffer;
  50219. private _effect;
  50220. private _positionX;
  50221. private _positionY;
  50222. private _isEnabled;
  50223. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  50224. /**
  50225. * Instantiates a lens flare system.
  50226. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50227. * It is usually composed of several `lensFlare`.
  50228. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50229. * @param name Define the name of the lens flare system in the scene
  50230. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50231. * @param scene Define the scene the lens flare system belongs to
  50232. */
  50233. constructor(
  50234. /**
  50235. * Define the name of the lens flare system
  50236. */
  50237. name: string, emitter: any, scene: Scene);
  50238. /**
  50239. * Define if the lens flare system is enabled.
  50240. */
  50241. isEnabled: boolean;
  50242. /**
  50243. * Get the scene the effects belongs to.
  50244. * @returns the scene holding the lens flare system
  50245. */
  50246. getScene(): Scene;
  50247. /**
  50248. * Get the emitter of the lens flare system.
  50249. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50250. * @returns the emitter of the lens flare system
  50251. */
  50252. getEmitter(): any;
  50253. /**
  50254. * Set the emitter of the lens flare system.
  50255. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50256. * @param newEmitter Define the new emitter of the system
  50257. */
  50258. setEmitter(newEmitter: any): void;
  50259. /**
  50260. * Get the lens flare system emitter position.
  50261. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50262. * @returns the position
  50263. */
  50264. getEmitterPosition(): Vector3;
  50265. /**
  50266. * @hidden
  50267. */
  50268. computeEffectivePosition(globalViewport: Viewport): boolean;
  50269. /** @hidden */ private _isVisible(): boolean;
  50270. /**
  50271. * @hidden
  50272. */
  50273. render(): boolean;
  50274. /**
  50275. * Dispose and release the lens flare with its associated resources.
  50276. */
  50277. dispose(): void;
  50278. /**
  50279. * Parse a lens flare system from a JSON repressentation
  50280. * @param parsedLensFlareSystem Define the JSON to parse
  50281. * @param scene Define the scene the parsed system should be instantiated in
  50282. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50283. * @returns the parsed system
  50284. */
  50285. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50286. /**
  50287. * Serialize the current Lens Flare System into a JSON representation.
  50288. * @returns the serialized JSON
  50289. */
  50290. serialize(): any;
  50291. }
  50292. }
  50293. declare module BABYLON {
  50294. /**
  50295. * This represents one of the lens effect in a `lensFlareSystem`.
  50296. * It controls one of the indiviual texture used in the effect.
  50297. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50298. */
  50299. export class LensFlare {
  50300. /**
  50301. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50302. */
  50303. size: number;
  50304. /**
  50305. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  50306. */
  50307. position: number;
  50308. /**
  50309. * Define the lens color.
  50310. */
  50311. color: Color3;
  50312. /**
  50313. * Define the lens texture.
  50314. */
  50315. texture: Nullable<Texture>;
  50316. /**
  50317. * Define the alpha mode to render this particular lens.
  50318. */
  50319. alphaMode: number;
  50320. private _system;
  50321. /**
  50322. * Creates a new Lens Flare.
  50323. * This represents one of the lens effect in a `lensFlareSystem`.
  50324. * It controls one of the indiviual texture used in the effect.
  50325. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50326. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50327. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  50328. * @param color Define the lens color
  50329. * @param imgUrl Define the lens texture url
  50330. * @param system Define the `lensFlareSystem` this flare is part of
  50331. * @returns The newly created Lens Flare
  50332. */
  50333. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50334. /**
  50335. * Instantiates a new Lens Flare.
  50336. * This represents one of the lens effect in a `lensFlareSystem`.
  50337. * It controls one of the indiviual texture used in the effect.
  50338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50339. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50340. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  50341. * @param color Define the lens color
  50342. * @param imgUrl Define the lens texture url
  50343. * @param system Define the `lensFlareSystem` this flare is part of
  50344. */
  50345. constructor(
  50346. /**
  50347. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50348. */
  50349. size: number,
  50350. /**
  50351. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  50352. */
  50353. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50354. /**
  50355. * Dispose and release the lens flare with its associated resources.
  50356. */
  50357. dispose(): void;
  50358. }
  50359. }
  50360. declare module BABYLON {
  50361. interface AbstractScene {
  50362. /**
  50363. * The list of lens flare system added to the scene
  50364. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50365. */
  50366. lensFlareSystems: Array<LensFlareSystem>;
  50367. /**
  50368. * Removes the given lens flare system from this scene.
  50369. * @param toRemove The lens flare system to remove
  50370. * @returns The index of the removed lens flare system
  50371. */
  50372. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50373. /**
  50374. * Adds the given lens flare system to this scene
  50375. * @param newLensFlareSystem The lens flare system to add
  50376. */
  50377. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50378. /**
  50379. * Gets a lens flare system using its name
  50380. * @param name defines the name to look for
  50381. * @returns the lens flare system or null if not found
  50382. */
  50383. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50384. /**
  50385. * Gets a lens flare system using its id
  50386. * @param id defines the id to look for
  50387. * @returns the lens flare system or null if not found
  50388. */
  50389. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50390. }
  50391. /**
  50392. * Defines the lens flare scene component responsible to manage any lens flares
  50393. * in a given scene.
  50394. */
  50395. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50396. /**
  50397. * The component name helpfull to identify the component in the list of scene components.
  50398. */
  50399. readonly name: string;
  50400. /**
  50401. * The scene the component belongs to.
  50402. */
  50403. scene: Scene;
  50404. /**
  50405. * Creates a new instance of the component for the given scene
  50406. * @param scene Defines the scene to register the component in
  50407. */
  50408. constructor(scene: Scene);
  50409. /**
  50410. * Registers the component in a given scene
  50411. */
  50412. register(): void;
  50413. /**
  50414. * Rebuilds the elements related to this component in case of
  50415. * context lost for instance.
  50416. */
  50417. rebuild(): void;
  50418. /**
  50419. * Adds all the elements from the container to the scene
  50420. * @param container the container holding the elements
  50421. */
  50422. addFromContainer(container: AbstractScene): void;
  50423. /**
  50424. * Removes all the elements in the container from the scene
  50425. * @param container contains the elements to remove
  50426. * @param dispose if the removed element should be disposed (default: false)
  50427. */
  50428. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50429. /**
  50430. * Serializes the component data to the specified json object
  50431. * @param serializationObject The object to serialize to
  50432. */
  50433. serialize(serializationObject: any): void;
  50434. /**
  50435. * Disposes the component and the associated ressources.
  50436. */
  50437. dispose(): void;
  50438. private _draw;
  50439. }
  50440. }
  50441. declare module BABYLON {
  50442. /**
  50443. * Defines the shadow generator component responsible to manage any shadow generators
  50444. * in a given scene.
  50445. */
  50446. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50447. /**
  50448. * The component name helpfull to identify the component in the list of scene components.
  50449. */
  50450. readonly name: string;
  50451. /**
  50452. * The scene the component belongs to.
  50453. */
  50454. scene: Scene;
  50455. /**
  50456. * Creates a new instance of the component for the given scene
  50457. * @param scene Defines the scene to register the component in
  50458. */
  50459. constructor(scene: Scene);
  50460. /**
  50461. * Registers the component in a given scene
  50462. */
  50463. register(): void;
  50464. /**
  50465. * Rebuilds the elements related to this component in case of
  50466. * context lost for instance.
  50467. */
  50468. rebuild(): void;
  50469. /**
  50470. * Serializes the component data to the specified json object
  50471. * @param serializationObject The object to serialize to
  50472. */
  50473. serialize(serializationObject: any): void;
  50474. /**
  50475. * Adds all the elements from the container to the scene
  50476. * @param container the container holding the elements
  50477. */
  50478. addFromContainer(container: AbstractScene): void;
  50479. /**
  50480. * Removes all the elements in the container from the scene
  50481. * @param container contains the elements to remove
  50482. * @param dispose if the removed element should be disposed (default: false)
  50483. */
  50484. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50485. /**
  50486. * Rebuilds the elements related to this component in case of
  50487. * context lost for instance.
  50488. */
  50489. dispose(): void;
  50490. private _gatherRenderTargets;
  50491. }
  50492. }
  50493. declare module BABYLON {
  50494. /**
  50495. * A point light is a light defined by an unique point in world space.
  50496. * The light is emitted in every direction from this point.
  50497. * A good example of a point light is a standard light bulb.
  50498. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50499. */
  50500. export class PointLight extends ShadowLight {
  50501. private _shadowAngle;
  50502. /**
  50503. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50504. * This specifies what angle the shadow will use to be created.
  50505. *
  50506. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50507. */
  50508. /**
  50509. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50510. * This specifies what angle the shadow will use to be created.
  50511. *
  50512. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50513. */
  50514. shadowAngle: number;
  50515. /**
  50516. * Gets the direction if it has been set.
  50517. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50518. */
  50519. /**
  50520. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50521. */
  50522. direction: Vector3;
  50523. /**
  50524. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50525. * A PointLight emits the light in every direction.
  50526. * It can cast shadows.
  50527. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50528. * ```javascript
  50529. * var pointLight = new PointLight("pl", camera.position, scene);
  50530. * ```
  50531. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50532. * @param name The light friendly name
  50533. * @param position The position of the point light in the scene
  50534. * @param scene The scene the lights belongs to
  50535. */
  50536. constructor(name: string, position: Vector3, scene: Scene);
  50537. /**
  50538. * Returns the string "PointLight"
  50539. * @returns the class name
  50540. */
  50541. getClassName(): string;
  50542. /**
  50543. * Returns the integer 0.
  50544. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50545. */
  50546. getTypeID(): number;
  50547. /**
  50548. * Specifies wether or not the shadowmap should be a cube texture.
  50549. * @returns true if the shadowmap needs to be a cube texture.
  50550. */
  50551. needCube(): boolean;
  50552. /**
  50553. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50554. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50555. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50556. */
  50557. getShadowDirection(faceIndex?: number): Vector3;
  50558. /**
  50559. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50560. * - fov = PI / 2
  50561. * - aspect ratio : 1.0
  50562. * - z-near and far equal to the active camera minZ and maxZ.
  50563. * Returns the PointLight.
  50564. */
  50565. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50566. protected _buildUniformLayout(): void;
  50567. /**
  50568. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50569. * @param effect The effect to update
  50570. * @param lightIndex The index of the light in the effect to update
  50571. * @returns The point light
  50572. */
  50573. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50574. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50575. /**
  50576. * Prepares the list of defines specific to the light type.
  50577. * @param defines the list of defines
  50578. * @param lightIndex defines the index of the light for the effect
  50579. */
  50580. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50581. }
  50582. }
  50583. declare module BABYLON {
  50584. /**
  50585. * Header information of HDR texture files.
  50586. */
  50587. export interface HDRInfo {
  50588. /**
  50589. * The height of the texture in pixels.
  50590. */
  50591. height: number;
  50592. /**
  50593. * The width of the texture in pixels.
  50594. */
  50595. width: number;
  50596. /**
  50597. * The index of the beginning of the data in the binary file.
  50598. */
  50599. dataPosition: number;
  50600. }
  50601. /**
  50602. * This groups tools to convert HDR texture to native colors array.
  50603. */
  50604. export class HDRTools {
  50605. private static Ldexp;
  50606. private static Rgbe2float;
  50607. private static readStringLine;
  50608. /**
  50609. * Reads header information from an RGBE texture stored in a native array.
  50610. * More information on this format are available here:
  50611. * https://en.wikipedia.org/wiki/RGBE_image_format
  50612. *
  50613. * @param uint8array The binary file stored in native array.
  50614. * @return The header information.
  50615. */
  50616. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50617. /**
  50618. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50619. * This RGBE texture needs to store the information as a panorama.
  50620. *
  50621. * More information on this format are available here:
  50622. * https://en.wikipedia.org/wiki/RGBE_image_format
  50623. *
  50624. * @param buffer The binary file stored in an array buffer.
  50625. * @param size The expected size of the extracted cubemap.
  50626. * @return The Cube Map information.
  50627. */
  50628. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50629. /**
  50630. * Returns the pixels data extracted from an RGBE texture.
  50631. * This pixels will be stored left to right up to down in the R G B order in one array.
  50632. *
  50633. * More information on this format are available here:
  50634. * https://en.wikipedia.org/wiki/RGBE_image_format
  50635. *
  50636. * @param uint8array The binary file stored in an array buffer.
  50637. * @param hdrInfo The header information of the file.
  50638. * @return The pixels data in RGB right to left up to down order.
  50639. */
  50640. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50641. private static RGBE_ReadPixels_RLE;
  50642. }
  50643. }
  50644. declare module BABYLON {
  50645. /**
  50646. * This represents a texture coming from an HDR input.
  50647. *
  50648. * The only supported format is currently panorama picture stored in RGBE format.
  50649. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50650. */
  50651. export class HDRCubeTexture extends BaseTexture {
  50652. private static _facesMapping;
  50653. private _generateHarmonics;
  50654. private _noMipmap;
  50655. private _textureMatrix;
  50656. private _size;
  50657. private _onLoad;
  50658. private _onError;
  50659. /**
  50660. * The texture URL.
  50661. */
  50662. url: string;
  50663. /**
  50664. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50665. */
  50666. coordinatesMode: number;
  50667. protected _isBlocking: boolean;
  50668. /**
  50669. * Sets wether or not the texture is blocking during loading.
  50670. */
  50671. /**
  50672. * Gets wether or not the texture is blocking during loading.
  50673. */
  50674. isBlocking: boolean;
  50675. protected _rotationY: number;
  50676. /**
  50677. * Sets texture matrix rotation angle around Y axis in radians.
  50678. */
  50679. /**
  50680. * Gets texture matrix rotation angle around Y axis radians.
  50681. */
  50682. rotationY: number;
  50683. /**
  50684. * Gets or sets the center of the bounding box associated with the cube texture
  50685. * It must define where the camera used to render the texture was set
  50686. */
  50687. boundingBoxPosition: Vector3;
  50688. private _boundingBoxSize;
  50689. /**
  50690. * Gets or sets the size of the bounding box associated with the cube texture
  50691. * When defined, the cubemap will switch to local mode
  50692. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50693. * @example https://www.babylonjs-playground.com/#RNASML
  50694. */
  50695. boundingBoxSize: Vector3;
  50696. /**
  50697. * Instantiates an HDRTexture from the following parameters.
  50698. *
  50699. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50700. * @param scene The scene the texture will be used in
  50701. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50702. * @param noMipmap Forces to not generate the mipmap if true
  50703. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50704. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  50705. * @param reserved Reserved flag for internal use.
  50706. */
  50707. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50708. /**
  50709. * Get the current class name of the texture useful for serialization or dynamic coding.
  50710. * @returns "HDRCubeTexture"
  50711. */
  50712. getClassName(): string;
  50713. /**
  50714. * Occurs when the file is raw .hdr file.
  50715. */
  50716. private loadTexture;
  50717. clone(): HDRCubeTexture;
  50718. delayLoad(): void;
  50719. /**
  50720. * Get the texture reflection matrix used to rotate/transform the reflection.
  50721. * @returns the reflection matrix
  50722. */
  50723. getReflectionTextureMatrix(): Matrix;
  50724. /**
  50725. * Set the texture reflection matrix used to rotate/transform the reflection.
  50726. * @param value Define the reflection matrix to set
  50727. */
  50728. setReflectionTextureMatrix(value: Matrix): void;
  50729. /**
  50730. * Parses a JSON representation of an HDR Texture in order to create the texture
  50731. * @param parsedTexture Define the JSON representation
  50732. * @param scene Define the scene the texture should be created in
  50733. * @param rootUrl Define the root url in case we need to load relative dependencies
  50734. * @returns the newly created texture after parsing
  50735. */
  50736. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50737. serialize(): any;
  50738. }
  50739. }
  50740. declare module BABYLON {
  50741. /**
  50742. * Class used to control physics engine
  50743. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50744. */
  50745. export class PhysicsEngine implements IPhysicsEngine {
  50746. private _physicsPlugin;
  50747. /**
  50748. * Global value used to control the smallest number supported by the simulation
  50749. */
  50750. static Epsilon: number;
  50751. private _impostors;
  50752. private _joints;
  50753. /**
  50754. * Gets the gravity vector used by the simulation
  50755. */
  50756. gravity: Vector3;
  50757. /**
  50758. * Factory used to create the default physics plugin.
  50759. * @returns The default physics plugin
  50760. */
  50761. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50762. /**
  50763. * Creates a new Physics Engine
  50764. * @param gravity defines the gravity vector used by the simulation
  50765. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50766. */
  50767. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50768. /**
  50769. * Sets the gravity vector used by the simulation
  50770. * @param gravity defines the gravity vector to use
  50771. */
  50772. setGravity(gravity: Vector3): void;
  50773. /**
  50774. * Set the time step of the physics engine.
  50775. * Default is 1/60.
  50776. * To slow it down, enter 1/600 for example.
  50777. * To speed it up, 1/30
  50778. * @param newTimeStep defines the new timestep to apply to this world.
  50779. */
  50780. setTimeStep(newTimeStep?: number): void;
  50781. /**
  50782. * Get the time step of the physics engine.
  50783. * @returns the current time step
  50784. */
  50785. getTimeStep(): number;
  50786. /**
  50787. * Release all resources
  50788. */
  50789. dispose(): void;
  50790. /**
  50791. * Gets the name of the current physics plugin
  50792. * @returns the name of the plugin
  50793. */
  50794. getPhysicsPluginName(): string;
  50795. /**
  50796. * Adding a new impostor for the impostor tracking.
  50797. * This will be done by the impostor itself.
  50798. * @param impostor the impostor to add
  50799. */
  50800. addImpostor(impostor: PhysicsImpostor): void;
  50801. /**
  50802. * Remove an impostor from the engine.
  50803. * This impostor and its mesh will not longer be updated by the physics engine.
  50804. * @param impostor the impostor to remove
  50805. */
  50806. removeImpostor(impostor: PhysicsImpostor): void;
  50807. /**
  50808. * Add a joint to the physics engine
  50809. * @param mainImpostor defines the main impostor to which the joint is added.
  50810. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50811. * @param joint defines the joint that will connect both impostors.
  50812. */
  50813. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50814. /**
  50815. * Removes a joint from the simulation
  50816. * @param mainImpostor defines the impostor used with the joint
  50817. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50818. * @param joint defines the joint to remove
  50819. */
  50820. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50821. /**
  50822. * Called by the scene. No need to call it.
  50823. * @param delta defines the timespam between frames
  50824. */ private _step(delta: number): void;
  50825. /**
  50826. * Gets the current plugin used to run the simulation
  50827. * @returns current plugin
  50828. */
  50829. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50830. /**
  50831. * Gets the list of physic impostors
  50832. * @returns an array of PhysicsImpostor
  50833. */
  50834. getImpostors(): Array<PhysicsImpostor>;
  50835. /**
  50836. * Gets the impostor for a physics enabled object
  50837. * @param object defines the object impersonated by the impostor
  50838. * @returns the PhysicsImpostor or null if not found
  50839. */
  50840. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50841. /**
  50842. * Gets the impostor for a physics body object
  50843. * @param body defines physics body used by the impostor
  50844. * @returns the PhysicsImpostor or null if not found
  50845. */
  50846. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50847. /**
  50848. * Does a raycast in the physics world
  50849. * @param from when should the ray start?
  50850. * @param to when should the ray end?
  50851. * @returns PhysicsRaycastResult
  50852. */
  50853. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50854. }
  50855. }
  50856. declare module BABYLON {
  50857. /** @hidden */
  50858. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50859. private _useDeltaForWorldStep;
  50860. world: any;
  50861. name: string;
  50862. private _physicsMaterials;
  50863. private _fixedTimeStep;
  50864. private _cannonRaycastResult;
  50865. private _raycastResult;
  50866. private _physicsBodysToRemoveAfterStep;
  50867. BJSCANNON: any;
  50868. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50869. setGravity(gravity: Vector3): void;
  50870. setTimeStep(timeStep: number): void;
  50871. getTimeStep(): number;
  50872. executeStep(delta: number): void;
  50873. private _removeMarkedPhysicsBodiesFromWorld;
  50874. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50875. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50876. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50877. private _processChildMeshes;
  50878. removePhysicsBody(impostor: PhysicsImpostor): void;
  50879. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50880. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50881. private _addMaterial;
  50882. private _checkWithEpsilon;
  50883. private _createShape;
  50884. private _createHeightmap;
  50885. private _minus90X;
  50886. private _plus90X;
  50887. private _tmpPosition;
  50888. private _tmpDeltaPosition;
  50889. private _tmpUnityRotation;
  50890. private _updatePhysicsBodyTransformation;
  50891. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50892. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50893. isSupported(): boolean;
  50894. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50895. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50896. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50898. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50899. getBodyMass(impostor: PhysicsImpostor): number;
  50900. getBodyFriction(impostor: PhysicsImpostor): number;
  50901. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50902. getBodyRestitution(impostor: PhysicsImpostor): number;
  50903. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50904. sleepBody(impostor: PhysicsImpostor): void;
  50905. wakeUpBody(impostor: PhysicsImpostor): void;
  50906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50907. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50909. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50910. getRadius(impostor: PhysicsImpostor): number;
  50911. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50912. dispose(): void;
  50913. private _extendNamespace;
  50914. /**
  50915. * Does a raycast in the physics world
  50916. * @param from when should the ray start?
  50917. * @param to when should the ray end?
  50918. * @returns PhysicsRaycastResult
  50919. */
  50920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50921. }
  50922. }
  50923. declare module BABYLON {
  50924. /** @hidden */
  50925. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50926. world: any;
  50927. name: string;
  50928. BJSOIMO: any;
  50929. private _raycastResult;
  50930. constructor(iterations?: number, oimoInjection?: any);
  50931. setGravity(gravity: Vector3): void;
  50932. setTimeStep(timeStep: number): void;
  50933. getTimeStep(): number;
  50934. private _tmpImpostorsArray;
  50935. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50936. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50937. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50938. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50939. private _tmpPositionVector;
  50940. removePhysicsBody(impostor: PhysicsImpostor): void;
  50941. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50942. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50943. isSupported(): boolean;
  50944. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50945. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50946. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50947. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50948. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50949. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50950. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50951. getBodyMass(impostor: PhysicsImpostor): number;
  50952. getBodyFriction(impostor: PhysicsImpostor): number;
  50953. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50954. getBodyRestitution(impostor: PhysicsImpostor): number;
  50955. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50956. sleepBody(impostor: PhysicsImpostor): void;
  50957. wakeUpBody(impostor: PhysicsImpostor): void;
  50958. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50959. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50960. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50961. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50962. getRadius(impostor: PhysicsImpostor): number;
  50963. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50964. dispose(): void;
  50965. /**
  50966. * Does a raycast in the physics world
  50967. * @param from when should the ray start?
  50968. * @param to when should the ray end?
  50969. * @returns PhysicsRaycastResult
  50970. */
  50971. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50972. }
  50973. }
  50974. declare module BABYLON {
  50975. /**
  50976. * Class containing static functions to help procedurally build meshes
  50977. */
  50978. export class RibbonBuilder {
  50979. /**
  50980. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50981. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50982. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50983. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50984. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  50985. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  50986. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  50987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50989. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50990. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  50991. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50992. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  50993. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50995. * @param name defines the name of the mesh
  50996. * @param options defines the options used to create the mesh
  50997. * @param scene defines the hosting scene
  50998. * @returns the ribbon mesh
  50999. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51000. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51001. */
  51002. static CreateRibbon(name: string, options: {
  51003. pathArray: Vector3[][];
  51004. closeArray?: boolean;
  51005. closePath?: boolean;
  51006. offset?: number;
  51007. updatable?: boolean;
  51008. sideOrientation?: number;
  51009. frontUVs?: Vector4;
  51010. backUVs?: Vector4;
  51011. instance?: Mesh;
  51012. invertUV?: boolean;
  51013. uvs?: Vector2[];
  51014. colors?: Color4[];
  51015. }, scene?: Nullable<Scene>): Mesh;
  51016. }
  51017. }
  51018. declare module BABYLON {
  51019. /**
  51020. * Class containing static functions to help procedurally build meshes
  51021. */
  51022. export class ShapeBuilder {
  51023. /**
  51024. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51025. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  51026. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51027. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  51028. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51029. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  51030. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  51031. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51036. * @param name defines the name of the mesh
  51037. * @param options defines the options used to create the mesh
  51038. * @param scene defines the hosting scene
  51039. * @returns the extruded shape mesh
  51040. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51041. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51042. */
  51043. static ExtrudeShape(name: string, options: {
  51044. shape: Vector3[];
  51045. path: Vector3[];
  51046. scale?: number;
  51047. rotation?: number;
  51048. cap?: number;
  51049. updatable?: boolean;
  51050. sideOrientation?: number;
  51051. frontUVs?: Vector4;
  51052. backUVs?: Vector4;
  51053. instance?: Mesh;
  51054. invertUV?: boolean;
  51055. }, scene?: Nullable<Scene>): Mesh;
  51056. /**
  51057. * Creates an custom extruded shape mesh.
  51058. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51059. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  51060. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51061. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  51062. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51063. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  51064. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51065. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51066. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51067. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  51068. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  51069. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51072. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51074. * @param name defines the name of the mesh
  51075. * @param options defines the options used to create the mesh
  51076. * @param scene defines the hosting scene
  51077. * @returns the custom extruded shape mesh
  51078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51081. */
  51082. static ExtrudeShapeCustom(name: string, options: {
  51083. shape: Vector3[];
  51084. path: Vector3[];
  51085. scaleFunction?: any;
  51086. rotationFunction?: any;
  51087. ribbonCloseArray?: boolean;
  51088. ribbonClosePath?: boolean;
  51089. cap?: number;
  51090. updatable?: boolean;
  51091. sideOrientation?: number;
  51092. frontUVs?: Vector4;
  51093. backUVs?: Vector4;
  51094. instance?: Mesh;
  51095. invertUV?: boolean;
  51096. }, scene?: Nullable<Scene>): Mesh;
  51097. private static _ExtrudeShapeGeneric;
  51098. }
  51099. }
  51100. declare module BABYLON {
  51101. /**
  51102. * AmmoJS Physics plugin
  51103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51104. * @see https://github.com/kripken/ammo.js/
  51105. */
  51106. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51107. private _useDeltaForWorldStep;
  51108. /**
  51109. * Reference to the Ammo library
  51110. */
  51111. bjsAMMO: any;
  51112. /**
  51113. * Created ammoJS world which physics bodies are added to
  51114. */
  51115. world: any;
  51116. /**
  51117. * Name of the plugin
  51118. */
  51119. name: string;
  51120. private _timeStep;
  51121. private _fixedTimeStep;
  51122. private _maxSteps;
  51123. private _tmpQuaternion;
  51124. private _tmpAmmoTransform;
  51125. private _tmpAmmoQuaternion;
  51126. private _tmpAmmoConcreteContactResultCallback;
  51127. private _collisionConfiguration;
  51128. private _dispatcher;
  51129. private _overlappingPairCache;
  51130. private _solver;
  51131. private _softBodySolver;
  51132. private _tmpAmmoVectorA;
  51133. private _tmpAmmoVectorB;
  51134. private _tmpAmmoVectorC;
  51135. private _tmpAmmoVectorD;
  51136. private _tmpContactCallbackResult;
  51137. private _tmpAmmoVectorRCA;
  51138. private _tmpAmmoVectorRCB;
  51139. private _raycastResult;
  51140. private static readonly DISABLE_COLLISION_FLAG;
  51141. private static readonly KINEMATIC_FLAG;
  51142. private static readonly DISABLE_DEACTIVATION_FLAG;
  51143. /**
  51144. * Initializes the ammoJS plugin
  51145. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51146. * @param ammoInjection can be used to inject your own ammo reference
  51147. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51148. */
  51149. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51150. /**
  51151. * Sets the gravity of the physics world (m/(s^2))
  51152. * @param gravity Gravity to set
  51153. */
  51154. setGravity(gravity: Vector3): void;
  51155. /**
  51156. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51157. * @param timeStep timestep to use in seconds
  51158. */
  51159. setTimeStep(timeStep: number): void;
  51160. /**
  51161. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  51162. * @param fixedTimeStep fixedTimeStep to use in seconds
  51163. */
  51164. setFixedTimeStep(fixedTimeStep: number): void;
  51165. /**
  51166. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51167. * @param maxSteps the maximum number of steps by the physics engine per frame
  51168. */
  51169. setMaxSteps(maxSteps: number): void;
  51170. /**
  51171. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51172. * @returns the current timestep in seconds
  51173. */
  51174. getTimeStep(): number;
  51175. private _isImpostorInContact;
  51176. private _isImpostorPairInContact;
  51177. private _stepSimulation;
  51178. /**
  51179. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51180. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51181. * After the step the babylon meshes are set to the position of the physics imposters
  51182. * @param delta amount of time to step forward
  51183. * @param impostors array of imposters to update before/after the step
  51184. */
  51185. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51186. /**
  51187. * Update babylon mesh to match physics world object
  51188. * @param impostor imposter to match
  51189. */
  51190. private _afterSoftStep;
  51191. /**
  51192. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51193. * @param impostor imposter to match
  51194. */
  51195. private _ropeStep;
  51196. /**
  51197. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51198. * @param impostor imposter to match
  51199. */
  51200. private _softbodyOrClothStep;
  51201. private _tmpVector;
  51202. private _tmpMatrix;
  51203. /**
  51204. * Applies an impulse on the imposter
  51205. * @param impostor imposter to apply impulse to
  51206. * @param force amount of force to be applied to the imposter
  51207. * @param contactPoint the location to apply the impulse on the imposter
  51208. */
  51209. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51210. /**
  51211. * Applies a force on the imposter
  51212. * @param impostor imposter to apply force
  51213. * @param force amount of force to be applied to the imposter
  51214. * @param contactPoint the location to apply the force on the imposter
  51215. */
  51216. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51217. /**
  51218. * Creates a physics body using the plugin
  51219. * @param impostor the imposter to create the physics body on
  51220. */
  51221. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51222. /**
  51223. * Removes the physics body from the imposter and disposes of the body's memory
  51224. * @param impostor imposter to remove the physics body from
  51225. */
  51226. removePhysicsBody(impostor: PhysicsImpostor): void;
  51227. /**
  51228. * Generates a joint
  51229. * @param impostorJoint the imposter joint to create the joint with
  51230. */
  51231. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51232. /**
  51233. * Removes a joint
  51234. * @param impostorJoint the imposter joint to remove the joint from
  51235. */
  51236. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51237. private _addMeshVerts;
  51238. /**
  51239. * Initialise the soft body vertices to match its object's (mesh) vertices
  51240. * Softbody vertices (nodes) are in world space and to match this
  51241. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51242. * @param impostor to create the softbody for
  51243. */
  51244. private _softVertexData;
  51245. /**
  51246. * Create an impostor's soft body
  51247. * @param impostor to create the softbody for
  51248. */
  51249. private _createSoftbody;
  51250. /**
  51251. * Create cloth for an impostor
  51252. * @param impostor to create the softbody for
  51253. */
  51254. private _createCloth;
  51255. /**
  51256. * Create rope for an impostor
  51257. * @param impostor to create the softbody for
  51258. */
  51259. private _createRope;
  51260. private _addHullVerts;
  51261. private _createShape;
  51262. /**
  51263. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51264. * @param impostor imposter containing the physics body and babylon object
  51265. */
  51266. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51267. /**
  51268. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51269. * @param impostor imposter containing the physics body and babylon object
  51270. * @param newPosition new position
  51271. * @param newRotation new rotation
  51272. */
  51273. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51274. /**
  51275. * If this plugin is supported
  51276. * @returns true if its supported
  51277. */
  51278. isSupported(): boolean;
  51279. /**
  51280. * Sets the linear velocity of the physics body
  51281. * @param impostor imposter to set the velocity on
  51282. * @param velocity velocity to set
  51283. */
  51284. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51285. /**
  51286. * Sets the angular velocity of the physics body
  51287. * @param impostor imposter to set the velocity on
  51288. * @param velocity velocity to set
  51289. */
  51290. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51291. /**
  51292. * gets the linear velocity
  51293. * @param impostor imposter to get linear velocity from
  51294. * @returns linear velocity
  51295. */
  51296. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51297. /**
  51298. * gets the angular velocity
  51299. * @param impostor imposter to get angular velocity from
  51300. * @returns angular velocity
  51301. */
  51302. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51303. /**
  51304. * Sets the mass of physics body
  51305. * @param impostor imposter to set the mass on
  51306. * @param mass mass to set
  51307. */
  51308. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51309. /**
  51310. * Gets the mass of the physics body
  51311. * @param impostor imposter to get the mass from
  51312. * @returns mass
  51313. */
  51314. getBodyMass(impostor: PhysicsImpostor): number;
  51315. /**
  51316. * Gets friction of the impostor
  51317. * @param impostor impostor to get friction from
  51318. * @returns friction value
  51319. */
  51320. getBodyFriction(impostor: PhysicsImpostor): number;
  51321. /**
  51322. * Sets friction of the impostor
  51323. * @param impostor impostor to set friction on
  51324. * @param friction friction value
  51325. */
  51326. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51327. /**
  51328. * Gets restitution of the impostor
  51329. * @param impostor impostor to get restitution from
  51330. * @returns restitution value
  51331. */
  51332. getBodyRestitution(impostor: PhysicsImpostor): number;
  51333. /**
  51334. * Sets resitution of the impostor
  51335. * @param impostor impostor to set resitution on
  51336. * @param restitution resitution value
  51337. */
  51338. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51339. /**
  51340. * Gets pressure inside the impostor
  51341. * @param impostor impostor to get pressure from
  51342. * @returns pressure value
  51343. */
  51344. getBodyPressure(impostor: PhysicsImpostor): number;
  51345. /**
  51346. * Sets pressure inside a soft body impostor
  51347. * Cloth and rope must remain 0 pressure
  51348. * @param impostor impostor to set pressure on
  51349. * @param pressure pressure value
  51350. */
  51351. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51352. /**
  51353. * Gets stiffness of the impostor
  51354. * @param impostor impostor to get stiffness from
  51355. * @returns pressure value
  51356. */
  51357. getBodyStiffness(impostor: PhysicsImpostor): number;
  51358. /**
  51359. * Sets stiffness of the impostor
  51360. * @param impostor impostor to set stiffness on
  51361. * @param stiffness stiffness value from 0 to 1
  51362. */
  51363. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51364. /**
  51365. * Gets velocityIterations of the impostor
  51366. * @param impostor impostor to get velocity iterations from
  51367. * @returns velocityIterations value
  51368. */
  51369. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51370. /**
  51371. * Sets velocityIterations of the impostor
  51372. * @param impostor impostor to set velocity iterations on
  51373. * @param velocityIterations velocityIterations value
  51374. */
  51375. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51376. /**
  51377. * Gets positionIterations of the impostor
  51378. * @param impostor impostor to get position iterations from
  51379. * @returns positionIterations value
  51380. */
  51381. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51382. /**
  51383. * Sets positionIterations of the impostor
  51384. * @param impostor impostor to set position on
  51385. * @param positionIterations positionIterations value
  51386. */
  51387. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51388. /**
  51389. * Append an anchor to a cloth object
  51390. * @param impostor is the cloth impostor to add anchor to
  51391. * @param otherImpostor is the rigid impostor to anchor to
  51392. * @param width ratio across width from 0 to 1
  51393. * @param height ratio up height from 0 to 1
  51394. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51395. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51396. */
  51397. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51398. /**
  51399. * Append an hook to a rope object
  51400. * @param impostor is the rope impostor to add hook to
  51401. * @param otherImpostor is the rigid impostor to hook to
  51402. * @param length ratio along the rope from 0 to 1
  51403. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51404. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51405. */
  51406. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51407. /**
  51408. * Sleeps the physics body and stops it from being active
  51409. * @param impostor impostor to sleep
  51410. */
  51411. sleepBody(impostor: PhysicsImpostor): void;
  51412. /**
  51413. * Activates the physics body
  51414. * @param impostor impostor to activate
  51415. */
  51416. wakeUpBody(impostor: PhysicsImpostor): void;
  51417. /**
  51418. * Updates the distance parameters of the joint
  51419. * @param joint joint to update
  51420. * @param maxDistance maximum distance of the joint
  51421. * @param minDistance minimum distance of the joint
  51422. */
  51423. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51424. /**
  51425. * Sets a motor on the joint
  51426. * @param joint joint to set motor on
  51427. * @param speed speed of the motor
  51428. * @param maxForce maximum force of the motor
  51429. * @param motorIndex index of the motor
  51430. */
  51431. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51432. /**
  51433. * Sets the motors limit
  51434. * @param joint joint to set limit on
  51435. * @param upperLimit upper limit
  51436. * @param lowerLimit lower limit
  51437. */
  51438. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51439. /**
  51440. * Syncs the position and rotation of a mesh with the impostor
  51441. * @param mesh mesh to sync
  51442. * @param impostor impostor to update the mesh with
  51443. */
  51444. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51445. /**
  51446. * Gets the radius of the impostor
  51447. * @param impostor impostor to get radius from
  51448. * @returns the radius
  51449. */
  51450. getRadius(impostor: PhysicsImpostor): number;
  51451. /**
  51452. * Gets the box size of the impostor
  51453. * @param impostor impostor to get box size from
  51454. * @param result the resulting box size
  51455. */
  51456. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51457. /**
  51458. * Disposes of the impostor
  51459. */
  51460. dispose(): void;
  51461. /**
  51462. * Does a raycast in the physics world
  51463. * @param from when should the ray start?
  51464. * @param to when should the ray end?
  51465. * @returns PhysicsRaycastResult
  51466. */
  51467. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51468. }
  51469. }
  51470. declare module BABYLON {
  51471. interface AbstractScene {
  51472. /**
  51473. * The list of reflection probes added to the scene
  51474. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51475. */
  51476. reflectionProbes: Array<ReflectionProbe>;
  51477. /**
  51478. * Removes the given reflection probe from this scene.
  51479. * @param toRemove The reflection probe to remove
  51480. * @returns The index of the removed reflection probe
  51481. */
  51482. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51483. /**
  51484. * Adds the given reflection probe to this scene.
  51485. * @param newReflectionProbe The reflection probe to add
  51486. */
  51487. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51488. }
  51489. /**
  51490. * Class used to generate realtime reflection / refraction cube textures
  51491. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51492. */
  51493. export class ReflectionProbe {
  51494. /** defines the name of the probe */
  51495. name: string;
  51496. private _scene;
  51497. private _renderTargetTexture;
  51498. private _projectionMatrix;
  51499. private _viewMatrix;
  51500. private _target;
  51501. private _add;
  51502. private _attachedMesh;
  51503. private _invertYAxis;
  51504. /** Gets or sets probe position (center of the cube map) */
  51505. position: Vector3;
  51506. /**
  51507. * Creates a new reflection probe
  51508. * @param name defines the name of the probe
  51509. * @param size defines the texture resolution (for each face)
  51510. * @param scene defines the hosting scene
  51511. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51512. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51513. */
  51514. constructor(
  51515. /** defines the name of the probe */
  51516. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51517. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51518. samples: number;
  51519. /** Gets or sets the refresh rate to use (on every frame by default) */
  51520. refreshRate: number;
  51521. /**
  51522. * Gets the hosting scene
  51523. * @returns a Scene
  51524. */
  51525. getScene(): Scene;
  51526. /** Gets the internal CubeTexture used to render to */
  51527. readonly cubeTexture: RenderTargetTexture;
  51528. /** Gets the list of meshes to render */
  51529. readonly renderList: Nullable<AbstractMesh[]>;
  51530. /**
  51531. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51532. * @param mesh defines the mesh to attach to
  51533. */
  51534. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51535. /**
  51536. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51537. * @param renderingGroupId The rendering group id corresponding to its index
  51538. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51539. */
  51540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51541. /**
  51542. * Clean all associated resources
  51543. */
  51544. dispose(): void;
  51545. /**
  51546. * Converts the reflection probe information to a readable string for debug purpose.
  51547. * @param fullDetails Supports for multiple levels of logging within scene loading
  51548. * @returns the human readable reflection probe info
  51549. */
  51550. toString(fullDetails?: boolean): string;
  51551. /**
  51552. * Get the class name of the relfection probe.
  51553. * @returns "ReflectionProbe"
  51554. */
  51555. getClassName(): string;
  51556. /**
  51557. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51558. * @returns The JSON representation of the texture
  51559. */
  51560. serialize(): any;
  51561. /**
  51562. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51563. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51564. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51565. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51566. * @returns The parsed reflection probe if successful
  51567. */
  51568. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51569. }
  51570. }
  51571. declare module BABYLON {
  51572. /** @hidden */
  51573. export var _BabylonLoaderRegistered: boolean;
  51574. }
  51575. declare module BABYLON {
  51576. /**
  51577. * The Physically based simple base material of BJS.
  51578. *
  51579. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51580. * It is used as the base class for both the specGloss and metalRough conventions.
  51581. */
  51582. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51583. /**
  51584. * Number of Simultaneous lights allowed on the material.
  51585. */
  51586. maxSimultaneousLights: number;
  51587. /**
  51588. * If sets to true, disables all the lights affecting the material.
  51589. */
  51590. disableLighting: boolean;
  51591. /**
  51592. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51593. */
  51594. environmentTexture: BaseTexture;
  51595. /**
  51596. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51597. */
  51598. invertNormalMapX: boolean;
  51599. /**
  51600. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51601. */
  51602. invertNormalMapY: boolean;
  51603. /**
  51604. * Normal map used in the model.
  51605. */
  51606. normalTexture: BaseTexture;
  51607. /**
  51608. * Emissivie color used to self-illuminate the model.
  51609. */
  51610. emissiveColor: Color3;
  51611. /**
  51612. * Emissivie texture used to self-illuminate the model.
  51613. */
  51614. emissiveTexture: BaseTexture;
  51615. /**
  51616. * Occlusion Channel Strenght.
  51617. */
  51618. occlusionStrength: number;
  51619. /**
  51620. * Occlusion Texture of the material (adding extra occlusion effects).
  51621. */
  51622. occlusionTexture: BaseTexture;
  51623. /**
  51624. * Defines the alpha limits in alpha test mode.
  51625. */
  51626. alphaCutOff: number;
  51627. /**
  51628. * Gets the current double sided mode.
  51629. */
  51630. /**
  51631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51632. */
  51633. doubleSided: boolean;
  51634. /**
  51635. * Stores the pre-calculated light information of a mesh in a texture.
  51636. */
  51637. lightmapTexture: BaseTexture;
  51638. /**
  51639. * If true, the light map contains occlusion information instead of lighting info.
  51640. */
  51641. useLightmapAsShadowmap: boolean;
  51642. /**
  51643. * Instantiates a new PBRMaterial instance.
  51644. *
  51645. * @param name The material name
  51646. * @param scene The scene the material will be use in.
  51647. */
  51648. constructor(name: string, scene: Scene);
  51649. getClassName(): string;
  51650. }
  51651. }
  51652. declare module BABYLON {
  51653. /**
  51654. * The PBR material of BJS following the metal roughness convention.
  51655. *
  51656. * This fits to the PBR convention in the GLTF definition:
  51657. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51658. */
  51659. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51660. /**
  51661. * The base color has two different interpretations depending on the value of metalness.
  51662. * When the material is a metal, the base color is the specific measured reflectance value
  51663. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51664. * of the material.
  51665. */
  51666. baseColor: Color3;
  51667. /**
  51668. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51669. * well as opacity information in the alpha channel.
  51670. */
  51671. baseTexture: BaseTexture;
  51672. /**
  51673. * Specifies the metallic scalar value of the material.
  51674. * Can also be used to scale the metalness values of the metallic texture.
  51675. */
  51676. metallic: number;
  51677. /**
  51678. * Specifies the roughness scalar value of the material.
  51679. * Can also be used to scale the roughness values of the metallic texture.
  51680. */
  51681. roughness: number;
  51682. /**
  51683. * Texture containing both the metallic value in the B channel and the
  51684. * roughness value in the G channel to keep better precision.
  51685. */
  51686. metallicRoughnessTexture: BaseTexture;
  51687. /**
  51688. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51689. *
  51690. * @param name The material name
  51691. * @param scene The scene the material will be use in.
  51692. */
  51693. constructor(name: string, scene: Scene);
  51694. /**
  51695. * Return the currrent class name of the material.
  51696. */
  51697. getClassName(): string;
  51698. /**
  51699. * Makes a duplicate of the current material.
  51700. * @param name - name to use for the new material.
  51701. */
  51702. clone(name: string): PBRMetallicRoughnessMaterial;
  51703. /**
  51704. * Serialize the material to a parsable JSON object.
  51705. */
  51706. serialize(): any;
  51707. /**
  51708. * Parses a JSON object correponding to the serialize function.
  51709. */
  51710. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51711. }
  51712. }
  51713. declare module BABYLON {
  51714. /**
  51715. * The PBR material of BJS following the specular glossiness convention.
  51716. *
  51717. * This fits to the PBR convention in the GLTF definition:
  51718. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51719. */
  51720. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51721. /**
  51722. * Specifies the diffuse color of the material.
  51723. */
  51724. diffuseColor: Color3;
  51725. /**
  51726. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51727. * channel.
  51728. */
  51729. diffuseTexture: BaseTexture;
  51730. /**
  51731. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51732. */
  51733. specularColor: Color3;
  51734. /**
  51735. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51736. */
  51737. glossiness: number;
  51738. /**
  51739. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51740. */
  51741. specularGlossinessTexture: BaseTexture;
  51742. /**
  51743. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51744. *
  51745. * @param name The material name
  51746. * @param scene The scene the material will be use in.
  51747. */
  51748. constructor(name: string, scene: Scene);
  51749. /**
  51750. * Return the currrent class name of the material.
  51751. */
  51752. getClassName(): string;
  51753. /**
  51754. * Makes a duplicate of the current material.
  51755. * @param name - name to use for the new material.
  51756. */
  51757. clone(name: string): PBRSpecularGlossinessMaterial;
  51758. /**
  51759. * Serialize the material to a parsable JSON object.
  51760. */
  51761. serialize(): any;
  51762. /**
  51763. * Parses a JSON object correponding to the serialize function.
  51764. */
  51765. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51766. }
  51767. }
  51768. declare module BABYLON {
  51769. /**
  51770. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51771. * It can help converting any input color in a desired output one. This can then be used to create effects
  51772. * from sepia, black and white to sixties or futuristic rendering...
  51773. *
  51774. * The only supported format is currently 3dl.
  51775. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51776. */
  51777. export class ColorGradingTexture extends BaseTexture {
  51778. /**
  51779. * The current texture matrix. (will always be identity in color grading texture)
  51780. */
  51781. private _textureMatrix;
  51782. /**
  51783. * The texture URL.
  51784. */
  51785. url: string;
  51786. /**
  51787. * Empty line regex stored for GC.
  51788. */
  51789. private static _noneEmptyLineRegex;
  51790. private _engine;
  51791. /**
  51792. * Instantiates a ColorGradingTexture from the following parameters.
  51793. *
  51794. * @param url The location of the color gradind data (currently only supporting 3dl)
  51795. * @param scene The scene the texture will be used in
  51796. */
  51797. constructor(url: string, scene: Scene);
  51798. /**
  51799. * Returns the texture matrix used in most of the material.
  51800. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51801. */
  51802. getTextureMatrix(): Matrix;
  51803. /**
  51804. * Occurs when the file being loaded is a .3dl LUT file.
  51805. */
  51806. private load3dlTexture;
  51807. /**
  51808. * Starts the loading process of the texture.
  51809. */
  51810. private loadTexture;
  51811. /**
  51812. * Clones the color gradind texture.
  51813. */
  51814. clone(): ColorGradingTexture;
  51815. /**
  51816. * Called during delayed load for textures.
  51817. */
  51818. delayLoad(): void;
  51819. /**
  51820. * Parses a color grading texture serialized by Babylon.
  51821. * @param parsedTexture The texture information being parsedTexture
  51822. * @param scene The scene to load the texture in
  51823. * @param rootUrl The root url of the data assets to load
  51824. * @return A color gradind texture
  51825. */
  51826. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51827. /**
  51828. * Serializes the LUT texture to json format.
  51829. */
  51830. serialize(): any;
  51831. }
  51832. }
  51833. declare module BABYLON {
  51834. /**
  51835. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51836. */
  51837. export class EquiRectangularCubeTexture extends BaseTexture {
  51838. /** The six faces of the cube. */
  51839. private static _FacesMapping;
  51840. private _noMipmap;
  51841. private _onLoad;
  51842. private _onError;
  51843. /** The size of the cubemap. */
  51844. private _size;
  51845. /** The buffer of the image. */
  51846. private _buffer;
  51847. /** The width of the input image. */
  51848. private _width;
  51849. /** The height of the input image. */
  51850. private _height;
  51851. /** The URL to the image. */
  51852. url: string;
  51853. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51854. coordinatesMode: number;
  51855. /**
  51856. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51857. * @param url The location of the image
  51858. * @param scene The scene the texture will be used in
  51859. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51860. * @param noMipmap Forces to not generate the mipmap if true
  51861. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51862. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51863. * @param onLoad — defines a callback called when texture is loaded
  51864. * @param onError — defines a callback called if there is an error
  51865. */
  51866. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51867. /**
  51868. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51869. */
  51870. private loadImage;
  51871. /**
  51872. * Convert the image buffer into a cubemap and create a CubeTexture.
  51873. */
  51874. private loadTexture;
  51875. /**
  51876. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51877. * @param buffer The ArrayBuffer that should be converted.
  51878. * @returns The buffer as Float32Array.
  51879. */
  51880. private getFloat32ArrayFromArrayBuffer;
  51881. /**
  51882. * Get the current class name of the texture useful for serialization or dynamic coding.
  51883. * @returns "EquiRectangularCubeTexture"
  51884. */
  51885. getClassName(): string;
  51886. /**
  51887. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51888. * @returns A clone of the current EquiRectangularCubeTexture.
  51889. */
  51890. clone(): EquiRectangularCubeTexture;
  51891. }
  51892. }
  51893. declare module BABYLON {
  51894. /**
  51895. * Based on jsTGALoader - Javascript loader for TGA file
  51896. * By Vincent Thibault
  51897. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51898. */
  51899. export class TGATools {
  51900. private static _TYPE_INDEXED;
  51901. private static _TYPE_RGB;
  51902. private static _TYPE_GREY;
  51903. private static _TYPE_RLE_INDEXED;
  51904. private static _TYPE_RLE_RGB;
  51905. private static _TYPE_RLE_GREY;
  51906. private static _ORIGIN_MASK;
  51907. private static _ORIGIN_SHIFT;
  51908. private static _ORIGIN_BL;
  51909. private static _ORIGIN_BR;
  51910. private static _ORIGIN_UL;
  51911. private static _ORIGIN_UR;
  51912. /**
  51913. * Gets the header of a TGA file
  51914. * @param data defines the TGA data
  51915. * @returns the header
  51916. */
  51917. static GetTGAHeader(data: Uint8Array): any;
  51918. /**
  51919. * Uploads TGA content to a Babylon Texture
  51920. * @hidden
  51921. */
  51922. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51923. /** @hidden */ private static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51924. /** @hidden */ private static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51925. /** @hidden */ private static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51926. /** @hidden */ private static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51927. /** @hidden */ private static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51928. /** @hidden */ private static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51929. }
  51930. }
  51931. declare module BABYLON {
  51932. /**
  51933. * Implementation of the TGA Texture Loader.
  51934. * @hidden
  51935. */
  51936. export class _TGATextureLoader implements IInternalTextureLoader {
  51937. /**
  51938. * Defines wether the loader supports cascade loading the different faces.
  51939. */
  51940. readonly supportCascades: boolean;
  51941. /**
  51942. * This returns if the loader support the current file information.
  51943. * @param extension defines the file extension of the file being loaded
  51944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51945. * @param fallback defines the fallback internal texture if any
  51946. * @param isBase64 defines whether the texture is encoded as a base64
  51947. * @param isBuffer defines whether the texture data are stored as a buffer
  51948. * @returns true if the loader can load the specified file
  51949. */
  51950. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51951. /**
  51952. * Transform the url before loading if required.
  51953. * @param rootUrl the url of the texture
  51954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51955. * @returns the transformed texture
  51956. */
  51957. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51958. /**
  51959. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51960. * @param rootUrl the url of the texture
  51961. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51962. * @returns the fallback texture
  51963. */
  51964. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51965. /**
  51966. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51967. * @param data contains the texture data
  51968. * @param texture defines the BabylonJS internal texture
  51969. * @param createPolynomials will be true if polynomials have been requested
  51970. * @param onLoad defines the callback to trigger once the texture is ready
  51971. * @param onError defines the callback to trigger in case of error
  51972. */
  51973. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51974. /**
  51975. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51976. * @param data contains the texture data
  51977. * @param texture defines the BabylonJS internal texture
  51978. * @param callback defines the method to call once ready to upload
  51979. */
  51980. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51981. }
  51982. }
  51983. declare module BABYLON {
  51984. /**
  51985. * Info about the .basis files
  51986. */
  51987. class BasisFileInfo {
  51988. /**
  51989. * If the file has alpha
  51990. */
  51991. hasAlpha: boolean;
  51992. /**
  51993. * Info about each image of the basis file
  51994. */
  51995. images: Array<{
  51996. levels: Array<{
  51997. width: number;
  51998. height: number;
  51999. transcodedPixels: ArrayBufferView;
  52000. }>;
  52001. }>;
  52002. }
  52003. /**
  52004. * Result of transcoding a basis file
  52005. */
  52006. class TranscodeResult {
  52007. /**
  52008. * Info about the .basis file
  52009. */
  52010. fileInfo: BasisFileInfo;
  52011. /**
  52012. * Format to use when loading the file
  52013. */
  52014. format: number;
  52015. }
  52016. /**
  52017. * Configuration options for the Basis transcoder
  52018. */
  52019. export class BasisTranscodeConfiguration {
  52020. /**
  52021. * Supported compression formats used to determine the supported output format of the transcoder
  52022. */
  52023. supportedCompressionFormats?: {
  52024. /**
  52025. * etc1 compression format
  52026. */
  52027. etc1?: boolean;
  52028. /**
  52029. * s3tc compression format
  52030. */
  52031. s3tc?: boolean;
  52032. /**
  52033. * pvrtc compression format
  52034. */
  52035. pvrtc?: boolean;
  52036. /**
  52037. * etc2 compression format
  52038. */
  52039. etc2?: boolean;
  52040. };
  52041. /**
  52042. * If mipmap levels should be loaded for transcoded images (Default: true)
  52043. */
  52044. loadMipmapLevels?: boolean;
  52045. /**
  52046. * Index of a single image to load (Default: all images)
  52047. */
  52048. loadSingleImage?: number;
  52049. }
  52050. /**
  52051. * Used to load .Basis files
  52052. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52053. */
  52054. export class BasisTools {
  52055. private static _IgnoreSupportedFormats;
  52056. /**
  52057. * URL to use when loading the basis transcoder
  52058. */
  52059. static JSModuleURL: string;
  52060. /**
  52061. * URL to use when loading the wasm module for the transcoder
  52062. */
  52063. static WasmModuleURL: string;
  52064. /**
  52065. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52066. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52067. * @returns internal format corresponding to the Basis format
  52068. */
  52069. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52070. private static _WorkerPromise;
  52071. private static _Worker;
  52072. private static _actionId;
  52073. private static _CreateWorkerAsync;
  52074. /**
  52075. * Transcodes a loaded image file to compressed pixel data
  52076. * @param imageData image data to transcode
  52077. * @param config configuration options for the transcoding
  52078. * @returns a promise resulting in the transcoded image
  52079. */
  52080. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52081. /**
  52082. * Loads a texture from the transcode result
  52083. * @param texture texture load to
  52084. * @param transcodeResult the result of transcoding the basis file to load from
  52085. */
  52086. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52087. }
  52088. }
  52089. declare module BABYLON {
  52090. /**
  52091. * Loader for .basis file format
  52092. */
  52093. export class _BasisTextureLoader implements IInternalTextureLoader {
  52094. /**
  52095. * Defines whether the loader supports cascade loading the different faces.
  52096. */
  52097. readonly supportCascades: boolean;
  52098. /**
  52099. * This returns if the loader support the current file information.
  52100. * @param extension defines the file extension of the file being loaded
  52101. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52102. * @param fallback defines the fallback internal texture if any
  52103. * @param isBase64 defines whether the texture is encoded as a base64
  52104. * @param isBuffer defines whether the texture data are stored as a buffer
  52105. * @returns true if the loader can load the specified file
  52106. */
  52107. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52108. /**
  52109. * Transform the url before loading if required.
  52110. * @param rootUrl the url of the texture
  52111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52112. * @returns the transformed texture
  52113. */
  52114. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52115. /**
  52116. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52117. * @param rootUrl the url of the texture
  52118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52119. * @returns the fallback texture
  52120. */
  52121. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52122. /**
  52123. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52124. * @param data contains the texture data
  52125. * @param texture defines the BabylonJS internal texture
  52126. * @param createPolynomials will be true if polynomials have been requested
  52127. * @param onLoad defines the callback to trigger once the texture is ready
  52128. * @param onError defines the callback to trigger in case of error
  52129. */
  52130. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52131. /**
  52132. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52133. * @param data contains the texture data
  52134. * @param texture defines the BabylonJS internal texture
  52135. * @param callback defines the method to call once ready to upload
  52136. */
  52137. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52138. }
  52139. }
  52140. declare module BABYLON {
  52141. /**
  52142. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  52143. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52144. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52145. */
  52146. export class CustomProceduralTexture extends ProceduralTexture {
  52147. private _animate;
  52148. private _time;
  52149. private _config;
  52150. private _texturePath;
  52151. /**
  52152. * Instantiates a new Custom Procedural Texture.
  52153. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  52154. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52155. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52156. * @param name Define the name of the texture
  52157. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52158. * @param size Define the size of the texture to create
  52159. * @param scene Define the scene the texture belongs to
  52160. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52161. * @param generateMipMaps Define if the texture should creates mip maps or not
  52162. */
  52163. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52164. private _loadJson;
  52165. /**
  52166. * Is the texture ready to be used ? (rendered at least once)
  52167. * @returns true if ready, otherwise, false.
  52168. */
  52169. isReady(): boolean;
  52170. /**
  52171. * Render the texture to its associated render target.
  52172. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52173. */
  52174. render(useCameraPostProcess?: boolean): void;
  52175. /**
  52176. * Update the list of dependant textures samplers in the shader.
  52177. */
  52178. updateTextures(): void;
  52179. /**
  52180. * Update the uniform values of the procedural texture in the shader.
  52181. */
  52182. updateShaderUniforms(): void;
  52183. /**
  52184. * Define if the texture animates or not.
  52185. */
  52186. animate: boolean;
  52187. }
  52188. }
  52189. declare module BABYLON {
  52190. /** @hidden */
  52191. export var noisePixelShader: {
  52192. name: string;
  52193. shader: string;
  52194. };
  52195. }
  52196. declare module BABYLON {
  52197. /**
  52198. * Class used to generate noise procedural textures
  52199. */
  52200. export class NoiseProceduralTexture extends ProceduralTexture {
  52201. private _time;
  52202. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52203. brightness: number;
  52204. /** Defines the number of octaves to process */
  52205. octaves: number;
  52206. /** Defines the level of persistence (0.8 by default) */
  52207. persistence: number;
  52208. /** Gets or sets animation speed factor (default is 1) */
  52209. animationSpeedFactor: number;
  52210. /**
  52211. * Creates a new NoiseProceduralTexture
  52212. * @param name defines the name fo the texture
  52213. * @param size defines the size of the texture (default is 256)
  52214. * @param scene defines the hosting scene
  52215. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52216. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52217. */
  52218. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52219. private _updateShaderUniforms;
  52220. protected _getDefines(): string;
  52221. /** Generate the current state of the procedural texture */
  52222. render(useCameraPostProcess?: boolean): void;
  52223. /**
  52224. * Serializes this noise procedural texture
  52225. * @returns a serialized noise procedural texture object
  52226. */
  52227. serialize(): any;
  52228. /**
  52229. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52230. * @param parsedTexture defines parsed texture data
  52231. * @param scene defines the current scene
  52232. * @param rootUrl defines the root URL containing noise procedural texture information
  52233. * @returns a parsed NoiseProceduralTexture
  52234. */
  52235. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52236. }
  52237. }
  52238. declare module BABYLON {
  52239. /**
  52240. * Raw cube texture where the raw buffers are passed in
  52241. */
  52242. export class RawCubeTexture extends CubeTexture {
  52243. /**
  52244. * Creates a cube texture where the raw buffers are passed in.
  52245. * @param scene defines the scene the texture is attached to
  52246. * @param data defines the array of data to use to create each face
  52247. * @param size defines the size of the textures
  52248. * @param format defines the format of the data
  52249. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52250. * @param generateMipMaps defines if the engine should generate the mip levels
  52251. * @param invertY defines if data must be stored with Y axis inverted
  52252. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52253. * @param compression defines the compression used (null by default)
  52254. */
  52255. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52256. /**
  52257. * Updates the raw cube texture.
  52258. * @param data defines the data to store
  52259. * @param format defines the data format
  52260. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52261. * @param invertY defines if data must be stored with Y axis inverted
  52262. * @param compression defines the compression used (null by default)
  52263. * @param level defines which level of the texture to update
  52264. */
  52265. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52266. /**
  52267. * Updates a raw cube texture with RGBD encoded data.
  52268. * @param data defines the array of data [mipmap][face] to use to create each face
  52269. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52270. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52271. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52272. * @returns a promsie that resolves when the operation is complete
  52273. */
  52274. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52275. /**
  52276. * Clones the raw cube texture.
  52277. * @return a new cube texture
  52278. */
  52279. clone(): CubeTexture;
  52280. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52281. }
  52282. }
  52283. declare module BABYLON {
  52284. /**
  52285. * Class used to store 3D textures containing user data
  52286. */
  52287. export class RawTexture3D extends Texture {
  52288. /** Gets or sets the texture format to use */
  52289. format: number;
  52290. private _engine;
  52291. /**
  52292. * Create a new RawTexture3D
  52293. * @param data defines the data of the texture
  52294. * @param width defines the width of the texture
  52295. * @param height defines the height of the texture
  52296. * @param depth defines the depth of the texture
  52297. * @param format defines the texture format to use
  52298. * @param scene defines the hosting scene
  52299. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52300. * @param invertY defines if texture must be stored with Y axis inverted
  52301. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52302. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52303. */
  52304. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52305. /** Gets or sets the texture format to use */
  52306. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52307. /**
  52308. * Update the texture with new data
  52309. * @param data defines the data to store in the texture
  52310. */
  52311. update(data: ArrayBufferView): void;
  52312. }
  52313. }
  52314. declare module BABYLON {
  52315. /**
  52316. * Creates a refraction texture used by refraction channel of the standard material.
  52317. * It is like a mirror but to see through a material.
  52318. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52319. */
  52320. export class RefractionTexture extends RenderTargetTexture {
  52321. /**
  52322. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52323. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  52324. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52325. */
  52326. refractionPlane: Plane;
  52327. /**
  52328. * Define how deep under the surface we should see.
  52329. */
  52330. depth: number;
  52331. /**
  52332. * Creates a refraction texture used by refraction channel of the standard material.
  52333. * It is like a mirror but to see through a material.
  52334. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52335. * @param name Define the texture name
  52336. * @param size Define the size of the underlying texture
  52337. * @param scene Define the scene the refraction belongs to
  52338. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52339. */
  52340. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52341. /**
  52342. * Clone the refraction texture.
  52343. * @returns the cloned texture
  52344. */
  52345. clone(): RefractionTexture;
  52346. /**
  52347. * Serialize the texture to a JSON representation you could use in Parse later on
  52348. * @returns the serialized JSON representation
  52349. */
  52350. serialize(): any;
  52351. }
  52352. }
  52353. declare module BABYLON {
  52354. /**
  52355. * Defines the options related to the creation of an HtmlElementTexture
  52356. */
  52357. export interface IHtmlElementTextureOptions {
  52358. /**
  52359. * Defines wether mip maps should be created or not.
  52360. */
  52361. generateMipMaps?: boolean;
  52362. /**
  52363. * Defines the sampling mode of the texture.
  52364. */
  52365. samplingMode?: number;
  52366. /**
  52367. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52368. */
  52369. engine: Nullable<Engine>;
  52370. /**
  52371. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52372. */
  52373. scene: Nullable<Scene>;
  52374. }
  52375. /**
  52376. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52377. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52378. * is automatically managed.
  52379. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52380. * in your application.
  52381. *
  52382. * As the update is not automatic, you need to call them manually.
  52383. */
  52384. export class HtmlElementTexture extends BaseTexture {
  52385. /**
  52386. * The texture URL.
  52387. */
  52388. element: HTMLVideoElement | HTMLCanvasElement;
  52389. private static readonly DefaultOptions;
  52390. private _textureMatrix;
  52391. private _engine;
  52392. private _isVideo;
  52393. private _generateMipMaps;
  52394. private _samplingMode;
  52395. /**
  52396. * Instantiates a HtmlElementTexture from the following parameters.
  52397. *
  52398. * @param name Defines the name of the texture
  52399. * @param element Defines the video or canvas the texture is filled with
  52400. * @param options Defines the other none mandatory texture creation options
  52401. */
  52402. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52403. private _createInternalTexture;
  52404. /**
  52405. * Returns the texture matrix used in most of the material.
  52406. */
  52407. getTextureMatrix(): Matrix;
  52408. /**
  52409. * Updates the content of the texture.
  52410. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52411. */
  52412. update(invertY?: Nullable<boolean>): void;
  52413. }
  52414. }
  52415. declare module BABYLON {
  52416. /**
  52417. * Enum used to define the target of a block
  52418. */
  52419. export enum NodeMaterialBlockTargets {
  52420. /** Vertex shader */
  52421. Vertex = 1,
  52422. /** Fragment shader */
  52423. Fragment = 2,
  52424. /** Neutral */
  52425. Neutral = 4,
  52426. /** Vertex and Fragment */
  52427. VertexAndFragment = 3
  52428. }
  52429. }
  52430. declare module BABYLON {
  52431. /**
  52432. * Defines the kind of connection point for node based material
  52433. */
  52434. export enum NodeMaterialBlockConnectionPointTypes {
  52435. /** Float */
  52436. Float = 1,
  52437. /** Int */
  52438. Int = 2,
  52439. /** Vector2 */
  52440. Vector2 = 4,
  52441. /** Vector3 */
  52442. Vector3 = 8,
  52443. /** Vector4 */
  52444. Vector4 = 16,
  52445. /** Color3 */
  52446. Color3 = 32,
  52447. /** Color4 */
  52448. Color4 = 64,
  52449. /** Matrix */
  52450. Matrix = 128,
  52451. /** Detect type based on connection */
  52452. AutoDetect = 1024,
  52453. /** Output type that will be defined by input type */
  52454. BasedOnInput = 2048
  52455. }
  52456. }
  52457. declare module BABYLON {
  52458. /**
  52459. * Root class for all node material optimizers
  52460. */
  52461. export class NodeMaterialOptimizer {
  52462. /**
  52463. * Function used to optimize a NodeMaterial graph
  52464. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52465. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52466. */
  52467. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52468. }
  52469. }
  52470. declare module BABYLON {
  52471. /**
  52472. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52473. */
  52474. export class TransformBlock extends NodeMaterialBlock {
  52475. /**
  52476. * Defines the value to use to complement W value to transform it to a Vector4
  52477. */
  52478. complementW: number;
  52479. /**
  52480. * Defines the value to use to complement z value to transform it to a Vector4
  52481. */
  52482. complementZ: number;
  52483. /**
  52484. * Creates a new TransformBlock
  52485. * @param name defines the block name
  52486. */
  52487. constructor(name: string);
  52488. /**
  52489. * Gets the current class name
  52490. * @returns the class name
  52491. */
  52492. getClassName(): string;
  52493. /**
  52494. * Gets the vector input
  52495. */
  52496. readonly vector: NodeMaterialConnectionPoint;
  52497. /**
  52498. * Gets the output component
  52499. */
  52500. readonly output: NodeMaterialConnectionPoint;
  52501. /**
  52502. * Gets the matrix transform input
  52503. */
  52504. readonly transform: NodeMaterialConnectionPoint;
  52505. protected _buildBlock(state: NodeMaterialBuildState): this;
  52506. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52507. protected _dumpPropertiesCode(): string;
  52508. }
  52509. }
  52510. declare module BABYLON {
  52511. /**
  52512. * Block used to output the vertex position
  52513. */
  52514. export class VertexOutputBlock extends NodeMaterialBlock {
  52515. /**
  52516. * Creates a new VertexOutputBlock
  52517. * @param name defines the block name
  52518. */
  52519. constructor(name: string);
  52520. /**
  52521. * Gets the current class name
  52522. * @returns the class name
  52523. */
  52524. getClassName(): string;
  52525. /**
  52526. * Gets the vector input component
  52527. */
  52528. readonly vector: NodeMaterialConnectionPoint;
  52529. protected _buildBlock(state: NodeMaterialBuildState): this;
  52530. }
  52531. }
  52532. declare module BABYLON {
  52533. /**
  52534. * Block used to output the final color
  52535. */
  52536. export class FragmentOutputBlock extends NodeMaterialBlock {
  52537. /**
  52538. * Create a new FragmentOutputBlock
  52539. * @param name defines the block name
  52540. */
  52541. constructor(name: string);
  52542. /**
  52543. * Gets the current class name
  52544. * @returns the class name
  52545. */
  52546. getClassName(): string;
  52547. /**
  52548. * Gets the rgba input component
  52549. */
  52550. readonly rgba: NodeMaterialConnectionPoint;
  52551. /**
  52552. * Gets the rgb input component
  52553. */
  52554. readonly rgb: NodeMaterialConnectionPoint;
  52555. /**
  52556. * Gets the a input component
  52557. */
  52558. readonly a: NodeMaterialConnectionPoint;
  52559. protected _buildBlock(state: NodeMaterialBuildState): this;
  52560. }
  52561. }
  52562. declare module BABYLON {
  52563. /**
  52564. * Enum used to define system values e.g. values automatically provided by the system
  52565. */
  52566. export enum NodeMaterialSystemValues {
  52567. /** World */
  52568. World = 1,
  52569. /** View */
  52570. View = 2,
  52571. /** Projection */
  52572. Projection = 3,
  52573. /** ViewProjection */
  52574. ViewProjection = 4,
  52575. /** WorldView */
  52576. WorldView = 5,
  52577. /** WorldViewProjection */
  52578. WorldViewProjection = 6,
  52579. /** CameraPosition */
  52580. CameraPosition = 7,
  52581. /** Fog Color */
  52582. FogColor = 8
  52583. }
  52584. }
  52585. declare module BABYLON {
  52586. /**
  52587. * Block used to read a reflection texture from a sampler
  52588. */
  52589. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52590. private _define3DName;
  52591. private _defineCubicName;
  52592. private _defineExplicitName;
  52593. private _defineProjectionName;
  52594. private _defineLocalCubicName;
  52595. private _defineSphericalName;
  52596. private _definePlanarName;
  52597. private _defineEquirectangularName;
  52598. private _defineMirroredEquirectangularFixedName;
  52599. private _defineEquirectangularFixedName;
  52600. private _defineSkyboxName;
  52601. private _cubeSamplerName;
  52602. private _2DSamplerName;
  52603. private _positionUVWName;
  52604. private _directionWName;
  52605. private _reflectionCoordsName;
  52606. private _reflection2DCoordsName;
  52607. private _reflectionColorName;
  52608. private _reflectionMatrixName;
  52609. /**
  52610. * Gets or sets the texture associated with the node
  52611. */
  52612. texture: Nullable<BaseTexture>;
  52613. /**
  52614. * Create a new TextureBlock
  52615. * @param name defines the block name
  52616. */
  52617. constructor(name: string);
  52618. /**
  52619. * Gets the current class name
  52620. * @returns the class name
  52621. */
  52622. getClassName(): string;
  52623. /**
  52624. * Gets the world position input component
  52625. */
  52626. readonly position: NodeMaterialConnectionPoint;
  52627. /**
  52628. * Gets the world position input component
  52629. */
  52630. readonly worldPosition: NodeMaterialConnectionPoint;
  52631. /**
  52632. * Gets the world normal input component
  52633. */
  52634. readonly worldNormal: NodeMaterialConnectionPoint;
  52635. /**
  52636. * Gets the world input component
  52637. */
  52638. readonly world: NodeMaterialConnectionPoint;
  52639. /**
  52640. * Gets the camera (or eye) position component
  52641. */
  52642. readonly cameraPosition: NodeMaterialConnectionPoint;
  52643. /**
  52644. * Gets the view input component
  52645. */
  52646. readonly view: NodeMaterialConnectionPoint;
  52647. /**
  52648. * Gets the rgb output component
  52649. */
  52650. readonly rgb: NodeMaterialConnectionPoint;
  52651. /**
  52652. * Gets the r output component
  52653. */
  52654. readonly r: NodeMaterialConnectionPoint;
  52655. /**
  52656. * Gets the g output component
  52657. */
  52658. readonly g: NodeMaterialConnectionPoint;
  52659. /**
  52660. * Gets the b output component
  52661. */
  52662. readonly b: NodeMaterialConnectionPoint;
  52663. autoConfigure(material: NodeMaterial): void;
  52664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52665. isReady(): boolean;
  52666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52667. private _injectVertexCode;
  52668. private _writeOutput;
  52669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52670. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52671. }
  52672. }
  52673. declare module BABYLON {
  52674. /**
  52675. * Interface used to configure the node material editor
  52676. */
  52677. export interface INodeMaterialEditorOptions {
  52678. /** Define the URl to load node editor script */
  52679. editorURL?: string;
  52680. }
  52681. /** @hidden */
  52682. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52683. /** BONES */
  52684. NUM_BONE_INFLUENCERS: number;
  52685. BonesPerMesh: number;
  52686. BONETEXTURE: boolean;
  52687. /** MORPH TARGETS */
  52688. MORPHTARGETS: boolean;
  52689. MORPHTARGETS_NORMAL: boolean;
  52690. MORPHTARGETS_TANGENT: boolean;
  52691. MORPHTARGETS_UV: boolean;
  52692. NUM_MORPH_INFLUENCERS: number;
  52693. /** IMAGE PROCESSING */
  52694. IMAGEPROCESSING: boolean;
  52695. VIGNETTE: boolean;
  52696. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52697. VIGNETTEBLENDMODEOPAQUE: boolean;
  52698. TONEMAPPING: boolean;
  52699. TONEMAPPING_ACES: boolean;
  52700. CONTRAST: boolean;
  52701. EXPOSURE: boolean;
  52702. COLORCURVES: boolean;
  52703. COLORGRADING: boolean;
  52704. COLORGRADING3D: boolean;
  52705. SAMPLER3DGREENDEPTH: boolean;
  52706. SAMPLER3DBGRMAP: boolean;
  52707. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52708. constructor();
  52709. setValue(name: string, value: boolean): void;
  52710. }
  52711. /**
  52712. * Class used to configure NodeMaterial
  52713. */
  52714. export interface INodeMaterialOptions {
  52715. /**
  52716. * Defines if blocks should emit comments
  52717. */
  52718. emitComments: boolean;
  52719. }
  52720. /**
  52721. * Class used to create a node based material built by assembling shader blocks
  52722. */
  52723. export class NodeMaterial extends PushMaterial {
  52724. private static _BuildIdGenerator;
  52725. private _options;
  52726. private _vertexCompilationState;
  52727. private _fragmentCompilationState;
  52728. private _sharedData;
  52729. private _buildId;
  52730. private _buildWasSuccessful;
  52731. private _cachedWorldViewMatrix;
  52732. private _cachedWorldViewProjectionMatrix;
  52733. private _optimizers;
  52734. private _animationFrame;
  52735. /** Define the URl to load node editor script */
  52736. static EditorURL: string;
  52737. private BJSNODEMATERIALEDITOR;
  52738. /** Get the inspector from bundle or global */
  52739. private _getGlobalNodeMaterialEditor;
  52740. /**
  52741. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  52742. */
  52743. ignoreAlpha: boolean;
  52744. /**
  52745. * Defines the maximum number of lights that can be used in the material
  52746. */
  52747. maxSimultaneousLights: number;
  52748. /**
  52749. * Observable raised when the material is built
  52750. */
  52751. onBuildObservable: Observable<NodeMaterial>;
  52752. /**
  52753. * Gets or sets the root nodes of the material vertex shader
  52754. */ private _vertexOutputNodes: NodeMaterialBlock[];
  52755. /**
  52756. * Gets or sets the root nodes of the material fragment (pixel) shader
  52757. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  52758. /** Gets or sets options to control the node material overall behavior */
  52759. options: INodeMaterialOptions;
  52760. /**
  52761. * Default configuration related to image processing available in the standard Material.
  52762. */
  52763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52764. /**
  52765. * Gets the image processing configuration used either in this material.
  52766. */
  52767. /**
  52768. * Sets the Default image processing configuration used either in the this material.
  52769. *
  52770. * If sets to null, the scene one is in use.
  52771. */
  52772. imageProcessingConfiguration: ImageProcessingConfiguration;
  52773. /**
  52774. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52775. */
  52776. attachedBlocks: NodeMaterialBlock[];
  52777. /**
  52778. * Create a new node based material
  52779. * @param name defines the material name
  52780. * @param scene defines the hosting scene
  52781. * @param options defines creation option
  52782. */
  52783. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52784. /**
  52785. * Gets the current class name of the material e.g. "NodeMaterial"
  52786. * @returns the class name
  52787. */
  52788. getClassName(): string;
  52789. /**
  52790. * Keep track of the image processing observer to allow dispose and replace.
  52791. */
  52792. private _imageProcessingObserver;
  52793. /**
  52794. * Attaches a new image processing configuration to the Standard Material.
  52795. * @param configuration
  52796. */
  52797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52798. /**
  52799. * Get a block by its name
  52800. * @param name defines the name of the block to retrieve
  52801. * @returns the required block or null if not found
  52802. */
  52803. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52804. /**
  52805. * Get a block by its name
  52806. * @param predicate defines the predicate used to find the good candidate
  52807. * @returns the required block or null if not found
  52808. */
  52809. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52810. /**
  52811. * Get an input block by its name
  52812. * @param predicate defines the predicate used to find the good candidate
  52813. * @returns the required input block or null if not found
  52814. */
  52815. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52816. /**
  52817. * Gets the list of input blocks attached to this material
  52818. * @returns an array of InputBlocks
  52819. */
  52820. getInputBlocks(): InputBlock[];
  52821. /**
  52822. * Adds a new optimizer to the list of optimizers
  52823. * @param optimizer defines the optimizers to add
  52824. * @returns the current material
  52825. */
  52826. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52827. /**
  52828. * Remove an optimizer from the list of optimizers
  52829. * @param optimizer defines the optimizers to remove
  52830. * @returns the current material
  52831. */
  52832. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52833. /**
  52834. * Add a new block to the list of output nodes
  52835. * @param node defines the node to add
  52836. * @returns the current material
  52837. */
  52838. addOutputNode(node: NodeMaterialBlock): this;
  52839. /**
  52840. * Remove a block from the list of root nodes
  52841. * @param node defines the node to remove
  52842. * @returns the current material
  52843. */
  52844. removeOutputNode(node: NodeMaterialBlock): this;
  52845. private _addVertexOutputNode;
  52846. private _removeVertexOutputNode;
  52847. private _addFragmentOutputNode;
  52848. private _removeFragmentOutputNode;
  52849. /**
  52850. * Specifies if the material will require alpha blending
  52851. * @returns a boolean specifying if alpha blending is needed
  52852. */
  52853. needAlphaBlending(): boolean;
  52854. /**
  52855. * Specifies if this material should be rendered in alpha test mode
  52856. * @returns a boolean specifying if an alpha test is needed.
  52857. */
  52858. needAlphaTesting(): boolean;
  52859. private _initializeBlock;
  52860. private _resetDualBlocks;
  52861. /**
  52862. * Build the material and generates the inner effect
  52863. * @param verbose defines if the build should log activity
  52864. */
  52865. build(verbose?: boolean): void;
  52866. /**
  52867. * Runs an otpimization phase to try to improve the shader code
  52868. */
  52869. optimize(): void;
  52870. private _prepareDefinesForAttributes;
  52871. /**
  52872. * Get if the submesh is ready to be used and all its information available.
  52873. * Child classes can use it to update shaders
  52874. * @param mesh defines the mesh to check
  52875. * @param subMesh defines which submesh to check
  52876. * @param useInstances specifies that instances should be used
  52877. * @returns a boolean indicating that the submesh is ready or not
  52878. */
  52879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52880. /**
  52881. * Get a string representing the shaders built by the current node graph
  52882. */
  52883. readonly compiledShaders: string;
  52884. /**
  52885. * Binds the world matrix to the material
  52886. * @param world defines the world transformation matrix
  52887. */
  52888. bindOnlyWorldMatrix(world: Matrix): void;
  52889. /**
  52890. * Binds the submesh to this material by preparing the effect and shader to draw
  52891. * @param world defines the world transformation matrix
  52892. * @param mesh defines the mesh containing the submesh
  52893. * @param subMesh defines the submesh to bind the material to
  52894. */
  52895. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52896. /**
  52897. * Gets the active textures from the material
  52898. * @returns an array of textures
  52899. */
  52900. getActiveTextures(): BaseTexture[];
  52901. /**
  52902. * Gets the list of texture blocks
  52903. * @returns an array of texture blocks
  52904. */
  52905. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52906. /**
  52907. * Specifies if the material uses a texture
  52908. * @param texture defines the texture to check against the material
  52909. * @returns a boolean specifying if the material uses the texture
  52910. */
  52911. hasTexture(texture: BaseTexture): boolean;
  52912. /**
  52913. * Disposes the material
  52914. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52915. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52916. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52917. */
  52918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52919. /** Creates the node editor window. */
  52920. private _createNodeEditor;
  52921. /**
  52922. * Launch the node material editor
  52923. * @param config Define the configuration of the editor
  52924. * @return a promise fulfilled when the node editor is visible
  52925. */
  52926. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52927. /**
  52928. * Clear the current material
  52929. */
  52930. clear(): void;
  52931. /**
  52932. * Clear the current material and set it to a default state
  52933. */
  52934. setToDefault(): void;
  52935. /**
  52936. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52937. * @param url defines the url to load from
  52938. * @returns a promise that will fullfil when the material is fully loaded
  52939. */
  52940. loadAsync(url: string): Promise<unknown>;
  52941. private _gatherBlocks;
  52942. /**
  52943. * Generate a string containing the code declaration required to create an equivalent of this material
  52944. * @returns a string
  52945. */
  52946. generateCode(): string;
  52947. /**
  52948. * Serializes this material in a JSON representation
  52949. * @returns the serialized material object
  52950. */
  52951. serialize(): any;
  52952. private _restoreConnections;
  52953. /**
  52954. * Clear the current graph and load a new one from a serialization object
  52955. * @param source defines the JSON representation of the material
  52956. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52957. */
  52958. loadFromSerialization(source: any, rootUrl?: string): void;
  52959. /**
  52960. * Creates a node material from parsed material data
  52961. * @param source defines the JSON representation of the material
  52962. * @param scene defines the hosting scene
  52963. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52964. * @returns a new node material
  52965. */
  52966. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52967. /**
  52968. * Creates a new node material set to default basic configuration
  52969. * @param name defines the name of the material
  52970. * @param scene defines the hosting scene
  52971. * @returns a new NodeMaterial
  52972. */
  52973. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52974. }
  52975. }
  52976. declare module BABYLON {
  52977. /**
  52978. * Block used to read a texture from a sampler
  52979. */
  52980. export class TextureBlock extends NodeMaterialBlock {
  52981. private _defineName;
  52982. private _samplerName;
  52983. private _transformedUVName;
  52984. private _textureTransformName;
  52985. private _textureInfoName;
  52986. private _mainUVName;
  52987. private _mainUVDefineName;
  52988. /**
  52989. * Gets or sets the texture associated with the node
  52990. */
  52991. texture: Nullable<BaseTexture>;
  52992. /**
  52993. * Create a new TextureBlock
  52994. * @param name defines the block name
  52995. */
  52996. constructor(name: string);
  52997. /**
  52998. * Gets the current class name
  52999. * @returns the class name
  53000. */
  53001. getClassName(): string;
  53002. /**
  53003. * Gets the uv input component
  53004. */
  53005. readonly uv: NodeMaterialConnectionPoint;
  53006. /**
  53007. * Gets the rgba output component
  53008. */
  53009. readonly rgba: NodeMaterialConnectionPoint;
  53010. /**
  53011. * Gets the rgb output component
  53012. */
  53013. readonly rgb: NodeMaterialConnectionPoint;
  53014. /**
  53015. * Gets the r output component
  53016. */
  53017. readonly r: NodeMaterialConnectionPoint;
  53018. /**
  53019. * Gets the g output component
  53020. */
  53021. readonly g: NodeMaterialConnectionPoint;
  53022. /**
  53023. * Gets the b output component
  53024. */
  53025. readonly b: NodeMaterialConnectionPoint;
  53026. /**
  53027. * Gets the a output component
  53028. */
  53029. readonly a: NodeMaterialConnectionPoint;
  53030. readonly target: NodeMaterialBlockTargets;
  53031. autoConfigure(material: NodeMaterial): void;
  53032. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53034. isReady(): boolean;
  53035. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53036. private readonly _isMixed;
  53037. private _injectVertexCode;
  53038. private _writeOutput;
  53039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53040. protected _dumpPropertiesCode(): string;
  53041. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53042. }
  53043. }
  53044. declare module BABYLON {
  53045. /**
  53046. * Class used to store shared data between 2 NodeMaterialBuildState
  53047. */
  53048. export class NodeMaterialBuildStateSharedData {
  53049. /**
  53050. * Gets the list of emitted varyings
  53051. */
  53052. temps: string[];
  53053. /**
  53054. * Gets the list of emitted varyings
  53055. */
  53056. varyings: string[];
  53057. /**
  53058. * Gets the varying declaration string
  53059. */
  53060. varyingDeclaration: string;
  53061. /**
  53062. * Input blocks
  53063. */
  53064. inputBlocks: InputBlock[];
  53065. /**
  53066. * Input blocks
  53067. */
  53068. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53069. /**
  53070. * Bindable blocks (Blocks that need to set data to the effect)
  53071. */
  53072. bindableBlocks: NodeMaterialBlock[];
  53073. /**
  53074. * List of blocks that can provide a compilation fallback
  53075. */
  53076. blocksWithFallbacks: NodeMaterialBlock[];
  53077. /**
  53078. * List of blocks that can provide a define update
  53079. */
  53080. blocksWithDefines: NodeMaterialBlock[];
  53081. /**
  53082. * List of blocks that can provide a repeatable content
  53083. */
  53084. repeatableContentBlocks: NodeMaterialBlock[];
  53085. /**
  53086. * List of blocks that can provide a dynamic list of uniforms
  53087. */
  53088. dynamicUniformBlocks: NodeMaterialBlock[];
  53089. /**
  53090. * List of blocks that can block the isReady function for the material
  53091. */
  53092. blockingBlocks: NodeMaterialBlock[];
  53093. /**
  53094. * Gets the list of animated inputs
  53095. */
  53096. animatedInputs: InputBlock[];
  53097. /**
  53098. * Build Id used to avoid multiple recompilations
  53099. */
  53100. buildId: number;
  53101. /** List of emitted variables */
  53102. variableNames: {
  53103. [key: string]: number;
  53104. };
  53105. /** List of emitted defines */
  53106. defineNames: {
  53107. [key: string]: number;
  53108. };
  53109. /** Should emit comments? */
  53110. emitComments: boolean;
  53111. /** Emit build activity */
  53112. verbose: boolean;
  53113. /**
  53114. * Gets the compilation hints emitted at compilation time
  53115. */
  53116. hints: {
  53117. needWorldViewMatrix: boolean;
  53118. needWorldViewProjectionMatrix: boolean;
  53119. needAlphaBlending: boolean;
  53120. needAlphaTesting: boolean;
  53121. };
  53122. /**
  53123. * List of compilation checks
  53124. */
  53125. checks: {
  53126. emitVertex: boolean;
  53127. emitFragment: boolean;
  53128. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53129. };
  53130. /** Creates a new shared data */
  53131. constructor();
  53132. /**
  53133. * Emits console errors and exceptions if there is a failing check
  53134. */
  53135. emitErrors(): void;
  53136. }
  53137. }
  53138. declare module BABYLON {
  53139. /**
  53140. * Class used to store node based material build state
  53141. */
  53142. export class NodeMaterialBuildState {
  53143. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53144. supportUniformBuffers: boolean;
  53145. /**
  53146. * Gets the list of emitted attributes
  53147. */
  53148. attributes: string[];
  53149. /**
  53150. * Gets the list of emitted uniforms
  53151. */
  53152. uniforms: string[];
  53153. /**
  53154. * Gets the list of emitted uniform buffers
  53155. */
  53156. uniformBuffers: string[];
  53157. /**
  53158. * Gets the list of emitted samplers
  53159. */
  53160. samplers: string[];
  53161. /**
  53162. * Gets the list of emitted functions
  53163. */
  53164. functions: {
  53165. [key: string]: string;
  53166. };
  53167. /**
  53168. * Gets the list of emitted extensions
  53169. */
  53170. extensions: {
  53171. [key: string]: string;
  53172. };
  53173. /**
  53174. * Gets the target of the compilation state
  53175. */
  53176. target: NodeMaterialBlockTargets;
  53177. /**
  53178. * Gets the list of emitted counters
  53179. */
  53180. counters: {
  53181. [key: string]: number;
  53182. };
  53183. /**
  53184. * Shared data between multiple NodeMaterialBuildState instances
  53185. */
  53186. sharedData: NodeMaterialBuildStateSharedData;
  53187. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  53188. /** @hidden */ private _attributeDeclaration: string;
  53189. /** @hidden */ private _uniformDeclaration: string;
  53190. /** @hidden */ private _samplerDeclaration: string;
  53191. /** @hidden */ private _varyingTransfer: string;
  53192. private _repeatableContentAnchorIndex;
  53193. /** @hidden */ private _builtCompilationString: string;
  53194. /**
  53195. * Gets the emitted compilation strings
  53196. */
  53197. compilationString: string;
  53198. /**
  53199. * Finalize the compilation strings
  53200. * @param state defines the current compilation state
  53201. */
  53202. finalize(state: NodeMaterialBuildState): void;
  53203. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  53204. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  53205. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  53206. /** @hidden */ private _excludeVariableName(name: string): void;
  53207. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53208. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  53209. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  53210. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53211. replaceStrings?: {
  53212. search: RegExp;
  53213. replace: string;
  53214. }[];
  53215. repeatKey?: string;
  53216. }): string;
  53217. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53218. repeatKey?: string;
  53219. removeAttributes?: boolean;
  53220. removeUniforms?: boolean;
  53221. removeVaryings?: boolean;
  53222. removeIfDef?: boolean;
  53223. replaceStrings?: {
  53224. search: RegExp;
  53225. replace: string;
  53226. }[];
  53227. }, storeKey?: string): void;
  53228. /** @hidden */ private _registerTempVariable(name: string): boolean;
  53229. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53230. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53231. }
  53232. }
  53233. declare module BABYLON {
  53234. /**
  53235. * Defines a block that can be used inside a node based material
  53236. */
  53237. export class NodeMaterialBlock {
  53238. private _buildId;
  53239. private _buildTarget;
  53240. private _target;
  53241. private _isFinalMerger;
  53242. private _isInput;
  53243. /** @hidden */ private _codeVariableName: string;
  53244. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  53245. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  53246. /** @hidden */ private _preparationId: number;
  53247. /**
  53248. * Gets or sets the name of the block
  53249. */
  53250. name: string;
  53251. /**
  53252. * Gets or sets the unique id of the node
  53253. */
  53254. uniqueId: number;
  53255. /**
  53256. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53257. */
  53258. readonly isFinalMerger: boolean;
  53259. /**
  53260. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53261. */
  53262. readonly isInput: boolean;
  53263. /**
  53264. * Gets or sets the build Id
  53265. */
  53266. buildId: number;
  53267. /**
  53268. * Gets or sets the target of the block
  53269. */
  53270. target: NodeMaterialBlockTargets;
  53271. /**
  53272. * Gets the list of input points
  53273. */
  53274. readonly inputs: NodeMaterialConnectionPoint[];
  53275. /** Gets the list of output points */
  53276. readonly outputs: NodeMaterialConnectionPoint[];
  53277. /**
  53278. * Find an input by its name
  53279. * @param name defines the name of the input to look for
  53280. * @returns the input or null if not found
  53281. */
  53282. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53283. /**
  53284. * Find an output by its name
  53285. * @param name defines the name of the outputto look for
  53286. * @returns the output or null if not found
  53287. */
  53288. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53289. /**
  53290. * Creates a new NodeMaterialBlock
  53291. * @param name defines the block name
  53292. * @param target defines the target of that block (Vertex by default)
  53293. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53294. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53295. */
  53296. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53297. /**
  53298. * Initialize the block and prepare the context for build
  53299. * @param state defines the state that will be used for the build
  53300. */
  53301. initialize(state: NodeMaterialBuildState): void;
  53302. /**
  53303. * Bind data to effect. Will only be called for blocks with isBindable === true
  53304. * @param effect defines the effect to bind data to
  53305. * @param nodeMaterial defines the hosting NodeMaterial
  53306. * @param mesh defines the mesh that will be rendered
  53307. */
  53308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53309. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53310. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53311. protected _writeFloat(value: number): string;
  53312. /**
  53313. * Gets the current class name e.g. "NodeMaterialBlock"
  53314. * @returns the class name
  53315. */
  53316. getClassName(): string;
  53317. /**
  53318. * Register a new input. Must be called inside a block constructor
  53319. * @param name defines the connection point name
  53320. * @param type defines the connection point type
  53321. * @param isOptional defines a boolean indicating that this input can be omitted
  53322. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53323. * @returns the current block
  53324. */
  53325. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53326. /**
  53327. * Register a new output. Must be called inside a block constructor
  53328. * @param name defines the connection point name
  53329. * @param type defines the connection point type
  53330. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53331. * @returns the current block
  53332. */
  53333. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53334. /**
  53335. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53336. * @param forOutput defines an optional connection point to check compatibility with
  53337. * @returns the first available input or null
  53338. */
  53339. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53340. /**
  53341. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53342. * @param forBlock defines an optional block to check compatibility with
  53343. * @returns the first available input or null
  53344. */
  53345. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53346. /**
  53347. * Gets the sibling of the given output
  53348. * @param current defines the current output
  53349. * @returns the next output in the list or null
  53350. */
  53351. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53352. /**
  53353. * Connect current block with another block
  53354. * @param other defines the block to connect with
  53355. * @param options define the various options to help pick the right connections
  53356. * @returns the current block
  53357. */
  53358. connectTo(other: NodeMaterialBlock, options?: {
  53359. input?: string;
  53360. output?: string;
  53361. outputSwizzle?: string;
  53362. }): this | undefined;
  53363. protected _buildBlock(state: NodeMaterialBuildState): void;
  53364. /**
  53365. * Add uniforms, samplers and uniform buffers at compilation time
  53366. * @param state defines the state to update
  53367. * @param nodeMaterial defines the node material requesting the update
  53368. * @param defines defines the material defines to update
  53369. */
  53370. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53371. /**
  53372. * Add potential fallbacks if shader compilation fails
  53373. * @param mesh defines the mesh to be rendered
  53374. * @param fallbacks defines the current prioritized list of fallbacks
  53375. */
  53376. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53377. /**
  53378. * Update defines for shader compilation
  53379. * @param mesh defines the mesh to be rendered
  53380. * @param nodeMaterial defines the node material requesting the update
  53381. * @param defines defines the material defines to update
  53382. * @param useInstances specifies that instances should be used
  53383. */
  53384. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53385. /**
  53386. * Initialize defines for shader compilation
  53387. * @param mesh defines the mesh to be rendered
  53388. * @param nodeMaterial defines the node material requesting the update
  53389. * @param defines defines the material defines to be prepared
  53390. * @param useInstances specifies that instances should be used
  53391. */
  53392. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53393. /**
  53394. * Lets the block try to connect some inputs automatically
  53395. * @param material defines the hosting NodeMaterial
  53396. */
  53397. autoConfigure(material: NodeMaterial): void;
  53398. /**
  53399. * Function called when a block is declared as repeatable content generator
  53400. * @param vertexShaderState defines the current compilation state for the vertex shader
  53401. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53402. * @param mesh defines the mesh to be rendered
  53403. * @param defines defines the material defines to update
  53404. */
  53405. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53406. /**
  53407. * Checks if the block is ready
  53408. * @param mesh defines the mesh to be rendered
  53409. * @param nodeMaterial defines the node material requesting the update
  53410. * @param defines defines the material defines to update
  53411. * @param useInstances specifies that instances should be used
  53412. * @returns true if the block is ready
  53413. */
  53414. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53415. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53416. private _processBuild;
  53417. /**
  53418. * Compile the current node and generate the shader code
  53419. * @param state defines the current compilation state (uniforms, samplers, current string)
  53420. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53421. * @returns true if already built
  53422. */
  53423. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53424. protected _inputRename(name: string): string;
  53425. protected _outputRename(name: string): string;
  53426. protected _dumpPropertiesCode(): string;
  53427. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53428. /**
  53429. * Clone the current block to a new identical block
  53430. * @param scene defines the hosting scene
  53431. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53432. * @returns a copy of the current block
  53433. */
  53434. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53435. /**
  53436. * Serializes this block in a JSON representation
  53437. * @returns the serialized block object
  53438. */
  53439. serialize(): any;
  53440. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53441. }
  53442. }
  53443. declare module BABYLON {
  53444. /**
  53445. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53446. */
  53447. export enum NodeMaterialBlockConnectionPointMode {
  53448. /** Value is an uniform */
  53449. Uniform = 0,
  53450. /** Value is a mesh attribute */
  53451. Attribute = 1,
  53452. /** Value is a varying between vertex and fragment shaders */
  53453. Varying = 2,
  53454. /** Mode is undefined */
  53455. Undefined = 3
  53456. }
  53457. }
  53458. declare module BABYLON {
  53459. /**
  53460. * Enum defining the type of animations supported by InputBlock
  53461. */
  53462. export enum AnimatedInputBlockTypes {
  53463. /** No animation */
  53464. None = 0,
  53465. /** Time based animation. Will only work for floats */
  53466. Time = 1
  53467. }
  53468. }
  53469. declare module BABYLON {
  53470. /**
  53471. * Block used to expose an input value
  53472. */
  53473. export class InputBlock extends NodeMaterialBlock {
  53474. private _mode;
  53475. private _associatedVariableName;
  53476. private _storedValue;
  53477. private _valueCallback;
  53478. private _type;
  53479. private _animationType;
  53480. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  53481. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53482. visibleInInspector: boolean;
  53483. /**
  53484. * Gets or sets the connection point type (default is float)
  53485. */
  53486. readonly type: NodeMaterialBlockConnectionPointTypes;
  53487. /**
  53488. * Creates a new InputBlock
  53489. * @param name defines the block name
  53490. * @param target defines the target of that block (Vertex by default)
  53491. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53492. */
  53493. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53494. /**
  53495. * Gets the output component
  53496. */
  53497. readonly output: NodeMaterialConnectionPoint;
  53498. /**
  53499. * Set the source of this connection point to a vertex attribute
  53500. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53501. * @returns the current connection point
  53502. */
  53503. setAsAttribute(attributeName?: string): InputBlock;
  53504. /**
  53505. * Set the source of this connection point to a system value
  53506. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53507. * @returns the current connection point
  53508. */
  53509. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53510. /**
  53511. * Gets or sets the value of that point.
  53512. * Please note that this value will be ignored if valueCallback is defined
  53513. */
  53514. value: any;
  53515. /**
  53516. * Gets or sets a callback used to get the value of that point.
  53517. * Please note that setting this value will force the connection point to ignore the value property
  53518. */
  53519. valueCallback: () => any;
  53520. /**
  53521. * Gets or sets the associated variable name in the shader
  53522. */
  53523. associatedVariableName: string;
  53524. /** Gets or sets the type of animation applied to the input */
  53525. animationType: AnimatedInputBlockTypes;
  53526. /**
  53527. * Gets a boolean indicating that this connection point not defined yet
  53528. */
  53529. readonly isUndefined: boolean;
  53530. /**
  53531. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53532. * In this case the connection point name must be the name of the uniform to use.
  53533. * Can only be set on inputs
  53534. */
  53535. isUniform: boolean;
  53536. /**
  53537. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53538. * In this case the connection point name must be the name of the attribute to use
  53539. * Can only be set on inputs
  53540. */
  53541. isAttribute: boolean;
  53542. /**
  53543. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53544. * Can only be set on exit points
  53545. */
  53546. isVarying: boolean;
  53547. /**
  53548. * Gets a boolean indicating that the current connection point is a system value
  53549. */
  53550. readonly isSystemValue: boolean;
  53551. /**
  53552. * Gets or sets the current well known value or null if not defined as a system value
  53553. */
  53554. systemValue: Nullable<NodeMaterialSystemValues>;
  53555. /**
  53556. * Gets the current class name
  53557. * @returns the class name
  53558. */
  53559. getClassName(): string;
  53560. /**
  53561. * Animate the input if animationType !== None
  53562. * @param scene defines the rendering scene
  53563. */
  53564. animate(scene: Scene): void;
  53565. private _emitDefine;
  53566. /**
  53567. * Set the input block to its default value (based on its type)
  53568. */
  53569. setDefaultValue(): void;
  53570. protected _dumpPropertiesCode(): string;
  53571. private _emit;
  53572. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53573. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  53574. protected _buildBlock(state: NodeMaterialBuildState): void;
  53575. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53576. }
  53577. }
  53578. declare module BABYLON {
  53579. /**
  53580. * Defines a connection point for a block
  53581. */
  53582. export class NodeMaterialConnectionPoint {
  53583. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  53584. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53585. private _endpoints;
  53586. private _associatedVariableName;
  53587. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53588. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53589. private _type;
  53590. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  53591. /**
  53592. * Gets or sets the additional types supported byt this connection point
  53593. */
  53594. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53595. /**
  53596. * Gets or sets the associated variable name in the shader
  53597. */
  53598. associatedVariableName: string;
  53599. /**
  53600. * Gets or sets the connection point type (default is float)
  53601. */
  53602. type: NodeMaterialBlockConnectionPointTypes;
  53603. /**
  53604. * Gets or sets the connection point name
  53605. */
  53606. name: string;
  53607. /**
  53608. * Gets or sets a boolean indicating that this connection point can be omitted
  53609. */
  53610. isOptional: boolean;
  53611. /**
  53612. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53613. */
  53614. define: string;
  53615. /** Gets or sets the target of that connection point */
  53616. target: NodeMaterialBlockTargets;
  53617. /**
  53618. * Gets a boolean indicating that the current point is connected
  53619. */
  53620. readonly isConnected: boolean;
  53621. /**
  53622. * Gets a boolean indicating that the current point is connected to an input block
  53623. */
  53624. readonly isConnectedToInputBlock: boolean;
  53625. /**
  53626. * Gets a the connected input block (if any)
  53627. */
  53628. readonly connectInputBlock: Nullable<InputBlock>;
  53629. /** Get the other side of the connection (if any) */
  53630. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53631. /** Get the block that owns this connection point */
  53632. readonly ownerBlock: NodeMaterialBlock;
  53633. /** Get the block connected on the other side of this connection (if any) */
  53634. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53635. /** Get the block connected on the endpoints of this connection (if any) */
  53636. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53637. /** Gets the list of connected endpoints */
  53638. readonly endpoints: NodeMaterialConnectionPoint[];
  53639. /** Gets a boolean indicating if that output point is connected to at least one input */
  53640. readonly hasEndpoints: boolean;
  53641. /**
  53642. * Creates a new connection point
  53643. * @param name defines the connection point name
  53644. * @param ownerBlock defines the block hosting this connection point
  53645. */
  53646. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53647. /**
  53648. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53649. * @returns the class name
  53650. */
  53651. getClassName(): string;
  53652. /**
  53653. * Gets an boolean indicating if the current point can be connected to another point
  53654. * @param connectionPoint defines the other connection point
  53655. * @returns true if the connection is possible
  53656. */
  53657. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53658. /**
  53659. * Connect this point to another connection point
  53660. * @param connectionPoint defines the other connection point
  53661. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53662. * @returns the current connection point
  53663. */
  53664. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53665. /**
  53666. * Disconnect this point from one of his endpoint
  53667. * @param endpoint defines the other connection point
  53668. * @returns the current connection point
  53669. */
  53670. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53671. /**
  53672. * Serializes this point in a JSON representation
  53673. * @returns the serialized point object
  53674. */
  53675. serialize(): any;
  53676. }
  53677. }
  53678. declare module BABYLON {
  53679. /**
  53680. * Block used to add support for vertex skinning (bones)
  53681. */
  53682. export class BonesBlock extends NodeMaterialBlock {
  53683. /**
  53684. * Creates a new BonesBlock
  53685. * @param name defines the block name
  53686. */
  53687. constructor(name: string);
  53688. /**
  53689. * Initialize the block and prepare the context for build
  53690. * @param state defines the state that will be used for the build
  53691. */
  53692. initialize(state: NodeMaterialBuildState): void;
  53693. /**
  53694. * Gets the current class name
  53695. * @returns the class name
  53696. */
  53697. getClassName(): string;
  53698. /**
  53699. * Gets the matrix indices input component
  53700. */
  53701. readonly matricesIndices: NodeMaterialConnectionPoint;
  53702. /**
  53703. * Gets the matrix weights input component
  53704. */
  53705. readonly matricesWeights: NodeMaterialConnectionPoint;
  53706. /**
  53707. * Gets the extra matrix indices input component
  53708. */
  53709. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53710. /**
  53711. * Gets the extra matrix weights input component
  53712. */
  53713. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53714. /**
  53715. * Gets the world input component
  53716. */
  53717. readonly world: NodeMaterialConnectionPoint;
  53718. /**
  53719. * Gets the output component
  53720. */
  53721. readonly output: NodeMaterialConnectionPoint;
  53722. autoConfigure(material: NodeMaterial): void;
  53723. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53724. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53726. protected _buildBlock(state: NodeMaterialBuildState): this;
  53727. }
  53728. }
  53729. declare module BABYLON {
  53730. /**
  53731. * Block used to add support for instances
  53732. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53733. */
  53734. export class InstancesBlock extends NodeMaterialBlock {
  53735. /**
  53736. * Creates a new InstancesBlock
  53737. * @param name defines the block name
  53738. */
  53739. constructor(name: string);
  53740. /**
  53741. * Gets the current class name
  53742. * @returns the class name
  53743. */
  53744. getClassName(): string;
  53745. /**
  53746. * Gets the first world row input component
  53747. */
  53748. readonly world0: NodeMaterialConnectionPoint;
  53749. /**
  53750. * Gets the second world row input component
  53751. */
  53752. readonly world1: NodeMaterialConnectionPoint;
  53753. /**
  53754. * Gets the third world row input component
  53755. */
  53756. readonly world2: NodeMaterialConnectionPoint;
  53757. /**
  53758. * Gets the forth world row input component
  53759. */
  53760. readonly world3: NodeMaterialConnectionPoint;
  53761. /**
  53762. * Gets the world input component
  53763. */
  53764. readonly world: NodeMaterialConnectionPoint;
  53765. /**
  53766. * Gets the output component
  53767. */
  53768. readonly output: NodeMaterialConnectionPoint;
  53769. autoConfigure(material: NodeMaterial): void;
  53770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53771. protected _buildBlock(state: NodeMaterialBuildState): this;
  53772. }
  53773. }
  53774. declare module BABYLON {
  53775. /**
  53776. * Block used to add morph targets support to vertex shader
  53777. */
  53778. export class MorphTargetsBlock extends NodeMaterialBlock {
  53779. private _repeatableContentAnchor;
  53780. private _repeatebleContentGenerated;
  53781. /**
  53782. * Create a new MorphTargetsBlock
  53783. * @param name defines the block name
  53784. */
  53785. constructor(name: string);
  53786. /**
  53787. * Gets the current class name
  53788. * @returns the class name
  53789. */
  53790. getClassName(): string;
  53791. /**
  53792. * Gets the position input component
  53793. */
  53794. readonly position: NodeMaterialConnectionPoint;
  53795. /**
  53796. * Gets the normal input component
  53797. */
  53798. readonly normal: NodeMaterialConnectionPoint;
  53799. /**
  53800. * Gets the tangent input component
  53801. */
  53802. readonly tangent: NodeMaterialConnectionPoint;
  53803. /**
  53804. * Gets the tangent input component
  53805. */
  53806. readonly uv: NodeMaterialConnectionPoint;
  53807. /**
  53808. * Gets the position output component
  53809. */
  53810. readonly positionOutput: NodeMaterialConnectionPoint;
  53811. /**
  53812. * Gets the normal output component
  53813. */
  53814. readonly normalOutput: NodeMaterialConnectionPoint;
  53815. /**
  53816. * Gets the tangent output component
  53817. */
  53818. readonly tangentOutput: NodeMaterialConnectionPoint;
  53819. /**
  53820. * Gets the tangent output component
  53821. */
  53822. readonly uvOutput: NodeMaterialConnectionPoint;
  53823. initialize(state: NodeMaterialBuildState): void;
  53824. autoConfigure(material: NodeMaterial): void;
  53825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53827. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53828. protected _buildBlock(state: NodeMaterialBuildState): this;
  53829. }
  53830. }
  53831. declare module BABYLON {
  53832. /**
  53833. * Block used to get data information from a light
  53834. */
  53835. export class LightInformationBlock extends NodeMaterialBlock {
  53836. private _lightDataDefineName;
  53837. private _lightColorDefineName;
  53838. /**
  53839. * Gets or sets the light associated with this block
  53840. */
  53841. light: Nullable<Light>;
  53842. /**
  53843. * Creates a new LightInformationBlock
  53844. * @param name defines the block name
  53845. */
  53846. constructor(name: string);
  53847. /**
  53848. * Gets the current class name
  53849. * @returns the class name
  53850. */
  53851. getClassName(): string;
  53852. /**
  53853. * Gets the world position input component
  53854. */
  53855. readonly worldPosition: NodeMaterialConnectionPoint;
  53856. /**
  53857. * Gets the direction output component
  53858. */
  53859. readonly direction: NodeMaterialConnectionPoint;
  53860. /**
  53861. * Gets the direction output component
  53862. */
  53863. readonly color: NodeMaterialConnectionPoint;
  53864. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53865. protected _buildBlock(state: NodeMaterialBuildState): this;
  53866. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53867. }
  53868. }
  53869. declare module BABYLON {
  53870. /**
  53871. * Block used to add an alpha test in the fragment shader
  53872. */
  53873. export class AlphaTestBlock extends NodeMaterialBlock {
  53874. /**
  53875. * Gets or sets the alpha value where alpha testing happens
  53876. */
  53877. alphaCutOff: number;
  53878. /**
  53879. * Create a new AlphaTestBlock
  53880. * @param name defines the block name
  53881. */
  53882. constructor(name: string);
  53883. /**
  53884. * Gets the current class name
  53885. * @returns the class name
  53886. */
  53887. getClassName(): string;
  53888. /**
  53889. * Gets the color input component
  53890. */
  53891. readonly color: NodeMaterialConnectionPoint;
  53892. /**
  53893. * Gets the alpha input component
  53894. */
  53895. readonly alpha: NodeMaterialConnectionPoint;
  53896. protected _buildBlock(state: NodeMaterialBuildState): this;
  53897. protected _dumpPropertiesCode(): string;
  53898. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53899. }
  53900. }
  53901. declare module BABYLON {
  53902. /**
  53903. * Block used to add image processing support to fragment shader
  53904. */
  53905. export class ImageProcessingBlock extends NodeMaterialBlock {
  53906. /**
  53907. * Create a new ImageProcessingBlock
  53908. * @param name defines the block name
  53909. */
  53910. constructor(name: string);
  53911. /**
  53912. * Gets the current class name
  53913. * @returns the class name
  53914. */
  53915. getClassName(): string;
  53916. /**
  53917. * Gets the color input component
  53918. */
  53919. readonly color: NodeMaterialConnectionPoint;
  53920. /**
  53921. * Gets the output component
  53922. */
  53923. readonly output: NodeMaterialConnectionPoint;
  53924. /**
  53925. * Initialize the block and prepare the context for build
  53926. * @param state defines the state that will be used for the build
  53927. */
  53928. initialize(state: NodeMaterialBuildState): void;
  53929. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53931. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53932. protected _buildBlock(state: NodeMaterialBuildState): this;
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /**
  53937. * Block used to pertub normals based on a normal map
  53938. */
  53939. export class PerturbNormalBlock extends NodeMaterialBlock {
  53940. /**
  53941. * Create a new PerturbNormalBlock
  53942. * @param name defines the block name
  53943. */
  53944. constructor(name: string);
  53945. /**
  53946. * Gets the current class name
  53947. * @returns the class name
  53948. */
  53949. getClassName(): string;
  53950. /**
  53951. * Gets the world position input component
  53952. */
  53953. readonly worldPosition: NodeMaterialConnectionPoint;
  53954. /**
  53955. * Gets the world normal input component
  53956. */
  53957. readonly worldNormal: NodeMaterialConnectionPoint;
  53958. /**
  53959. * Gets the uv input component
  53960. */
  53961. readonly uv: NodeMaterialConnectionPoint;
  53962. /**
  53963. * Gets the normal map color input component
  53964. */
  53965. readonly normalMapColor: NodeMaterialConnectionPoint;
  53966. /**
  53967. * Gets the strength input component
  53968. */
  53969. readonly strength: NodeMaterialConnectionPoint;
  53970. /**
  53971. * Gets the output component
  53972. */
  53973. readonly output: NodeMaterialConnectionPoint;
  53974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53975. autoConfigure(material: NodeMaterial): void;
  53976. protected _buildBlock(state: NodeMaterialBuildState): this;
  53977. }
  53978. }
  53979. declare module BABYLON {
  53980. /**
  53981. * Block used to add support for scene fog
  53982. */
  53983. export class FogBlock extends NodeMaterialBlock {
  53984. private _fogDistanceName;
  53985. private _fogParameters;
  53986. /**
  53987. * Create a new FogBlock
  53988. * @param name defines the block name
  53989. */
  53990. constructor(name: string);
  53991. /**
  53992. * Gets the current class name
  53993. * @returns the class name
  53994. */
  53995. getClassName(): string;
  53996. /**
  53997. * Gets the world position input component
  53998. */
  53999. readonly worldPosition: NodeMaterialConnectionPoint;
  54000. /**
  54001. * Gets the view input component
  54002. */
  54003. readonly view: NodeMaterialConnectionPoint;
  54004. /**
  54005. * Gets the color input component
  54006. */
  54007. readonly input: NodeMaterialConnectionPoint;
  54008. /**
  54009. * Gets the fog color input component
  54010. */
  54011. readonly fogColor: NodeMaterialConnectionPoint;
  54012. /**
  54013. * Gets the output component
  54014. */
  54015. readonly output: NodeMaterialConnectionPoint;
  54016. autoConfigure(material: NodeMaterial): void;
  54017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54019. protected _buildBlock(state: NodeMaterialBuildState): this;
  54020. }
  54021. }
  54022. declare module BABYLON {
  54023. /**
  54024. * Block used to add light in the fragment shader
  54025. */
  54026. export class LightBlock extends NodeMaterialBlock {
  54027. private _lightId;
  54028. /**
  54029. * Gets or sets the light associated with this block
  54030. */
  54031. light: Nullable<Light>;
  54032. /**
  54033. * Create a new LightBlock
  54034. * @param name defines the block name
  54035. */
  54036. constructor(name: string);
  54037. /**
  54038. * Gets the current class name
  54039. * @returns the class name
  54040. */
  54041. getClassName(): string;
  54042. /**
  54043. * Gets the world position input component
  54044. */
  54045. readonly worldPosition: NodeMaterialConnectionPoint;
  54046. /**
  54047. * Gets the world normal input component
  54048. */
  54049. readonly worldNormal: NodeMaterialConnectionPoint;
  54050. /**
  54051. * Gets the camera (or eye) position component
  54052. */
  54053. readonly cameraPosition: NodeMaterialConnectionPoint;
  54054. /**
  54055. * Gets the diffuse output component
  54056. */
  54057. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54058. /**
  54059. * Gets the specular output component
  54060. */
  54061. readonly specularOutput: NodeMaterialConnectionPoint;
  54062. autoConfigure(material: NodeMaterial): void;
  54063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54064. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54066. private _injectVertexCode;
  54067. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54068. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54069. }
  54070. }
  54071. declare module BABYLON {
  54072. /**
  54073. * Block used to multiply 2 values
  54074. */
  54075. export class MultiplyBlock extends NodeMaterialBlock {
  54076. /**
  54077. * Creates a new MultiplyBlock
  54078. * @param name defines the block name
  54079. */
  54080. constructor(name: string);
  54081. /**
  54082. * Gets the current class name
  54083. * @returns the class name
  54084. */
  54085. getClassName(): string;
  54086. /**
  54087. * Gets the left operand input component
  54088. */
  54089. readonly left: NodeMaterialConnectionPoint;
  54090. /**
  54091. * Gets the right operand input component
  54092. */
  54093. readonly right: NodeMaterialConnectionPoint;
  54094. /**
  54095. * Gets the output component
  54096. */
  54097. readonly output: NodeMaterialConnectionPoint;
  54098. protected _buildBlock(state: NodeMaterialBuildState): this;
  54099. }
  54100. }
  54101. declare module BABYLON {
  54102. /**
  54103. * Block used to add 2 vectors
  54104. */
  54105. export class AddBlock extends NodeMaterialBlock {
  54106. /**
  54107. * Creates a new AddBlock
  54108. * @param name defines the block name
  54109. */
  54110. constructor(name: string);
  54111. /**
  54112. * Gets the current class name
  54113. * @returns the class name
  54114. */
  54115. getClassName(): string;
  54116. /**
  54117. * Gets the left operand input component
  54118. */
  54119. readonly left: NodeMaterialConnectionPoint;
  54120. /**
  54121. * Gets the right operand input component
  54122. */
  54123. readonly right: NodeMaterialConnectionPoint;
  54124. /**
  54125. * Gets the output component
  54126. */
  54127. readonly output: NodeMaterialConnectionPoint;
  54128. protected _buildBlock(state: NodeMaterialBuildState): this;
  54129. }
  54130. }
  54131. declare module BABYLON {
  54132. /**
  54133. * Block used to scale a vector by a float
  54134. */
  54135. export class ScaleBlock extends NodeMaterialBlock {
  54136. /**
  54137. * Creates a new ScaleBlock
  54138. * @param name defines the block name
  54139. */
  54140. constructor(name: string);
  54141. /**
  54142. * Gets the current class name
  54143. * @returns the class name
  54144. */
  54145. getClassName(): string;
  54146. /**
  54147. * Gets the input component
  54148. */
  54149. readonly input: NodeMaterialConnectionPoint;
  54150. /**
  54151. * Gets the factor input component
  54152. */
  54153. readonly factor: NodeMaterialConnectionPoint;
  54154. /**
  54155. * Gets the output component
  54156. */
  54157. readonly output: NodeMaterialConnectionPoint;
  54158. protected _buildBlock(state: NodeMaterialBuildState): this;
  54159. }
  54160. }
  54161. declare module BABYLON {
  54162. /**
  54163. * Block used to clamp a float
  54164. */
  54165. export class ClampBlock extends NodeMaterialBlock {
  54166. /** Gets or sets the minimum range */
  54167. minimum: number;
  54168. /** Gets or sets the maximum range */
  54169. maximum: number;
  54170. /**
  54171. * Creates a new ClampBlock
  54172. * @param name defines the block name
  54173. */
  54174. constructor(name: string);
  54175. /**
  54176. * Gets the current class name
  54177. * @returns the class name
  54178. */
  54179. getClassName(): string;
  54180. /**
  54181. * Gets the value input component
  54182. */
  54183. readonly value: NodeMaterialConnectionPoint;
  54184. /**
  54185. * Gets the output component
  54186. */
  54187. readonly output: NodeMaterialConnectionPoint;
  54188. protected _buildBlock(state: NodeMaterialBuildState): this;
  54189. protected _dumpPropertiesCode(): string;
  54190. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54191. }
  54192. }
  54193. declare module BABYLON {
  54194. /**
  54195. * Block used to apply a cross product between 2 vectors
  54196. */
  54197. export class CrossBlock extends NodeMaterialBlock {
  54198. /**
  54199. * Creates a new CrossBlock
  54200. * @param name defines the block name
  54201. */
  54202. constructor(name: string);
  54203. /**
  54204. * Gets the current class name
  54205. * @returns the class name
  54206. */
  54207. getClassName(): string;
  54208. /**
  54209. * Gets the left operand input component
  54210. */
  54211. readonly left: NodeMaterialConnectionPoint;
  54212. /**
  54213. * Gets the right operand input component
  54214. */
  54215. readonly right: NodeMaterialConnectionPoint;
  54216. /**
  54217. * Gets the output component
  54218. */
  54219. readonly output: NodeMaterialConnectionPoint;
  54220. protected _buildBlock(state: NodeMaterialBuildState): this;
  54221. }
  54222. }
  54223. declare module BABYLON {
  54224. /**
  54225. * Block used to apply a dot product between 2 vectors
  54226. */
  54227. export class DotBlock extends NodeMaterialBlock {
  54228. /**
  54229. * Creates a new DotBlock
  54230. * @param name defines the block name
  54231. */
  54232. constructor(name: string);
  54233. /**
  54234. * Gets the current class name
  54235. * @returns the class name
  54236. */
  54237. getClassName(): string;
  54238. /**
  54239. * Gets the left operand input component
  54240. */
  54241. readonly left: NodeMaterialConnectionPoint;
  54242. /**
  54243. * Gets the right operand input component
  54244. */
  54245. readonly right: NodeMaterialConnectionPoint;
  54246. /**
  54247. * Gets the output component
  54248. */
  54249. readonly output: NodeMaterialConnectionPoint;
  54250. protected _buildBlock(state: NodeMaterialBuildState): this;
  54251. }
  54252. }
  54253. declare module BABYLON {
  54254. /**
  54255. * Block used to remap a float from a range to a new one
  54256. */
  54257. export class RemapBlock extends NodeMaterialBlock {
  54258. /**
  54259. * Gets or sets the source range
  54260. */
  54261. sourceRange: Vector2;
  54262. /**
  54263. * Gets or sets the target range
  54264. */
  54265. targetRange: Vector2;
  54266. /**
  54267. * Creates a new RemapBlock
  54268. * @param name defines the block name
  54269. */
  54270. constructor(name: string);
  54271. /**
  54272. * Gets the current class name
  54273. * @returns the class name
  54274. */
  54275. getClassName(): string;
  54276. /**
  54277. * Gets the input component
  54278. */
  54279. readonly input: NodeMaterialConnectionPoint;
  54280. /**
  54281. * Gets the output component
  54282. */
  54283. readonly output: NodeMaterialConnectionPoint;
  54284. protected _buildBlock(state: NodeMaterialBuildState): this;
  54285. protected _dumpPropertiesCode(): string;
  54286. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54287. }
  54288. }
  54289. declare module BABYLON {
  54290. /**
  54291. * Block used to normalize a vector
  54292. */
  54293. export class NormalizeBlock extends NodeMaterialBlock {
  54294. /**
  54295. * Creates a new NormalizeBlock
  54296. * @param name defines the block name
  54297. */
  54298. constructor(name: string);
  54299. /**
  54300. * Gets the current class name
  54301. * @returns the class name
  54302. */
  54303. getClassName(): string;
  54304. /**
  54305. * Gets the input component
  54306. */
  54307. readonly input: NodeMaterialConnectionPoint;
  54308. /**
  54309. * Gets the output component
  54310. */
  54311. readonly output: NodeMaterialConnectionPoint;
  54312. protected _buildBlock(state: NodeMaterialBuildState): this;
  54313. }
  54314. }
  54315. declare module BABYLON {
  54316. /**
  54317. * Operations supported by the Trigonometry block
  54318. */
  54319. export enum TrigonometryBlockOperations {
  54320. /** Cos */
  54321. Cos = 0,
  54322. /** Sin */
  54323. Sin = 1,
  54324. /** Abs */
  54325. Abs = 2,
  54326. /** Exp */
  54327. Exp = 3,
  54328. /** Exp2 */
  54329. Exp2 = 4,
  54330. /** Round */
  54331. Round = 5,
  54332. /** Floor */
  54333. Floor = 6,
  54334. /** Ceiling */
  54335. Ceiling = 7
  54336. }
  54337. /**
  54338. * Block used to apply trigonometry operation to floats
  54339. */
  54340. export class TrigonometryBlock extends NodeMaterialBlock {
  54341. /**
  54342. * Gets or sets the operation applied by the block
  54343. */
  54344. operation: TrigonometryBlockOperations;
  54345. /**
  54346. * Creates a new TrigonometryBlock
  54347. * @param name defines the block name
  54348. */
  54349. constructor(name: string);
  54350. /**
  54351. * Gets the current class name
  54352. * @returns the class name
  54353. */
  54354. getClassName(): string;
  54355. /**
  54356. * Gets the input component
  54357. */
  54358. readonly input: NodeMaterialConnectionPoint;
  54359. /**
  54360. * Gets the output component
  54361. */
  54362. readonly output: NodeMaterialConnectionPoint;
  54363. protected _buildBlock(state: NodeMaterialBuildState): this;
  54364. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54365. }
  54366. }
  54367. declare module BABYLON {
  54368. /**
  54369. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54370. */
  54371. export class ColorMergerBlock extends NodeMaterialBlock {
  54372. /**
  54373. * Create a new ColorMergerBlock
  54374. * @param name defines the block name
  54375. */
  54376. constructor(name: string);
  54377. /**
  54378. * Gets the current class name
  54379. * @returns the class name
  54380. */
  54381. getClassName(): string;
  54382. /**
  54383. * Gets the r component (input)
  54384. */
  54385. readonly r: NodeMaterialConnectionPoint;
  54386. /**
  54387. * Gets the g component (input)
  54388. */
  54389. readonly g: NodeMaterialConnectionPoint;
  54390. /**
  54391. * Gets the b component (input)
  54392. */
  54393. readonly b: NodeMaterialConnectionPoint;
  54394. /**
  54395. * Gets the a component (input)
  54396. */
  54397. readonly a: NodeMaterialConnectionPoint;
  54398. /**
  54399. * Gets the rgba component (output)
  54400. */
  54401. readonly rgba: NodeMaterialConnectionPoint;
  54402. /**
  54403. * Gets the rgb component (output)
  54404. */
  54405. readonly rgb: NodeMaterialConnectionPoint;
  54406. protected _buildBlock(state: NodeMaterialBuildState): this;
  54407. }
  54408. }
  54409. declare module BABYLON {
  54410. /**
  54411. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54412. */
  54413. export class VectorMergerBlock extends NodeMaterialBlock {
  54414. /**
  54415. * Create a new VectorMergerBlock
  54416. * @param name defines the block name
  54417. */
  54418. constructor(name: string);
  54419. /**
  54420. * Gets the current class name
  54421. * @returns the class name
  54422. */
  54423. getClassName(): string;
  54424. /**
  54425. * Gets the x component (input)
  54426. */
  54427. readonly x: NodeMaterialConnectionPoint;
  54428. /**
  54429. * Gets the y component (input)
  54430. */
  54431. readonly y: NodeMaterialConnectionPoint;
  54432. /**
  54433. * Gets the z component (input)
  54434. */
  54435. readonly z: NodeMaterialConnectionPoint;
  54436. /**
  54437. * Gets the w component (input)
  54438. */
  54439. readonly w: NodeMaterialConnectionPoint;
  54440. /**
  54441. * Gets the xyzw component (output)
  54442. */
  54443. readonly xyzw: NodeMaterialConnectionPoint;
  54444. /**
  54445. * Gets the xyz component (output)
  54446. */
  54447. readonly xyz: NodeMaterialConnectionPoint;
  54448. /**
  54449. * Gets the xy component (output)
  54450. */
  54451. readonly xy: NodeMaterialConnectionPoint;
  54452. protected _buildBlock(state: NodeMaterialBuildState): this;
  54453. }
  54454. }
  54455. declare module BABYLON {
  54456. /**
  54457. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54458. */
  54459. export class ColorSplitterBlock extends NodeMaterialBlock {
  54460. /**
  54461. * Create a new ColorSplitterBlock
  54462. * @param name defines the block name
  54463. */
  54464. constructor(name: string);
  54465. /**
  54466. * Gets the current class name
  54467. * @returns the class name
  54468. */
  54469. getClassName(): string;
  54470. /**
  54471. * Gets the rgba component (input)
  54472. */
  54473. readonly rgba: NodeMaterialConnectionPoint;
  54474. /**
  54475. * Gets the rgb component (input)
  54476. */
  54477. readonly rgbIn: NodeMaterialConnectionPoint;
  54478. /**
  54479. * Gets the rgb component (output)
  54480. */
  54481. readonly rgbOut: NodeMaterialConnectionPoint;
  54482. /**
  54483. * Gets the r component (output)
  54484. */
  54485. readonly r: NodeMaterialConnectionPoint;
  54486. /**
  54487. * Gets the g component (output)
  54488. */
  54489. readonly g: NodeMaterialConnectionPoint;
  54490. /**
  54491. * Gets the b component (output)
  54492. */
  54493. readonly b: NodeMaterialConnectionPoint;
  54494. /**
  54495. * Gets the a component (output)
  54496. */
  54497. readonly a: NodeMaterialConnectionPoint;
  54498. protected _inputRename(name: string): string;
  54499. protected _outputRename(name: string): string;
  54500. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54501. }
  54502. }
  54503. declare module BABYLON {
  54504. /**
  54505. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54506. */
  54507. export class VectorSplitterBlock extends NodeMaterialBlock {
  54508. /**
  54509. * Create a new VectorSplitterBlock
  54510. * @param name defines the block name
  54511. */
  54512. constructor(name: string);
  54513. /**
  54514. * Gets the current class name
  54515. * @returns the class name
  54516. */
  54517. getClassName(): string;
  54518. /**
  54519. * Gets the xyzw component (input)
  54520. */
  54521. readonly xyzw: NodeMaterialConnectionPoint;
  54522. /**
  54523. * Gets the xyz component (input)
  54524. */
  54525. readonly xyzIn: NodeMaterialConnectionPoint;
  54526. /**
  54527. * Gets the xy component (input)
  54528. */
  54529. readonly xyIn: NodeMaterialConnectionPoint;
  54530. /**
  54531. * Gets the xyz component (output)
  54532. */
  54533. readonly xyzOut: NodeMaterialConnectionPoint;
  54534. /**
  54535. * Gets the xy component (output)
  54536. */
  54537. readonly xyOut: NodeMaterialConnectionPoint;
  54538. /**
  54539. * Gets the x component (output)
  54540. */
  54541. readonly x: NodeMaterialConnectionPoint;
  54542. /**
  54543. * Gets the y component (output)
  54544. */
  54545. readonly y: NodeMaterialConnectionPoint;
  54546. /**
  54547. * Gets the z component (output)
  54548. */
  54549. readonly z: NodeMaterialConnectionPoint;
  54550. /**
  54551. * Gets the w component (output)
  54552. */
  54553. readonly w: NodeMaterialConnectionPoint;
  54554. protected _inputRename(name: string): string;
  54555. protected _outputRename(name: string): string;
  54556. protected _buildBlock(state: NodeMaterialBuildState): this;
  54557. }
  54558. }
  54559. declare module BABYLON {
  54560. /**
  54561. * Block used to lerp 2 values
  54562. */
  54563. export class LerpBlock extends NodeMaterialBlock {
  54564. /**
  54565. * Creates a new LerpBlock
  54566. * @param name defines the block name
  54567. */
  54568. constructor(name: string);
  54569. /**
  54570. * Gets the current class name
  54571. * @returns the class name
  54572. */
  54573. getClassName(): string;
  54574. /**
  54575. * Gets the left operand input component
  54576. */
  54577. readonly left: NodeMaterialConnectionPoint;
  54578. /**
  54579. * Gets the right operand input component
  54580. */
  54581. readonly right: NodeMaterialConnectionPoint;
  54582. /**
  54583. * Gets the gradient operand input component
  54584. */
  54585. readonly gradient: NodeMaterialConnectionPoint;
  54586. /**
  54587. * Gets the output component
  54588. */
  54589. readonly output: NodeMaterialConnectionPoint;
  54590. protected _buildBlock(state: NodeMaterialBuildState): this;
  54591. }
  54592. }
  54593. declare module BABYLON {
  54594. /**
  54595. * Block used to divide 2 vectors
  54596. */
  54597. export class DivideBlock extends NodeMaterialBlock {
  54598. /**
  54599. * Creates a new DivideBlock
  54600. * @param name defines the block name
  54601. */
  54602. constructor(name: string);
  54603. /**
  54604. * Gets the current class name
  54605. * @returns the class name
  54606. */
  54607. getClassName(): string;
  54608. /**
  54609. * Gets the left operand input component
  54610. */
  54611. readonly left: NodeMaterialConnectionPoint;
  54612. /**
  54613. * Gets the right operand input component
  54614. */
  54615. readonly right: NodeMaterialConnectionPoint;
  54616. /**
  54617. * Gets the output component
  54618. */
  54619. readonly output: NodeMaterialConnectionPoint;
  54620. protected _buildBlock(state: NodeMaterialBuildState): this;
  54621. }
  54622. }
  54623. declare module BABYLON {
  54624. /**
  54625. * Block used to subtract 2 vectors
  54626. */
  54627. export class SubtractBlock extends NodeMaterialBlock {
  54628. /**
  54629. * Creates a new SubtractBlock
  54630. * @param name defines the block name
  54631. */
  54632. constructor(name: string);
  54633. /**
  54634. * Gets the current class name
  54635. * @returns the class name
  54636. */
  54637. getClassName(): string;
  54638. /**
  54639. * Gets the left operand input component
  54640. */
  54641. readonly left: NodeMaterialConnectionPoint;
  54642. /**
  54643. * Gets the right operand input component
  54644. */
  54645. readonly right: NodeMaterialConnectionPoint;
  54646. /**
  54647. * Gets the output component
  54648. */
  54649. readonly output: NodeMaterialConnectionPoint;
  54650. protected _buildBlock(state: NodeMaterialBuildState): this;
  54651. }
  54652. }
  54653. declare module BABYLON {
  54654. /**
  54655. * Block used to step a value
  54656. */
  54657. export class StepBlock extends NodeMaterialBlock {
  54658. /**
  54659. * Creates a new AddBlock
  54660. * @param name defines the block name
  54661. */
  54662. constructor(name: string);
  54663. /**
  54664. * Gets the current class name
  54665. * @returns the class name
  54666. */
  54667. getClassName(): string;
  54668. /**
  54669. * Gets the value operand input component
  54670. */
  54671. readonly value: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the edge operand input component
  54674. */
  54675. readonly edge: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the output component
  54678. */
  54679. readonly output: NodeMaterialConnectionPoint;
  54680. protected _buildBlock(state: NodeMaterialBuildState): this;
  54681. }
  54682. }
  54683. declare module BABYLON {
  54684. /**
  54685. * Block used to get the opposite of a value
  54686. */
  54687. export class OppositeBlock extends NodeMaterialBlock {
  54688. /**
  54689. * Creates a new OppositeBlock
  54690. * @param name defines the block name
  54691. */
  54692. constructor(name: string);
  54693. /**
  54694. * Gets the current class name
  54695. * @returns the class name
  54696. */
  54697. getClassName(): string;
  54698. /**
  54699. * Gets the input component
  54700. */
  54701. readonly input: NodeMaterialConnectionPoint;
  54702. /**
  54703. * Gets the output component
  54704. */
  54705. readonly output: NodeMaterialConnectionPoint;
  54706. protected _buildBlock(state: NodeMaterialBuildState): this;
  54707. }
  54708. }
  54709. declare module BABYLON {
  54710. /**
  54711. * Block used to get the view direction
  54712. */
  54713. export class ViewDirectionBlock extends NodeMaterialBlock {
  54714. /**
  54715. * Creates a new ViewDirectionBlock
  54716. * @param name defines the block name
  54717. */
  54718. constructor(name: string);
  54719. /**
  54720. * Gets the current class name
  54721. * @returns the class name
  54722. */
  54723. getClassName(): string;
  54724. /**
  54725. * Gets the world position component
  54726. */
  54727. readonly worldPosition: NodeMaterialConnectionPoint;
  54728. /**
  54729. * Gets the camera position component
  54730. */
  54731. readonly cameraPosition: NodeMaterialConnectionPoint;
  54732. /**
  54733. * Gets the output component
  54734. */
  54735. readonly output: NodeMaterialConnectionPoint;
  54736. autoConfigure(material: NodeMaterial): void;
  54737. protected _buildBlock(state: NodeMaterialBuildState): this;
  54738. }
  54739. }
  54740. declare module BABYLON {
  54741. /**
  54742. * Block used to compute fresnel value
  54743. */
  54744. export class FresnelBlock extends NodeMaterialBlock {
  54745. /**
  54746. * Create a new FresnelBlock
  54747. * @param name defines the block name
  54748. */
  54749. constructor(name: string);
  54750. /**
  54751. * Gets the current class name
  54752. * @returns the class name
  54753. */
  54754. getClassName(): string;
  54755. /**
  54756. * Gets the world normal input component
  54757. */
  54758. readonly worldNormal: NodeMaterialConnectionPoint;
  54759. /**
  54760. * Gets the view direction input component
  54761. */
  54762. readonly viewDirection: NodeMaterialConnectionPoint;
  54763. /**
  54764. * Gets the bias input component
  54765. */
  54766. readonly bias: NodeMaterialConnectionPoint;
  54767. /**
  54768. * Gets the camera (or eye) position component
  54769. */
  54770. readonly power: NodeMaterialConnectionPoint;
  54771. /**
  54772. * Gets the fresnel output component
  54773. */
  54774. readonly fresnel: NodeMaterialConnectionPoint;
  54775. autoConfigure(material: NodeMaterial): void;
  54776. protected _buildBlock(state: NodeMaterialBuildState): this;
  54777. }
  54778. }
  54779. declare module BABYLON {
  54780. /**
  54781. * Block used to get the max of 2 values
  54782. */
  54783. export class MaxBlock extends NodeMaterialBlock {
  54784. /**
  54785. * Creates a new MaxBlock
  54786. * @param name defines the block name
  54787. */
  54788. constructor(name: string);
  54789. /**
  54790. * Gets the current class name
  54791. * @returns the class name
  54792. */
  54793. getClassName(): string;
  54794. /**
  54795. * Gets the left operand input component
  54796. */
  54797. readonly left: NodeMaterialConnectionPoint;
  54798. /**
  54799. * Gets the right operand input component
  54800. */
  54801. readonly right: NodeMaterialConnectionPoint;
  54802. /**
  54803. * Gets the output component
  54804. */
  54805. readonly output: NodeMaterialConnectionPoint;
  54806. protected _buildBlock(state: NodeMaterialBuildState): this;
  54807. }
  54808. }
  54809. declare module BABYLON {
  54810. /**
  54811. * Block used to get the min of 2 values
  54812. */
  54813. export class MinBlock extends NodeMaterialBlock {
  54814. /**
  54815. * Creates a new MinBlock
  54816. * @param name defines the block name
  54817. */
  54818. constructor(name: string);
  54819. /**
  54820. * Gets the current class name
  54821. * @returns the class name
  54822. */
  54823. getClassName(): string;
  54824. /**
  54825. * Gets the left operand input component
  54826. */
  54827. readonly left: NodeMaterialConnectionPoint;
  54828. /**
  54829. * Gets the right operand input component
  54830. */
  54831. readonly right: NodeMaterialConnectionPoint;
  54832. /**
  54833. * Gets the output component
  54834. */
  54835. readonly output: NodeMaterialConnectionPoint;
  54836. protected _buildBlock(state: NodeMaterialBuildState): this;
  54837. }
  54838. }
  54839. declare module BABYLON {
  54840. /**
  54841. * Effect Render Options
  54842. */
  54843. export interface IEffectRendererOptions {
  54844. /**
  54845. * Defines the vertices positions.
  54846. */
  54847. positions?: number[];
  54848. /**
  54849. * Defines the indices.
  54850. */
  54851. indices?: number[];
  54852. }
  54853. /**
  54854. * Helper class to render one or more effects
  54855. */
  54856. export class EffectRenderer {
  54857. private engine;
  54858. private static _DefaultOptions;
  54859. private _vertexBuffers;
  54860. private _indexBuffer;
  54861. private _ringBufferIndex;
  54862. private _ringScreenBuffer;
  54863. private _fullscreenViewport;
  54864. private _getNextFrameBuffer;
  54865. /**
  54866. * Creates an effect renderer
  54867. * @param engine the engine to use for rendering
  54868. * @param options defines the options of the effect renderer
  54869. */
  54870. constructor(engine: Engine, options?: IEffectRendererOptions);
  54871. /**
  54872. * Sets the current viewport in normalized coordinates 0-1
  54873. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54874. */
  54875. setViewport(viewport?: Viewport): void;
  54876. /**
  54877. * Binds the embedded attributes buffer to the effect.
  54878. * @param effect Defines the effect to bind the attributes for
  54879. */
  54880. bindBuffers(effect: Effect): void;
  54881. /**
  54882. * Sets the current effect wrapper to use during draw.
  54883. * The effect needs to be ready before calling this api.
  54884. * This also sets the default full screen position attribute.
  54885. * @param effectWrapper Defines the effect to draw with
  54886. */
  54887. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54888. /**
  54889. * Draws a full screen quad.
  54890. */
  54891. draw(): void;
  54892. /**
  54893. * renders one or more effects to a specified texture
  54894. * @param effectWrappers list of effects to renderer
  54895. * @param outputTexture texture to draw to, if null it will render to the screen
  54896. */
  54897. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54898. /**
  54899. * Disposes of the effect renderer
  54900. */
  54901. dispose(): void;
  54902. }
  54903. /**
  54904. * Options to create an EffectWrapper
  54905. */
  54906. interface EffectWrapperCreationOptions {
  54907. /**
  54908. * Engine to use to create the effect
  54909. */
  54910. engine: Engine;
  54911. /**
  54912. * Fragment shader for the effect
  54913. */
  54914. fragmentShader: string;
  54915. /**
  54916. * Vertex shader for the effect
  54917. */
  54918. vertexShader?: string;
  54919. /**
  54920. * Attributes to use in the shader
  54921. */
  54922. attributeNames?: Array<string>;
  54923. /**
  54924. * Uniforms to use in the shader
  54925. */
  54926. uniformNames?: Array<string>;
  54927. /**
  54928. * Texture sampler names to use in the shader
  54929. */
  54930. samplerNames?: Array<string>;
  54931. /**
  54932. * The friendly name of the effect displayed in Spector.
  54933. */
  54934. name?: string;
  54935. }
  54936. /**
  54937. * Wraps an effect to be used for rendering
  54938. */
  54939. export class EffectWrapper {
  54940. /**
  54941. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54942. */
  54943. onApplyObservable: Observable<{}>;
  54944. /**
  54945. * The underlying effect
  54946. */
  54947. effect: Effect;
  54948. /**
  54949. * Creates an effect to be renderer
  54950. * @param creationOptions options to create the effect
  54951. */
  54952. constructor(creationOptions: EffectWrapperCreationOptions);
  54953. /**
  54954. * Disposes of the effect wrapper
  54955. */
  54956. dispose(): void;
  54957. }
  54958. }
  54959. declare module BABYLON {
  54960. /**
  54961. * Helper class to push actions to a pool of workers.
  54962. */
  54963. export class WorkerPool implements IDisposable {
  54964. private _workerInfos;
  54965. private _pendingActions;
  54966. /**
  54967. * Constructor
  54968. * @param workers Array of workers to use for actions
  54969. */
  54970. constructor(workers: Array<Worker>);
  54971. /**
  54972. * Terminates all workers and clears any pending actions.
  54973. */
  54974. dispose(): void;
  54975. /**
  54976. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54977. * pended until a worker has completed its action.
  54978. * @param action The action to perform. Call onComplete when the action is complete.
  54979. */
  54980. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54981. private _execute;
  54982. }
  54983. }
  54984. declare module BABYLON {
  54985. /**
  54986. * Configuration for Draco compression
  54987. */
  54988. export interface IDracoCompressionConfiguration {
  54989. /**
  54990. * Configuration for the decoder.
  54991. */
  54992. decoder: {
  54993. /**
  54994. * The url to the WebAssembly module.
  54995. */
  54996. wasmUrl?: string;
  54997. /**
  54998. * The url to the WebAssembly binary.
  54999. */
  55000. wasmBinaryUrl?: string;
  55001. /**
  55002. * The url to the fallback JavaScript module.
  55003. */
  55004. fallbackUrl?: string;
  55005. };
  55006. }
  55007. /**
  55008. * Draco compression (https://google.github.io/draco/)
  55009. *
  55010. * This class wraps the Draco module.
  55011. *
  55012. * **Encoder**
  55013. *
  55014. * The encoder is not currently implemented.
  55015. *
  55016. * **Decoder**
  55017. *
  55018. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  55019. *
  55020. * To update the configuration, use the following code:
  55021. * ```javascript
  55022. * DracoCompression.Configuration = {
  55023. * decoder: {
  55024. * wasmUrl: "<url to the WebAssembly library>",
  55025. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55026. * fallbackUrl: "<url to the fallback JavaScript library>",
  55027. * }
  55028. * };
  55029. * ```
  55030. *
  55031. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  55032. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55033. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55034. *
  55035. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55036. * ```javascript
  55037. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55038. * ```
  55039. *
  55040. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55041. */
  55042. export class DracoCompression implements IDisposable {
  55043. private _workerPoolPromise?;
  55044. private _decoderModulePromise?;
  55045. /**
  55046. * The configuration. Defaults to the following urls:
  55047. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55048. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55049. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55050. */
  55051. static Configuration: IDracoCompressionConfiguration;
  55052. /**
  55053. * Returns true if the decoder configuration is available.
  55054. */
  55055. static readonly DecoderAvailable: boolean;
  55056. /**
  55057. * Default number of workers to create when creating the draco compression object.
  55058. */
  55059. static DefaultNumWorkers: number;
  55060. private static GetDefaultNumWorkers;
  55061. private static _Default;
  55062. /**
  55063. * Default instance for the draco compression object.
  55064. */
  55065. static readonly Default: DracoCompression;
  55066. /**
  55067. * Constructor
  55068. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55069. */
  55070. constructor(numWorkers?: number);
  55071. /**
  55072. * Stop all async operations and release resources.
  55073. */
  55074. dispose(): void;
  55075. /**
  55076. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55077. * @returns a promise that resolves when ready
  55078. */
  55079. whenReadyAsync(): Promise<void>;
  55080. /**
  55081. * Decode Draco compressed mesh data to vertex data.
  55082. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55083. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55084. * @returns A promise that resolves with the decoded vertex data
  55085. */
  55086. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55087. [kind: string]: number;
  55088. }): Promise<VertexData>;
  55089. }
  55090. }
  55091. declare module BABYLON {
  55092. /**
  55093. * Class for building Constructive Solid Geometry
  55094. */
  55095. export class CSG {
  55096. private polygons;
  55097. /**
  55098. * The world matrix
  55099. */
  55100. matrix: Matrix;
  55101. /**
  55102. * Stores the position
  55103. */
  55104. position: Vector3;
  55105. /**
  55106. * Stores the rotation
  55107. */
  55108. rotation: Vector3;
  55109. /**
  55110. * Stores the rotation quaternion
  55111. */
  55112. rotationQuaternion: Nullable<Quaternion>;
  55113. /**
  55114. * Stores the scaling vector
  55115. */
  55116. scaling: Vector3;
  55117. /**
  55118. * Convert the Mesh to CSG
  55119. * @param mesh The Mesh to convert to CSG
  55120. * @returns A new CSG from the Mesh
  55121. */
  55122. static FromMesh(mesh: Mesh): CSG;
  55123. /**
  55124. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55125. * @param polygons Polygons used to construct a CSG solid
  55126. */
  55127. private static FromPolygons;
  55128. /**
  55129. * Clones, or makes a deep copy, of the CSG
  55130. * @returns A new CSG
  55131. */
  55132. clone(): CSG;
  55133. /**
  55134. * Unions this CSG with another CSG
  55135. * @param csg The CSG to union against this CSG
  55136. * @returns The unioned CSG
  55137. */
  55138. union(csg: CSG): CSG;
  55139. /**
  55140. * Unions this CSG with another CSG in place
  55141. * @param csg The CSG to union against this CSG
  55142. */
  55143. unionInPlace(csg: CSG): void;
  55144. /**
  55145. * Subtracts this CSG with another CSG
  55146. * @param csg The CSG to subtract against this CSG
  55147. * @returns A new CSG
  55148. */
  55149. subtract(csg: CSG): CSG;
  55150. /**
  55151. * Subtracts this CSG with another CSG in place
  55152. * @param csg The CSG to subtact against this CSG
  55153. */
  55154. subtractInPlace(csg: CSG): void;
  55155. /**
  55156. * Intersect this CSG with another CSG
  55157. * @param csg The CSG to intersect against this CSG
  55158. * @returns A new CSG
  55159. */
  55160. intersect(csg: CSG): CSG;
  55161. /**
  55162. * Intersects this CSG with another CSG in place
  55163. * @param csg The CSG to intersect against this CSG
  55164. */
  55165. intersectInPlace(csg: CSG): void;
  55166. /**
  55167. * Return a new CSG solid with solid and empty space switched. This solid is
  55168. * not modified.
  55169. * @returns A new CSG solid with solid and empty space switched
  55170. */
  55171. inverse(): CSG;
  55172. /**
  55173. * Inverses the CSG in place
  55174. */
  55175. inverseInPlace(): void;
  55176. /**
  55177. * This is used to keep meshes transformations so they can be restored
  55178. * when we build back a Babylon Mesh
  55179. * NB : All CSG operations are performed in world coordinates
  55180. * @param csg The CSG to copy the transform attributes from
  55181. * @returns This CSG
  55182. */
  55183. copyTransformAttributes(csg: CSG): CSG;
  55184. /**
  55185. * Build Raw mesh from CSG
  55186. * Coordinates here are in world space
  55187. * @param name The name of the mesh geometry
  55188. * @param scene The Scene
  55189. * @param keepSubMeshes Specifies if the submeshes should be kept
  55190. * @returns A new Mesh
  55191. */
  55192. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55193. /**
  55194. * Build Mesh from CSG taking material and transforms into account
  55195. * @param name The name of the Mesh
  55196. * @param material The material of the Mesh
  55197. * @param scene The Scene
  55198. * @param keepSubMeshes Specifies if submeshes should be kept
  55199. * @returns The new Mesh
  55200. */
  55201. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55202. }
  55203. }
  55204. declare module BABYLON {
  55205. /**
  55206. * Class used to create a trail following a mesh
  55207. */
  55208. export class TrailMesh extends Mesh {
  55209. private _generator;
  55210. private _autoStart;
  55211. private _running;
  55212. private _diameter;
  55213. private _length;
  55214. private _sectionPolygonPointsCount;
  55215. private _sectionVectors;
  55216. private _sectionNormalVectors;
  55217. private _beforeRenderObserver;
  55218. /**
  55219. * @constructor
  55220. * @param name The value used by scene.getMeshByName() to do a lookup.
  55221. * @param generator The mesh to generate a trail.
  55222. * @param scene The scene to add this mesh to.
  55223. * @param diameter Diameter of trailing mesh. Default is 1.
  55224. * @param length Length of trailing mesh. Default is 60.
  55225. * @param autoStart Automatically start trailing mesh. Default true.
  55226. */
  55227. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55228. /**
  55229. * "TrailMesh"
  55230. * @returns "TrailMesh"
  55231. */
  55232. getClassName(): string;
  55233. private _createMesh;
  55234. /**
  55235. * Start trailing mesh.
  55236. */
  55237. start(): void;
  55238. /**
  55239. * Stop trailing mesh.
  55240. */
  55241. stop(): void;
  55242. /**
  55243. * Update trailing mesh geometry.
  55244. */
  55245. update(): void;
  55246. /**
  55247. * Returns a new TrailMesh object.
  55248. * @param name is a string, the name given to the new mesh
  55249. * @param newGenerator use new generator object for cloned trail mesh
  55250. * @returns a new mesh
  55251. */
  55252. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55253. /**
  55254. * Serializes this trail mesh
  55255. * @param serializationObject object to write serialization to
  55256. */
  55257. serialize(serializationObject: any): void;
  55258. /**
  55259. * Parses a serialized trail mesh
  55260. * @param parsedMesh the serialized mesh
  55261. * @param scene the scene to create the trail mesh in
  55262. * @returns the created trail mesh
  55263. */
  55264. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55265. }
  55266. }
  55267. declare module BABYLON {
  55268. /**
  55269. * Class containing static functions to help procedurally build meshes
  55270. */
  55271. export class TiledBoxBuilder {
  55272. /**
  55273. * Creates a box mesh
  55274. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  55275. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55279. * @param name defines the name of the mesh
  55280. * @param options defines the options used to create the mesh
  55281. * @param scene defines the hosting scene
  55282. * @returns the box mesh
  55283. */
  55284. static CreateTiledBox(name: string, options: {
  55285. pattern?: number;
  55286. width?: number;
  55287. height?: number;
  55288. depth?: number;
  55289. tileSize?: number;
  55290. tileWidth?: number;
  55291. tileHeight?: number;
  55292. alignHorizontal?: number;
  55293. alignVertical?: number;
  55294. faceUV?: Vector4[];
  55295. faceColors?: Color4[];
  55296. sideOrientation?: number;
  55297. updatable?: boolean;
  55298. }, scene?: Nullable<Scene>): Mesh;
  55299. }
  55300. }
  55301. declare module BABYLON {
  55302. /**
  55303. * Class containing static functions to help procedurally build meshes
  55304. */
  55305. export class TorusKnotBuilder {
  55306. /**
  55307. * Creates a torus knot mesh
  55308. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55309. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55310. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55311. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55315. * @param name defines the name of the mesh
  55316. * @param options defines the options used to create the mesh
  55317. * @param scene defines the hosting scene
  55318. * @returns the torus knot mesh
  55319. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55320. */
  55321. static CreateTorusKnot(name: string, options: {
  55322. radius?: number;
  55323. tube?: number;
  55324. radialSegments?: number;
  55325. tubularSegments?: number;
  55326. p?: number;
  55327. q?: number;
  55328. updatable?: boolean;
  55329. sideOrientation?: number;
  55330. frontUVs?: Vector4;
  55331. backUVs?: Vector4;
  55332. }, scene: any): Mesh;
  55333. }
  55334. }
  55335. declare module BABYLON {
  55336. /**
  55337. * Polygon
  55338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55339. */
  55340. export class Polygon {
  55341. /**
  55342. * Creates a rectangle
  55343. * @param xmin bottom X coord
  55344. * @param ymin bottom Y coord
  55345. * @param xmax top X coord
  55346. * @param ymax top Y coord
  55347. * @returns points that make the resulting rectation
  55348. */
  55349. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55350. /**
  55351. * Creates a circle
  55352. * @param radius radius of circle
  55353. * @param cx scale in x
  55354. * @param cy scale in y
  55355. * @param numberOfSides number of sides that make up the circle
  55356. * @returns points that make the resulting circle
  55357. */
  55358. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55359. /**
  55360. * Creates a polygon from input string
  55361. * @param input Input polygon data
  55362. * @returns the parsed points
  55363. */
  55364. static Parse(input: string): Vector2[];
  55365. /**
  55366. * Starts building a polygon from x and y coordinates
  55367. * @param x x coordinate
  55368. * @param y y coordinate
  55369. * @returns the started path2
  55370. */
  55371. static StartingAt(x: number, y: number): Path2;
  55372. }
  55373. /**
  55374. * Builds a polygon
  55375. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55376. */
  55377. export class PolygonMeshBuilder {
  55378. private _points;
  55379. private _outlinepoints;
  55380. private _holes;
  55381. private _name;
  55382. private _scene;
  55383. private _epoints;
  55384. private _eholes;
  55385. private _addToepoint;
  55386. /**
  55387. * Babylon reference to the earcut plugin.
  55388. */
  55389. bjsEarcut: any;
  55390. /**
  55391. * Creates a PolygonMeshBuilder
  55392. * @param name name of the builder
  55393. * @param contours Path of the polygon
  55394. * @param scene scene to add to when creating the mesh
  55395. * @param earcutInjection can be used to inject your own earcut reference
  55396. */
  55397. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55398. /**
  55399. * Adds a whole within the polygon
  55400. * @param hole Array of points defining the hole
  55401. * @returns this
  55402. */
  55403. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55404. /**
  55405. * Creates the polygon
  55406. * @param updatable If the mesh should be updatable
  55407. * @param depth The depth of the mesh created
  55408. * @returns the created mesh
  55409. */
  55410. build(updatable?: boolean, depth?: number): Mesh;
  55411. /**
  55412. * Creates the polygon
  55413. * @param depth The depth of the mesh created
  55414. * @returns the created VertexData
  55415. */
  55416. buildVertexData(depth?: number): VertexData;
  55417. /**
  55418. * Adds a side to the polygon
  55419. * @param positions points that make the polygon
  55420. * @param normals normals of the polygon
  55421. * @param uvs uvs of the polygon
  55422. * @param indices indices of the polygon
  55423. * @param bounds bounds of the polygon
  55424. * @param points points of the polygon
  55425. * @param depth depth of the polygon
  55426. * @param flip flip of the polygon
  55427. */
  55428. private addSide;
  55429. }
  55430. }
  55431. declare module BABYLON {
  55432. /**
  55433. * Class containing static functions to help procedurally build meshes
  55434. */
  55435. export class PolygonBuilder {
  55436. /**
  55437. * Creates a polygon mesh
  55438. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55439. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  55440. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55443. * * Remember you can only change the shape positions, not their number when updating a polygon
  55444. * @param name defines the name of the mesh
  55445. * @param options defines the options used to create the mesh
  55446. * @param scene defines the hosting scene
  55447. * @param earcutInjection can be used to inject your own earcut reference
  55448. * @returns the polygon mesh
  55449. */
  55450. static CreatePolygon(name: string, options: {
  55451. shape: Vector3[];
  55452. holes?: Vector3[][];
  55453. depth?: number;
  55454. faceUV?: Vector4[];
  55455. faceColors?: Color4[];
  55456. updatable?: boolean;
  55457. sideOrientation?: number;
  55458. frontUVs?: Vector4;
  55459. backUVs?: Vector4;
  55460. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55461. /**
  55462. * Creates an extruded polygon mesh, with depth in the Y direction.
  55463. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  55464. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55465. * @param name defines the name of the mesh
  55466. * @param options defines the options used to create the mesh
  55467. * @param scene defines the hosting scene
  55468. * @param earcutInjection can be used to inject your own earcut reference
  55469. * @returns the polygon mesh
  55470. */
  55471. static ExtrudePolygon(name: string, options: {
  55472. shape: Vector3[];
  55473. holes?: Vector3[][];
  55474. depth?: number;
  55475. faceUV?: Vector4[];
  55476. faceColors?: Color4[];
  55477. updatable?: boolean;
  55478. sideOrientation?: number;
  55479. frontUVs?: Vector4;
  55480. backUVs?: Vector4;
  55481. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55482. }
  55483. }
  55484. declare module BABYLON {
  55485. /**
  55486. * Class containing static functions to help procedurally build meshes
  55487. */
  55488. export class LatheBuilder {
  55489. /**
  55490. * Creates lathe mesh.
  55491. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55492. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  55493. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55494. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55495. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55496. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  55497. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55498. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55503. * @param name defines the name of the mesh
  55504. * @param options defines the options used to create the mesh
  55505. * @param scene defines the hosting scene
  55506. * @returns the lathe mesh
  55507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55508. */
  55509. static CreateLathe(name: string, options: {
  55510. shape: Vector3[];
  55511. radius?: number;
  55512. tessellation?: number;
  55513. clip?: number;
  55514. arc?: number;
  55515. closed?: boolean;
  55516. updatable?: boolean;
  55517. sideOrientation?: number;
  55518. frontUVs?: Vector4;
  55519. backUVs?: Vector4;
  55520. cap?: number;
  55521. invertUV?: boolean;
  55522. }, scene?: Nullable<Scene>): Mesh;
  55523. }
  55524. }
  55525. declare module BABYLON {
  55526. /**
  55527. * Class containing static functions to help procedurally build meshes
  55528. */
  55529. export class TiledPlaneBuilder {
  55530. /**
  55531. * Creates a tiled plane mesh
  55532. * * The parameter `pattern` will, depending on value, do nothing or
  55533. * * * flip (reflect about central vertical) alternate tiles across and up
  55534. * * * flip every tile on alternate rows
  55535. * * * rotate (180 degs) alternate tiles across and up
  55536. * * * rotate every tile on alternate rows
  55537. * * * flip and rotate alternate tiles across and up
  55538. * * * flip and rotate every tile on alternate rows
  55539. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55540. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55543. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  55544. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  55545. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55546. * @param name defines the name of the mesh
  55547. * @param options defines the options used to create the mesh
  55548. * @param scene defines the hosting scene
  55549. * @returns the box mesh
  55550. */
  55551. static CreateTiledPlane(name: string, options: {
  55552. pattern?: number;
  55553. tileSize?: number;
  55554. tileWidth?: number;
  55555. tileHeight?: number;
  55556. size?: number;
  55557. width?: number;
  55558. height?: number;
  55559. alignHorizontal?: number;
  55560. alignVertical?: number;
  55561. sideOrientation?: number;
  55562. frontUVs?: Vector4;
  55563. backUVs?: Vector4;
  55564. updatable?: boolean;
  55565. }, scene?: Nullable<Scene>): Mesh;
  55566. }
  55567. }
  55568. declare module BABYLON {
  55569. /**
  55570. * Class containing static functions to help procedurally build meshes
  55571. */
  55572. export class TubeBuilder {
  55573. /**
  55574. * Creates a tube mesh.
  55575. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55576. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55577. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55578. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55579. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55580. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  55581. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55582. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55583. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  55584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55588. * @param name defines the name of the mesh
  55589. * @param options defines the options used to create the mesh
  55590. * @param scene defines the hosting scene
  55591. * @returns the tube mesh
  55592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55593. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55594. */
  55595. static CreateTube(name: string, options: {
  55596. path: Vector3[];
  55597. radius?: number;
  55598. tessellation?: number;
  55599. radiusFunction?: {
  55600. (i: number, distance: number): number;
  55601. };
  55602. cap?: number;
  55603. arc?: number;
  55604. updatable?: boolean;
  55605. sideOrientation?: number;
  55606. frontUVs?: Vector4;
  55607. backUVs?: Vector4;
  55608. instance?: Mesh;
  55609. invertUV?: boolean;
  55610. }, scene?: Nullable<Scene>): Mesh;
  55611. }
  55612. }
  55613. declare module BABYLON {
  55614. /**
  55615. * Class containing static functions to help procedurally build meshes
  55616. */
  55617. export class IcoSphereBuilder {
  55618. /**
  55619. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55620. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55621. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  55622. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55623. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  55624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55627. * @param name defines the name of the mesh
  55628. * @param options defines the options used to create the mesh
  55629. * @param scene defines the hosting scene
  55630. * @returns the icosahedron mesh
  55631. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55632. */
  55633. static CreateIcoSphere(name: string, options: {
  55634. radius?: number;
  55635. radiusX?: number;
  55636. radiusY?: number;
  55637. radiusZ?: number;
  55638. flat?: boolean;
  55639. subdivisions?: number;
  55640. sideOrientation?: number;
  55641. frontUVs?: Vector4;
  55642. backUVs?: Vector4;
  55643. updatable?: boolean;
  55644. }, scene?: Nullable<Scene>): Mesh;
  55645. }
  55646. }
  55647. declare module BABYLON {
  55648. /**
  55649. * Class containing static functions to help procedurally build meshes
  55650. */
  55651. export class DecalBuilder {
  55652. /**
  55653. * Creates a decal mesh.
  55654. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  55655. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55656. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55657. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55658. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55659. * @param name defines the name of the mesh
  55660. * @param sourceMesh defines the mesh where the decal must be applied
  55661. * @param options defines the options used to create the mesh
  55662. * @param scene defines the hosting scene
  55663. * @returns the decal mesh
  55664. * @see https://doc.babylonjs.com/how_to/decals
  55665. */
  55666. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55667. position?: Vector3;
  55668. normal?: Vector3;
  55669. size?: Vector3;
  55670. angle?: number;
  55671. }): Mesh;
  55672. }
  55673. }
  55674. declare module BABYLON {
  55675. /**
  55676. * Class containing static functions to help procedurally build meshes
  55677. */
  55678. export class MeshBuilder {
  55679. /**
  55680. * Creates a box mesh
  55681. * * The parameter `size` sets the size (float) of each box side (default 1)
  55682. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55683. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  55684. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55688. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55689. * @param name defines the name of the mesh
  55690. * @param options defines the options used to create the mesh
  55691. * @param scene defines the hosting scene
  55692. * @returns the box mesh
  55693. */
  55694. static CreateBox(name: string, options: {
  55695. size?: number;
  55696. width?: number;
  55697. height?: number;
  55698. depth?: number;
  55699. faceUV?: Vector4[];
  55700. faceColors?: Color4[];
  55701. sideOrientation?: number;
  55702. frontUVs?: Vector4;
  55703. backUVs?: Vector4;
  55704. updatable?: boolean;
  55705. }, scene?: Nullable<Scene>): Mesh;
  55706. /**
  55707. * Creates a tiled box mesh
  55708. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55710. * @param name defines the name of the mesh
  55711. * @param options defines the options used to create the mesh
  55712. * @param scene defines the hosting scene
  55713. * @returns the tiled box mesh
  55714. */
  55715. static CreateTiledBox(name: string, options: {
  55716. pattern?: number;
  55717. size?: number;
  55718. width?: number;
  55719. height?: number;
  55720. depth: number;
  55721. tileSize?: number;
  55722. tileWidth?: number;
  55723. tileHeight?: number;
  55724. faceUV?: Vector4[];
  55725. faceColors?: Color4[];
  55726. alignHorizontal?: number;
  55727. alignVertical?: number;
  55728. sideOrientation?: number;
  55729. updatable?: boolean;
  55730. }, scene?: Nullable<Scene>): Mesh;
  55731. /**
  55732. * Creates a sphere mesh
  55733. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55734. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  55735. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55736. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  55737. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  55738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55741. * @param name defines the name of the mesh
  55742. * @param options defines the options used to create the mesh
  55743. * @param scene defines the hosting scene
  55744. * @returns the sphere mesh
  55745. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55746. */
  55747. static CreateSphere(name: string, options: {
  55748. segments?: number;
  55749. diameter?: number;
  55750. diameterX?: number;
  55751. diameterY?: number;
  55752. diameterZ?: number;
  55753. arc?: number;
  55754. slice?: number;
  55755. sideOrientation?: number;
  55756. frontUVs?: Vector4;
  55757. backUVs?: Vector4;
  55758. updatable?: boolean;
  55759. }, scene?: Nullable<Scene>): Mesh;
  55760. /**
  55761. * Creates a plane polygonal mesh. By default, this is a disc
  55762. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55763. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  55764. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  55765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55768. * @param name defines the name of the mesh
  55769. * @param options defines the options used to create the mesh
  55770. * @param scene defines the hosting scene
  55771. * @returns the plane polygonal mesh
  55772. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55773. */
  55774. static CreateDisc(name: string, options: {
  55775. radius?: number;
  55776. tessellation?: number;
  55777. arc?: number;
  55778. updatable?: boolean;
  55779. sideOrientation?: number;
  55780. frontUVs?: Vector4;
  55781. backUVs?: Vector4;
  55782. }, scene?: Nullable<Scene>): Mesh;
  55783. /**
  55784. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55785. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55786. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  55787. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55788. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  55789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55792. * @param name defines the name of the mesh
  55793. * @param options defines the options used to create the mesh
  55794. * @param scene defines the hosting scene
  55795. * @returns the icosahedron mesh
  55796. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55797. */
  55798. static CreateIcoSphere(name: string, options: {
  55799. radius?: number;
  55800. radiusX?: number;
  55801. radiusY?: number;
  55802. radiusZ?: number;
  55803. flat?: boolean;
  55804. subdivisions?: number;
  55805. sideOrientation?: number;
  55806. frontUVs?: Vector4;
  55807. backUVs?: Vector4;
  55808. updatable?: boolean;
  55809. }, scene?: Nullable<Scene>): Mesh;
  55810. /**
  55811. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55812. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55813. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55814. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55815. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  55816. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  55817. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  55818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55821. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  55822. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55823. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  55824. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55826. * @param name defines the name of the mesh
  55827. * @param options defines the options used to create the mesh
  55828. * @param scene defines the hosting scene
  55829. * @returns the ribbon mesh
  55830. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55832. */
  55833. static CreateRibbon(name: string, options: {
  55834. pathArray: Vector3[][];
  55835. closeArray?: boolean;
  55836. closePath?: boolean;
  55837. offset?: number;
  55838. updatable?: boolean;
  55839. sideOrientation?: number;
  55840. frontUVs?: Vector4;
  55841. backUVs?: Vector4;
  55842. instance?: Mesh;
  55843. invertUV?: boolean;
  55844. uvs?: Vector2[];
  55845. colors?: Color4[];
  55846. }, scene?: Nullable<Scene>): Mesh;
  55847. /**
  55848. * Creates a cylinder or a cone mesh
  55849. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55850. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55851. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  55852. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55853. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55854. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55855. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55856. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55857. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55858. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  55859. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  55860. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55861. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  55862. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  55863. * * If `enclose` is false, a ring surface is one element.
  55864. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55865. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  55866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55869. * @param name defines the name of the mesh
  55870. * @param options defines the options used to create the mesh
  55871. * @param scene defines the hosting scene
  55872. * @returns the cylinder mesh
  55873. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55874. */
  55875. static CreateCylinder(name: string, options: {
  55876. height?: number;
  55877. diameterTop?: number;
  55878. diameterBottom?: number;
  55879. diameter?: number;
  55880. tessellation?: number;
  55881. subdivisions?: number;
  55882. arc?: number;
  55883. faceColors?: Color4[];
  55884. faceUV?: Vector4[];
  55885. updatable?: boolean;
  55886. hasRings?: boolean;
  55887. enclose?: boolean;
  55888. cap?: number;
  55889. sideOrientation?: number;
  55890. frontUVs?: Vector4;
  55891. backUVs?: Vector4;
  55892. }, scene?: Nullable<Scene>): Mesh;
  55893. /**
  55894. * Creates a torus mesh
  55895. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55896. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55897. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55901. * @param name defines the name of the mesh
  55902. * @param options defines the options used to create the mesh
  55903. * @param scene defines the hosting scene
  55904. * @returns the torus mesh
  55905. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55906. */
  55907. static CreateTorus(name: string, options: {
  55908. diameter?: number;
  55909. thickness?: number;
  55910. tessellation?: number;
  55911. updatable?: boolean;
  55912. sideOrientation?: number;
  55913. frontUVs?: Vector4;
  55914. backUVs?: Vector4;
  55915. }, scene?: Nullable<Scene>): Mesh;
  55916. /**
  55917. * Creates a torus knot mesh
  55918. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55919. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55920. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55921. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55925. * @param name defines the name of the mesh
  55926. * @param options defines the options used to create the mesh
  55927. * @param scene defines the hosting scene
  55928. * @returns the torus knot mesh
  55929. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55930. */
  55931. static CreateTorusKnot(name: string, options: {
  55932. radius?: number;
  55933. tube?: number;
  55934. radialSegments?: number;
  55935. tubularSegments?: number;
  55936. p?: number;
  55937. q?: number;
  55938. updatable?: boolean;
  55939. sideOrientation?: number;
  55940. frontUVs?: Vector4;
  55941. backUVs?: Vector4;
  55942. }, scene?: Nullable<Scene>): Mesh;
  55943. /**
  55944. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55945. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  55946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55947. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55948. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55949. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55950. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55951. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  55952. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55955. * @param name defines the name of the new line system
  55956. * @param options defines the options used to create the line system
  55957. * @param scene defines the hosting scene
  55958. * @returns a new line system mesh
  55959. */
  55960. static CreateLineSystem(name: string, options: {
  55961. lines: Vector3[][];
  55962. updatable?: boolean;
  55963. instance?: Nullable<LinesMesh>;
  55964. colors?: Nullable<Color4[][]>;
  55965. useVertexAlpha?: boolean;
  55966. }, scene: Nullable<Scene>): LinesMesh;
  55967. /**
  55968. * Creates a line mesh
  55969. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  55970. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55971. * * The parameter `points` is an array successive Vector3
  55972. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  55973. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55974. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55975. * * When updating an instance, remember that only point positions can change, not the number of points
  55976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55978. * @param name defines the name of the new line system
  55979. * @param options defines the options used to create the line system
  55980. * @param scene defines the hosting scene
  55981. * @returns a new line mesh
  55982. */
  55983. static CreateLines(name: string, options: {
  55984. points: Vector3[];
  55985. updatable?: boolean;
  55986. instance?: Nullable<LinesMesh>;
  55987. colors?: Color4[];
  55988. useVertexAlpha?: boolean;
  55989. }, scene?: Nullable<Scene>): LinesMesh;
  55990. /**
  55991. * Creates a dashed line mesh
  55992. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  55993. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55994. * * The parameter `points` is an array successive Vector3
  55995. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55996. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55997. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55998. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  55999. * * When updating an instance, remember that only point positions can change, not the number of points
  56000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56001. * @param name defines the name of the mesh
  56002. * @param options defines the options used to create the mesh
  56003. * @param scene defines the hosting scene
  56004. * @returns the dashed line mesh
  56005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56006. */
  56007. static CreateDashedLines(name: string, options: {
  56008. points: Vector3[];
  56009. dashSize?: number;
  56010. gapSize?: number;
  56011. dashNb?: number;
  56012. updatable?: boolean;
  56013. instance?: LinesMesh;
  56014. }, scene?: Nullable<Scene>): LinesMesh;
  56015. /**
  56016. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56017. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  56018. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56019. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  56020. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56021. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  56022. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  56023. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56024. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56025. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56026. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56028. * @param name defines the name of the mesh
  56029. * @param options defines the options used to create the mesh
  56030. * @param scene defines the hosting scene
  56031. * @returns the extruded shape mesh
  56032. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56034. */
  56035. static ExtrudeShape(name: string, options: {
  56036. shape: Vector3[];
  56037. path: Vector3[];
  56038. scale?: number;
  56039. rotation?: number;
  56040. cap?: number;
  56041. updatable?: boolean;
  56042. sideOrientation?: number;
  56043. frontUVs?: Vector4;
  56044. backUVs?: Vector4;
  56045. instance?: Mesh;
  56046. invertUV?: boolean;
  56047. }, scene?: Nullable<Scene>): Mesh;
  56048. /**
  56049. * Creates an custom extruded shape mesh.
  56050. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56051. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  56052. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56053. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  56054. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56055. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  56056. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56057. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56058. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56059. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  56060. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  56061. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56062. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56064. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56066. * @param name defines the name of the mesh
  56067. * @param options defines the options used to create the mesh
  56068. * @param scene defines the hosting scene
  56069. * @returns the custom extruded shape mesh
  56070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56071. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56073. */
  56074. static ExtrudeShapeCustom(name: string, options: {
  56075. shape: Vector3[];
  56076. path: Vector3[];
  56077. scaleFunction?: any;
  56078. rotationFunction?: any;
  56079. ribbonCloseArray?: boolean;
  56080. ribbonClosePath?: boolean;
  56081. cap?: number;
  56082. updatable?: boolean;
  56083. sideOrientation?: number;
  56084. frontUVs?: Vector4;
  56085. backUVs?: Vector4;
  56086. instance?: Mesh;
  56087. invertUV?: boolean;
  56088. }, scene?: Nullable<Scene>): Mesh;
  56089. /**
  56090. * Creates lathe mesh.
  56091. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56092. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  56093. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56094. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56095. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56096. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  56097. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56098. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  56099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56103. * @param name defines the name of the mesh
  56104. * @param options defines the options used to create the mesh
  56105. * @param scene defines the hosting scene
  56106. * @returns the lathe mesh
  56107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56108. */
  56109. static CreateLathe(name: string, options: {
  56110. shape: Vector3[];
  56111. radius?: number;
  56112. tessellation?: number;
  56113. clip?: number;
  56114. arc?: number;
  56115. closed?: boolean;
  56116. updatable?: boolean;
  56117. sideOrientation?: number;
  56118. frontUVs?: Vector4;
  56119. backUVs?: Vector4;
  56120. cap?: number;
  56121. invertUV?: boolean;
  56122. }, scene?: Nullable<Scene>): Mesh;
  56123. /**
  56124. * Creates a tiled plane mesh
  56125. * * You can set a limited pattern arrangement with the tiles
  56126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56129. * @param name defines the name of the mesh
  56130. * @param options defines the options used to create the mesh
  56131. * @param scene defines the hosting scene
  56132. * @returns the plane mesh
  56133. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56134. */
  56135. static CreateTiledPlane(name: string, options: {
  56136. pattern?: number;
  56137. tileSize?: number;
  56138. tileWidth?: number;
  56139. tileHeight?: number;
  56140. size?: number;
  56141. width?: number;
  56142. height?: number;
  56143. alignHorizontal?: number;
  56144. alignVertical?: number;
  56145. sideOrientation?: number;
  56146. frontUVs?: Vector4;
  56147. backUVs?: Vector4;
  56148. updatable?: boolean;
  56149. }, scene?: Nullable<Scene>): Mesh;
  56150. /**
  56151. * Creates a plane mesh
  56152. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56153. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56154. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56158. * @param name defines the name of the mesh
  56159. * @param options defines the options used to create the mesh
  56160. * @param scene defines the hosting scene
  56161. * @returns the plane mesh
  56162. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56163. */
  56164. static CreatePlane(name: string, options: {
  56165. size?: number;
  56166. width?: number;
  56167. height?: number;
  56168. sideOrientation?: number;
  56169. frontUVs?: Vector4;
  56170. backUVs?: Vector4;
  56171. updatable?: boolean;
  56172. sourcePlane?: Plane;
  56173. }, scene?: Nullable<Scene>): Mesh;
  56174. /**
  56175. * Creates a ground mesh
  56176. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56177. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56179. * @param name defines the name of the mesh
  56180. * @param options defines the options used to create the mesh
  56181. * @param scene defines the hosting scene
  56182. * @returns the ground mesh
  56183. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56184. */
  56185. static CreateGround(name: string, options: {
  56186. width?: number;
  56187. height?: number;
  56188. subdivisions?: number;
  56189. subdivisionsX?: number;
  56190. subdivisionsY?: number;
  56191. updatable?: boolean;
  56192. }, scene?: Nullable<Scene>): Mesh;
  56193. /**
  56194. * Creates a tiled ground mesh
  56195. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56196. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56197. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  56198. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  56199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56200. * @param name defines the name of the mesh
  56201. * @param options defines the options used to create the mesh
  56202. * @param scene defines the hosting scene
  56203. * @returns the tiled ground mesh
  56204. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56205. */
  56206. static CreateTiledGround(name: string, options: {
  56207. xmin: number;
  56208. zmin: number;
  56209. xmax: number;
  56210. zmax: number;
  56211. subdivisions?: {
  56212. w: number;
  56213. h: number;
  56214. };
  56215. precision?: {
  56216. w: number;
  56217. h: number;
  56218. };
  56219. updatable?: boolean;
  56220. }, scene?: Nullable<Scene>): Mesh;
  56221. /**
  56222. * Creates a ground mesh from a height map
  56223. * * The parameter `url` sets the URL of the height map image resource.
  56224. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56225. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56226. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56227. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56228. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  56229. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  56230. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56232. * @param name defines the name of the mesh
  56233. * @param url defines the url to the height map
  56234. * @param options defines the options used to create the mesh
  56235. * @param scene defines the hosting scene
  56236. * @returns the ground mesh
  56237. * @see https://doc.babylonjs.com/babylon101/height_map
  56238. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56239. */
  56240. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56241. width?: number;
  56242. height?: number;
  56243. subdivisions?: number;
  56244. minHeight?: number;
  56245. maxHeight?: number;
  56246. colorFilter?: Color3;
  56247. alphaFilter?: number;
  56248. updatable?: boolean;
  56249. onReady?: (mesh: GroundMesh) => void;
  56250. }, scene?: Nullable<Scene>): GroundMesh;
  56251. /**
  56252. * Creates a polygon mesh
  56253. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56254. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  56255. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56258. * * Remember you can only change the shape positions, not their number when updating a polygon
  56259. * @param name defines the name of the mesh
  56260. * @param options defines the options used to create the mesh
  56261. * @param scene defines the hosting scene
  56262. * @param earcutInjection can be used to inject your own earcut reference
  56263. * @returns the polygon mesh
  56264. */
  56265. static CreatePolygon(name: string, options: {
  56266. shape: Vector3[];
  56267. holes?: Vector3[][];
  56268. depth?: number;
  56269. faceUV?: Vector4[];
  56270. faceColors?: Color4[];
  56271. updatable?: boolean;
  56272. sideOrientation?: number;
  56273. frontUVs?: Vector4;
  56274. backUVs?: Vector4;
  56275. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56276. /**
  56277. * Creates an extruded polygon mesh, with depth in the Y direction.
  56278. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  56279. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56280. * @param name defines the name of the mesh
  56281. * @param options defines the options used to create the mesh
  56282. * @param scene defines the hosting scene
  56283. * @param earcutInjection can be used to inject your own earcut reference
  56284. * @returns the polygon mesh
  56285. */
  56286. static ExtrudePolygon(name: string, options: {
  56287. shape: Vector3[];
  56288. holes?: Vector3[][];
  56289. depth?: number;
  56290. faceUV?: Vector4[];
  56291. faceColors?: Color4[];
  56292. updatable?: boolean;
  56293. sideOrientation?: number;
  56294. frontUVs?: Vector4;
  56295. backUVs?: Vector4;
  56296. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56297. /**
  56298. * Creates a tube mesh.
  56299. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56300. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56301. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56302. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56303. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56304. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  56305. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56306. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  56307. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  56308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56309. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56310. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56312. * @param name defines the name of the mesh
  56313. * @param options defines the options used to create the mesh
  56314. * @param scene defines the hosting scene
  56315. * @returns the tube mesh
  56316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56317. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56318. */
  56319. static CreateTube(name: string, options: {
  56320. path: Vector3[];
  56321. radius?: number;
  56322. tessellation?: number;
  56323. radiusFunction?: {
  56324. (i: number, distance: number): number;
  56325. };
  56326. cap?: number;
  56327. arc?: number;
  56328. updatable?: boolean;
  56329. sideOrientation?: number;
  56330. frontUVs?: Vector4;
  56331. backUVs?: Vector4;
  56332. instance?: Mesh;
  56333. invertUV?: boolean;
  56334. }, scene?: Nullable<Scene>): Mesh;
  56335. /**
  56336. * Creates a polyhedron mesh
  56337. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  56338. * * The parameter `size` (positive float, default 1) sets the polygon size
  56339. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56340. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  56341. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  56342. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  56343. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56344. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  56345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56348. * @param name defines the name of the mesh
  56349. * @param options defines the options used to create the mesh
  56350. * @param scene defines the hosting scene
  56351. * @returns the polyhedron mesh
  56352. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56353. */
  56354. static CreatePolyhedron(name: string, options: {
  56355. type?: number;
  56356. size?: number;
  56357. sizeX?: number;
  56358. sizeY?: number;
  56359. sizeZ?: number;
  56360. custom?: any;
  56361. faceUV?: Vector4[];
  56362. faceColors?: Color4[];
  56363. flat?: boolean;
  56364. updatable?: boolean;
  56365. sideOrientation?: number;
  56366. frontUVs?: Vector4;
  56367. backUVs?: Vector4;
  56368. }, scene?: Nullable<Scene>): Mesh;
  56369. /**
  56370. * Creates a decal mesh.
  56371. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  56372. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56373. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56374. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56375. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56376. * @param name defines the name of the mesh
  56377. * @param sourceMesh defines the mesh where the decal must be applied
  56378. * @param options defines the options used to create the mesh
  56379. * @param scene defines the hosting scene
  56380. * @returns the decal mesh
  56381. * @see https://doc.babylonjs.com/how_to/decals
  56382. */
  56383. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56384. position?: Vector3;
  56385. normal?: Vector3;
  56386. size?: Vector3;
  56387. angle?: number;
  56388. }): Mesh;
  56389. }
  56390. }
  56391. declare module BABYLON {
  56392. /**
  56393. * A simplifier interface for future simplification implementations
  56394. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56395. */
  56396. export interface ISimplifier {
  56397. /**
  56398. * Simplification of a given mesh according to the given settings.
  56399. * Since this requires computation, it is assumed that the function runs async.
  56400. * @param settings The settings of the simplification, including quality and distance
  56401. * @param successCallback A callback that will be called after the mesh was simplified.
  56402. * @param errorCallback in case of an error, this callback will be called. optional.
  56403. */
  56404. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56405. }
  56406. /**
  56407. * Expected simplification settings.
  56408. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56409. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56410. */
  56411. export interface ISimplificationSettings {
  56412. /**
  56413. * Gets or sets the expected quality
  56414. */
  56415. quality: number;
  56416. /**
  56417. * Gets or sets the distance when this optimized version should be used
  56418. */
  56419. distance: number;
  56420. /**
  56421. * Gets an already optimized mesh
  56422. */
  56423. optimizeMesh?: boolean;
  56424. }
  56425. /**
  56426. * Class used to specify simplification options
  56427. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56428. */
  56429. export class SimplificationSettings implements ISimplificationSettings {
  56430. /** expected quality */
  56431. quality: number;
  56432. /** distance when this optimized version should be used */
  56433. distance: number;
  56434. /** already optimized mesh */
  56435. optimizeMesh?: boolean | undefined;
  56436. /**
  56437. * Creates a SimplificationSettings
  56438. * @param quality expected quality
  56439. * @param distance distance when this optimized version should be used
  56440. * @param optimizeMesh already optimized mesh
  56441. */
  56442. constructor(
  56443. /** expected quality */
  56444. quality: number,
  56445. /** distance when this optimized version should be used */
  56446. distance: number,
  56447. /** already optimized mesh */
  56448. optimizeMesh?: boolean | undefined);
  56449. }
  56450. /**
  56451. * Interface used to define a simplification task
  56452. */
  56453. export interface ISimplificationTask {
  56454. /**
  56455. * Array of settings
  56456. */
  56457. settings: Array<ISimplificationSettings>;
  56458. /**
  56459. * Simplification type
  56460. */
  56461. simplificationType: SimplificationType;
  56462. /**
  56463. * Mesh to simplify
  56464. */
  56465. mesh: Mesh;
  56466. /**
  56467. * Callback called on success
  56468. */
  56469. successCallback?: () => void;
  56470. /**
  56471. * Defines if parallel processing can be used
  56472. */
  56473. parallelProcessing: boolean;
  56474. }
  56475. /**
  56476. * Queue used to order the simplification tasks
  56477. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56478. */
  56479. export class SimplificationQueue {
  56480. private _simplificationArray;
  56481. /**
  56482. * Gets a boolean indicating that the process is still running
  56483. */
  56484. running: boolean;
  56485. /**
  56486. * Creates a new queue
  56487. */
  56488. constructor();
  56489. /**
  56490. * Adds a new simplification task
  56491. * @param task defines a task to add
  56492. */
  56493. addTask(task: ISimplificationTask): void;
  56494. /**
  56495. * Execute next task
  56496. */
  56497. executeNext(): void;
  56498. /**
  56499. * Execute a simplification task
  56500. * @param task defines the task to run
  56501. */
  56502. runSimplification(task: ISimplificationTask): void;
  56503. private getSimplifier;
  56504. }
  56505. /**
  56506. * The implemented types of simplification
  56507. * At the moment only Quadratic Error Decimation is implemented
  56508. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56509. */
  56510. export enum SimplificationType {
  56511. /** Quadratic error decimation */
  56512. QUADRATIC = 0
  56513. }
  56514. }
  56515. declare module BABYLON {
  56516. interface Scene {
  56517. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  56518. /**
  56519. * Gets or sets the simplification queue attached to the scene
  56520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56521. */
  56522. simplificationQueue: SimplificationQueue;
  56523. }
  56524. interface Mesh {
  56525. /**
  56526. * Simplify the mesh according to the given array of settings.
  56527. * Function will return immediately and will simplify async
  56528. * @param settings a collection of simplification settings
  56529. * @param parallelProcessing should all levels calculate parallel or one after the other
  56530. * @param simplificationType the type of simplification to run
  56531. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56532. * @returns the current mesh
  56533. */
  56534. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56535. }
  56536. /**
  56537. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56538. * created in a scene
  56539. */
  56540. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56541. /**
  56542. * The component name helpfull to identify the component in the list of scene components.
  56543. */
  56544. readonly name: string;
  56545. /**
  56546. * The scene the component belongs to.
  56547. */
  56548. scene: Scene;
  56549. /**
  56550. * Creates a new instance of the component for the given scene
  56551. * @param scene Defines the scene to register the component in
  56552. */
  56553. constructor(scene: Scene);
  56554. /**
  56555. * Registers the component in a given scene
  56556. */
  56557. register(): void;
  56558. /**
  56559. * Rebuilds the elements related to this component in case of
  56560. * context lost for instance.
  56561. */
  56562. rebuild(): void;
  56563. /**
  56564. * Disposes the component and the associated ressources
  56565. */
  56566. dispose(): void;
  56567. private _beforeCameraUpdate;
  56568. }
  56569. }
  56570. declare module BABYLON {
  56571. /**
  56572. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56573. */
  56574. export interface INavigationEnginePlugin {
  56575. /**
  56576. * plugin name
  56577. */
  56578. name: string;
  56579. /**
  56580. * Creates a navigation mesh
  56581. * @param meshes array of all the geometry used to compute the navigatio mesh
  56582. * @param parameters bunch of parameters used to filter geometry
  56583. */
  56584. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56585. /**
  56586. * Create a navigation mesh debug mesh
  56587. * @param scene is where the mesh will be added
  56588. * @returns debug display mesh
  56589. */
  56590. createDebugNavMesh(scene: Scene): Mesh;
  56591. /**
  56592. * Get a navigation mesh constrained position, closest to the parameter position
  56593. * @param position world position
  56594. * @returns the closest point to position constrained by the navigation mesh
  56595. */
  56596. getClosestPoint(position: Vector3): Vector3;
  56597. /**
  56598. * Get a navigation mesh constrained position, within a particular radius
  56599. * @param position world position
  56600. * @param maxRadius the maximum distance to the constrained world position
  56601. * @returns the closest point to position constrained by the navigation mesh
  56602. */
  56603. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56604. /**
  56605. * Compute the final position from a segment made of destination-position
  56606. * @param position world position
  56607. * @param destination world position
  56608. * @returns the resulting point along the navmesh
  56609. */
  56610. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56611. /**
  56612. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56613. * @param start world position
  56614. * @param end world position
  56615. * @returns array containing world position composing the path
  56616. */
  56617. computePath(start: Vector3, end: Vector3): Vector3[];
  56618. /**
  56619. * If this plugin is supported
  56620. * @returns true if plugin is supported
  56621. */
  56622. isSupported(): boolean;
  56623. /**
  56624. * Create a new Crowd so you can add agents
  56625. * @param maxAgents the maximum agent count in the crowd
  56626. * @param maxAgentRadius the maximum radius an agent can have
  56627. * @param scene to attach the crowd to
  56628. * @returns the crowd you can add agents to
  56629. */
  56630. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56631. /**
  56632. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56633. * The queries will try to find a solution within those bounds
  56634. * default is (1,1,1)
  56635. * @param extent x,y,z value that define the extent around the queries point of reference
  56636. */
  56637. setDefaultQueryExtent(extent: Vector3): void;
  56638. /**
  56639. * Get the Bounding box extent specified by setDefaultQueryExtent
  56640. * @returns the box extent values
  56641. */
  56642. getDefaultQueryExtent(): Vector3;
  56643. /**
  56644. * Release all resources
  56645. */
  56646. dispose(): void;
  56647. }
  56648. /**
  56649. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56650. */
  56651. export interface ICrowd {
  56652. /**
  56653. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56654. * You can attach anything to that node. The node position is updated in the scene update tick.
  56655. * @param pos world position that will be constrained by the navigation mesh
  56656. * @param parameters agent parameters
  56657. * @param transform hooked to the agent that will be update by the scene
  56658. * @returns agent index
  56659. */
  56660. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56661. /**
  56662. * Returns the agent position in world space
  56663. * @param index agent index returned by addAgent
  56664. * @returns world space position
  56665. */
  56666. getAgentPosition(index: number): Vector3;
  56667. /**
  56668. * Gets the agent velocity in world space
  56669. * @param index agent index returned by addAgent
  56670. * @returns world space velocity
  56671. */
  56672. getAgentVelocity(index: number): Vector3;
  56673. /**
  56674. * remove a particular agent previously created
  56675. * @param index agent index returned by addAgent
  56676. */
  56677. removeAgent(index: number): void;
  56678. /**
  56679. * get the list of all agents attached to this crowd
  56680. * @returns list of agent indices
  56681. */
  56682. getAgents(): number[];
  56683. /**
  56684. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56685. * @param deltaTime in seconds
  56686. */
  56687. update(deltaTime: number): void;
  56688. /**
  56689. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56690. * @param index agent index returned by addAgent
  56691. * @param destination targeted world position
  56692. */
  56693. agentGoto(index: number, destination: Vector3): void;
  56694. /**
  56695. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56696. * The queries will try to find a solution within those bounds
  56697. * default is (1,1,1)
  56698. * @param extent x,y,z value that define the extent around the queries point of reference
  56699. */
  56700. setDefaultQueryExtent(extent: Vector3): void;
  56701. /**
  56702. * Get the Bounding box extent specified by setDefaultQueryExtent
  56703. * @returns the box extent values
  56704. */
  56705. getDefaultQueryExtent(): Vector3;
  56706. /**
  56707. * Release all resources
  56708. */
  56709. dispose(): void;
  56710. }
  56711. /**
  56712. * Configures an agent
  56713. */
  56714. export interface IAgentParameters {
  56715. /**
  56716. * Agent radius. [Limit: >= 0]
  56717. */
  56718. radius: number;
  56719. /**
  56720. * Agent height. [Limit: > 0]
  56721. */
  56722. height: number;
  56723. /**
  56724. * Maximum allowed acceleration. [Limit: >= 0]
  56725. */
  56726. maxAcceleration: number;
  56727. /**
  56728. * Maximum allowed speed. [Limit: >= 0]
  56729. */
  56730. maxSpeed: number;
  56731. /**
  56732. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56733. */
  56734. collisionQueryRange: number;
  56735. /**
  56736. * The path visibility optimization range. [Limit: > 0]
  56737. */
  56738. pathOptimizationRange: number;
  56739. /**
  56740. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56741. */
  56742. separationWeight: number;
  56743. }
  56744. /**
  56745. * Configures the navigation mesh creation
  56746. */
  56747. export interface INavMeshParameters {
  56748. /**
  56749. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56750. */
  56751. cs: number;
  56752. /**
  56753. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56754. */
  56755. ch: number;
  56756. /**
  56757. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56758. */
  56759. walkableSlopeAngle: number;
  56760. /**
  56761. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56762. * be considered walkable. [Limit: >= 3] [Units: vx]
  56763. */
  56764. walkableHeight: number;
  56765. /**
  56766. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56767. */
  56768. walkableClimb: number;
  56769. /**
  56770. * The distance to erode/shrink the walkable area of the heightfield away from
  56771. * obstructions. [Limit: >=0] [Units: vx]
  56772. */
  56773. walkableRadius: number;
  56774. /**
  56775. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56776. */
  56777. maxEdgeLen: number;
  56778. /**
  56779. * The maximum distance a simplfied contour's border edges should deviate
  56780. * the original raw contour. [Limit: >=0] [Units: vx]
  56781. */
  56782. maxSimplificationError: number;
  56783. /**
  56784. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56785. */
  56786. minRegionArea: number;
  56787. /**
  56788. * Any regions with a span count smaller than this value will, if possible,
  56789. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56790. */
  56791. mergeRegionArea: number;
  56792. /**
  56793. * The maximum number of vertices allowed for polygons generated during the
  56794. * contour to polygon conversion process. [Limit: >= 3]
  56795. */
  56796. maxVertsPerPoly: number;
  56797. /**
  56798. * Sets the sampling distance to use when generating the detail mesh.
  56799. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56800. */
  56801. detailSampleDist: number;
  56802. /**
  56803. * The maximum distance the detail mesh surface should deviate from heightfield
  56804. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56805. */
  56806. detailSampleMaxError: number;
  56807. }
  56808. }
  56809. declare module BABYLON {
  56810. /**
  56811. * RecastJS navigation plugin
  56812. */
  56813. export class RecastJSPlugin implements INavigationEnginePlugin {
  56814. /**
  56815. * Reference to the Recast library
  56816. */
  56817. bjsRECAST: any;
  56818. /**
  56819. * plugin name
  56820. */
  56821. name: string;
  56822. /**
  56823. * the first navmesh created. We might extend this to support multiple navmeshes
  56824. */
  56825. navMesh: any;
  56826. /**
  56827. * Initializes the recastJS plugin
  56828. * @param recastInjection can be used to inject your own recast reference
  56829. */
  56830. constructor(recastInjection?: any);
  56831. /**
  56832. * Creates a navigation mesh
  56833. * @param meshes array of all the geometry used to compute the navigatio mesh
  56834. * @param parameters bunch of parameters used to filter geometry
  56835. */
  56836. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56837. /**
  56838. * Create a navigation mesh debug mesh
  56839. * @param scene is where the mesh will be added
  56840. * @returns debug display mesh
  56841. */
  56842. createDebugNavMesh(scene: Scene): Mesh;
  56843. /**
  56844. * Get a navigation mesh constrained position, closest to the parameter position
  56845. * @param position world position
  56846. * @returns the closest point to position constrained by the navigation mesh
  56847. */
  56848. getClosestPoint(position: Vector3): Vector3;
  56849. /**
  56850. * Get a navigation mesh constrained position, within a particular radius
  56851. * @param position world position
  56852. * @param maxRadius the maximum distance to the constrained world position
  56853. * @returns the closest point to position constrained by the navigation mesh
  56854. */
  56855. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56856. /**
  56857. * Compute the final position from a segment made of destination-position
  56858. * @param position world position
  56859. * @param destination world position
  56860. * @returns the resulting point along the navmesh
  56861. */
  56862. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56863. /**
  56864. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56865. * @param start world position
  56866. * @param end world position
  56867. * @returns array containing world position composing the path
  56868. */
  56869. computePath(start: Vector3, end: Vector3): Vector3[];
  56870. /**
  56871. * Create a new Crowd so you can add agents
  56872. * @param maxAgents the maximum agent count in the crowd
  56873. * @param maxAgentRadius the maximum radius an agent can have
  56874. * @param scene to attach the crowd to
  56875. * @returns the crowd you can add agents to
  56876. */
  56877. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56878. /**
  56879. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56880. * The queries will try to find a solution within those bounds
  56881. * default is (1,1,1)
  56882. * @param extent x,y,z value that define the extent around the queries point of reference
  56883. */
  56884. setDefaultQueryExtent(extent: Vector3): void;
  56885. /**
  56886. * Get the Bounding box extent specified by setDefaultQueryExtent
  56887. * @returns the box extent values
  56888. */
  56889. getDefaultQueryExtent(): Vector3;
  56890. /**
  56891. * Disposes
  56892. */
  56893. dispose(): void;
  56894. /**
  56895. * If this plugin is supported
  56896. * @returns true if plugin is supported
  56897. */
  56898. isSupported(): boolean;
  56899. }
  56900. /**
  56901. * Recast detour crowd implementation
  56902. */
  56903. export class RecastJSCrowd implements ICrowd {
  56904. /**
  56905. * Recast/detour plugin
  56906. */
  56907. bjsRECASTPlugin: RecastJSPlugin;
  56908. /**
  56909. * Link to the detour crowd
  56910. */
  56911. recastCrowd: any;
  56912. /**
  56913. * One transform per agent
  56914. */
  56915. transforms: TransformNode[];
  56916. /**
  56917. * All agents created
  56918. */
  56919. agents: number[];
  56920. /**
  56921. * Link to the scene is kept to unregister the crowd from the scene
  56922. */
  56923. private _scene;
  56924. /**
  56925. * Observer for crowd updates
  56926. */
  56927. private _onBeforeAnimationsObserver;
  56928. /**
  56929. * Constructor
  56930. * @param plugin recastJS plugin
  56931. * @param maxAgents the maximum agent count in the crowd
  56932. * @param maxAgentRadius the maximum radius an agent can have
  56933. * @param scene to attach the crowd to
  56934. * @returns the crowd you can add agents to
  56935. */
  56936. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56937. /**
  56938. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56939. * You can attach anything to that node. The node position is updated in the scene update tick.
  56940. * @param pos world position that will be constrained by the navigation mesh
  56941. * @param parameters agent parameters
  56942. * @param transform hooked to the agent that will be update by the scene
  56943. * @returns agent index
  56944. */
  56945. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56946. /**
  56947. * Returns the agent position in world space
  56948. * @param index agent index returned by addAgent
  56949. * @returns world space position
  56950. */
  56951. getAgentPosition(index: number): Vector3;
  56952. /**
  56953. * Returns the agent velocity in world space
  56954. * @param index agent index returned by addAgent
  56955. * @returns world space velocity
  56956. */
  56957. getAgentVelocity(index: number): Vector3;
  56958. /**
  56959. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56960. * @param index agent index returned by addAgent
  56961. * @param destination targeted world position
  56962. */
  56963. agentGoto(index: number, destination: Vector3): void;
  56964. /**
  56965. * remove a particular agent previously created
  56966. * @param index agent index returned by addAgent
  56967. */
  56968. removeAgent(index: number): void;
  56969. /**
  56970. * get the list of all agents attached to this crowd
  56971. * @returns list of agent indices
  56972. */
  56973. getAgents(): number[];
  56974. /**
  56975. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56976. * @param deltaTime in seconds
  56977. */
  56978. update(deltaTime: number): void;
  56979. /**
  56980. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56981. * The queries will try to find a solution within those bounds
  56982. * default is (1,1,1)
  56983. * @param extent x,y,z value that define the extent around the queries point of reference
  56984. */
  56985. setDefaultQueryExtent(extent: Vector3): void;
  56986. /**
  56987. * Get the Bounding box extent specified by setDefaultQueryExtent
  56988. * @returns the box extent values
  56989. */
  56990. getDefaultQueryExtent(): Vector3;
  56991. /**
  56992. * Release all resources
  56993. */
  56994. dispose(): void;
  56995. }
  56996. }
  56997. declare module BABYLON {
  56998. /**
  56999. * Class used to enable access to IndexedDB
  57000. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57001. */
  57002. export class Database implements IOfflineProvider {
  57003. private _callbackManifestChecked;
  57004. private _currentSceneUrl;
  57005. private _db;
  57006. private _enableSceneOffline;
  57007. private _enableTexturesOffline;
  57008. private _manifestVersionFound;
  57009. private _mustUpdateRessources;
  57010. private _hasReachedQuota;
  57011. private _isSupported;
  57012. private _idbFactory;
  57013. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57014. private static IsUASupportingBlobStorage;
  57015. /**
  57016. * Gets a boolean indicating if Database storate is enabled (off by default)
  57017. */
  57018. static IDBStorageEnabled: boolean;
  57019. /**
  57020. * Gets a boolean indicating if scene must be saved in the database
  57021. */
  57022. readonly enableSceneOffline: boolean;
  57023. /**
  57024. * Gets a boolean indicating if textures must be saved in the database
  57025. */
  57026. readonly enableTexturesOffline: boolean;
  57027. /**
  57028. * Creates a new Database
  57029. * @param urlToScene defines the url to load the scene
  57030. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57031. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57032. */
  57033. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57034. private static _ParseURL;
  57035. private static _ReturnFullUrlLocation;
  57036. private _checkManifestFile;
  57037. /**
  57038. * Open the database and make it available
  57039. * @param successCallback defines the callback to call on success
  57040. * @param errorCallback defines the callback to call on error
  57041. */
  57042. open(successCallback: () => void, errorCallback: () => void): void;
  57043. /**
  57044. * Loads an image from the database
  57045. * @param url defines the url to load from
  57046. * @param image defines the target DOM image
  57047. */
  57048. loadImage(url: string, image: HTMLImageElement): void;
  57049. private _loadImageFromDBAsync;
  57050. private _saveImageIntoDBAsync;
  57051. private _checkVersionFromDB;
  57052. private _loadVersionFromDBAsync;
  57053. private _saveVersionIntoDBAsync;
  57054. /**
  57055. * Loads a file from database
  57056. * @param url defines the URL to load from
  57057. * @param sceneLoaded defines a callback to call on success
  57058. * @param progressCallBack defines a callback to call when progress changed
  57059. * @param errorCallback defines a callback to call on error
  57060. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57061. */
  57062. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57063. private _loadFileAsync;
  57064. private _saveFileAsync;
  57065. /**
  57066. * Validates if xhr data is correct
  57067. * @param xhr defines the request to validate
  57068. * @param dataType defines the expected data type
  57069. * @returns true if data is correct
  57070. */
  57071. private static _ValidateXHRData;
  57072. }
  57073. }
  57074. declare module BABYLON {
  57075. /** @hidden */
  57076. export var gpuUpdateParticlesPixelShader: {
  57077. name: string;
  57078. shader: string;
  57079. };
  57080. }
  57081. declare module BABYLON {
  57082. /** @hidden */
  57083. export var gpuUpdateParticlesVertexShader: {
  57084. name: string;
  57085. shader: string;
  57086. };
  57087. }
  57088. declare module BABYLON {
  57089. /** @hidden */
  57090. export var clipPlaneFragmentDeclaration2: {
  57091. name: string;
  57092. shader: string;
  57093. };
  57094. }
  57095. declare module BABYLON {
  57096. /** @hidden */
  57097. export var gpuRenderParticlesPixelShader: {
  57098. name: string;
  57099. shader: string;
  57100. };
  57101. }
  57102. declare module BABYLON {
  57103. /** @hidden */
  57104. export var clipPlaneVertexDeclaration2: {
  57105. name: string;
  57106. shader: string;
  57107. };
  57108. }
  57109. declare module BABYLON {
  57110. /** @hidden */
  57111. export var gpuRenderParticlesVertexShader: {
  57112. name: string;
  57113. shader: string;
  57114. };
  57115. }
  57116. declare module BABYLON {
  57117. /**
  57118. * This represents a GPU particle system in Babylon
  57119. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57120. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57121. */
  57122. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57123. /**
  57124. * The layer mask we are rendering the particles through.
  57125. */
  57126. layerMask: number;
  57127. private _capacity;
  57128. private _activeCount;
  57129. private _currentActiveCount;
  57130. private _accumulatedCount;
  57131. private _renderEffect;
  57132. private _updateEffect;
  57133. private _buffer0;
  57134. private _buffer1;
  57135. private _spriteBuffer;
  57136. private _updateVAO;
  57137. private _renderVAO;
  57138. private _targetIndex;
  57139. private _sourceBuffer;
  57140. private _targetBuffer;
  57141. private _engine;
  57142. private _currentRenderId;
  57143. private _started;
  57144. private _stopped;
  57145. private _timeDelta;
  57146. private _randomTexture;
  57147. private _randomTexture2;
  57148. private _attributesStrideSize;
  57149. private _updateEffectOptions;
  57150. private _randomTextureSize;
  57151. private _actualFrame;
  57152. private readonly _rawTextureWidth;
  57153. /**
  57154. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57155. */
  57156. static readonly IsSupported: boolean;
  57157. /**
  57158. * An event triggered when the system is disposed.
  57159. */
  57160. onDisposeObservable: Observable<GPUParticleSystem>;
  57161. /**
  57162. * Gets the maximum number of particles active at the same time.
  57163. * @returns The max number of active particles.
  57164. */
  57165. getCapacity(): number;
  57166. /**
  57167. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57168. * to override the particles.
  57169. */
  57170. forceDepthWrite: boolean;
  57171. /**
  57172. * Gets or set the number of active particles
  57173. */
  57174. activeParticleCount: number;
  57175. private _preWarmDone;
  57176. /**
  57177. * Is this system ready to be used/rendered
  57178. * @return true if the system is ready
  57179. */
  57180. isReady(): boolean;
  57181. /**
  57182. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57183. * @returns True if it has been started, otherwise false.
  57184. */
  57185. isStarted(): boolean;
  57186. /**
  57187. * Starts the particle system and begins to emit
  57188. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57189. */
  57190. start(delay?: number): void;
  57191. /**
  57192. * Stops the particle system.
  57193. */
  57194. stop(): void;
  57195. /**
  57196. * Remove all active particles
  57197. */
  57198. reset(): void;
  57199. /**
  57200. * Returns the string "GPUParticleSystem"
  57201. * @returns a string containing the class name
  57202. */
  57203. getClassName(): string;
  57204. private _colorGradientsTexture;
  57205. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57206. /**
  57207. * Adds a new color gradient
  57208. * @param gradient defines the gradient to use (between 0 and 1)
  57209. * @param color1 defines the color to affect to the specified gradient
  57210. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57211. * @returns the current particle system
  57212. */
  57213. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57214. /**
  57215. * Remove a specific color gradient
  57216. * @param gradient defines the gradient to remove
  57217. * @returns the current particle system
  57218. */
  57219. removeColorGradient(gradient: number): GPUParticleSystem;
  57220. private _angularSpeedGradientsTexture;
  57221. private _sizeGradientsTexture;
  57222. private _velocityGradientsTexture;
  57223. private _limitVelocityGradientsTexture;
  57224. private _dragGradientsTexture;
  57225. private _addFactorGradient;
  57226. /**
  57227. * Adds a new size gradient
  57228. * @param gradient defines the gradient to use (between 0 and 1)
  57229. * @param factor defines the size factor to affect to the specified gradient
  57230. * @returns the current particle system
  57231. */
  57232. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57233. /**
  57234. * Remove a specific size gradient
  57235. * @param gradient defines the gradient to remove
  57236. * @returns the current particle system
  57237. */
  57238. removeSizeGradient(gradient: number): GPUParticleSystem;
  57239. /**
  57240. * Adds a new angular speed gradient
  57241. * @param gradient defines the gradient to use (between 0 and 1)
  57242. * @param factor defines the angular speed to affect to the specified gradient
  57243. * @returns the current particle system
  57244. */
  57245. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57246. /**
  57247. * Remove a specific angular speed gradient
  57248. * @param gradient defines the gradient to remove
  57249. * @returns the current particle system
  57250. */
  57251. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57252. /**
  57253. * Adds a new velocity gradient
  57254. * @param gradient defines the gradient to use (between 0 and 1)
  57255. * @param factor defines the velocity to affect to the specified gradient
  57256. * @returns the current particle system
  57257. */
  57258. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57259. /**
  57260. * Remove a specific velocity gradient
  57261. * @param gradient defines the gradient to remove
  57262. * @returns the current particle system
  57263. */
  57264. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57265. /**
  57266. * Adds a new limit velocity gradient
  57267. * @param gradient defines the gradient to use (between 0 and 1)
  57268. * @param factor defines the limit velocity value to affect to the specified gradient
  57269. * @returns the current particle system
  57270. */
  57271. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57272. /**
  57273. * Remove a specific limit velocity gradient
  57274. * @param gradient defines the gradient to remove
  57275. * @returns the current particle system
  57276. */
  57277. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57278. /**
  57279. * Adds a new drag gradient
  57280. * @param gradient defines the gradient to use (between 0 and 1)
  57281. * @param factor defines the drag value to affect to the specified gradient
  57282. * @returns the current particle system
  57283. */
  57284. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57285. /**
  57286. * Remove a specific drag gradient
  57287. * @param gradient defines the gradient to remove
  57288. * @returns the current particle system
  57289. */
  57290. removeDragGradient(gradient: number): GPUParticleSystem;
  57291. /**
  57292. * Not supported by GPUParticleSystem
  57293. * @param gradient defines the gradient to use (between 0 and 1)
  57294. * @param factor defines the emit rate value to affect to the specified gradient
  57295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57296. * @returns the current particle system
  57297. */
  57298. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57299. /**
  57300. * Not supported by GPUParticleSystem
  57301. * @param gradient defines the gradient to remove
  57302. * @returns the current particle system
  57303. */
  57304. removeEmitRateGradient(gradient: number): IParticleSystem;
  57305. /**
  57306. * Not supported by GPUParticleSystem
  57307. * @param gradient defines the gradient to use (between 0 and 1)
  57308. * @param factor defines the start size value to affect to the specified gradient
  57309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57310. * @returns the current particle system
  57311. */
  57312. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57313. /**
  57314. * Not supported by GPUParticleSystem
  57315. * @param gradient defines the gradient to remove
  57316. * @returns the current particle system
  57317. */
  57318. removeStartSizeGradient(gradient: number): IParticleSystem;
  57319. /**
  57320. * Not supported by GPUParticleSystem
  57321. * @param gradient defines the gradient to use (between 0 and 1)
  57322. * @param min defines the color remap minimal range
  57323. * @param max defines the color remap maximal range
  57324. * @returns the current particle system
  57325. */
  57326. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57327. /**
  57328. * Not supported by GPUParticleSystem
  57329. * @param gradient defines the gradient to remove
  57330. * @returns the current particle system
  57331. */
  57332. removeColorRemapGradient(): IParticleSystem;
  57333. /**
  57334. * Not supported by GPUParticleSystem
  57335. * @param gradient defines the gradient to use (between 0 and 1)
  57336. * @param min defines the alpha remap minimal range
  57337. * @param max defines the alpha remap maximal range
  57338. * @returns the current particle system
  57339. */
  57340. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57341. /**
  57342. * Not supported by GPUParticleSystem
  57343. * @param gradient defines the gradient to remove
  57344. * @returns the current particle system
  57345. */
  57346. removeAlphaRemapGradient(): IParticleSystem;
  57347. /**
  57348. * Not supported by GPUParticleSystem
  57349. * @param gradient defines the gradient to use (between 0 and 1)
  57350. * @param color defines the color to affect to the specified gradient
  57351. * @returns the current particle system
  57352. */
  57353. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57354. /**
  57355. * Not supported by GPUParticleSystem
  57356. * @param gradient defines the gradient to remove
  57357. * @returns the current particle system
  57358. */
  57359. removeRampGradient(): IParticleSystem;
  57360. /**
  57361. * Not supported by GPUParticleSystem
  57362. * @returns the list of ramp gradients
  57363. */
  57364. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57365. /**
  57366. * Not supported by GPUParticleSystem
  57367. * Gets or sets a boolean indicating that ramp gradients must be used
  57368. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57369. */
  57370. useRampGradients: boolean;
  57371. /**
  57372. * Not supported by GPUParticleSystem
  57373. * @param gradient defines the gradient to use (between 0 and 1)
  57374. * @param factor defines the life time factor to affect to the specified gradient
  57375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57376. * @returns the current particle system
  57377. */
  57378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57379. /**
  57380. * Not supported by GPUParticleSystem
  57381. * @param gradient defines the gradient to remove
  57382. * @returns the current particle system
  57383. */
  57384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57385. /**
  57386. * Instantiates a GPU particle system.
  57387. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  57388. * @param name The name of the particle system
  57389. * @param options The options used to create the system
  57390. * @param scene The scene the particle system belongs to
  57391. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57392. */
  57393. constructor(name: string, options: Partial<{
  57394. capacity: number;
  57395. randomTextureSize: number;
  57396. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57397. protected _reset(): void;
  57398. private _createUpdateVAO;
  57399. private _createRenderVAO;
  57400. private _initialize;
  57401. /** @hidden */ private _recreateUpdateEffect(): void;
  57402. /** @hidden */ private _recreateRenderEffect(): void;
  57403. /**
  57404. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57405. * @param preWarm defines if we are in the pre-warmimg phase
  57406. */
  57407. animate(preWarm?: boolean): void;
  57408. private _createFactorGradientTexture;
  57409. private _createSizeGradientTexture;
  57410. private _createAngularSpeedGradientTexture;
  57411. private _createVelocityGradientTexture;
  57412. private _createLimitVelocityGradientTexture;
  57413. private _createDragGradientTexture;
  57414. private _createColorGradientTexture;
  57415. /**
  57416. * Renders the particle system in its current state
  57417. * @param preWarm defines if the system should only update the particles but not render them
  57418. * @returns the current number of particles
  57419. */
  57420. render(preWarm?: boolean): number;
  57421. /**
  57422. * Rebuilds the particle system
  57423. */
  57424. rebuild(): void;
  57425. private _releaseBuffers;
  57426. private _releaseVAOs;
  57427. /**
  57428. * Disposes the particle system and free the associated resources
  57429. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57430. */
  57431. dispose(disposeTexture?: boolean): void;
  57432. /**
  57433. * Clones the particle system.
  57434. * @param name The name of the cloned object
  57435. * @param newEmitter The new emitter to use
  57436. * @returns the cloned particle system
  57437. */
  57438. clone(name: string, newEmitter: any): GPUParticleSystem;
  57439. /**
  57440. * Serializes the particle system to a JSON object.
  57441. * @returns the JSON object
  57442. */
  57443. serialize(): any;
  57444. /**
  57445. * Parses a JSON object to create a GPU particle system.
  57446. * @param parsedParticleSystem The JSON object to parse
  57447. * @param scene The scene to create the particle system in
  57448. * @param rootUrl The root url to use to load external dependencies like texture
  57449. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57450. * @returns the parsed GPU particle system
  57451. */
  57452. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57453. }
  57454. }
  57455. declare module BABYLON {
  57456. /**
  57457. * Represents a set of particle systems working together to create a specific effect
  57458. */
  57459. export class ParticleSystemSet implements IDisposable {
  57460. private _emitterCreationOptions;
  57461. private _emitterNode;
  57462. /**
  57463. * Gets the particle system list
  57464. */
  57465. systems: IParticleSystem[];
  57466. /**
  57467. * Gets the emitter node used with this set
  57468. */
  57469. readonly emitterNode: Nullable<TransformNode>;
  57470. /**
  57471. * Creates a new emitter mesh as a sphere
  57472. * @param options defines the options used to create the sphere
  57473. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57474. * @param scene defines the hosting scene
  57475. */
  57476. setEmitterAsSphere(options: {
  57477. diameter: number;
  57478. segments: number;
  57479. color: Color3;
  57480. }, renderingGroupId: number, scene: Scene): void;
  57481. /**
  57482. * Starts all particle systems of the set
  57483. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57484. */
  57485. start(emitter?: AbstractMesh): void;
  57486. /**
  57487. * Release all associated resources
  57488. */
  57489. dispose(): void;
  57490. /**
  57491. * Serialize the set into a JSON compatible object
  57492. * @returns a JSON compatible representation of the set
  57493. */
  57494. serialize(): any;
  57495. /**
  57496. * Parse a new ParticleSystemSet from a serialized source
  57497. * @param data defines a JSON compatible representation of the set
  57498. * @param scene defines the hosting scene
  57499. * @param gpu defines if we want GPU particles or CPU particles
  57500. * @returns a new ParticleSystemSet
  57501. */
  57502. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57503. }
  57504. }
  57505. declare module BABYLON {
  57506. /**
  57507. * This class is made for on one-liner static method to help creating particle system set.
  57508. */
  57509. export class ParticleHelper {
  57510. /**
  57511. * Gets or sets base Assets URL
  57512. */
  57513. static BaseAssetsUrl: string;
  57514. /**
  57515. * Create a default particle system that you can tweak
  57516. * @param emitter defines the emitter to use
  57517. * @param capacity defines the system capacity (default is 500 particles)
  57518. * @param scene defines the hosting scene
  57519. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57520. * @returns the new Particle system
  57521. */
  57522. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57523. /**
  57524. * This is the main static method (one-liner) of this helper to create different particle systems
  57525. * @param type This string represents the type to the particle system to create
  57526. * @param scene The scene where the particle system should live
  57527. * @param gpu If the system will use gpu
  57528. * @returns the ParticleSystemSet created
  57529. */
  57530. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57531. /**
  57532. * Static function used to export a particle system to a ParticleSystemSet variable.
  57533. * Please note that the emitter shape is not exported
  57534. * @param systems defines the particle systems to export
  57535. * @returns the created particle system set
  57536. */
  57537. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57538. }
  57539. }
  57540. declare module BABYLON {
  57541. interface Engine {
  57542. /**
  57543. * Create an effect to use with particle systems.
  57544. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57545. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57546. * @param uniformsNames defines a list of attribute names
  57547. * @param samplers defines an array of string used to represent textures
  57548. * @param defines defines the string containing the defines to use to compile the shaders
  57549. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57550. * @param onCompiled defines a function to call when the effect creation is successful
  57551. * @param onError defines a function to call when the effect creation has failed
  57552. * @returns the new Effect
  57553. */
  57554. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57555. }
  57556. interface Mesh {
  57557. /**
  57558. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57559. * @returns an array of IParticleSystem
  57560. */
  57561. getEmittedParticleSystems(): IParticleSystem[];
  57562. /**
  57563. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57564. * @returns an array of IParticleSystem
  57565. */
  57566. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57567. }
  57568. /**
  57569. * @hidden
  57570. */
  57571. export var _IDoNeedToBeInTheBuild: number;
  57572. }
  57573. declare module BABYLON {
  57574. interface Scene {
  57575. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  57576. /**
  57577. * Gets the current physics engine
  57578. * @returns a IPhysicsEngine or null if none attached
  57579. */
  57580. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57581. /**
  57582. * Enables physics to the current scene
  57583. * @param gravity defines the scene's gravity for the physics engine
  57584. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57585. * @return a boolean indicating if the physics engine was initialized
  57586. */
  57587. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57588. /**
  57589. * Disables and disposes the physics engine associated with the scene
  57590. */
  57591. disablePhysicsEngine(): void;
  57592. /**
  57593. * Gets a boolean indicating if there is an active physics engine
  57594. * @returns a boolean indicating if there is an active physics engine
  57595. */
  57596. isPhysicsEnabled(): boolean;
  57597. /**
  57598. * Deletes a physics compound impostor
  57599. * @param compound defines the compound to delete
  57600. */
  57601. deleteCompoundImpostor(compound: any): void;
  57602. /**
  57603. * An event triggered when physic simulation is about to be run
  57604. */
  57605. onBeforePhysicsObservable: Observable<Scene>;
  57606. /**
  57607. * An event triggered when physic simulation has been done
  57608. */
  57609. onAfterPhysicsObservable: Observable<Scene>;
  57610. }
  57611. interface AbstractMesh {
  57612. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  57613. /**
  57614. * Gets or sets impostor used for physic simulation
  57615. * @see http://doc.babylonjs.com/features/physics_engine
  57616. */
  57617. physicsImpostor: Nullable<PhysicsImpostor>;
  57618. /**
  57619. * Gets the current physics impostor
  57620. * @see http://doc.babylonjs.com/features/physics_engine
  57621. * @returns a physics impostor or null
  57622. */
  57623. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57624. /** Apply a physic impulse to the mesh
  57625. * @param force defines the force to apply
  57626. * @param contactPoint defines where to apply the force
  57627. * @returns the current mesh
  57628. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57629. */
  57630. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57631. /**
  57632. * Creates a physic joint between two meshes
  57633. * @param otherMesh defines the other mesh to use
  57634. * @param pivot1 defines the pivot to use on this mesh
  57635. * @param pivot2 defines the pivot to use on the other mesh
  57636. * @param options defines additional options (can be plugin dependent)
  57637. * @returns the current mesh
  57638. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57639. */
  57640. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57641. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  57642. }
  57643. /**
  57644. * Defines the physics engine scene component responsible to manage a physics engine
  57645. */
  57646. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57647. /**
  57648. * The component name helpful to identify the component in the list of scene components.
  57649. */
  57650. readonly name: string;
  57651. /**
  57652. * The scene the component belongs to.
  57653. */
  57654. scene: Scene;
  57655. /**
  57656. * Creates a new instance of the component for the given scene
  57657. * @param scene Defines the scene to register the component in
  57658. */
  57659. constructor(scene: Scene);
  57660. /**
  57661. * Registers the component in a given scene
  57662. */
  57663. register(): void;
  57664. /**
  57665. * Rebuilds the elements related to this component in case of
  57666. * context lost for instance.
  57667. */
  57668. rebuild(): void;
  57669. /**
  57670. * Disposes the component and the associated ressources
  57671. */
  57672. dispose(): void;
  57673. }
  57674. }
  57675. declare module BABYLON {
  57676. /**
  57677. * A helper for physics simulations
  57678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57679. */
  57680. export class PhysicsHelper {
  57681. private _scene;
  57682. private _physicsEngine;
  57683. /**
  57684. * Initializes the Physics helper
  57685. * @param scene Babylon.js scene
  57686. */
  57687. constructor(scene: Scene);
  57688. /**
  57689. * Applies a radial explosion impulse
  57690. * @param origin the origin of the explosion
  57691. * @param radiusOrEventOptions the radius or the options of radial explosion
  57692. * @param strength the explosion strength
  57693. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57694. * @returns A physics radial explosion event, or null
  57695. */
  57696. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57697. /**
  57698. * Applies a radial explosion force
  57699. * @param origin the origin of the explosion
  57700. * @param radiusOrEventOptions the radius or the options of radial explosion
  57701. * @param strength the explosion strength
  57702. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57703. * @returns A physics radial explosion event, or null
  57704. */
  57705. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57706. /**
  57707. * Creates a gravitational field
  57708. * @param origin the origin of the explosion
  57709. * @param radiusOrEventOptions the radius or the options of radial explosion
  57710. * @param strength the explosion strength
  57711. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57712. * @returns A physics gravitational field event, or null
  57713. */
  57714. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57715. /**
  57716. * Creates a physics updraft event
  57717. * @param origin the origin of the updraft
  57718. * @param radiusOrEventOptions the radius or the options of the updraft
  57719. * @param strength the strength of the updraft
  57720. * @param height the height of the updraft
  57721. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57722. * @returns A physics updraft event, or null
  57723. */
  57724. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57725. /**
  57726. * Creates a physics vortex event
  57727. * @param origin the of the vortex
  57728. * @param radiusOrEventOptions the radius or the options of the vortex
  57729. * @param strength the strength of the vortex
  57730. * @param height the height of the vortex
  57731. * @returns a Physics vortex event, or null
  57732. * A physics vortex event or null
  57733. */
  57734. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57735. }
  57736. /**
  57737. * Represents a physics radial explosion event
  57738. */
  57739. class PhysicsRadialExplosionEvent {
  57740. private _scene;
  57741. private _options;
  57742. private _sphere;
  57743. private _dataFetched;
  57744. /**
  57745. * Initializes a radial explosioin event
  57746. * @param _scene BabylonJS scene
  57747. * @param _options The options for the vortex event
  57748. */
  57749. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57750. /**
  57751. * Returns the data related to the radial explosion event (sphere).
  57752. * @returns The radial explosion event data
  57753. */
  57754. getData(): PhysicsRadialExplosionEventData;
  57755. /**
  57756. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57757. * @param impostor A physics imposter
  57758. * @param origin the origin of the explosion
  57759. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57760. */
  57761. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57762. /**
  57763. * Triggers affecterd impostors callbacks
  57764. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57765. */
  57766. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57767. /**
  57768. * Disposes the sphere.
  57769. * @param force Specifies if the sphere should be disposed by force
  57770. */
  57771. dispose(force?: boolean): void;
  57772. /*** Helpers ***/
  57773. private _prepareSphere;
  57774. private _intersectsWithSphere;
  57775. }
  57776. /**
  57777. * Represents a gravitational field event
  57778. */
  57779. class PhysicsGravitationalFieldEvent {
  57780. private _physicsHelper;
  57781. private _scene;
  57782. private _origin;
  57783. private _options;
  57784. private _tickCallback;
  57785. private _sphere;
  57786. private _dataFetched;
  57787. /**
  57788. * Initializes the physics gravitational field event
  57789. * @param _physicsHelper A physics helper
  57790. * @param _scene BabylonJS scene
  57791. * @param _origin The origin position of the gravitational field event
  57792. * @param _options The options for the vortex event
  57793. */
  57794. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57795. /**
  57796. * Returns the data related to the gravitational field event (sphere).
  57797. * @returns A gravitational field event
  57798. */
  57799. getData(): PhysicsGravitationalFieldEventData;
  57800. /**
  57801. * Enables the gravitational field.
  57802. */
  57803. enable(): void;
  57804. /**
  57805. * Disables the gravitational field.
  57806. */
  57807. disable(): void;
  57808. /**
  57809. * Disposes the sphere.
  57810. * @param force The force to dispose from the gravitational field event
  57811. */
  57812. dispose(force?: boolean): void;
  57813. private _tick;
  57814. }
  57815. /**
  57816. * Represents a physics updraft event
  57817. */
  57818. class PhysicsUpdraftEvent {
  57819. private _scene;
  57820. private _origin;
  57821. private _options;
  57822. private _physicsEngine;
  57823. private _originTop;
  57824. private _originDirection;
  57825. private _tickCallback;
  57826. private _cylinder;
  57827. private _cylinderPosition;
  57828. private _dataFetched;
  57829. /**
  57830. * Initializes the physics updraft event
  57831. * @param _scene BabylonJS scene
  57832. * @param _origin The origin position of the updraft
  57833. * @param _options The options for the updraft event
  57834. */
  57835. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57836. /**
  57837. * Returns the data related to the updraft event (cylinder).
  57838. * @returns A physics updraft event
  57839. */
  57840. getData(): PhysicsUpdraftEventData;
  57841. /**
  57842. * Enables the updraft.
  57843. */
  57844. enable(): void;
  57845. /**
  57846. * Disables the updraft.
  57847. */
  57848. disable(): void;
  57849. /**
  57850. * Disposes the cylinder.
  57851. * @param force Specifies if the updraft should be disposed by force
  57852. */
  57853. dispose(force?: boolean): void;
  57854. private getImpostorHitData;
  57855. private _tick;
  57856. /*** Helpers ***/
  57857. private _prepareCylinder;
  57858. private _intersectsWithCylinder;
  57859. }
  57860. /**
  57861. * Represents a physics vortex event
  57862. */
  57863. class PhysicsVortexEvent {
  57864. private _scene;
  57865. private _origin;
  57866. private _options;
  57867. private _physicsEngine;
  57868. private _originTop;
  57869. private _tickCallback;
  57870. private _cylinder;
  57871. private _cylinderPosition;
  57872. private _dataFetched;
  57873. /**
  57874. * Initializes the physics vortex event
  57875. * @param _scene The BabylonJS scene
  57876. * @param _origin The origin position of the vortex
  57877. * @param _options The options for the vortex event
  57878. */
  57879. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57880. /**
  57881. * Returns the data related to the vortex event (cylinder).
  57882. * @returns The physics vortex event data
  57883. */
  57884. getData(): PhysicsVortexEventData;
  57885. /**
  57886. * Enables the vortex.
  57887. */
  57888. enable(): void;
  57889. /**
  57890. * Disables the cortex.
  57891. */
  57892. disable(): void;
  57893. /**
  57894. * Disposes the sphere.
  57895. * @param force
  57896. */
  57897. dispose(force?: boolean): void;
  57898. private getImpostorHitData;
  57899. private _tick;
  57900. /*** Helpers ***/
  57901. private _prepareCylinder;
  57902. private _intersectsWithCylinder;
  57903. }
  57904. /**
  57905. * Options fot the radial explosion event
  57906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57907. */
  57908. export class PhysicsRadialExplosionEventOptions {
  57909. /**
  57910. * The radius of the sphere for the radial explosion.
  57911. */
  57912. radius: number;
  57913. /**
  57914. * The strenth of the explosion.
  57915. */
  57916. strength: number;
  57917. /**
  57918. * The strenght of the force in correspondence to the distance of the affected object
  57919. */
  57920. falloff: PhysicsRadialImpulseFalloff;
  57921. /**
  57922. * Sphere options for the radial explosion.
  57923. */
  57924. sphere: {
  57925. segments: number;
  57926. diameter: number;
  57927. };
  57928. /**
  57929. * Sphere options for the radial explosion.
  57930. */
  57931. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57932. }
  57933. /**
  57934. * Options fot the updraft event
  57935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57936. */
  57937. export class PhysicsUpdraftEventOptions {
  57938. /**
  57939. * The radius of the cylinder for the vortex
  57940. */
  57941. radius: number;
  57942. /**
  57943. * The strenth of the updraft.
  57944. */
  57945. strength: number;
  57946. /**
  57947. * The height of the cylinder for the updraft.
  57948. */
  57949. height: number;
  57950. /**
  57951. * The mode for the the updraft.
  57952. */
  57953. updraftMode: PhysicsUpdraftMode;
  57954. }
  57955. /**
  57956. * Options fot the vortex event
  57957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57958. */
  57959. export class PhysicsVortexEventOptions {
  57960. /**
  57961. * The radius of the cylinder for the vortex
  57962. */
  57963. radius: number;
  57964. /**
  57965. * The strenth of the vortex.
  57966. */
  57967. strength: number;
  57968. /**
  57969. * The height of the cylinder for the vortex.
  57970. */
  57971. height: number;
  57972. /**
  57973. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57974. */
  57975. centripetalForceThreshold: number;
  57976. /**
  57977. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57978. */
  57979. centripetalForceMultiplier: number;
  57980. /**
  57981. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57982. */
  57983. centrifugalForceMultiplier: number;
  57984. /**
  57985. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57986. */
  57987. updraftForceMultiplier: number;
  57988. }
  57989. /**
  57990. * The strenght of the force in correspondence to the distance of the affected object
  57991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57992. */
  57993. export enum PhysicsRadialImpulseFalloff {
  57994. /** Defines that impulse is constant in strength across it's whole radius */
  57995. Constant = 0,
  57996. /** Defines that impulse gets weaker if it's further from the origin */
  57997. Linear = 1
  57998. }
  57999. /**
  58000. * The strength of the force in correspondence to the distance of the affected object
  58001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58002. */
  58003. export enum PhysicsUpdraftMode {
  58004. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58005. Center = 0,
  58006. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58007. Perpendicular = 1
  58008. }
  58009. /**
  58010. * Interface for a physics hit data
  58011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58012. */
  58013. export interface PhysicsHitData {
  58014. /**
  58015. * The force applied at the contact point
  58016. */
  58017. force: Vector3;
  58018. /**
  58019. * The contact point
  58020. */
  58021. contactPoint: Vector3;
  58022. /**
  58023. * The distance from the origin to the contact point
  58024. */
  58025. distanceFromOrigin: number;
  58026. }
  58027. /**
  58028. * Interface for radial explosion event data
  58029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58030. */
  58031. export interface PhysicsRadialExplosionEventData {
  58032. /**
  58033. * A sphere used for the radial explosion event
  58034. */
  58035. sphere: Mesh;
  58036. }
  58037. /**
  58038. * Interface for gravitational field event data
  58039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58040. */
  58041. export interface PhysicsGravitationalFieldEventData {
  58042. /**
  58043. * A sphere mesh used for the gravitational field event
  58044. */
  58045. sphere: Mesh;
  58046. }
  58047. /**
  58048. * Interface for updraft event data
  58049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58050. */
  58051. export interface PhysicsUpdraftEventData {
  58052. /**
  58053. * A cylinder used for the updraft event
  58054. */
  58055. cylinder: Mesh;
  58056. }
  58057. /**
  58058. * Interface for vortex event data
  58059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58060. */
  58061. export interface PhysicsVortexEventData {
  58062. /**
  58063. * A cylinder used for the vortex event
  58064. */
  58065. cylinder: Mesh;
  58066. }
  58067. /**
  58068. * Interface for an affected physics impostor
  58069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58070. */
  58071. export interface PhysicsAffectedImpostorWithData {
  58072. /**
  58073. * The impostor affected by the effect
  58074. */
  58075. impostor: PhysicsImpostor;
  58076. /**
  58077. * The data about the hit/horce from the explosion
  58078. */
  58079. hitData: PhysicsHitData;
  58080. }
  58081. }
  58082. declare module BABYLON {
  58083. /** @hidden */
  58084. export var blackAndWhitePixelShader: {
  58085. name: string;
  58086. shader: string;
  58087. };
  58088. }
  58089. declare module BABYLON {
  58090. /**
  58091. * Post process used to render in black and white
  58092. */
  58093. export class BlackAndWhitePostProcess extends PostProcess {
  58094. /**
  58095. * Linear about to convert he result to black and white (default: 1)
  58096. */
  58097. degree: number;
  58098. /**
  58099. * Creates a black and white post process
  58100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58101. * @param name The name of the effect.
  58102. * @param options The required width/height ratio to downsize to before computing the render pass.
  58103. * @param camera The camera to apply the render pass to.
  58104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58105. * @param engine The engine which the post process will be applied. (default: current engine)
  58106. * @param reusable If the post process can be reused on the same frame. (default: false)
  58107. */
  58108. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58109. }
  58110. }
  58111. declare module BABYLON {
  58112. /**
  58113. * This represents a set of one or more post processes in Babylon.
  58114. * A post process can be used to apply a shader to a texture after it is rendered.
  58115. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58116. */
  58117. export class PostProcessRenderEffect {
  58118. private _postProcesses;
  58119. private _getPostProcesses;
  58120. private _singleInstance;
  58121. private _cameras;
  58122. private _indicesForCamera;
  58123. /**
  58124. * Name of the effect
  58125. * @hidden
  58126. */ private _name: string;
  58127. /**
  58128. * Instantiates a post process render effect.
  58129. * A post process can be used to apply a shader to a texture after it is rendered.
  58130. * @param engine The engine the effect is tied to
  58131. * @param name The name of the effect
  58132. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58133. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58134. */
  58135. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58136. /**
  58137. * Checks if all the post processes in the effect are supported.
  58138. */
  58139. readonly isSupported: boolean;
  58140. /**
  58141. * Updates the current state of the effect
  58142. * @hidden
  58143. */ private _update(): void;
  58144. /**
  58145. * Attaches the effect on cameras
  58146. * @param cameras The camera to attach to.
  58147. * @hidden
  58148. */ private _attachCameras(cameras: Camera): void;
  58149. /**
  58150. * Attaches the effect on cameras
  58151. * @param cameras The camera to attach to.
  58152. * @hidden
  58153. */ private _attachCameras(cameras: Camera[]): void;
  58154. /**
  58155. * Detaches the effect on cameras
  58156. * @param cameras The camera to detatch from.
  58157. * @hidden
  58158. */ private _detachCameras(cameras: Camera): void;
  58159. /**
  58160. * Detatches the effect on cameras
  58161. * @param cameras The camera to detatch from.
  58162. * @hidden
  58163. */ private _detachCameras(cameras: Camera[]): void;
  58164. /**
  58165. * Enables the effect on given cameras
  58166. * @param cameras The camera to enable.
  58167. * @hidden
  58168. */ private _enable(cameras: Camera): void;
  58169. /**
  58170. * Enables the effect on given cameras
  58171. * @param cameras The camera to enable.
  58172. * @hidden
  58173. */ private _enable(cameras: Nullable<Camera[]>): void;
  58174. /**
  58175. * Disables the effect on the given cameras
  58176. * @param cameras The camera to disable.
  58177. * @hidden
  58178. */ private _disable(cameras: Camera): void;
  58179. /**
  58180. * Disables the effect on the given cameras
  58181. * @param cameras The camera to disable.
  58182. * @hidden
  58183. */ private _disable(cameras: Nullable<Camera[]>): void;
  58184. /**
  58185. * Gets a list of the post processes contained in the effect.
  58186. * @param camera The camera to get the post processes on.
  58187. * @returns The list of the post processes in the effect.
  58188. */
  58189. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58190. }
  58191. }
  58192. declare module BABYLON {
  58193. /** @hidden */
  58194. export var extractHighlightsPixelShader: {
  58195. name: string;
  58196. shader: string;
  58197. };
  58198. }
  58199. declare module BABYLON {
  58200. /**
  58201. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  58202. */
  58203. export class ExtractHighlightsPostProcess extends PostProcess {
  58204. /**
  58205. * The luminance threshold, pixels below this value will be set to black.
  58206. */
  58207. threshold: number;
  58208. /** @hidden */ private _exposure: number;
  58209. /**
  58210. * Post process which has the input texture to be used when performing highlight extraction
  58211. * @hidden
  58212. */ private _inputPostProcess: Nullable<PostProcess>;
  58213. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58214. }
  58215. }
  58216. declare module BABYLON {
  58217. /** @hidden */
  58218. export var bloomMergePixelShader: {
  58219. name: string;
  58220. shader: string;
  58221. };
  58222. }
  58223. declare module BABYLON {
  58224. /**
  58225. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58226. */
  58227. export class BloomMergePostProcess extends PostProcess {
  58228. /** Weight of the bloom to be added to the original input. */
  58229. weight: number;
  58230. /**
  58231. * Creates a new instance of @see BloomMergePostProcess
  58232. * @param name The name of the effect.
  58233. * @param originalFromInput Post process which's input will be used for the merge.
  58234. * @param blurred Blurred highlights post process which's output will be used.
  58235. * @param weight Weight of the bloom to be added to the original input.
  58236. * @param options The required width/height ratio to downsize to before computing the render pass.
  58237. * @param camera The camera to apply the render pass to.
  58238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58239. * @param engine The engine which the post process will be applied. (default: current engine)
  58240. * @param reusable If the post process can be reused on the same frame. (default: false)
  58241. * @param textureType Type of textures used when performing the post process. (default: 0)
  58242. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58243. */
  58244. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58245. /** Weight of the bloom to be added to the original input. */
  58246. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58247. }
  58248. }
  58249. declare module BABYLON {
  58250. /**
  58251. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58252. */
  58253. export class BloomEffect extends PostProcessRenderEffect {
  58254. private bloomScale;
  58255. /**
  58256. * @hidden Internal
  58257. */ private _effects: Array<PostProcess>;
  58258. /**
  58259. * @hidden Internal
  58260. */ private _downscale: ExtractHighlightsPostProcess;
  58261. private _blurX;
  58262. private _blurY;
  58263. private _merge;
  58264. /**
  58265. * The luminance threshold to find bright areas of the image to bloom.
  58266. */
  58267. threshold: number;
  58268. /**
  58269. * The strength of the bloom.
  58270. */
  58271. weight: number;
  58272. /**
  58273. * Specifies the size of the bloom blur kernel, relative to the final output size
  58274. */
  58275. kernel: number;
  58276. /**
  58277. * Creates a new instance of @see BloomEffect
  58278. * @param scene The scene the effect belongs to.
  58279. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58280. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58281. * @param bloomWeight The the strength of bloom.
  58282. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58283. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58284. */
  58285. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58286. /**
  58287. * Disposes each of the internal effects for a given camera.
  58288. * @param camera The camera to dispose the effect on.
  58289. */
  58290. disposeEffects(camera: Camera): void;
  58291. /**
  58292. * @hidden Internal
  58293. */ private _updateEffects(): void;
  58294. /**
  58295. * Internal
  58296. * @returns if all the contained post processes are ready.
  58297. * @hidden
  58298. */ private _isReady(): boolean;
  58299. }
  58300. }
  58301. declare module BABYLON {
  58302. /** @hidden */
  58303. export var chromaticAberrationPixelShader: {
  58304. name: string;
  58305. shader: string;
  58306. };
  58307. }
  58308. declare module BABYLON {
  58309. /**
  58310. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58311. */
  58312. export class ChromaticAberrationPostProcess extends PostProcess {
  58313. /**
  58314. * The amount of seperation of rgb channels (default: 30)
  58315. */
  58316. aberrationAmount: number;
  58317. /**
  58318. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58319. */
  58320. radialIntensity: number;
  58321. /**
  58322. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  58323. */
  58324. direction: Vector2;
  58325. /**
  58326. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  58327. */
  58328. centerPosition: Vector2;
  58329. /**
  58330. * Creates a new instance ChromaticAberrationPostProcess
  58331. * @param name The name of the effect.
  58332. * @param screenWidth The width of the screen to apply the effect on.
  58333. * @param screenHeight The height of the screen to apply the effect on.
  58334. * @param options The required width/height ratio to downsize to before computing the render pass.
  58335. * @param camera The camera to apply the render pass to.
  58336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58337. * @param engine The engine which the post process will be applied. (default: current engine)
  58338. * @param reusable If the post process can be reused on the same frame. (default: false)
  58339. * @param textureType Type of textures used when performing the post process. (default: 0)
  58340. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58341. */
  58342. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58343. }
  58344. }
  58345. declare module BABYLON {
  58346. /** @hidden */
  58347. export var circleOfConfusionPixelShader: {
  58348. name: string;
  58349. shader: string;
  58350. };
  58351. }
  58352. declare module BABYLON {
  58353. /**
  58354. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58355. */
  58356. export class CircleOfConfusionPostProcess extends PostProcess {
  58357. /**
  58358. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  58359. */
  58360. lensSize: number;
  58361. /**
  58362. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58363. */
  58364. fStop: number;
  58365. /**
  58366. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58367. */
  58368. focusDistance: number;
  58369. /**
  58370. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58371. */
  58372. focalLength: number;
  58373. private _depthTexture;
  58374. /**
  58375. * Creates a new instance CircleOfConfusionPostProcess
  58376. * @param name The name of the effect.
  58377. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  58378. * @param options The required width/height ratio to downsize to before computing the render pass.
  58379. * @param camera The camera to apply the render pass to.
  58380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58381. * @param engine The engine which the post process will be applied. (default: current engine)
  58382. * @param reusable If the post process can be reused on the same frame. (default: false)
  58383. * @param textureType Type of textures used when performing the post process. (default: 0)
  58384. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58385. */
  58386. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58387. /**
  58388. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  58389. */
  58390. depthTexture: RenderTargetTexture;
  58391. }
  58392. }
  58393. declare module BABYLON {
  58394. /** @hidden */
  58395. export var colorCorrectionPixelShader: {
  58396. name: string;
  58397. shader: string;
  58398. };
  58399. }
  58400. declare module BABYLON {
  58401. /**
  58402. *
  58403. * This post-process allows the modification of rendered colors by using
  58404. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58405. *
  58406. * The object needs to be provided an url to a texture containing the color
  58407. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58408. * Use an image editing software to tweak the LUT to match your needs.
  58409. *
  58410. * For an example of a color LUT, see here:
  58411. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58412. * For explanations on color grading, see here:
  58413. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58414. *
  58415. */
  58416. export class ColorCorrectionPostProcess extends PostProcess {
  58417. private _colorTableTexture;
  58418. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58419. }
  58420. }
  58421. declare module BABYLON {
  58422. /** @hidden */
  58423. export var convolutionPixelShader: {
  58424. name: string;
  58425. shader: string;
  58426. };
  58427. }
  58428. declare module BABYLON {
  58429. /**
  58430. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58431. * input texture to perform effects such as edge detection or sharpening
  58432. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58433. */
  58434. export class ConvolutionPostProcess extends PostProcess {
  58435. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58436. kernel: number[];
  58437. /**
  58438. * Creates a new instance ConvolutionPostProcess
  58439. * @param name The name of the effect.
  58440. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58441. * @param options The required width/height ratio to downsize to before computing the render pass.
  58442. * @param camera The camera to apply the render pass to.
  58443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58444. * @param engine The engine which the post process will be applied. (default: current engine)
  58445. * @param reusable If the post process can be reused on the same frame. (default: false)
  58446. * @param textureType Type of textures used when performing the post process. (default: 0)
  58447. */
  58448. constructor(name: string,
  58449. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58450. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58451. /**
  58452. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58453. */
  58454. static EdgeDetect0Kernel: number[];
  58455. /**
  58456. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58457. */
  58458. static EdgeDetect1Kernel: number[];
  58459. /**
  58460. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58461. */
  58462. static EdgeDetect2Kernel: number[];
  58463. /**
  58464. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58465. */
  58466. static SharpenKernel: number[];
  58467. /**
  58468. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58469. */
  58470. static EmbossKernel: number[];
  58471. /**
  58472. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58473. */
  58474. static GaussianKernel: number[];
  58475. }
  58476. }
  58477. declare module BABYLON {
  58478. /**
  58479. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58480. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58481. * based on samples that have a large difference in distance than the center pixel.
  58482. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58483. */
  58484. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58485. direction: Vector2;
  58486. /**
  58487. * Creates a new instance CircleOfConfusionPostProcess
  58488. * @param name The name of the effect.
  58489. * @param scene The scene the effect belongs to.
  58490. * @param direction The direction the blur should be applied.
  58491. * @param kernel The size of the kernel used to blur.
  58492. * @param options The required width/height ratio to downsize to before computing the render pass.
  58493. * @param camera The camera to apply the render pass to.
  58494. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58495. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58497. * @param engine The engine which the post process will be applied. (default: current engine)
  58498. * @param reusable If the post process can be reused on the same frame. (default: false)
  58499. * @param textureType Type of textures used when performing the post process. (default: 0)
  58500. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58501. */
  58502. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58503. }
  58504. }
  58505. declare module BABYLON {
  58506. /** @hidden */
  58507. export var depthOfFieldMergePixelShader: {
  58508. name: string;
  58509. shader: string;
  58510. };
  58511. }
  58512. declare module BABYLON {
  58513. /**
  58514. * Options to be set when merging outputs from the default pipeline.
  58515. */
  58516. export class DepthOfFieldMergePostProcessOptions {
  58517. /**
  58518. * The original image to merge on top of
  58519. */
  58520. originalFromInput: PostProcess;
  58521. /**
  58522. * Parameters to perform the merge of the depth of field effect
  58523. */
  58524. depthOfField?: {
  58525. circleOfConfusion: PostProcess;
  58526. blurSteps: Array<PostProcess>;
  58527. };
  58528. /**
  58529. * Parameters to perform the merge of bloom effect
  58530. */
  58531. bloom?: {
  58532. blurred: PostProcess;
  58533. weight: number;
  58534. };
  58535. }
  58536. /**
  58537. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58538. */
  58539. export class DepthOfFieldMergePostProcess extends PostProcess {
  58540. private blurSteps;
  58541. /**
  58542. * Creates a new instance of DepthOfFieldMergePostProcess
  58543. * @param name The name of the effect.
  58544. * @param originalFromInput Post process which's input will be used for the merge.
  58545. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58546. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58547. * @param options The required width/height ratio to downsize to before computing the render pass.
  58548. * @param camera The camera to apply the render pass to.
  58549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58550. * @param engine The engine which the post process will be applied. (default: current engine)
  58551. * @param reusable If the post process can be reused on the same frame. (default: false)
  58552. * @param textureType Type of textures used when performing the post process. (default: 0)
  58553. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58554. */
  58555. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58556. /**
  58557. * Updates the effect with the current post process compile time values and recompiles the shader.
  58558. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58559. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58560. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58561. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  58562. * @param onCompiled Called when the shader has been compiled.
  58563. * @param onError Called if there is an error when compiling a shader.
  58564. */
  58565. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58566. }
  58567. }
  58568. declare module BABYLON {
  58569. /**
  58570. * Specifies the level of max blur that should be applied when using the depth of field effect
  58571. */
  58572. export enum DepthOfFieldEffectBlurLevel {
  58573. /**
  58574. * Subtle blur
  58575. */
  58576. Low = 0,
  58577. /**
  58578. * Medium blur
  58579. */
  58580. Medium = 1,
  58581. /**
  58582. * Large blur
  58583. */
  58584. High = 2
  58585. }
  58586. /**
  58587. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58588. */
  58589. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58590. private _circleOfConfusion;
  58591. /**
  58592. * @hidden Internal, blurs from high to low
  58593. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58594. private _depthOfFieldBlurY;
  58595. private _dofMerge;
  58596. /**
  58597. * @hidden Internal post processes in depth of field effect
  58598. */ private _effects: Array<PostProcess>;
  58599. /**
  58600. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58601. */
  58602. focalLength: number;
  58603. /**
  58604. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58605. */
  58606. fStop: number;
  58607. /**
  58608. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58609. */
  58610. focusDistance: number;
  58611. /**
  58612. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  58613. */
  58614. lensSize: number;
  58615. /**
  58616. * Creates a new instance DepthOfFieldEffect
  58617. * @param scene The scene the effect belongs to.
  58618. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  58619. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58620. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58621. */
  58622. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58623. /**
  58624. * Get the current class name of the current effet
  58625. * @returns "DepthOfFieldEffect"
  58626. */
  58627. getClassName(): string;
  58628. /**
  58629. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  58630. */
  58631. depthTexture: RenderTargetTexture;
  58632. /**
  58633. * Disposes each of the internal effects for a given camera.
  58634. * @param camera The camera to dispose the effect on.
  58635. */
  58636. disposeEffects(camera: Camera): void;
  58637. /**
  58638. * @hidden Internal
  58639. */ private _updateEffects(): void;
  58640. /**
  58641. * Internal
  58642. * @returns if all the contained post processes are ready.
  58643. * @hidden
  58644. */ private _isReady(): boolean;
  58645. }
  58646. }
  58647. declare module BABYLON {
  58648. /** @hidden */
  58649. export var displayPassPixelShader: {
  58650. name: string;
  58651. shader: string;
  58652. };
  58653. }
  58654. declare module BABYLON {
  58655. /**
  58656. * DisplayPassPostProcess which produces an output the same as it's input
  58657. */
  58658. export class DisplayPassPostProcess extends PostProcess {
  58659. /**
  58660. * Creates the DisplayPassPostProcess
  58661. * @param name The name of the effect.
  58662. * @param options The required width/height ratio to downsize to before computing the render pass.
  58663. * @param camera The camera to apply the render pass to.
  58664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58665. * @param engine The engine which the post process will be applied. (default: current engine)
  58666. * @param reusable If the post process can be reused on the same frame. (default: false)
  58667. */
  58668. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58669. }
  58670. }
  58671. declare module BABYLON {
  58672. /** @hidden */
  58673. export var filterPixelShader: {
  58674. name: string;
  58675. shader: string;
  58676. };
  58677. }
  58678. declare module BABYLON {
  58679. /**
  58680. * Applies a kernel filter to the image
  58681. */
  58682. export class FilterPostProcess extends PostProcess {
  58683. /** The matrix to be applied to the image */
  58684. kernelMatrix: Matrix;
  58685. /**
  58686. *
  58687. * @param name The name of the effect.
  58688. * @param kernelMatrix The matrix to be applied to the image
  58689. * @param options The required width/height ratio to downsize to before computing the render pass.
  58690. * @param camera The camera to apply the render pass to.
  58691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58692. * @param engine The engine which the post process will be applied. (default: current engine)
  58693. * @param reusable If the post process can be reused on the same frame. (default: false)
  58694. */
  58695. constructor(name: string,
  58696. /** The matrix to be applied to the image */
  58697. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58698. }
  58699. }
  58700. declare module BABYLON {
  58701. /** @hidden */
  58702. export var fxaaPixelShader: {
  58703. name: string;
  58704. shader: string;
  58705. };
  58706. }
  58707. declare module BABYLON {
  58708. /** @hidden */
  58709. export var fxaaVertexShader: {
  58710. name: string;
  58711. shader: string;
  58712. };
  58713. }
  58714. declare module BABYLON {
  58715. /**
  58716. * Fxaa post process
  58717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58718. */
  58719. export class FxaaPostProcess extends PostProcess {
  58720. /** @hidden */
  58721. texelWidth: number;
  58722. /** @hidden */
  58723. texelHeight: number;
  58724. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58725. private _getDefines;
  58726. }
  58727. }
  58728. declare module BABYLON {
  58729. /** @hidden */
  58730. export var grainPixelShader: {
  58731. name: string;
  58732. shader: string;
  58733. };
  58734. }
  58735. declare module BABYLON {
  58736. /**
  58737. * The GrainPostProcess adds noise to the image at mid luminance levels
  58738. */
  58739. export class GrainPostProcess extends PostProcess {
  58740. /**
  58741. * The intensity of the grain added (default: 30)
  58742. */
  58743. intensity: number;
  58744. /**
  58745. * If the grain should be randomized on every frame
  58746. */
  58747. animated: boolean;
  58748. /**
  58749. * Creates a new instance of @see GrainPostProcess
  58750. * @param name The name of the effect.
  58751. * @param options The required width/height ratio to downsize to before computing the render pass.
  58752. * @param camera The camera to apply the render pass to.
  58753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58754. * @param engine The engine which the post process will be applied. (default: current engine)
  58755. * @param reusable If the post process can be reused on the same frame. (default: false)
  58756. * @param textureType Type of textures used when performing the post process. (default: 0)
  58757. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58758. */
  58759. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58760. }
  58761. }
  58762. declare module BABYLON {
  58763. /** @hidden */
  58764. export var highlightsPixelShader: {
  58765. name: string;
  58766. shader: string;
  58767. };
  58768. }
  58769. declare module BABYLON {
  58770. /**
  58771. * Extracts highlights from the image
  58772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58773. */
  58774. export class HighlightsPostProcess extends PostProcess {
  58775. /**
  58776. * Extracts highlights from the image
  58777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58778. * @param name The name of the effect.
  58779. * @param options The required width/height ratio to downsize to before computing the render pass.
  58780. * @param camera The camera to apply the render pass to.
  58781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58782. * @param engine The engine which the post process will be applied. (default: current engine)
  58783. * @param reusable If the post process can be reused on the same frame. (default: false)
  58784. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58785. */
  58786. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58787. }
  58788. }
  58789. declare module BABYLON {
  58790. /** @hidden */
  58791. export var mrtFragmentDeclaration: {
  58792. name: string;
  58793. shader: string;
  58794. };
  58795. }
  58796. declare module BABYLON {
  58797. /** @hidden */
  58798. export var geometryPixelShader: {
  58799. name: string;
  58800. shader: string;
  58801. };
  58802. }
  58803. declare module BABYLON {
  58804. /** @hidden */
  58805. export var geometryVertexShader: {
  58806. name: string;
  58807. shader: string;
  58808. };
  58809. }
  58810. declare module BABYLON {
  58811. /** @hidden */
  58812. interface ISavedTransformationMatrix {
  58813. world: Matrix;
  58814. viewProjection: Matrix;
  58815. }
  58816. /**
  58817. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58818. */
  58819. export class GeometryBufferRenderer {
  58820. /**
  58821. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58822. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58823. */
  58824. static readonly POSITION_TEXTURE_TYPE: number;
  58825. /**
  58826. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58827. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58828. */
  58829. static readonly VELOCITY_TEXTURE_TYPE: number;
  58830. /**
  58831. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58832. * in order to compute objects velocities when enableVelocity is set to "true"
  58833. * @hidden
  58834. */ private _previousTransformationMatrices: {
  58835. [index: number]: ISavedTransformationMatrix;
  58836. };
  58837. /**
  58838. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58839. * in order to compute objects velocities when enableVelocity is set to "true"
  58840. * @hidden
  58841. */ private _previousBonesTransformationMatrices: {
  58842. [index: number]: Float32Array;
  58843. };
  58844. /**
  58845. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58846. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58847. */
  58848. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58849. private _scene;
  58850. private _multiRenderTarget;
  58851. private _ratio;
  58852. private _enablePosition;
  58853. private _enableVelocity;
  58854. private _positionIndex;
  58855. private _velocityIndex;
  58856. protected _effect: Effect;
  58857. protected _cachedDefines: string;
  58858. /**
  58859. * Set the render list (meshes to be rendered) used in the G buffer.
  58860. */
  58861. renderList: Mesh[];
  58862. /**
  58863. * Gets wether or not G buffer are supported by the running hardware.
  58864. * This requires draw buffer supports
  58865. */
  58866. readonly isSupported: boolean;
  58867. /**
  58868. * Returns the index of the given texture type in the G-Buffer textures array
  58869. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58870. * @returns the index of the given texture type in the G-Buffer textures array
  58871. */
  58872. getTextureIndex(textureType: number): number;
  58873. /**
  58874. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58875. */
  58876. /**
  58877. * Sets whether or not objects positions are enabled for the G buffer.
  58878. */
  58879. enablePosition: boolean;
  58880. /**
  58881. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58882. */
  58883. /**
  58884. * Sets wether or not objects velocities are enabled for the G buffer.
  58885. */
  58886. enableVelocity: boolean;
  58887. /**
  58888. * Gets the scene associated with the buffer.
  58889. */
  58890. readonly scene: Scene;
  58891. /**
  58892. * Gets the ratio used by the buffer during its creation.
  58893. * How big is the buffer related to the main canvas.
  58894. */
  58895. readonly ratio: number;
  58896. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  58897. /**
  58898. * Creates a new G Buffer for the scene
  58899. * @param scene The scene the buffer belongs to
  58900. * @param ratio How big is the buffer related to the main canvas.
  58901. */
  58902. constructor(scene: Scene, ratio?: number);
  58903. /**
  58904. * Checks wether everything is ready to render a submesh to the G buffer.
  58905. * @param subMesh the submesh to check readiness for
  58906. * @param useInstances is the mesh drawn using instance or not
  58907. * @returns true if ready otherwise false
  58908. */
  58909. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58910. /**
  58911. * Gets the current underlying G Buffer.
  58912. * @returns the buffer
  58913. */
  58914. getGBuffer(): MultiRenderTarget;
  58915. /**
  58916. * Gets the number of samples used to render the buffer (anti aliasing).
  58917. */
  58918. /**
  58919. * Sets the number of samples used to render the buffer (anti aliasing).
  58920. */
  58921. samples: number;
  58922. /**
  58923. * Disposes the renderer and frees up associated resources.
  58924. */
  58925. dispose(): void;
  58926. protected _createRenderTargets(): void;
  58927. private _copyBonesTransformationMatrices;
  58928. }
  58929. }
  58930. declare module BABYLON {
  58931. interface Scene {
  58932. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58933. /**
  58934. * Gets or Sets the current geometry buffer associated to the scene.
  58935. */
  58936. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58937. /**
  58938. * Enables a GeometryBufferRender and associates it with the scene
  58939. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58940. * @returns the GeometryBufferRenderer
  58941. */
  58942. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58943. /**
  58944. * Disables the GeometryBufferRender associated with the scene
  58945. */
  58946. disableGeometryBufferRenderer(): void;
  58947. }
  58948. /**
  58949. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58950. * in several rendering techniques.
  58951. */
  58952. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58953. /**
  58954. * The component name helpful to identify the component in the list of scene components.
  58955. */
  58956. readonly name: string;
  58957. /**
  58958. * The scene the component belongs to.
  58959. */
  58960. scene: Scene;
  58961. /**
  58962. * Creates a new instance of the component for the given scene
  58963. * @param scene Defines the scene to register the component in
  58964. */
  58965. constructor(scene: Scene);
  58966. /**
  58967. * Registers the component in a given scene
  58968. */
  58969. register(): void;
  58970. /**
  58971. * Rebuilds the elements related to this component in case of
  58972. * context lost for instance.
  58973. */
  58974. rebuild(): void;
  58975. /**
  58976. * Disposes the component and the associated ressources
  58977. */
  58978. dispose(): void;
  58979. private _gatherRenderTargets;
  58980. }
  58981. }
  58982. declare module BABYLON {
  58983. /** @hidden */
  58984. export var motionBlurPixelShader: {
  58985. name: string;
  58986. shader: string;
  58987. };
  58988. }
  58989. declare module BABYLON {
  58990. /**
  58991. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58992. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58993. * As an example, all you have to do is to create the post-process:
  58994. * var mb = new BABYLON.MotionBlurPostProcess(
  58995. * 'mb', // The name of the effect.
  58996. * scene, // The scene containing the objects to blur according to their velocity.
  58997. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58998. * camera // The camera to apply the render pass to.
  58999. * );
  59000. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59001. */
  59002. export class MotionBlurPostProcess extends PostProcess {
  59003. /**
  59004. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59005. */
  59006. motionStrength: number;
  59007. /**
  59008. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59009. */
  59010. /**
  59011. * Sets the number of iterations to be used for motion blur quality
  59012. */
  59013. motionBlurSamples: number;
  59014. private _motionBlurSamples;
  59015. private _geometryBufferRenderer;
  59016. /**
  59017. * Creates a new instance MotionBlurPostProcess
  59018. * @param name The name of the effect.
  59019. * @param scene The scene containing the objects to blur according to their velocity.
  59020. * @param options The required width/height ratio to downsize to before computing the render pass.
  59021. * @param camera The camera to apply the render pass to.
  59022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59023. * @param engine The engine which the post process will be applied. (default: current engine)
  59024. * @param reusable If the post process can be reused on the same frame. (default: false)
  59025. * @param textureType Type of textures used when performing the post process. (default: 0)
  59026. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  59027. */
  59028. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59029. /**
  59030. * Excludes the given skinned mesh from computing bones velocities.
  59031. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  59032. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59033. */
  59034. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59035. /**
  59036. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59037. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59038. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59039. */
  59040. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59041. /**
  59042. * Disposes the post process.
  59043. * @param camera The camera to dispose the post process on.
  59044. */
  59045. dispose(camera?: Camera): void;
  59046. }
  59047. }
  59048. declare module BABYLON {
  59049. /** @hidden */
  59050. export var refractionPixelShader: {
  59051. name: string;
  59052. shader: string;
  59053. };
  59054. }
  59055. declare module BABYLON {
  59056. /**
  59057. * Post process which applies a refractin texture
  59058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59059. */
  59060. export class RefractionPostProcess extends PostProcess {
  59061. /** the base color of the refraction (used to taint the rendering) */
  59062. color: Color3;
  59063. /** simulated refraction depth */
  59064. depth: number;
  59065. /** the coefficient of the base color (0 to remove base color tainting) */
  59066. colorLevel: number;
  59067. private _refTexture;
  59068. private _ownRefractionTexture;
  59069. /**
  59070. * Gets or sets the refraction texture
  59071. * Please note that you are responsible for disposing the texture if you set it manually
  59072. */
  59073. refractionTexture: Texture;
  59074. /**
  59075. * Initializes the RefractionPostProcess
  59076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59077. * @param name The name of the effect.
  59078. * @param refractionTextureUrl Url of the refraction texture to use
  59079. * @param color the base color of the refraction (used to taint the rendering)
  59080. * @param depth simulated refraction depth
  59081. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59082. * @param camera The camera to apply the render pass to.
  59083. * @param options The required width/height ratio to downsize to before computing the render pass.
  59084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59085. * @param engine The engine which the post process will be applied. (default: current engine)
  59086. * @param reusable If the post process can be reused on the same frame. (default: false)
  59087. */
  59088. constructor(name: string, refractionTextureUrl: string,
  59089. /** the base color of the refraction (used to taint the rendering) */
  59090. color: Color3,
  59091. /** simulated refraction depth */
  59092. depth: number,
  59093. /** the coefficient of the base color (0 to remove base color tainting) */
  59094. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59095. /**
  59096. * Disposes of the post process
  59097. * @param camera Camera to dispose post process on
  59098. */
  59099. dispose(camera: Camera): void;
  59100. }
  59101. }
  59102. declare module BABYLON {
  59103. /** @hidden */
  59104. export var sharpenPixelShader: {
  59105. name: string;
  59106. shader: string;
  59107. };
  59108. }
  59109. declare module BABYLON {
  59110. /**
  59111. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59112. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59113. */
  59114. export class SharpenPostProcess extends PostProcess {
  59115. /**
  59116. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59117. */
  59118. colorAmount: number;
  59119. /**
  59120. * How much sharpness should be applied (default: 0.3)
  59121. */
  59122. edgeAmount: number;
  59123. /**
  59124. * Creates a new instance ConvolutionPostProcess
  59125. * @param name The name of the effect.
  59126. * @param options The required width/height ratio to downsize to before computing the render pass.
  59127. * @param camera The camera to apply the render pass to.
  59128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59129. * @param engine The engine which the post process will be applied. (default: current engine)
  59130. * @param reusable If the post process can be reused on the same frame. (default: false)
  59131. * @param textureType Type of textures used when performing the post process. (default: 0)
  59132. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  59133. */
  59134. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59135. }
  59136. }
  59137. declare module BABYLON {
  59138. /**
  59139. * PostProcessRenderPipeline
  59140. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59141. */
  59142. export class PostProcessRenderPipeline {
  59143. private engine;
  59144. private _renderEffects;
  59145. private _renderEffectsForIsolatedPass;
  59146. /**
  59147. * List of inspectable custom properties (used by the Inspector)
  59148. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59149. */
  59150. inspectableCustomProperties: IInspectable[];
  59151. /**
  59152. * @hidden
  59153. */
  59154. protected _cameras: Camera[];
  59155. /** @hidden */ private _name: string;
  59156. /**
  59157. * Gets pipeline name
  59158. */
  59159. readonly name: string;
  59160. /**
  59161. * Initializes a PostProcessRenderPipeline
  59162. * @param engine engine to add the pipeline to
  59163. * @param name name of the pipeline
  59164. */
  59165. constructor(engine: Engine, name: string);
  59166. /**
  59167. * Gets the class name
  59168. * @returns "PostProcessRenderPipeline"
  59169. */
  59170. getClassName(): string;
  59171. /**
  59172. * If all the render effects in the pipeline are supported
  59173. */
  59174. readonly isSupported: boolean;
  59175. /**
  59176. * Adds an effect to the pipeline
  59177. * @param renderEffect the effect to add
  59178. */
  59179. addEffect(renderEffect: PostProcessRenderEffect): void;
  59180. /** @hidden */ private _rebuild(): void;
  59181. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  59182. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59183. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59184. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59185. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  59186. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  59187. /** @hidden */ private _detachCameras(cameras: Camera): void;
  59188. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  59189. /** @hidden */ private _update(): void;
  59190. /** @hidden */ private _reset(): void;
  59191. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59192. /**
  59193. * Disposes of the pipeline
  59194. */
  59195. dispose(): void;
  59196. }
  59197. }
  59198. declare module BABYLON {
  59199. /**
  59200. * PostProcessRenderPipelineManager class
  59201. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59202. */
  59203. export class PostProcessRenderPipelineManager {
  59204. private _renderPipelines;
  59205. /**
  59206. * Initializes a PostProcessRenderPipelineManager
  59207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59208. */
  59209. constructor();
  59210. /**
  59211. * Gets the list of supported render pipelines
  59212. */
  59213. readonly supportedPipelines: PostProcessRenderPipeline[];
  59214. /**
  59215. * Adds a pipeline to the manager
  59216. * @param renderPipeline The pipeline to add
  59217. */
  59218. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59219. /**
  59220. * Attaches a camera to the pipeline
  59221. * @param renderPipelineName The name of the pipeline to attach to
  59222. * @param cameras the camera to attach
  59223. * @param unique if the camera can be attached multiple times to the pipeline
  59224. */
  59225. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59226. /**
  59227. * Detaches a camera from the pipeline
  59228. * @param renderPipelineName The name of the pipeline to detach from
  59229. * @param cameras the camera to detach
  59230. */
  59231. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59232. /**
  59233. * Enables an effect by name on a pipeline
  59234. * @param renderPipelineName the name of the pipeline to enable the effect in
  59235. * @param renderEffectName the name of the effect to enable
  59236. * @param cameras the cameras that the effect should be enabled on
  59237. */
  59238. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59239. /**
  59240. * Disables an effect by name on a pipeline
  59241. * @param renderPipelineName the name of the pipeline to disable the effect in
  59242. * @param renderEffectName the name of the effect to disable
  59243. * @param cameras the cameras that the effect should be disabled on
  59244. */
  59245. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59246. /**
  59247. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59248. */
  59249. update(): void;
  59250. /** @hidden */ private _rebuild(): void;
  59251. /**
  59252. * Disposes of the manager and pipelines
  59253. */
  59254. dispose(): void;
  59255. }
  59256. }
  59257. declare module BABYLON {
  59258. interface Scene {
  59259. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59260. /**
  59261. * Gets the postprocess render pipeline manager
  59262. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59263. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59264. */
  59265. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59266. }
  59267. /**
  59268. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59269. */
  59270. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59271. /**
  59272. * The component name helpfull to identify the component in the list of scene components.
  59273. */
  59274. readonly name: string;
  59275. /**
  59276. * The scene the component belongs to.
  59277. */
  59278. scene: Scene;
  59279. /**
  59280. * Creates a new instance of the component for the given scene
  59281. * @param scene Defines the scene to register the component in
  59282. */
  59283. constructor(scene: Scene);
  59284. /**
  59285. * Registers the component in a given scene
  59286. */
  59287. register(): void;
  59288. /**
  59289. * Rebuilds the elements related to this component in case of
  59290. * context lost for instance.
  59291. */
  59292. rebuild(): void;
  59293. /**
  59294. * Disposes the component and the associated ressources
  59295. */
  59296. dispose(): void;
  59297. private _gatherRenderTargets;
  59298. }
  59299. }
  59300. declare module BABYLON {
  59301. /**
  59302. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59303. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59304. */
  59305. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59306. private _scene;
  59307. private _camerasToBeAttached;
  59308. /**
  59309. * ID of the sharpen post process,
  59310. */
  59311. private readonly SharpenPostProcessId;
  59312. /**
  59313. * @ignore
  59314. * ID of the image processing post process;
  59315. */
  59316. readonly ImageProcessingPostProcessId: string;
  59317. /**
  59318. * @ignore
  59319. * ID of the Fast Approximate Anti-Aliasing post process;
  59320. */
  59321. readonly FxaaPostProcessId: string;
  59322. /**
  59323. * ID of the chromatic aberration post process,
  59324. */
  59325. private readonly ChromaticAberrationPostProcessId;
  59326. /**
  59327. * ID of the grain post process
  59328. */
  59329. private readonly GrainPostProcessId;
  59330. /**
  59331. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59332. */
  59333. sharpen: SharpenPostProcess;
  59334. private _sharpenEffect;
  59335. private bloom;
  59336. /**
  59337. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59338. */
  59339. depthOfField: DepthOfFieldEffect;
  59340. /**
  59341. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59342. */
  59343. fxaa: FxaaPostProcess;
  59344. /**
  59345. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59346. */
  59347. imageProcessing: ImageProcessingPostProcess;
  59348. /**
  59349. * Chromatic aberration post process which will shift rgb colors in the image
  59350. */
  59351. chromaticAberration: ChromaticAberrationPostProcess;
  59352. private _chromaticAberrationEffect;
  59353. /**
  59354. * Grain post process which add noise to the image
  59355. */
  59356. grain: GrainPostProcess;
  59357. private _grainEffect;
  59358. /**
  59359. * Glow post process which adds a glow to emissive areas of the image
  59360. */
  59361. private _glowLayer;
  59362. /**
  59363. * Animations which can be used to tweak settings over a period of time
  59364. */
  59365. animations: Animation[];
  59366. private _imageProcessingConfigurationObserver;
  59367. private _sharpenEnabled;
  59368. private _bloomEnabled;
  59369. private _depthOfFieldEnabled;
  59370. private _depthOfFieldBlurLevel;
  59371. private _fxaaEnabled;
  59372. private _imageProcessingEnabled;
  59373. private _defaultPipelineTextureType;
  59374. private _bloomScale;
  59375. private _chromaticAberrationEnabled;
  59376. private _grainEnabled;
  59377. private _buildAllowed;
  59378. /**
  59379. * Gets active scene
  59380. */
  59381. readonly scene: Scene;
  59382. /**
  59383. * Enable or disable the sharpen process from the pipeline
  59384. */
  59385. sharpenEnabled: boolean;
  59386. private _resizeObserver;
  59387. private _hardwareScaleLevel;
  59388. private _bloomKernel;
  59389. /**
  59390. * Specifies the size of the bloom blur kernel, relative to the final output size
  59391. */
  59392. bloomKernel: number;
  59393. /**
  59394. * Specifies the weight of the bloom in the final rendering
  59395. */
  59396. private _bloomWeight;
  59397. /**
  59398. * Specifies the luma threshold for the area that will be blurred by the bloom
  59399. */
  59400. private _bloomThreshold;
  59401. private _hdr;
  59402. /**
  59403. * The strength of the bloom.
  59404. */
  59405. bloomWeight: number;
  59406. /**
  59407. * The strength of the bloom.
  59408. */
  59409. bloomThreshold: number;
  59410. /**
  59411. * The scale of the bloom, lower value will provide better performance.
  59412. */
  59413. bloomScale: number;
  59414. /**
  59415. * Enable or disable the bloom from the pipeline
  59416. */
  59417. bloomEnabled: boolean;
  59418. private _rebuildBloom;
  59419. /**
  59420. * If the depth of field is enabled.
  59421. */
  59422. depthOfFieldEnabled: boolean;
  59423. /**
  59424. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59425. */
  59426. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59427. /**
  59428. * If the anti aliasing is enabled.
  59429. */
  59430. fxaaEnabled: boolean;
  59431. private _samples;
  59432. /**
  59433. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59434. */
  59435. samples: number;
  59436. /**
  59437. * If image processing is enabled.
  59438. */
  59439. imageProcessingEnabled: boolean;
  59440. /**
  59441. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59442. */
  59443. glowLayerEnabled: boolean;
  59444. /**
  59445. * Gets the glow layer (or null if not defined)
  59446. */
  59447. readonly glowLayer: Nullable<GlowLayer>;
  59448. /**
  59449. * Enable or disable the chromaticAberration process from the pipeline
  59450. */
  59451. chromaticAberrationEnabled: boolean;
  59452. /**
  59453. * Enable or disable the grain process from the pipeline
  59454. */
  59455. grainEnabled: boolean;
  59456. /**
  59457. * @constructor
  59458. * @param name - The rendering pipeline name (default: "")
  59459. * @param hdr - If high dynamic range textures should be used (default: true)
  59460. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59461. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59462. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59463. */
  59464. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59465. /**
  59466. * Get the class name
  59467. * @returns "DefaultRenderingPipeline"
  59468. */
  59469. getClassName(): string;
  59470. /**
  59471. * Force the compilation of the entire pipeline.
  59472. */
  59473. prepare(): void;
  59474. private _hasCleared;
  59475. private _prevPostProcess;
  59476. private _prevPrevPostProcess;
  59477. private _setAutoClearAndTextureSharing;
  59478. private _depthOfFieldSceneObserver;
  59479. private _buildPipeline;
  59480. private _disposePostProcesses;
  59481. /**
  59482. * Adds a camera to the pipeline
  59483. * @param camera the camera to be added
  59484. */
  59485. addCamera(camera: Camera): void;
  59486. /**
  59487. * Removes a camera from the pipeline
  59488. * @param camera the camera to remove
  59489. */
  59490. removeCamera(camera: Camera): void;
  59491. /**
  59492. * Dispose of the pipeline and stop all post processes
  59493. */
  59494. dispose(): void;
  59495. /**
  59496. * Serialize the rendering pipeline (Used when exporting)
  59497. * @returns the serialized object
  59498. */
  59499. serialize(): any;
  59500. /**
  59501. * Parse the serialized pipeline
  59502. * @param source Source pipeline.
  59503. * @param scene The scene to load the pipeline to.
  59504. * @param rootUrl The URL of the serialized pipeline.
  59505. * @returns An instantiated pipeline from the serialized object.
  59506. */
  59507. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59508. }
  59509. }
  59510. declare module BABYLON {
  59511. /** @hidden */
  59512. export var lensHighlightsPixelShader: {
  59513. name: string;
  59514. shader: string;
  59515. };
  59516. }
  59517. declare module BABYLON {
  59518. /** @hidden */
  59519. export var depthOfFieldPixelShader: {
  59520. name: string;
  59521. shader: string;
  59522. };
  59523. }
  59524. declare module BABYLON {
  59525. /**
  59526. * BABYLON.JS Chromatic Aberration GLSL Shader
  59527. * Author: Olivier Guyot
  59528. * Separates very slightly R, G and B colors on the edges of the screen
  59529. * Inspired by Francois Tarlier & Martins Upitis
  59530. */
  59531. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59532. /**
  59533. * @ignore
  59534. * The chromatic aberration PostProcess id in the pipeline
  59535. */
  59536. LensChromaticAberrationEffect: string;
  59537. /**
  59538. * @ignore
  59539. * The highlights enhancing PostProcess id in the pipeline
  59540. */
  59541. HighlightsEnhancingEffect: string;
  59542. /**
  59543. * @ignore
  59544. * The depth-of-field PostProcess id in the pipeline
  59545. */
  59546. LensDepthOfFieldEffect: string;
  59547. private _scene;
  59548. private _depthTexture;
  59549. private _grainTexture;
  59550. private _chromaticAberrationPostProcess;
  59551. private _highlightsPostProcess;
  59552. private _depthOfFieldPostProcess;
  59553. private _edgeBlur;
  59554. private _grainAmount;
  59555. private _chromaticAberration;
  59556. private _distortion;
  59557. private _highlightsGain;
  59558. private _highlightsThreshold;
  59559. private _dofDistance;
  59560. private _dofAperture;
  59561. private _dofDarken;
  59562. private _dofPentagon;
  59563. private _blurNoise;
  59564. /**
  59565. * @constructor
  59566. *
  59567. * Effect parameters are as follow:
  59568. * {
  59569. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59570. * edge_blur: number; // from 0 to x (1 for realism)
  59571. * distortion: number; // from 0 to x (1 for realism)
  59572. * grain_amount: number; // from 0 to 1
  59573. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59574. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59575. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59576. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59577. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59578. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59579. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59580. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59581. * }
  59582. * Note: if an effect parameter is unset, effect is disabled
  59583. *
  59584. * @param name The rendering pipeline name
  59585. * @param parameters - An object containing all parameters (see above)
  59586. * @param scene The scene linked to this pipeline
  59587. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  59588. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59589. */
  59590. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59591. /**
  59592. * Get the class name
  59593. * @returns "LensRenderingPipeline"
  59594. */
  59595. getClassName(): string;
  59596. /**
  59597. * Gets associated scene
  59598. */
  59599. readonly scene: Scene;
  59600. /**
  59601. * Gets or sets the edge blur
  59602. */
  59603. edgeBlur: number;
  59604. /**
  59605. * Gets or sets the grain amount
  59606. */
  59607. grainAmount: number;
  59608. /**
  59609. * Gets or sets the chromatic aberration amount
  59610. */
  59611. chromaticAberration: number;
  59612. /**
  59613. * Gets or sets the depth of field aperture
  59614. */
  59615. dofAperture: number;
  59616. /**
  59617. * Gets or sets the edge distortion
  59618. */
  59619. edgeDistortion: number;
  59620. /**
  59621. * Gets or sets the depth of field distortion
  59622. */
  59623. dofDistortion: number;
  59624. /**
  59625. * Gets or sets the darken out of focus amount
  59626. */
  59627. darkenOutOfFocus: number;
  59628. /**
  59629. * Gets or sets a boolean indicating if blur noise is enabled
  59630. */
  59631. blurNoise: boolean;
  59632. /**
  59633. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59634. */
  59635. pentagonBokeh: boolean;
  59636. /**
  59637. * Gets or sets the highlight grain amount
  59638. */
  59639. highlightsGain: number;
  59640. /**
  59641. * Gets or sets the highlight threshold
  59642. */
  59643. highlightsThreshold: number;
  59644. /**
  59645. * Sets the amount of blur at the edges
  59646. * @param amount blur amount
  59647. */
  59648. setEdgeBlur(amount: number): void;
  59649. /**
  59650. * Sets edge blur to 0
  59651. */
  59652. disableEdgeBlur(): void;
  59653. /**
  59654. * Sets the amout of grain
  59655. * @param amount Amount of grain
  59656. */
  59657. setGrainAmount(amount: number): void;
  59658. /**
  59659. * Set grain amount to 0
  59660. */
  59661. disableGrain(): void;
  59662. /**
  59663. * Sets the chromatic aberration amount
  59664. * @param amount amount of chromatic aberration
  59665. */
  59666. setChromaticAberration(amount: number): void;
  59667. /**
  59668. * Sets chromatic aberration amount to 0
  59669. */
  59670. disableChromaticAberration(): void;
  59671. /**
  59672. * Sets the EdgeDistortion amount
  59673. * @param amount amount of EdgeDistortion
  59674. */
  59675. setEdgeDistortion(amount: number): void;
  59676. /**
  59677. * Sets edge distortion to 0
  59678. */
  59679. disableEdgeDistortion(): void;
  59680. /**
  59681. * Sets the FocusDistance amount
  59682. * @param amount amount of FocusDistance
  59683. */
  59684. setFocusDistance(amount: number): void;
  59685. /**
  59686. * Disables depth of field
  59687. */
  59688. disableDepthOfField(): void;
  59689. /**
  59690. * Sets the Aperture amount
  59691. * @param amount amount of Aperture
  59692. */
  59693. setAperture(amount: number): void;
  59694. /**
  59695. * Sets the DarkenOutOfFocus amount
  59696. * @param amount amount of DarkenOutOfFocus
  59697. */
  59698. setDarkenOutOfFocus(amount: number): void;
  59699. private _pentagonBokehIsEnabled;
  59700. /**
  59701. * Creates a pentagon bokeh effect
  59702. */
  59703. enablePentagonBokeh(): void;
  59704. /**
  59705. * Disables the pentagon bokeh effect
  59706. */
  59707. disablePentagonBokeh(): void;
  59708. /**
  59709. * Enables noise blur
  59710. */
  59711. enableNoiseBlur(): void;
  59712. /**
  59713. * Disables noise blur
  59714. */
  59715. disableNoiseBlur(): void;
  59716. /**
  59717. * Sets the HighlightsGain amount
  59718. * @param amount amount of HighlightsGain
  59719. */
  59720. setHighlightsGain(amount: number): void;
  59721. /**
  59722. * Sets the HighlightsThreshold amount
  59723. * @param amount amount of HighlightsThreshold
  59724. */
  59725. setHighlightsThreshold(amount: number): void;
  59726. /**
  59727. * Disables highlights
  59728. */
  59729. disableHighlights(): void;
  59730. /**
  59731. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59732. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59733. */
  59734. dispose(disableDepthRender?: boolean): void;
  59735. private _createChromaticAberrationPostProcess;
  59736. private _createHighlightsPostProcess;
  59737. private _createDepthOfFieldPostProcess;
  59738. private _createGrainTexture;
  59739. }
  59740. }
  59741. declare module BABYLON {
  59742. /** @hidden */
  59743. export var ssao2PixelShader: {
  59744. name: string;
  59745. shader: string;
  59746. };
  59747. }
  59748. declare module BABYLON {
  59749. /** @hidden */
  59750. export var ssaoCombinePixelShader: {
  59751. name: string;
  59752. shader: string;
  59753. };
  59754. }
  59755. declare module BABYLON {
  59756. /**
  59757. * Render pipeline to produce ssao effect
  59758. */
  59759. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59760. /**
  59761. * @ignore
  59762. * The PassPostProcess id in the pipeline that contains the original scene color
  59763. */
  59764. SSAOOriginalSceneColorEffect: string;
  59765. /**
  59766. * @ignore
  59767. * The SSAO PostProcess id in the pipeline
  59768. */
  59769. SSAORenderEffect: string;
  59770. /**
  59771. * @ignore
  59772. * The horizontal blur PostProcess id in the pipeline
  59773. */
  59774. SSAOBlurHRenderEffect: string;
  59775. /**
  59776. * @ignore
  59777. * The vertical blur PostProcess id in the pipeline
  59778. */
  59779. SSAOBlurVRenderEffect: string;
  59780. /**
  59781. * @ignore
  59782. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59783. */
  59784. SSAOCombineRenderEffect: string;
  59785. /**
  59786. * The output strength of the SSAO post-process. Default value is 1.0.
  59787. */
  59788. totalStrength: number;
  59789. /**
  59790. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59791. */
  59792. maxZ: number;
  59793. /**
  59794. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59795. */
  59796. minZAspect: number;
  59797. private _samples;
  59798. /**
  59799. * Number of samples used for the SSAO calculations. Default value is 8
  59800. */
  59801. samples: number;
  59802. private _textureSamples;
  59803. /**
  59804. * Number of samples to use for antialiasing
  59805. */
  59806. textureSamples: number;
  59807. /**
  59808. * Ratio object used for SSAO ratio and blur ratio
  59809. */
  59810. private _ratio;
  59811. /**
  59812. * Dynamically generated sphere sampler.
  59813. */
  59814. private _sampleSphere;
  59815. /**
  59816. * Blur filter offsets
  59817. */
  59818. private _samplerOffsets;
  59819. private _expensiveBlur;
  59820. /**
  59821. * If bilateral blur should be used
  59822. */
  59823. expensiveBlur: boolean;
  59824. /**
  59825. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59826. */
  59827. radius: number;
  59828. /**
  59829. * The base color of the SSAO post-process
  59830. * The final result is "base + ssao" between [0, 1]
  59831. */
  59832. base: number;
  59833. /**
  59834. * Support test.
  59835. */
  59836. static readonly IsSupported: boolean;
  59837. private _scene;
  59838. private _depthTexture;
  59839. private _normalTexture;
  59840. private _randomTexture;
  59841. private _originalColorPostProcess;
  59842. private _ssaoPostProcess;
  59843. private _blurHPostProcess;
  59844. private _blurVPostProcess;
  59845. private _ssaoCombinePostProcess;
  59846. private _firstUpdate;
  59847. /**
  59848. * Gets active scene
  59849. */
  59850. readonly scene: Scene;
  59851. /**
  59852. * @constructor
  59853. * @param name The rendering pipeline name
  59854. * @param scene The scene linked to this pipeline
  59855. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  59856. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59857. */
  59858. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59859. /**
  59860. * Get the class name
  59861. * @returns "SSAO2RenderingPipeline"
  59862. */
  59863. getClassName(): string;
  59864. /**
  59865. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59866. */
  59867. dispose(disableGeometryBufferRenderer?: boolean): void;
  59868. private _createBlurPostProcess;
  59869. /** @hidden */ private _rebuild(): void;
  59870. private _bits;
  59871. private _radicalInverse_VdC;
  59872. private _hammersley;
  59873. private _hemisphereSample_uniform;
  59874. private _generateHemisphere;
  59875. private _createSSAOPostProcess;
  59876. private _createSSAOCombinePostProcess;
  59877. private _createRandomTexture;
  59878. /**
  59879. * Serialize the rendering pipeline (Used when exporting)
  59880. * @returns the serialized object
  59881. */
  59882. serialize(): any;
  59883. /**
  59884. * Parse the serialized pipeline
  59885. * @param source Source pipeline.
  59886. * @param scene The scene to load the pipeline to.
  59887. * @param rootUrl The URL of the serialized pipeline.
  59888. * @returns An instantiated pipeline from the serialized object.
  59889. */
  59890. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59891. }
  59892. }
  59893. declare module BABYLON {
  59894. /** @hidden */
  59895. export var ssaoPixelShader: {
  59896. name: string;
  59897. shader: string;
  59898. };
  59899. }
  59900. declare module BABYLON {
  59901. /**
  59902. * Render pipeline to produce ssao effect
  59903. */
  59904. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59905. /**
  59906. * @ignore
  59907. * The PassPostProcess id in the pipeline that contains the original scene color
  59908. */
  59909. SSAOOriginalSceneColorEffect: string;
  59910. /**
  59911. * @ignore
  59912. * The SSAO PostProcess id in the pipeline
  59913. */
  59914. SSAORenderEffect: string;
  59915. /**
  59916. * @ignore
  59917. * The horizontal blur PostProcess id in the pipeline
  59918. */
  59919. SSAOBlurHRenderEffect: string;
  59920. /**
  59921. * @ignore
  59922. * The vertical blur PostProcess id in the pipeline
  59923. */
  59924. SSAOBlurVRenderEffect: string;
  59925. /**
  59926. * @ignore
  59927. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59928. */
  59929. SSAOCombineRenderEffect: string;
  59930. /**
  59931. * The output strength of the SSAO post-process. Default value is 1.0.
  59932. */
  59933. totalStrength: number;
  59934. /**
  59935. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59936. */
  59937. radius: number;
  59938. /**
  59939. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59940. * Must not be equal to fallOff and superior to fallOff.
  59941. * Default value is 0.0075
  59942. */
  59943. area: number;
  59944. /**
  59945. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59946. * Must not be equal to area and inferior to area.
  59947. * Default value is 0.000001
  59948. */
  59949. fallOff: number;
  59950. /**
  59951. * The base color of the SSAO post-process
  59952. * The final result is "base + ssao" between [0, 1]
  59953. */
  59954. base: number;
  59955. private _scene;
  59956. private _depthTexture;
  59957. private _randomTexture;
  59958. private _originalColorPostProcess;
  59959. private _ssaoPostProcess;
  59960. private _blurHPostProcess;
  59961. private _blurVPostProcess;
  59962. private _ssaoCombinePostProcess;
  59963. private _firstUpdate;
  59964. /**
  59965. * Gets active scene
  59966. */
  59967. readonly scene: Scene;
  59968. /**
  59969. * @constructor
  59970. * @param name - The rendering pipeline name
  59971. * @param scene - The scene linked to this pipeline
  59972. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  59973. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59974. */
  59975. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59976. /**
  59977. * Get the class name
  59978. * @returns "SSAORenderingPipeline"
  59979. */
  59980. getClassName(): string;
  59981. /**
  59982. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59983. */
  59984. dispose(disableDepthRender?: boolean): void;
  59985. private _createBlurPostProcess;
  59986. /** @hidden */ private _rebuild(): void;
  59987. private _createSSAOPostProcess;
  59988. private _createSSAOCombinePostProcess;
  59989. private _createRandomTexture;
  59990. }
  59991. }
  59992. declare module BABYLON {
  59993. /** @hidden */
  59994. export var standardPixelShader: {
  59995. name: string;
  59996. shader: string;
  59997. };
  59998. }
  59999. declare module BABYLON {
  60000. /**
  60001. * Standard rendering pipeline
  60002. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60003. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60004. */
  60005. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60006. /**
  60007. * Public members
  60008. */
  60009. /**
  60010. * Post-process which contains the original scene color before the pipeline applies all the effects
  60011. */
  60012. originalPostProcess: Nullable<PostProcess>;
  60013. /**
  60014. * Post-process used to down scale an image x4
  60015. */
  60016. downSampleX4PostProcess: Nullable<PostProcess>;
  60017. /**
  60018. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60019. */
  60020. brightPassPostProcess: Nullable<PostProcess>;
  60021. /**
  60022. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60023. */
  60024. blurHPostProcesses: PostProcess[];
  60025. /**
  60026. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60027. */
  60028. blurVPostProcesses: PostProcess[];
  60029. /**
  60030. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60031. */
  60032. textureAdderPostProcess: Nullable<PostProcess>;
  60033. /**
  60034. * Post-process used to create volumetric lighting effect
  60035. */
  60036. volumetricLightPostProcess: Nullable<PostProcess>;
  60037. /**
  60038. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60039. */
  60040. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60041. /**
  60042. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60043. */
  60044. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60045. /**
  60046. * Post-process used to merge the volumetric light effect and the real scene color
  60047. */
  60048. volumetricLightMergePostProces: Nullable<PostProcess>;
  60049. /**
  60050. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60051. */
  60052. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60053. /**
  60054. * Base post-process used to calculate the average luminance of the final image for HDR
  60055. */
  60056. luminancePostProcess: Nullable<PostProcess>;
  60057. /**
  60058. * Post-processes used to create down sample post-processes in order to get
  60059. * the average luminance of the final image for HDR
  60060. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60061. */
  60062. luminanceDownSamplePostProcesses: PostProcess[];
  60063. /**
  60064. * Post-process used to create a HDR effect (light adaptation)
  60065. */
  60066. hdrPostProcess: Nullable<PostProcess>;
  60067. /**
  60068. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60069. */
  60070. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60071. /**
  60072. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60073. */
  60074. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60075. /**
  60076. * Post-process used to merge the final HDR post-process and the real scene color
  60077. */
  60078. hdrFinalPostProcess: Nullable<PostProcess>;
  60079. /**
  60080. * Post-process used to create a lens flare effect
  60081. */
  60082. lensFlarePostProcess: Nullable<PostProcess>;
  60083. /**
  60084. * Post-process that merges the result of the lens flare post-process and the real scene color
  60085. */
  60086. lensFlareComposePostProcess: Nullable<PostProcess>;
  60087. /**
  60088. * Post-process used to create a motion blur effect
  60089. */
  60090. motionBlurPostProcess: Nullable<PostProcess>;
  60091. /**
  60092. * Post-process used to create a depth of field effect
  60093. */
  60094. depthOfFieldPostProcess: Nullable<PostProcess>;
  60095. /**
  60096. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60097. */
  60098. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60099. /**
  60100. * Represents the brightness threshold in order to configure the illuminated surfaces
  60101. */
  60102. brightThreshold: number;
  60103. /**
  60104. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60105. */
  60106. blurWidth: number;
  60107. /**
  60108. * Sets if the blur for highlighted surfaces must be only horizontal
  60109. */
  60110. horizontalBlur: boolean;
  60111. /**
  60112. * Gets the overall exposure used by the pipeline
  60113. */
  60114. /**
  60115. * Sets the overall exposure used by the pipeline
  60116. */
  60117. exposure: number;
  60118. /**
  60119. * Texture used typically to simulate "dirty" on camera lens
  60120. */
  60121. lensTexture: Nullable<Texture>;
  60122. /**
  60123. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60124. */
  60125. volumetricLightCoefficient: number;
  60126. /**
  60127. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60128. */
  60129. volumetricLightPower: number;
  60130. /**
  60131. * Used the set the blur intensity to smooth the volumetric lights
  60132. */
  60133. volumetricLightBlurScale: number;
  60134. /**
  60135. * Light (spot or directional) used to generate the volumetric lights rays
  60136. * The source light must have a shadow generate so the pipeline can get its
  60137. * depth map
  60138. */
  60139. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60140. /**
  60141. * For eye adaptation, represents the minimum luminance the eye can see
  60142. */
  60143. hdrMinimumLuminance: number;
  60144. /**
  60145. * For eye adaptation, represents the decrease luminance speed
  60146. */
  60147. hdrDecreaseRate: number;
  60148. /**
  60149. * For eye adaptation, represents the increase luminance speed
  60150. */
  60151. hdrIncreaseRate: number;
  60152. /**
  60153. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60154. */
  60155. /**
  60156. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60157. */
  60158. hdrAutoExposure: boolean;
  60159. /**
  60160. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60161. */
  60162. lensColorTexture: Nullable<Texture>;
  60163. /**
  60164. * The overall strengh for the lens flare effect
  60165. */
  60166. lensFlareStrength: number;
  60167. /**
  60168. * Dispersion coefficient for lens flare ghosts
  60169. */
  60170. lensFlareGhostDispersal: number;
  60171. /**
  60172. * Main lens flare halo width
  60173. */
  60174. lensFlareHaloWidth: number;
  60175. /**
  60176. * Based on the lens distortion effect, defines how much the lens flare result
  60177. * is distorted
  60178. */
  60179. lensFlareDistortionStrength: number;
  60180. /**
  60181. * Configures the blur intensity used for for lens flare (halo)
  60182. */
  60183. lensFlareBlurWidth: number;
  60184. /**
  60185. * Lens star texture must be used to simulate rays on the flares and is available
  60186. * in the documentation
  60187. */
  60188. lensStarTexture: Nullable<Texture>;
  60189. /**
  60190. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60191. * flare effect by taking account of the dirt texture
  60192. */
  60193. lensFlareDirtTexture: Nullable<Texture>;
  60194. /**
  60195. * Represents the focal length for the depth of field effect
  60196. */
  60197. depthOfFieldDistance: number;
  60198. /**
  60199. * Represents the blur intensity for the blurred part of the depth of field effect
  60200. */
  60201. depthOfFieldBlurWidth: number;
  60202. /**
  60203. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60204. */
  60205. /**
  60206. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60207. */
  60208. motionStrength: number;
  60209. /**
  60210. * Gets wether or not the motion blur post-process is object based or screen based.
  60211. */
  60212. /**
  60213. * Sets wether or not the motion blur post-process should be object based or screen based
  60214. */
  60215. objectBasedMotionBlur: boolean;
  60216. /**
  60217. * List of animations for the pipeline (IAnimatable implementation)
  60218. */
  60219. animations: Animation[];
  60220. /**
  60221. * Private members
  60222. */
  60223. private _scene;
  60224. private _currentDepthOfFieldSource;
  60225. private _basePostProcess;
  60226. private _fixedExposure;
  60227. private _currentExposure;
  60228. private _hdrAutoExposure;
  60229. private _hdrCurrentLuminance;
  60230. private _motionStrength;
  60231. private _isObjectBasedMotionBlur;
  60232. private _floatTextureType;
  60233. private _camerasToBeAttached;
  60234. private _ratio;
  60235. private _bloomEnabled;
  60236. private _depthOfFieldEnabled;
  60237. private _vlsEnabled;
  60238. private _lensFlareEnabled;
  60239. private _hdrEnabled;
  60240. private _motionBlurEnabled;
  60241. private _fxaaEnabled;
  60242. private _motionBlurSamples;
  60243. private _volumetricLightStepsCount;
  60244. private _samples;
  60245. /**
  60246. * @ignore
  60247. * Specifies if the bloom pipeline is enabled
  60248. */
  60249. BloomEnabled: boolean;
  60250. /**
  60251. * @ignore
  60252. * Specifies if the depth of field pipeline is enabed
  60253. */
  60254. DepthOfFieldEnabled: boolean;
  60255. /**
  60256. * @ignore
  60257. * Specifies if the lens flare pipeline is enabed
  60258. */
  60259. LensFlareEnabled: boolean;
  60260. /**
  60261. * @ignore
  60262. * Specifies if the HDR pipeline is enabled
  60263. */
  60264. HDREnabled: boolean;
  60265. /**
  60266. * @ignore
  60267. * Specifies if the volumetric lights scattering effect is enabled
  60268. */
  60269. VLSEnabled: boolean;
  60270. /**
  60271. * @ignore
  60272. * Specifies if the motion blur effect is enabled
  60273. */
  60274. MotionBlurEnabled: boolean;
  60275. /**
  60276. * Specifies if anti-aliasing is enabled
  60277. */
  60278. fxaaEnabled: boolean;
  60279. /**
  60280. * Specifies the number of steps used to calculate the volumetric lights
  60281. * Typically in interval [50, 200]
  60282. */
  60283. volumetricLightStepsCount: number;
  60284. /**
  60285. * Specifies the number of samples used for the motion blur effect
  60286. * Typically in interval [16, 64]
  60287. */
  60288. motionBlurSamples: number;
  60289. /**
  60290. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60291. */
  60292. samples: number;
  60293. /**
  60294. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60295. * @constructor
  60296. * @param name The rendering pipeline name
  60297. * @param scene The scene linked to this pipeline
  60298. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  60299. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60300. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60301. */
  60302. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60303. private _buildPipeline;
  60304. private _createDownSampleX4PostProcess;
  60305. private _createBrightPassPostProcess;
  60306. private _createBlurPostProcesses;
  60307. private _createTextureAdderPostProcess;
  60308. private _createVolumetricLightPostProcess;
  60309. private _createLuminancePostProcesses;
  60310. private _createHdrPostProcess;
  60311. private _createLensFlarePostProcess;
  60312. private _createDepthOfFieldPostProcess;
  60313. private _createMotionBlurPostProcess;
  60314. private _getDepthTexture;
  60315. private _disposePostProcesses;
  60316. /**
  60317. * Dispose of the pipeline and stop all post processes
  60318. */
  60319. dispose(): void;
  60320. /**
  60321. * Serialize the rendering pipeline (Used when exporting)
  60322. * @returns the serialized object
  60323. */
  60324. serialize(): any;
  60325. /**
  60326. * Parse the serialized pipeline
  60327. * @param source Source pipeline.
  60328. * @param scene The scene to load the pipeline to.
  60329. * @param rootUrl The URL of the serialized pipeline.
  60330. * @returns An instantiated pipeline from the serialized object.
  60331. */
  60332. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60333. /**
  60334. * Luminance steps
  60335. */
  60336. static LuminanceSteps: number;
  60337. }
  60338. }
  60339. declare module BABYLON {
  60340. /** @hidden */
  60341. export var tonemapPixelShader: {
  60342. name: string;
  60343. shader: string;
  60344. };
  60345. }
  60346. declare module BABYLON {
  60347. /** Defines operator used for tonemapping */
  60348. export enum TonemappingOperator {
  60349. /** Hable */
  60350. Hable = 0,
  60351. /** Reinhard */
  60352. Reinhard = 1,
  60353. /** HejiDawson */
  60354. HejiDawson = 2,
  60355. /** Photographic */
  60356. Photographic = 3
  60357. }
  60358. /**
  60359. * Defines a post process to apply tone mapping
  60360. */
  60361. export class TonemapPostProcess extends PostProcess {
  60362. private _operator;
  60363. /** Defines the required exposure adjustement */
  60364. exposureAdjustment: number;
  60365. /**
  60366. * Creates a new TonemapPostProcess
  60367. * @param name defines the name of the postprocess
  60368. * @param _operator defines the operator to use
  60369. * @param exposureAdjustment defines the required exposure adjustement
  60370. * @param camera defines the camera to use (can be null)
  60371. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60372. * @param engine defines the hosting engine (can be ignore if camera is set)
  60373. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60374. */
  60375. constructor(name: string, _operator: TonemappingOperator,
  60376. /** Defines the required exposure adjustement */
  60377. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60378. }
  60379. }
  60380. declare module BABYLON {
  60381. /** @hidden */
  60382. export var depthVertexShader: {
  60383. name: string;
  60384. shader: string;
  60385. };
  60386. }
  60387. declare module BABYLON {
  60388. /** @hidden */
  60389. export var volumetricLightScatteringPixelShader: {
  60390. name: string;
  60391. shader: string;
  60392. };
  60393. }
  60394. declare module BABYLON {
  60395. /** @hidden */
  60396. export var volumetricLightScatteringPassVertexShader: {
  60397. name: string;
  60398. shader: string;
  60399. };
  60400. }
  60401. declare module BABYLON {
  60402. /** @hidden */
  60403. export var volumetricLightScatteringPassPixelShader: {
  60404. name: string;
  60405. shader: string;
  60406. };
  60407. }
  60408. declare module BABYLON {
  60409. /**
  60410. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60411. */
  60412. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60413. private _volumetricLightScatteringPass;
  60414. private _volumetricLightScatteringRTT;
  60415. private _viewPort;
  60416. private _screenCoordinates;
  60417. private _cachedDefines;
  60418. /**
  60419. * If not undefined, the mesh position is computed from the attached node position
  60420. */
  60421. attachedNode: {
  60422. position: Vector3;
  60423. };
  60424. /**
  60425. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60426. */
  60427. customMeshPosition: Vector3;
  60428. /**
  60429. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60430. */
  60431. useCustomMeshPosition: boolean;
  60432. /**
  60433. * If the post-process should inverse the light scattering direction
  60434. */
  60435. invert: boolean;
  60436. /**
  60437. * The internal mesh used by the post-process
  60438. */
  60439. mesh: Mesh;
  60440. /**
  60441. * @hidden
  60442. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60443. */
  60444. useDiffuseColor: boolean;
  60445. /**
  60446. * Array containing the excluded meshes not rendered in the internal pass
  60447. */
  60448. excludedMeshes: AbstractMesh[];
  60449. /**
  60450. * Controls the overall intensity of the post-process
  60451. */
  60452. exposure: number;
  60453. /**
  60454. * Dissipates each sample's contribution in range [0, 1]
  60455. */
  60456. decay: number;
  60457. /**
  60458. * Controls the overall intensity of each sample
  60459. */
  60460. weight: number;
  60461. /**
  60462. * Controls the density of each sample
  60463. */
  60464. density: number;
  60465. /**
  60466. * @constructor
  60467. * @param name The post-process name
  60468. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  60469. * @param camera The camera that the post-process will be attached to
  60470. * @param mesh The mesh used to create the light scattering
  60471. * @param samples The post-process quality, default 100
  60472. * @param samplingModeThe post-process filtering mode
  60473. * @param engine The babylon engine
  60474. * @param reusable If the post-process is reusable
  60475. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60476. */
  60477. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60478. /**
  60479. * Returns the string "VolumetricLightScatteringPostProcess"
  60480. * @returns "VolumetricLightScatteringPostProcess"
  60481. */
  60482. getClassName(): string;
  60483. private _isReady;
  60484. /**
  60485. * Sets the new light position for light scattering effect
  60486. * @param position The new custom light position
  60487. */
  60488. setCustomMeshPosition(position: Vector3): void;
  60489. /**
  60490. * Returns the light position for light scattering effect
  60491. * @return Vector3 The custom light position
  60492. */
  60493. getCustomMeshPosition(): Vector3;
  60494. /**
  60495. * Disposes the internal assets and detaches the post-process from the camera
  60496. */
  60497. dispose(camera: Camera): void;
  60498. /**
  60499. * Returns the render target texture used by the post-process
  60500. * @return the render target texture used by the post-process
  60501. */
  60502. getPass(): RenderTargetTexture;
  60503. private _meshExcluded;
  60504. private _createPass;
  60505. private _updateMeshScreenCoordinates;
  60506. /**
  60507. * Creates a default mesh for the Volumeric Light Scattering post-process
  60508. * @param name The mesh name
  60509. * @param scene The scene where to create the mesh
  60510. * @return the default mesh
  60511. */
  60512. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60513. }
  60514. }
  60515. declare module BABYLON {
  60516. interface Scene {
  60517. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  60518. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  60519. /**
  60520. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60521. */
  60522. forceShowBoundingBoxes: boolean;
  60523. /**
  60524. * Gets the bounding box renderer associated with the scene
  60525. * @returns a BoundingBoxRenderer
  60526. */
  60527. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60528. }
  60529. interface AbstractMesh {
  60530. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  60531. /**
  60532. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60533. */
  60534. showBoundingBox: boolean;
  60535. }
  60536. /**
  60537. * Component responsible of rendering the bounding box of the meshes in a scene.
  60538. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60539. */
  60540. export class BoundingBoxRenderer implements ISceneComponent {
  60541. /**
  60542. * The component name helpfull to identify the component in the list of scene components.
  60543. */
  60544. readonly name: string;
  60545. /**
  60546. * The scene the component belongs to.
  60547. */
  60548. scene: Scene;
  60549. /**
  60550. * Color of the bounding box lines placed in front of an object
  60551. */
  60552. frontColor: Color3;
  60553. /**
  60554. * Color of the bounding box lines placed behind an object
  60555. */
  60556. backColor: Color3;
  60557. /**
  60558. * Defines if the renderer should show the back lines or not
  60559. */
  60560. showBackLines: boolean;
  60561. /**
  60562. * @hidden
  60563. */
  60564. renderList: SmartArray<BoundingBox>;
  60565. private _colorShader;
  60566. private _vertexBuffers;
  60567. private _indexBuffer;
  60568. private _fillIndexBuffer;
  60569. private _fillIndexData;
  60570. /**
  60571. * Instantiates a new bounding box renderer in a scene.
  60572. * @param scene the scene the renderer renders in
  60573. */
  60574. constructor(scene: Scene);
  60575. /**
  60576. * Registers the component in a given scene
  60577. */
  60578. register(): void;
  60579. private _evaluateSubMesh;
  60580. private _activeMesh;
  60581. private _prepareRessources;
  60582. private _createIndexBuffer;
  60583. /**
  60584. * Rebuilds the elements related to this component in case of
  60585. * context lost for instance.
  60586. */
  60587. rebuild(): void;
  60588. /**
  60589. * @hidden
  60590. */
  60591. reset(): void;
  60592. /**
  60593. * Render the bounding boxes of a specific rendering group
  60594. * @param renderingGroupId defines the rendering group to render
  60595. */
  60596. render(renderingGroupId: number): void;
  60597. /**
  60598. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60599. * @param mesh Define the mesh to render the occlusion bounding box for
  60600. */
  60601. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60602. /**
  60603. * Dispose and release the resources attached to this renderer.
  60604. */
  60605. dispose(): void;
  60606. }
  60607. }
  60608. declare module BABYLON {
  60609. /** @hidden */
  60610. export var depthPixelShader: {
  60611. name: string;
  60612. shader: string;
  60613. };
  60614. }
  60615. declare module BABYLON {
  60616. /**
  60617. * This represents a depth renderer in Babylon.
  60618. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60619. */
  60620. export class DepthRenderer {
  60621. private _scene;
  60622. private _depthMap;
  60623. private _effect;
  60624. private readonly _storeNonLinearDepth;
  60625. private readonly _clearColor;
  60626. /** Get if the depth renderer is using packed depth or not */
  60627. readonly isPacked: boolean;
  60628. private _cachedDefines;
  60629. private _camera;
  60630. /**
  60631. * Specifiess that the depth renderer will only be used within
  60632. * the camera it is created for.
  60633. * This can help forcing its rendering during the camera processing.
  60634. */
  60635. useOnlyInActiveCamera: boolean;
  60636. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  60637. /**
  60638. * Instantiates a depth renderer
  60639. * @param scene The scene the renderer belongs to
  60640. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60641. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60642. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60643. */
  60644. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60645. /**
  60646. * Creates the depth rendering effect and checks if the effect is ready.
  60647. * @param subMesh The submesh to be used to render the depth map of
  60648. * @param useInstances If multiple world instances should be used
  60649. * @returns if the depth renderer is ready to render the depth map
  60650. */
  60651. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60652. /**
  60653. * Gets the texture which the depth map will be written to.
  60654. * @returns The depth map texture
  60655. */
  60656. getDepthMap(): RenderTargetTexture;
  60657. /**
  60658. * Disposes of the depth renderer.
  60659. */
  60660. dispose(): void;
  60661. }
  60662. }
  60663. declare module BABYLON {
  60664. interface Scene {
  60665. /** @hidden (Backing field) */ private _depthRenderer: {
  60666. [id: string]: DepthRenderer;
  60667. };
  60668. /**
  60669. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60670. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60671. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60672. * @returns the created depth renderer
  60673. */
  60674. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60675. /**
  60676. * Disables a depth renderer for a given camera
  60677. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60678. */
  60679. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60680. }
  60681. /**
  60682. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60683. * in several rendering techniques.
  60684. */
  60685. export class DepthRendererSceneComponent implements ISceneComponent {
  60686. /**
  60687. * The component name helpfull to identify the component in the list of scene components.
  60688. */
  60689. readonly name: string;
  60690. /**
  60691. * The scene the component belongs to.
  60692. */
  60693. scene: Scene;
  60694. /**
  60695. * Creates a new instance of the component for the given scene
  60696. * @param scene Defines the scene to register the component in
  60697. */
  60698. constructor(scene: Scene);
  60699. /**
  60700. * Registers the component in a given scene
  60701. */
  60702. register(): void;
  60703. /**
  60704. * Rebuilds the elements related to this component in case of
  60705. * context lost for instance.
  60706. */
  60707. rebuild(): void;
  60708. /**
  60709. * Disposes the component and the associated ressources
  60710. */
  60711. dispose(): void;
  60712. private _gatherRenderTargets;
  60713. private _gatherActiveCameraRenderTargets;
  60714. }
  60715. }
  60716. declare module BABYLON {
  60717. /** @hidden */
  60718. export var outlinePixelShader: {
  60719. name: string;
  60720. shader: string;
  60721. };
  60722. }
  60723. declare module BABYLON {
  60724. /** @hidden */
  60725. export var outlineVertexShader: {
  60726. name: string;
  60727. shader: string;
  60728. };
  60729. }
  60730. declare module BABYLON {
  60731. interface Scene {
  60732. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  60733. /**
  60734. * Gets the outline renderer associated with the scene
  60735. * @returns a OutlineRenderer
  60736. */
  60737. getOutlineRenderer(): OutlineRenderer;
  60738. }
  60739. interface AbstractMesh {
  60740. /** @hidden (Backing field) */ private _renderOutline: boolean;
  60741. /**
  60742. * Gets or sets a boolean indicating if the outline must be rendered as well
  60743. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60744. */
  60745. renderOutline: boolean;
  60746. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  60747. /**
  60748. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60749. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60750. */
  60751. renderOverlay: boolean;
  60752. }
  60753. /**
  60754. * This class is responsible to draw bothe outline/overlay of meshes.
  60755. * It should not be used directly but through the available method on mesh.
  60756. */
  60757. export class OutlineRenderer implements ISceneComponent {
  60758. /**
  60759. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60760. */
  60761. private static _StencilReference;
  60762. /**
  60763. * The name of the component. Each component must have a unique name.
  60764. */
  60765. name: string;
  60766. /**
  60767. * The scene the component belongs to.
  60768. */
  60769. scene: Scene;
  60770. /**
  60771. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60772. */
  60773. zOffset: number;
  60774. private _engine;
  60775. private _effect;
  60776. private _cachedDefines;
  60777. private _savedDepthWrite;
  60778. /**
  60779. * Instantiates a new outline renderer. (There could be only one per scene).
  60780. * @param scene Defines the scene it belongs to
  60781. */
  60782. constructor(scene: Scene);
  60783. /**
  60784. * Register the component to one instance of a scene.
  60785. */
  60786. register(): void;
  60787. /**
  60788. * Rebuilds the elements related to this component in case of
  60789. * context lost for instance.
  60790. */
  60791. rebuild(): void;
  60792. /**
  60793. * Disposes the component and the associated ressources.
  60794. */
  60795. dispose(): void;
  60796. /**
  60797. * Renders the outline in the canvas.
  60798. * @param subMesh Defines the sumesh to render
  60799. * @param batch Defines the batch of meshes in case of instances
  60800. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60801. */
  60802. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60803. /**
  60804. * Returns whether or not the outline renderer is ready for a given submesh.
  60805. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60806. * @param subMesh Defines the submesh to check readyness for
  60807. * @param useInstances Defines wheter wee are trying to render instances or not
  60808. * @returns true if ready otherwise false
  60809. */
  60810. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60811. private _beforeRenderingMesh;
  60812. private _afterRenderingMesh;
  60813. }
  60814. }
  60815. declare module BABYLON {
  60816. /**
  60817. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60818. * @see http://doc.babylonjs.com/babylon101/sprites
  60819. */
  60820. export class SpritePackedManager extends SpriteManager {
  60821. /** defines the packed manager's name */
  60822. name: string;
  60823. /**
  60824. * Creates a new sprite manager from a packed sprite sheet
  60825. * @param name defines the manager's name
  60826. * @param imgUrl defines the sprite sheet url
  60827. * @param capacity defines the maximum allowed number of sprites
  60828. * @param scene defines the hosting scene
  60829. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60830. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60831. * @param samplingMode defines the smapling mode to use with spritesheet
  60832. * @param fromPacked set to true; do not alter
  60833. */
  60834. constructor(
  60835. /** defines the packed manager's name */
  60836. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60837. }
  60838. }
  60839. declare module BABYLON {
  60840. /**
  60841. * Defines the list of states available for a task inside a AssetsManager
  60842. */
  60843. export enum AssetTaskState {
  60844. /**
  60845. * Initialization
  60846. */
  60847. INIT = 0,
  60848. /**
  60849. * Running
  60850. */
  60851. RUNNING = 1,
  60852. /**
  60853. * Done
  60854. */
  60855. DONE = 2,
  60856. /**
  60857. * Error
  60858. */
  60859. ERROR = 3
  60860. }
  60861. /**
  60862. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60863. */
  60864. export abstract class AbstractAssetTask {
  60865. /**
  60866. * Task name
  60867. */ name: string;
  60868. /**
  60869. * Callback called when the task is successful
  60870. */
  60871. onSuccess: (task: any) => void;
  60872. /**
  60873. * Callback called when the task is not successful
  60874. */
  60875. onError: (task: any, message?: string, exception?: any) => void;
  60876. /**
  60877. * Creates a new AssetsManager
  60878. * @param name defines the name of the task
  60879. */
  60880. constructor(
  60881. /**
  60882. * Task name
  60883. */ name: string);
  60884. private _isCompleted;
  60885. private _taskState;
  60886. private _errorObject;
  60887. /**
  60888. * Get if the task is completed
  60889. */
  60890. readonly isCompleted: boolean;
  60891. /**
  60892. * Gets the current state of the task
  60893. */
  60894. readonly taskState: AssetTaskState;
  60895. /**
  60896. * Gets the current error object (if task is in error)
  60897. */
  60898. readonly errorObject: {
  60899. message?: string;
  60900. exception?: any;
  60901. };
  60902. /**
  60903. * Internal only
  60904. * @hidden
  60905. */ private _setErrorObject(message?: string, exception?: any): void;
  60906. /**
  60907. * Execute the current task
  60908. * @param scene defines the scene where you want your assets to be loaded
  60909. * @param onSuccess is a callback called when the task is successfully executed
  60910. * @param onError is a callback called if an error occurs
  60911. */
  60912. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60913. /**
  60914. * Execute the current task
  60915. * @param scene defines the scene where you want your assets to be loaded
  60916. * @param onSuccess is a callback called when the task is successfully executed
  60917. * @param onError is a callback called if an error occurs
  60918. */
  60919. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60920. /**
  60921. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60922. * This can be used with failed tasks that have the reason for failure fixed.
  60923. */
  60924. reset(): void;
  60925. private onErrorCallback;
  60926. private onDoneCallback;
  60927. }
  60928. /**
  60929. * Define the interface used by progress events raised during assets loading
  60930. */
  60931. export interface IAssetsProgressEvent {
  60932. /**
  60933. * Defines the number of remaining tasks to process
  60934. */
  60935. remainingCount: number;
  60936. /**
  60937. * Defines the total number of tasks
  60938. */
  60939. totalCount: number;
  60940. /**
  60941. * Defines the task that was just processed
  60942. */
  60943. task: AbstractAssetTask;
  60944. }
  60945. /**
  60946. * Class used to share progress information about assets loading
  60947. */
  60948. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60949. /**
  60950. * Defines the number of remaining tasks to process
  60951. */
  60952. remainingCount: number;
  60953. /**
  60954. * Defines the total number of tasks
  60955. */
  60956. totalCount: number;
  60957. /**
  60958. * Defines the task that was just processed
  60959. */
  60960. task: AbstractAssetTask;
  60961. /**
  60962. * Creates a AssetsProgressEvent
  60963. * @param remainingCount defines the number of remaining tasks to process
  60964. * @param totalCount defines the total number of tasks
  60965. * @param task defines the task that was just processed
  60966. */
  60967. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60968. }
  60969. /**
  60970. * Define a task used by AssetsManager to load meshes
  60971. */
  60972. export class MeshAssetTask extends AbstractAssetTask {
  60973. /**
  60974. * Defines the name of the task
  60975. */
  60976. name: string;
  60977. /**
  60978. * Defines the list of mesh's names you want to load
  60979. */
  60980. meshesNames: any;
  60981. /**
  60982. * Defines the root url to use as a base to load your meshes and associated resources
  60983. */
  60984. rootUrl: string;
  60985. /**
  60986. * Defines the filename of the scene to load from
  60987. */
  60988. sceneFilename: string;
  60989. /**
  60990. * Gets the list of loaded meshes
  60991. */
  60992. loadedMeshes: Array<AbstractMesh>;
  60993. /**
  60994. * Gets the list of loaded particle systems
  60995. */
  60996. loadedParticleSystems: Array<IParticleSystem>;
  60997. /**
  60998. * Gets the list of loaded skeletons
  60999. */
  61000. loadedSkeletons: Array<Skeleton>;
  61001. /**
  61002. * Gets the list of loaded animation groups
  61003. */
  61004. loadedAnimationGroups: Array<AnimationGroup>;
  61005. /**
  61006. * Callback called when the task is successful
  61007. */
  61008. onSuccess: (task: MeshAssetTask) => void;
  61009. /**
  61010. * Callback called when the task is successful
  61011. */
  61012. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61013. /**
  61014. * Creates a new MeshAssetTask
  61015. * @param name defines the name of the task
  61016. * @param meshesNames defines the list of mesh's names you want to load
  61017. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61018. * @param sceneFilename defines the filename of the scene to load from
  61019. */
  61020. constructor(
  61021. /**
  61022. * Defines the name of the task
  61023. */
  61024. name: string,
  61025. /**
  61026. * Defines the list of mesh's names you want to load
  61027. */
  61028. meshesNames: any,
  61029. /**
  61030. * Defines the root url to use as a base to load your meshes and associated resources
  61031. */
  61032. rootUrl: string,
  61033. /**
  61034. * Defines the filename of the scene to load from
  61035. */
  61036. sceneFilename: string);
  61037. /**
  61038. * Execute the current task
  61039. * @param scene defines the scene where you want your assets to be loaded
  61040. * @param onSuccess is a callback called when the task is successfully executed
  61041. * @param onError is a callback called if an error occurs
  61042. */
  61043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61044. }
  61045. /**
  61046. * Define a task used by AssetsManager to load text content
  61047. */
  61048. export class TextFileAssetTask extends AbstractAssetTask {
  61049. /**
  61050. * Defines the name of the task
  61051. */
  61052. name: string;
  61053. /**
  61054. * Defines the location of the file to load
  61055. */
  61056. url: string;
  61057. /**
  61058. * Gets the loaded text string
  61059. */
  61060. text: string;
  61061. /**
  61062. * Callback called when the task is successful
  61063. */
  61064. onSuccess: (task: TextFileAssetTask) => void;
  61065. /**
  61066. * Callback called when the task is successful
  61067. */
  61068. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61069. /**
  61070. * Creates a new TextFileAssetTask object
  61071. * @param name defines the name of the task
  61072. * @param url defines the location of the file to load
  61073. */
  61074. constructor(
  61075. /**
  61076. * Defines the name of the task
  61077. */
  61078. name: string,
  61079. /**
  61080. * Defines the location of the file to load
  61081. */
  61082. url: string);
  61083. /**
  61084. * Execute the current task
  61085. * @param scene defines the scene where you want your assets to be loaded
  61086. * @param onSuccess is a callback called when the task is successfully executed
  61087. * @param onError is a callback called if an error occurs
  61088. */
  61089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61090. }
  61091. /**
  61092. * Define a task used by AssetsManager to load binary data
  61093. */
  61094. export class BinaryFileAssetTask extends AbstractAssetTask {
  61095. /**
  61096. * Defines the name of the task
  61097. */
  61098. name: string;
  61099. /**
  61100. * Defines the location of the file to load
  61101. */
  61102. url: string;
  61103. /**
  61104. * Gets the lodaded data (as an array buffer)
  61105. */
  61106. data: ArrayBuffer;
  61107. /**
  61108. * Callback called when the task is successful
  61109. */
  61110. onSuccess: (task: BinaryFileAssetTask) => void;
  61111. /**
  61112. * Callback called when the task is successful
  61113. */
  61114. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61115. /**
  61116. * Creates a new BinaryFileAssetTask object
  61117. * @param name defines the name of the new task
  61118. * @param url defines the location of the file to load
  61119. */
  61120. constructor(
  61121. /**
  61122. * Defines the name of the task
  61123. */
  61124. name: string,
  61125. /**
  61126. * Defines the location of the file to load
  61127. */
  61128. url: string);
  61129. /**
  61130. * Execute the current task
  61131. * @param scene defines the scene where you want your assets to be loaded
  61132. * @param onSuccess is a callback called when the task is successfully executed
  61133. * @param onError is a callback called if an error occurs
  61134. */
  61135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61136. }
  61137. /**
  61138. * Define a task used by AssetsManager to load images
  61139. */
  61140. export class ImageAssetTask extends AbstractAssetTask {
  61141. /**
  61142. * Defines the name of the task
  61143. */
  61144. name: string;
  61145. /**
  61146. * Defines the location of the image to load
  61147. */
  61148. url: string;
  61149. /**
  61150. * Gets the loaded images
  61151. */
  61152. image: HTMLImageElement;
  61153. /**
  61154. * Callback called when the task is successful
  61155. */
  61156. onSuccess: (task: ImageAssetTask) => void;
  61157. /**
  61158. * Callback called when the task is successful
  61159. */
  61160. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61161. /**
  61162. * Creates a new ImageAssetTask
  61163. * @param name defines the name of the task
  61164. * @param url defines the location of the image to load
  61165. */
  61166. constructor(
  61167. /**
  61168. * Defines the name of the task
  61169. */
  61170. name: string,
  61171. /**
  61172. * Defines the location of the image to load
  61173. */
  61174. url: string);
  61175. /**
  61176. * Execute the current task
  61177. * @param scene defines the scene where you want your assets to be loaded
  61178. * @param onSuccess is a callback called when the task is successfully executed
  61179. * @param onError is a callback called if an error occurs
  61180. */
  61181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61182. }
  61183. /**
  61184. * Defines the interface used by texture loading tasks
  61185. */
  61186. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61187. /**
  61188. * Gets the loaded texture
  61189. */
  61190. texture: TEX;
  61191. }
  61192. /**
  61193. * Define a task used by AssetsManager to load 2D textures
  61194. */
  61195. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61196. /**
  61197. * Defines the name of the task
  61198. */
  61199. name: string;
  61200. /**
  61201. * Defines the location of the file to load
  61202. */
  61203. url: string;
  61204. /**
  61205. * Defines if mipmap should not be generated (default is false)
  61206. */
  61207. noMipmap?: boolean | undefined;
  61208. /**
  61209. * Defines if texture must be inverted on Y axis (default is false)
  61210. */
  61211. invertY?: boolean | undefined;
  61212. /**
  61213. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61214. */
  61215. samplingMode: number;
  61216. /**
  61217. * Gets the loaded texture
  61218. */
  61219. texture: Texture;
  61220. /**
  61221. * Callback called when the task is successful
  61222. */
  61223. onSuccess: (task: TextureAssetTask) => void;
  61224. /**
  61225. * Callback called when the task is successful
  61226. */
  61227. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61228. /**
  61229. * Creates a new TextureAssetTask object
  61230. * @param name defines the name of the task
  61231. * @param url defines the location of the file to load
  61232. * @param noMipmap defines if mipmap should not be generated (default is false)
  61233. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61234. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61235. */
  61236. constructor(
  61237. /**
  61238. * Defines the name of the task
  61239. */
  61240. name: string,
  61241. /**
  61242. * Defines the location of the file to load
  61243. */
  61244. url: string,
  61245. /**
  61246. * Defines if mipmap should not be generated (default is false)
  61247. */
  61248. noMipmap?: boolean | undefined,
  61249. /**
  61250. * Defines if texture must be inverted on Y axis (default is false)
  61251. */
  61252. invertY?: boolean | undefined,
  61253. /**
  61254. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61255. */
  61256. samplingMode?: number);
  61257. /**
  61258. * Execute the current task
  61259. * @param scene defines the scene where you want your assets to be loaded
  61260. * @param onSuccess is a callback called when the task is successfully executed
  61261. * @param onError is a callback called if an error occurs
  61262. */
  61263. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61264. }
  61265. /**
  61266. * Define a task used by AssetsManager to load cube textures
  61267. */
  61268. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61269. /**
  61270. * Defines the name of the task
  61271. */
  61272. name: string;
  61273. /**
  61274. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61275. */
  61276. url: string;
  61277. /**
  61278. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61279. */
  61280. extensions?: string[] | undefined;
  61281. /**
  61282. * Defines if mipmaps should not be generated (default is false)
  61283. */
  61284. noMipmap?: boolean | undefined;
  61285. /**
  61286. * Defines the explicit list of files (undefined by default)
  61287. */
  61288. files?: string[] | undefined;
  61289. /**
  61290. * Gets the loaded texture
  61291. */
  61292. texture: CubeTexture;
  61293. /**
  61294. * Callback called when the task is successful
  61295. */
  61296. onSuccess: (task: CubeTextureAssetTask) => void;
  61297. /**
  61298. * Callback called when the task is successful
  61299. */
  61300. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61301. /**
  61302. * Creates a new CubeTextureAssetTask
  61303. * @param name defines the name of the task
  61304. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61305. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61306. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61307. * @param files defines the explicit list of files (undefined by default)
  61308. */
  61309. constructor(
  61310. /**
  61311. * Defines the name of the task
  61312. */
  61313. name: string,
  61314. /**
  61315. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61316. */
  61317. url: string,
  61318. /**
  61319. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61320. */
  61321. extensions?: string[] | undefined,
  61322. /**
  61323. * Defines if mipmaps should not be generated (default is false)
  61324. */
  61325. noMipmap?: boolean | undefined,
  61326. /**
  61327. * Defines the explicit list of files (undefined by default)
  61328. */
  61329. files?: string[] | undefined);
  61330. /**
  61331. * Execute the current task
  61332. * @param scene defines the scene where you want your assets to be loaded
  61333. * @param onSuccess is a callback called when the task is successfully executed
  61334. * @param onError is a callback called if an error occurs
  61335. */
  61336. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61337. }
  61338. /**
  61339. * Define a task used by AssetsManager to load HDR cube textures
  61340. */
  61341. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61342. /**
  61343. * Defines the name of the task
  61344. */
  61345. name: string;
  61346. /**
  61347. * Defines the location of the file to load
  61348. */
  61349. url: string;
  61350. /**
  61351. * Defines the desired size (the more it increases the longer the generation will be)
  61352. */
  61353. size: number;
  61354. /**
  61355. * Defines if mipmaps should not be generated (default is false)
  61356. */
  61357. noMipmap: boolean;
  61358. /**
  61359. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61360. */
  61361. generateHarmonics: boolean;
  61362. /**
  61363. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61364. */
  61365. gammaSpace: boolean;
  61366. /**
  61367. * Internal Use Only
  61368. */
  61369. reserved: boolean;
  61370. /**
  61371. * Gets the loaded texture
  61372. */
  61373. texture: HDRCubeTexture;
  61374. /**
  61375. * Callback called when the task is successful
  61376. */
  61377. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61378. /**
  61379. * Callback called when the task is successful
  61380. */
  61381. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61382. /**
  61383. * Creates a new HDRCubeTextureAssetTask object
  61384. * @param name defines the name of the task
  61385. * @param url defines the location of the file to load
  61386. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  61387. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61388. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61389. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61390. * @param reserved Internal use only
  61391. */
  61392. constructor(
  61393. /**
  61394. * Defines the name of the task
  61395. */
  61396. name: string,
  61397. /**
  61398. * Defines the location of the file to load
  61399. */
  61400. url: string,
  61401. /**
  61402. * Defines the desired size (the more it increases the longer the generation will be)
  61403. */
  61404. size: number,
  61405. /**
  61406. * Defines if mipmaps should not be generated (default is false)
  61407. */
  61408. noMipmap?: boolean,
  61409. /**
  61410. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61411. */
  61412. generateHarmonics?: boolean,
  61413. /**
  61414. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61415. */
  61416. gammaSpace?: boolean,
  61417. /**
  61418. * Internal Use Only
  61419. */
  61420. reserved?: boolean);
  61421. /**
  61422. * Execute the current task
  61423. * @param scene defines the scene where you want your assets to be loaded
  61424. * @param onSuccess is a callback called when the task is successfully executed
  61425. * @param onError is a callback called if an error occurs
  61426. */
  61427. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61428. }
  61429. /**
  61430. * Define a task used by AssetsManager to load Equirectangular cube textures
  61431. */
  61432. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61433. /**
  61434. * Defines the name of the task
  61435. */
  61436. name: string;
  61437. /**
  61438. * Defines the location of the file to load
  61439. */
  61440. url: string;
  61441. /**
  61442. * Defines the desired size (the more it increases the longer the generation will be)
  61443. */
  61444. size: number;
  61445. /**
  61446. * Defines if mipmaps should not be generated (default is false)
  61447. */
  61448. noMipmap: boolean;
  61449. /**
  61450. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61451. * but the standard material would require them in Gamma space) (default is true)
  61452. */
  61453. gammaSpace: boolean;
  61454. /**
  61455. * Gets the loaded texture
  61456. */
  61457. texture: EquiRectangularCubeTexture;
  61458. /**
  61459. * Callback called when the task is successful
  61460. */
  61461. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61462. /**
  61463. * Callback called when the task is successful
  61464. */
  61465. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61466. /**
  61467. * Creates a new EquiRectangularCubeTextureAssetTask object
  61468. * @param name defines the name of the task
  61469. * @param url defines the location of the file to load
  61470. * @param size defines the desired size (the more it increases the longer the generation will be)
  61471. * If the size is omitted this implies you are using a preprocessed cubemap.
  61472. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61473. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61474. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61475. * (default is true)
  61476. */
  61477. constructor(
  61478. /**
  61479. * Defines the name of the task
  61480. */
  61481. name: string,
  61482. /**
  61483. * Defines the location of the file to load
  61484. */
  61485. url: string,
  61486. /**
  61487. * Defines the desired size (the more it increases the longer the generation will be)
  61488. */
  61489. size: number,
  61490. /**
  61491. * Defines if mipmaps should not be generated (default is false)
  61492. */
  61493. noMipmap?: boolean,
  61494. /**
  61495. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61496. * but the standard material would require them in Gamma space) (default is true)
  61497. */
  61498. gammaSpace?: boolean);
  61499. /**
  61500. * Execute the current task
  61501. * @param scene defines the scene where you want your assets to be loaded
  61502. * @param onSuccess is a callback called when the task is successfully executed
  61503. * @param onError is a callback called if an error occurs
  61504. */
  61505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61506. }
  61507. /**
  61508. * This class can be used to easily import assets into a scene
  61509. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61510. */
  61511. export class AssetsManager {
  61512. private _scene;
  61513. private _isLoading;
  61514. protected _tasks: AbstractAssetTask[];
  61515. protected _waitingTasksCount: number;
  61516. protected _totalTasksCount: number;
  61517. /**
  61518. * Callback called when all tasks are processed
  61519. */
  61520. onFinish: (tasks: AbstractAssetTask[]) => void;
  61521. /**
  61522. * Callback called when a task is successful
  61523. */
  61524. onTaskSuccess: (task: AbstractAssetTask) => void;
  61525. /**
  61526. * Callback called when a task had an error
  61527. */
  61528. onTaskError: (task: AbstractAssetTask) => void;
  61529. /**
  61530. * Callback called when a task is done (whatever the result is)
  61531. */
  61532. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61533. /**
  61534. * Observable called when all tasks are processed
  61535. */
  61536. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61537. /**
  61538. * Observable called when a task had an error
  61539. */
  61540. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61541. /**
  61542. * Observable called when all tasks were executed
  61543. */
  61544. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61545. /**
  61546. * Observable called when a task is done (whatever the result is)
  61547. */
  61548. onProgressObservable: Observable<IAssetsProgressEvent>;
  61549. /**
  61550. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61552. */
  61553. useDefaultLoadingScreen: boolean;
  61554. /**
  61555. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61556. * when all assets have been downloaded.
  61557. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61558. */
  61559. autoHideLoadingUI: boolean;
  61560. /**
  61561. * Creates a new AssetsManager
  61562. * @param scene defines the scene to work on
  61563. */
  61564. constructor(scene: Scene);
  61565. /**
  61566. * Add a MeshAssetTask to the list of active tasks
  61567. * @param taskName defines the name of the new task
  61568. * @param meshesNames defines the name of meshes to load
  61569. * @param rootUrl defines the root url to use to locate files
  61570. * @param sceneFilename defines the filename of the scene file
  61571. * @returns a new MeshAssetTask object
  61572. */
  61573. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61574. /**
  61575. * Add a TextFileAssetTask to the list of active tasks
  61576. * @param taskName defines the name of the new task
  61577. * @param url defines the url of the file to load
  61578. * @returns a new TextFileAssetTask object
  61579. */
  61580. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61581. /**
  61582. * Add a BinaryFileAssetTask to the list of active tasks
  61583. * @param taskName defines the name of the new task
  61584. * @param url defines the url of the file to load
  61585. * @returns a new BinaryFileAssetTask object
  61586. */
  61587. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61588. /**
  61589. * Add a ImageAssetTask to the list of active tasks
  61590. * @param taskName defines the name of the new task
  61591. * @param url defines the url of the file to load
  61592. * @returns a new ImageAssetTask object
  61593. */
  61594. addImageTask(taskName: string, url: string): ImageAssetTask;
  61595. /**
  61596. * Add a TextureAssetTask to the list of active tasks
  61597. * @param taskName defines the name of the new task
  61598. * @param url defines the url of the file to load
  61599. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61600. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61601. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61602. * @returns a new TextureAssetTask object
  61603. */
  61604. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61605. /**
  61606. * Add a CubeTextureAssetTask to the list of active tasks
  61607. * @param taskName defines the name of the new task
  61608. * @param url defines the url of the file to load
  61609. * @param extensions defines the extension to use to load the cube map (can be null)
  61610. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61611. * @param files defines the list of files to load (can be null)
  61612. * @returns a new CubeTextureAssetTask object
  61613. */
  61614. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61615. /**
  61616. *
  61617. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61618. * @param taskName defines the name of the new task
  61619. * @param url defines the url of the file to load
  61620. * @param size defines the size you want for the cubemap (can be null)
  61621. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61622. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61623. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61624. * @param reserved Internal use only
  61625. * @returns a new HDRCubeTextureAssetTask object
  61626. */
  61627. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61628. /**
  61629. *
  61630. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61631. * @param taskName defines the name of the new task
  61632. * @param url defines the url of the file to load
  61633. * @param size defines the size you want for the cubemap (can be null)
  61634. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61635. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61636. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61637. * @returns a new EquiRectangularCubeTextureAssetTask object
  61638. */
  61639. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61640. /**
  61641. * Remove a task from the assets manager.
  61642. * @param task the task to remove
  61643. */
  61644. removeTask(task: AbstractAssetTask): void;
  61645. private _decreaseWaitingTasksCount;
  61646. private _runTask;
  61647. /**
  61648. * Reset the AssetsManager and remove all tasks
  61649. * @return the current instance of the AssetsManager
  61650. */
  61651. reset(): AssetsManager;
  61652. /**
  61653. * Start the loading process
  61654. * @return the current instance of the AssetsManager
  61655. */
  61656. load(): AssetsManager;
  61657. /**
  61658. * Start the loading process as an async operation
  61659. * @return a promise returning the list of failed tasks
  61660. */
  61661. loadAsync(): Promise<void>;
  61662. }
  61663. }
  61664. declare module BABYLON {
  61665. /**
  61666. * Wrapper class for promise with external resolve and reject.
  61667. */
  61668. export class Deferred<T> {
  61669. /**
  61670. * The promise associated with this deferred object.
  61671. */
  61672. readonly promise: Promise<T>;
  61673. private _resolve;
  61674. private _reject;
  61675. /**
  61676. * The resolve method of the promise associated with this deferred object.
  61677. */
  61678. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61679. /**
  61680. * The reject method of the promise associated with this deferred object.
  61681. */
  61682. readonly reject: (reason?: any) => void;
  61683. /**
  61684. * Constructor for this deferred object.
  61685. */
  61686. constructor();
  61687. }
  61688. }
  61689. declare module BABYLON {
  61690. /**
  61691. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61692. */
  61693. export class MeshExploder {
  61694. private _centerMesh;
  61695. private _meshes;
  61696. private _meshesOrigins;
  61697. private _toCenterVectors;
  61698. private _scaledDirection;
  61699. private _newPosition;
  61700. private _centerPosition;
  61701. /**
  61702. * Explodes meshes from a center mesh.
  61703. * @param meshes The meshes to explode.
  61704. * @param centerMesh The mesh to be center of explosion.
  61705. */
  61706. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61707. private _setCenterMesh;
  61708. /**
  61709. * Get class name
  61710. * @returns "MeshExploder"
  61711. */
  61712. getClassName(): string;
  61713. /**
  61714. * "Exploded meshes"
  61715. * @returns Array of meshes with the centerMesh at index 0.
  61716. */
  61717. getMeshes(): Array<Mesh>;
  61718. /**
  61719. * Explodes meshes giving a specific direction
  61720. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61721. */
  61722. explode(direction?: number): void;
  61723. }
  61724. }
  61725. declare module BABYLON {
  61726. /**
  61727. * Class used to help managing file picking and drag'n'drop
  61728. */
  61729. export class FilesInput {
  61730. /**
  61731. * List of files ready to be loaded
  61732. */
  61733. static readonly FilesToLoad: {
  61734. [key: string]: File;
  61735. };
  61736. /**
  61737. * Callback called when a file is processed
  61738. */
  61739. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61740. private _engine;
  61741. private _currentScene;
  61742. private _sceneLoadedCallback;
  61743. private _progressCallback;
  61744. private _additionalRenderLoopLogicCallback;
  61745. private _textureLoadingCallback;
  61746. private _startingProcessingFilesCallback;
  61747. private _onReloadCallback;
  61748. private _errorCallback;
  61749. private _elementToMonitor;
  61750. private _sceneFileToLoad;
  61751. private _filesToLoad;
  61752. /**
  61753. * Creates a new FilesInput
  61754. * @param engine defines the rendering engine
  61755. * @param scene defines the hosting scene
  61756. * @param sceneLoadedCallback callback called when scene is loaded
  61757. * @param progressCallback callback called to track progress
  61758. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61759. * @param textureLoadingCallback callback called when a texture is loading
  61760. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61761. * @param onReloadCallback callback called when a reload is requested
  61762. * @param errorCallback callback call if an error occurs
  61763. */
  61764. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  61765. private _dragEnterHandler;
  61766. private _dragOverHandler;
  61767. private _dropHandler;
  61768. /**
  61769. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61770. * @param elementToMonitor defines the DOM element to track
  61771. */
  61772. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61773. /**
  61774. * Release all associated resources
  61775. */
  61776. dispose(): void;
  61777. private renderFunction;
  61778. private drag;
  61779. private drop;
  61780. private _traverseFolder;
  61781. private _processFiles;
  61782. /**
  61783. * Load files from a drop event
  61784. * @param event defines the drop event to use as source
  61785. */
  61786. loadFiles(event: any): void;
  61787. private _processReload;
  61788. /**
  61789. * Reload the current scene from the loaded files
  61790. */
  61791. reload(): void;
  61792. }
  61793. }
  61794. declare module BABYLON {
  61795. /**
  61796. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61798. */
  61799. export class SceneOptimization {
  61800. /**
  61801. * Defines the priority of this optimization (0 by default which means first in the list)
  61802. */
  61803. priority: number;
  61804. /**
  61805. * Gets a string describing the action executed by the current optimization
  61806. * @returns description string
  61807. */
  61808. getDescription(): string;
  61809. /**
  61810. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61811. * @param scene defines the current scene where to apply this optimization
  61812. * @param optimizer defines the current optimizer
  61813. * @returns true if everything that can be done was applied
  61814. */
  61815. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61816. /**
  61817. * Creates the SceneOptimization object
  61818. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61819. * @param desc defines the description associated with the optimization
  61820. */
  61821. constructor(
  61822. /**
  61823. * Defines the priority of this optimization (0 by default which means first in the list)
  61824. */
  61825. priority?: number);
  61826. }
  61827. /**
  61828. * Defines an optimization used to reduce the size of render target textures
  61829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61830. */
  61831. export class TextureOptimization extends SceneOptimization {
  61832. /**
  61833. * Defines the priority of this optimization (0 by default which means first in the list)
  61834. */
  61835. priority: number;
  61836. /**
  61837. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  61838. */
  61839. maximumSize: number;
  61840. /**
  61841. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61842. */
  61843. step: number;
  61844. /**
  61845. * Gets a string describing the action executed by the current optimization
  61846. * @returns description string
  61847. */
  61848. getDescription(): string;
  61849. /**
  61850. * Creates the TextureOptimization object
  61851. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61852. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  61853. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61854. */
  61855. constructor(
  61856. /**
  61857. * Defines the priority of this optimization (0 by default which means first in the list)
  61858. */
  61859. priority?: number,
  61860. /**
  61861. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  61862. */
  61863. maximumSize?: number,
  61864. /**
  61865. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61866. */
  61867. step?: number);
  61868. /**
  61869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61870. * @param scene defines the current scene where to apply this optimization
  61871. * @param optimizer defines the current optimizer
  61872. * @returns true if everything that can be done was applied
  61873. */
  61874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61875. }
  61876. /**
  61877. * Defines an optimization used to increase or decrease the rendering resolution
  61878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61879. */
  61880. export class HardwareScalingOptimization extends SceneOptimization {
  61881. /**
  61882. * Defines the priority of this optimization (0 by default which means first in the list)
  61883. */
  61884. priority: number;
  61885. /**
  61886. * Defines the maximum scale to use (2 by default)
  61887. */
  61888. maximumScale: number;
  61889. /**
  61890. * Defines the step to use between two passes (0.5 by default)
  61891. */
  61892. step: number;
  61893. private _currentScale;
  61894. private _directionOffset;
  61895. /**
  61896. * Gets a string describing the action executed by the current optimization
  61897. * @return description string
  61898. */
  61899. getDescription(): string;
  61900. /**
  61901. * Creates the HardwareScalingOptimization object
  61902. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61903. * @param maximumScale defines the maximum scale to use (2 by default)
  61904. * @param step defines the step to use between two passes (0.5 by default)
  61905. */
  61906. constructor(
  61907. /**
  61908. * Defines the priority of this optimization (0 by default which means first in the list)
  61909. */
  61910. priority?: number,
  61911. /**
  61912. * Defines the maximum scale to use (2 by default)
  61913. */
  61914. maximumScale?: number,
  61915. /**
  61916. * Defines the step to use between two passes (0.5 by default)
  61917. */
  61918. step?: number);
  61919. /**
  61920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61921. * @param scene defines the current scene where to apply this optimization
  61922. * @param optimizer defines the current optimizer
  61923. * @returns true if everything that can be done was applied
  61924. */
  61925. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61926. }
  61927. /**
  61928. * Defines an optimization used to remove shadows
  61929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61930. */
  61931. export class ShadowsOptimization extends SceneOptimization {
  61932. /**
  61933. * Gets a string describing the action executed by the current optimization
  61934. * @return description string
  61935. */
  61936. getDescription(): string;
  61937. /**
  61938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61939. * @param scene defines the current scene where to apply this optimization
  61940. * @param optimizer defines the current optimizer
  61941. * @returns true if everything that can be done was applied
  61942. */
  61943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61944. }
  61945. /**
  61946. * Defines an optimization used to turn post-processes off
  61947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61948. */
  61949. export class PostProcessesOptimization extends SceneOptimization {
  61950. /**
  61951. * Gets a string describing the action executed by the current optimization
  61952. * @return description string
  61953. */
  61954. getDescription(): string;
  61955. /**
  61956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61957. * @param scene defines the current scene where to apply this optimization
  61958. * @param optimizer defines the current optimizer
  61959. * @returns true if everything that can be done was applied
  61960. */
  61961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61962. }
  61963. /**
  61964. * Defines an optimization used to turn lens flares off
  61965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61966. */
  61967. export class LensFlaresOptimization extends SceneOptimization {
  61968. /**
  61969. * Gets a string describing the action executed by the current optimization
  61970. * @return description string
  61971. */
  61972. getDescription(): string;
  61973. /**
  61974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61975. * @param scene defines the current scene where to apply this optimization
  61976. * @param optimizer defines the current optimizer
  61977. * @returns true if everything that can be done was applied
  61978. */
  61979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61980. }
  61981. /**
  61982. * Defines an optimization based on user defined callback.
  61983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61984. */
  61985. export class CustomOptimization extends SceneOptimization {
  61986. /**
  61987. * Callback called to apply the custom optimization.
  61988. */
  61989. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61990. /**
  61991. * Callback called to get custom description
  61992. */
  61993. onGetDescription: () => string;
  61994. /**
  61995. * Gets a string describing the action executed by the current optimization
  61996. * @returns description string
  61997. */
  61998. getDescription(): string;
  61999. /**
  62000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62001. * @param scene defines the current scene where to apply this optimization
  62002. * @param optimizer defines the current optimizer
  62003. * @returns true if everything that can be done was applied
  62004. */
  62005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62006. }
  62007. /**
  62008. * Defines an optimization used to turn particles off
  62009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62010. */
  62011. export class ParticlesOptimization extends SceneOptimization {
  62012. /**
  62013. * Gets a string describing the action executed by the current optimization
  62014. * @return description string
  62015. */
  62016. getDescription(): string;
  62017. /**
  62018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62019. * @param scene defines the current scene where to apply this optimization
  62020. * @param optimizer defines the current optimizer
  62021. * @returns true if everything that can be done was applied
  62022. */
  62023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62024. }
  62025. /**
  62026. * Defines an optimization used to turn render targets off
  62027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62028. */
  62029. export class RenderTargetsOptimization extends SceneOptimization {
  62030. /**
  62031. * Gets a string describing the action executed by the current optimization
  62032. * @return description string
  62033. */
  62034. getDescription(): string;
  62035. /**
  62036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62037. * @param scene defines the current scene where to apply this optimization
  62038. * @param optimizer defines the current optimizer
  62039. * @returns true if everything that can be done was applied
  62040. */
  62041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62042. }
  62043. /**
  62044. * Defines an optimization used to merge meshes with compatible materials
  62045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62046. */
  62047. export class MergeMeshesOptimization extends SceneOptimization {
  62048. private static _UpdateSelectionTree;
  62049. /**
  62050. * Gets or sets a boolean which defines if optimization octree has to be updated
  62051. */
  62052. /**
  62053. * Gets or sets a boolean which defines if optimization octree has to be updated
  62054. */
  62055. static UpdateSelectionTree: boolean;
  62056. /**
  62057. * Gets a string describing the action executed by the current optimization
  62058. * @return description string
  62059. */
  62060. getDescription(): string;
  62061. private _canBeMerged;
  62062. /**
  62063. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62064. * @param scene defines the current scene where to apply this optimization
  62065. * @param optimizer defines the current optimizer
  62066. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62067. * @returns true if everything that can be done was applied
  62068. */
  62069. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62070. }
  62071. /**
  62072. * Defines a list of options used by SceneOptimizer
  62073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62074. */
  62075. export class SceneOptimizerOptions {
  62076. /**
  62077. * Defines the target frame rate to reach (60 by default)
  62078. */
  62079. targetFrameRate: number;
  62080. /**
  62081. * Defines the interval between two checkes (2000ms by default)
  62082. */
  62083. trackerDuration: number;
  62084. /**
  62085. * Gets the list of optimizations to apply
  62086. */
  62087. optimizations: SceneOptimization[];
  62088. /**
  62089. * Creates a new list of options used by SceneOptimizer
  62090. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62091. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62092. */
  62093. constructor(
  62094. /**
  62095. * Defines the target frame rate to reach (60 by default)
  62096. */
  62097. targetFrameRate?: number,
  62098. /**
  62099. * Defines the interval between two checkes (2000ms by default)
  62100. */
  62101. trackerDuration?: number);
  62102. /**
  62103. * Add a new optimization
  62104. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62105. * @returns the current SceneOptimizerOptions
  62106. */
  62107. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62108. /**
  62109. * Add a new custom optimization
  62110. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62111. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62112. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62113. * @returns the current SceneOptimizerOptions
  62114. */
  62115. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62116. /**
  62117. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62118. * @param targetFrameRate defines the target frame rate (60 by default)
  62119. * @returns a SceneOptimizerOptions object
  62120. */
  62121. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62122. /**
  62123. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62124. * @param targetFrameRate defines the target frame rate (60 by default)
  62125. * @returns a SceneOptimizerOptions object
  62126. */
  62127. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62128. /**
  62129. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62130. * @param targetFrameRate defines the target frame rate (60 by default)
  62131. * @returns a SceneOptimizerOptions object
  62132. */
  62133. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62134. }
  62135. /**
  62136. * Class used to run optimizations in order to reach a target frame rate
  62137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62138. */
  62139. export class SceneOptimizer implements IDisposable {
  62140. private _isRunning;
  62141. private _options;
  62142. private _scene;
  62143. private _currentPriorityLevel;
  62144. private _targetFrameRate;
  62145. private _trackerDuration;
  62146. private _currentFrameRate;
  62147. private _sceneDisposeObserver;
  62148. private _improvementMode;
  62149. /**
  62150. * Defines an observable called when the optimizer reaches the target frame rate
  62151. */
  62152. onSuccessObservable: Observable<SceneOptimizer>;
  62153. /**
  62154. * Defines an observable called when the optimizer enables an optimization
  62155. */
  62156. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62157. /**
  62158. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62159. */
  62160. onFailureObservable: Observable<SceneOptimizer>;
  62161. /**
  62162. * Gets a boolean indicating if the optimizer is in improvement mode
  62163. */
  62164. readonly isInImprovementMode: boolean;
  62165. /**
  62166. * Gets the current priority level (0 at start)
  62167. */
  62168. readonly currentPriorityLevel: number;
  62169. /**
  62170. * Gets the current frame rate checked by the SceneOptimizer
  62171. */
  62172. readonly currentFrameRate: number;
  62173. /**
  62174. * Gets or sets the current target frame rate (60 by default)
  62175. */
  62176. /**
  62177. * Gets or sets the current target frame rate (60 by default)
  62178. */
  62179. targetFrameRate: number;
  62180. /**
  62181. * Gets or sets the current interval between two checks (every 2000ms by default)
  62182. */
  62183. /**
  62184. * Gets or sets the current interval between two checks (every 2000ms by default)
  62185. */
  62186. trackerDuration: number;
  62187. /**
  62188. * Gets the list of active optimizations
  62189. */
  62190. readonly optimizations: SceneOptimization[];
  62191. /**
  62192. * Creates a new SceneOptimizer
  62193. * @param scene defines the scene to work on
  62194. * @param options defines the options to use with the SceneOptimizer
  62195. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62196. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  62197. */
  62198. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62199. /**
  62200. * Stops the current optimizer
  62201. */
  62202. stop(): void;
  62203. /**
  62204. * Reset the optimizer to initial step (current priority level = 0)
  62205. */
  62206. reset(): void;
  62207. /**
  62208. * Start the optimizer. By default it will try to reach a specific framerate
  62209. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62210. */
  62211. start(): void;
  62212. private _checkCurrentState;
  62213. /**
  62214. * Release all resources
  62215. */
  62216. dispose(): void;
  62217. /**
  62218. * Helper function to create a SceneOptimizer with one single line of code
  62219. * @param scene defines the scene to work on
  62220. * @param options defines the options to use with the SceneOptimizer
  62221. * @param onSuccess defines a callback to call on success
  62222. * @param onFailure defines a callback to call on failure
  62223. * @returns the new SceneOptimizer object
  62224. */
  62225. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62226. }
  62227. }
  62228. declare module BABYLON {
  62229. /**
  62230. * Class used to serialize a scene into a string
  62231. */
  62232. export class SceneSerializer {
  62233. /**
  62234. * Clear cache used by a previous serialization
  62235. */
  62236. static ClearCache(): void;
  62237. /**
  62238. * Serialize a scene into a JSON compatible object
  62239. * @param scene defines the scene to serialize
  62240. * @returns a JSON compatible object
  62241. */
  62242. static Serialize(scene: Scene): any;
  62243. /**
  62244. * Serialize a mesh into a JSON compatible object
  62245. * @param toSerialize defines the mesh to serialize
  62246. * @param withParents defines if parents must be serialized as well
  62247. * @param withChildren defines if children must be serialized as well
  62248. * @returns a JSON compatible object
  62249. */
  62250. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62251. }
  62252. }
  62253. declare module BABYLON {
  62254. /**
  62255. * Class used to host texture specific utilities
  62256. */
  62257. export class TextureTools {
  62258. /**
  62259. * Uses the GPU to create a copy texture rescaled at a given size
  62260. * @param texture Texture to copy from
  62261. * @param width defines the desired width
  62262. * @param height defines the desired height
  62263. * @param useBilinearMode defines if bilinear mode has to be used
  62264. * @return the generated texture
  62265. */
  62266. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62267. }
  62268. }
  62269. declare module BABYLON {
  62270. /**
  62271. * This represents the different options available for the video capture.
  62272. */
  62273. export interface VideoRecorderOptions {
  62274. /** Defines the mime type of the video. */
  62275. mimeType: string;
  62276. /** Defines the FPS the video should be recorded at. */
  62277. fps: number;
  62278. /** Defines the chunk size for the recording data. */
  62279. recordChunckSize: number;
  62280. /** The audio tracks to attach to the recording. */
  62281. audioTracks?: MediaStreamTrack[];
  62282. }
  62283. /**
  62284. * This can help with recording videos from BabylonJS.
  62285. * This is based on the available WebRTC functionalities of the browser.
  62286. *
  62287. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62288. */
  62289. export class VideoRecorder {
  62290. private static readonly _defaultOptions;
  62291. /**
  62292. * Returns whether or not the VideoRecorder is available in your browser.
  62293. * @param engine Defines the Babylon Engine.
  62294. * @returns true if supported otherwise false.
  62295. */
  62296. static IsSupported(engine: Engine): boolean;
  62297. private readonly _options;
  62298. private _canvas;
  62299. private _mediaRecorder;
  62300. private _recordedChunks;
  62301. private _fileName;
  62302. private _resolve;
  62303. private _reject;
  62304. /**
  62305. * True when a recording is already in progress.
  62306. */
  62307. readonly isRecording: boolean;
  62308. /**
  62309. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62310. * @param engine Defines the BabylonJS Engine you wish to record.
  62311. * @param options Defines options that can be used to customize the capture.
  62312. */
  62313. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62314. /**
  62315. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62316. */
  62317. stopRecording(): void;
  62318. /**
  62319. * Starts recording the canvas for a max duration specified in parameters.
  62320. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62321. * If null no automatic download will start and you can rely on the promise to get the data back.
  62322. * @param maxDuration Defines the maximum recording time in seconds.
  62323. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62324. * @return A promise callback at the end of the recording with the video data in Blob.
  62325. */
  62326. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62327. /**
  62328. * Releases internal resources used during the recording.
  62329. */
  62330. dispose(): void;
  62331. private _handleDataAvailable;
  62332. private _handleError;
  62333. private _handleStop;
  62334. }
  62335. }
  62336. declare module BABYLON {
  62337. /**
  62338. * Class containing a set of static utilities functions for screenshots
  62339. */
  62340. export class ScreenshotTools {
  62341. /**
  62342. * Captures a screenshot of the current rendering
  62343. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62344. * @param engine defines the rendering engine
  62345. * @param camera defines the source camera
  62346. * @param size This parameter can be set to a single number or to an object with the
  62347. * following (optional) properties: precision, width, height. If a single number is passed,
  62348. * it will be used for both width and height. If an object is passed, the screenshot size
  62349. * will be derived from the parameters. The precision property is a multiplier allowing
  62350. * rendering at a higher or lower resolution
  62351. * @param successCallback defines the callback receives a single parameter which contains the
  62352. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62353. * src parameter of an <img> to display it
  62354. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62355. * Check your browser for supported MIME types
  62356. */
  62357. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62358. /**
  62359. * Captures a screenshot of the current rendering
  62360. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62361. * @param engine defines the rendering engine
  62362. * @param camera defines the source camera
  62363. * @param size This parameter can be set to a single number or to an object with the
  62364. * following (optional) properties: precision, width, height. If a single number is passed,
  62365. * it will be used for both width and height. If an object is passed, the screenshot size
  62366. * will be derived from the parameters. The precision property is a multiplier allowing
  62367. * rendering at a higher or lower resolution
  62368. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62369. * Check your browser for supported MIME types
  62370. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62371. * to the src parameter of an <img> to display it
  62372. */
  62373. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62374. /**
  62375. * Generates an image screenshot from the specified camera.
  62376. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62377. * @param engine The engine to use for rendering
  62378. * @param camera The camera to use for rendering
  62379. * @param size This parameter can be set to a single number or to an object with the
  62380. * following (optional) properties: precision, width, height. If a single number is passed,
  62381. * it will be used for both width and height. If an object is passed, the screenshot size
  62382. * will be derived from the parameters. The precision property is a multiplier allowing
  62383. * rendering at a higher or lower resolution
  62384. * @param successCallback The callback receives a single parameter which contains the
  62385. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62386. * src parameter of an <img> to display it
  62387. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62388. * Check your browser for supported MIME types
  62389. * @param samples Texture samples (default: 1)
  62390. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62391. * @param fileName A name for for the downloaded file.
  62392. */
  62393. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62394. /**
  62395. * Generates an image screenshot from the specified camera.
  62396. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62397. * @param engine The engine to use for rendering
  62398. * @param camera The camera to use for rendering
  62399. * @param size This parameter can be set to a single number or to an object with the
  62400. * following (optional) properties: precision, width, height. If a single number is passed,
  62401. * it will be used for both width and height. If an object is passed, the screenshot size
  62402. * will be derived from the parameters. The precision property is a multiplier allowing
  62403. * rendering at a higher or lower resolution
  62404. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62405. * Check your browser for supported MIME types
  62406. * @param samples Texture samples (default: 1)
  62407. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62408. * @param fileName A name for for the downloaded file.
  62409. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62410. * to the src parameter of an <img> to display it
  62411. */
  62412. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62413. /**
  62414. * Gets height and width for screenshot size
  62415. * @private
  62416. */
  62417. private static _getScreenshotSize;
  62418. }
  62419. }
  62420. declare module BABYLON {
  62421. /**
  62422. * A cursor which tracks a point on a path
  62423. */
  62424. export class PathCursor {
  62425. private path;
  62426. /**
  62427. * Stores path cursor callbacks for when an onchange event is triggered
  62428. */
  62429. private _onchange;
  62430. /**
  62431. * The value of the path cursor
  62432. */
  62433. value: number;
  62434. /**
  62435. * The animation array of the path cursor
  62436. */
  62437. animations: Animation[];
  62438. /**
  62439. * Initializes the path cursor
  62440. * @param path The path to track
  62441. */
  62442. constructor(path: Path2);
  62443. /**
  62444. * Gets the cursor point on the path
  62445. * @returns A point on the path cursor at the cursor location
  62446. */
  62447. getPoint(): Vector3;
  62448. /**
  62449. * Moves the cursor ahead by the step amount
  62450. * @param step The amount to move the cursor forward
  62451. * @returns This path cursor
  62452. */
  62453. moveAhead(step?: number): PathCursor;
  62454. /**
  62455. * Moves the cursor behind by the step amount
  62456. * @param step The amount to move the cursor back
  62457. * @returns This path cursor
  62458. */
  62459. moveBack(step?: number): PathCursor;
  62460. /**
  62461. * Moves the cursor by the step amount
  62462. * If the step amount is greater than one, an exception is thrown
  62463. * @param step The amount to move the cursor
  62464. * @returns This path cursor
  62465. */
  62466. move(step: number): PathCursor;
  62467. /**
  62468. * Ensures that the value is limited between zero and one
  62469. * @returns This path cursor
  62470. */
  62471. private ensureLimits;
  62472. /**
  62473. * Runs onchange callbacks on change (used by the animation engine)
  62474. * @returns This path cursor
  62475. */
  62476. private raiseOnChange;
  62477. /**
  62478. * Executes a function on change
  62479. * @param f A path cursor onchange callback
  62480. * @returns This path cursor
  62481. */
  62482. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62483. }
  62484. }
  62485. declare module BABYLON {
  62486. /** @hidden */
  62487. export var blurPixelShader: {
  62488. name: string;
  62489. shader: string;
  62490. };
  62491. }
  62492. declare module BABYLON {
  62493. /** @hidden */
  62494. export var pointCloudVertexDeclaration: {
  62495. name: string;
  62496. shader: string;
  62497. };
  62498. }
  62499. // Mixins
  62500. interface Window {
  62501. mozIndexedDB: IDBFactory;
  62502. webkitIndexedDB: IDBFactory;
  62503. msIndexedDB: IDBFactory;
  62504. webkitURL: typeof URL;
  62505. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62506. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62507. WebGLRenderingContext: WebGLRenderingContext;
  62508. MSGesture: MSGesture;
  62509. CANNON: any;
  62510. AudioContext: AudioContext;
  62511. webkitAudioContext: AudioContext;
  62512. PointerEvent: any;
  62513. Math: Math;
  62514. Uint8Array: Uint8ArrayConstructor;
  62515. Float32Array: Float32ArrayConstructor;
  62516. mozURL: typeof URL;
  62517. msURL: typeof URL;
  62518. VRFrameData: any; // WebVR, from specs 1.1
  62519. DracoDecoderModule: any;
  62520. setImmediate(handler: (...args: any[]) => void): number;
  62521. }
  62522. interface HTMLCanvasElement {
  62523. requestPointerLock(): void;
  62524. msRequestPointerLock?(): void;
  62525. mozRequestPointerLock?(): void;
  62526. webkitRequestPointerLock?(): void;
  62527. /** Track wether a record is in progress */
  62528. isRecording: boolean;
  62529. /** Capture Stream method defined by some browsers */
  62530. captureStream(fps?: number): MediaStream;
  62531. }
  62532. interface CanvasRenderingContext2D {
  62533. msImageSmoothingEnabled: boolean;
  62534. }
  62535. interface MouseEvent {
  62536. mozMovementX: number;
  62537. mozMovementY: number;
  62538. webkitMovementX: number;
  62539. webkitMovementY: number;
  62540. msMovementX: number;
  62541. msMovementY: number;
  62542. }
  62543. interface Navigator {
  62544. mozGetVRDevices: (any: any) => any;
  62545. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62546. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62547. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62548. webkitGetGamepads(): Gamepad[];
  62549. msGetGamepads(): Gamepad[];
  62550. webkitGamepads(): Gamepad[];
  62551. }
  62552. interface HTMLVideoElement {
  62553. mozSrcObject: any;
  62554. }
  62555. interface Math {
  62556. fround(x: number): number;
  62557. imul(a: number, b: number): number;
  62558. }
  62559. interface WebGLRenderingContext {
  62560. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62561. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62562. vertexAttribDivisor(index: number, divisor: number): void;
  62563. createVertexArray(): any;
  62564. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62565. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62566. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62567. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62568. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62569. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62570. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62571. // Queries
  62572. createQuery(): WebGLQuery;
  62573. deleteQuery(query: WebGLQuery): void;
  62574. beginQuery(target: number, query: WebGLQuery): void;
  62575. endQuery(target: number): void;
  62576. getQueryParameter(query: WebGLQuery, pname: number): any;
  62577. getQuery(target: number, pname: number): any;
  62578. MAX_SAMPLES: number;
  62579. RGBA8: number;
  62580. READ_FRAMEBUFFER: number;
  62581. DRAW_FRAMEBUFFER: number;
  62582. UNIFORM_BUFFER: number;
  62583. HALF_FLOAT_OES: number;
  62584. RGBA16F: number;
  62585. RGBA32F: number;
  62586. R32F: number;
  62587. RG32F: number;
  62588. RGB32F: number;
  62589. R16F: number;
  62590. RG16F: number;
  62591. RGB16F: number;
  62592. RED: number;
  62593. RG: number;
  62594. R8: number;
  62595. RG8: number;
  62596. UNSIGNED_INT_24_8: number;
  62597. DEPTH24_STENCIL8: number;
  62598. /* Multiple Render Targets */
  62599. drawBuffers(buffers: number[]): void;
  62600. readBuffer(src: number): void;
  62601. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62602. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62603. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62604. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62605. // Occlusion Query
  62606. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62607. ANY_SAMPLES_PASSED: number;
  62608. QUERY_RESULT_AVAILABLE: number;
  62609. QUERY_RESULT: number;
  62610. }
  62611. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62612. }
  62613. interface EXT_disjoint_timer_query {
  62614. QUERY_COUNTER_BITS_EXT: number;
  62615. TIME_ELAPSED_EXT: number;
  62616. TIMESTAMP_EXT: number;
  62617. GPU_DISJOINT_EXT: number;
  62618. QUERY_RESULT_EXT: number;
  62619. QUERY_RESULT_AVAILABLE_EXT: number;
  62620. queryCounterEXT(query: WebGLQuery, target: number): void;
  62621. createQueryEXT(): WebGLQuery;
  62622. beginQueryEXT(target: number, query: WebGLQuery): void;
  62623. endQueryEXT(target: number): void;
  62624. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62625. deleteQueryEXT(query: WebGLQuery): void;
  62626. }
  62627. interface WebGLUniformLocation { private _currentState: any;
  62628. }
  62629. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62630. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62631. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62632. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62633. interface WebGLRenderingContext {
  62634. readonly RASTERIZER_DISCARD: number;
  62635. readonly DEPTH_COMPONENT24: number;
  62636. readonly TEXTURE_3D: number;
  62637. readonly TEXTURE_2D_ARRAY: number;
  62638. readonly TEXTURE_COMPARE_FUNC: number;
  62639. readonly TEXTURE_COMPARE_MODE: number;
  62640. readonly COMPARE_REF_TO_TEXTURE: number;
  62641. readonly TEXTURE_WRAP_R: number;
  62642. readonly HALF_FLOAT: number;
  62643. readonly RGB8: number;
  62644. readonly RED_INTEGER: number;
  62645. readonly RG_INTEGER: number;
  62646. readonly RGB_INTEGER: number;
  62647. readonly RGBA_INTEGER: number;
  62648. readonly R8_SNORM: number;
  62649. readonly RG8_SNORM: number;
  62650. readonly RGB8_SNORM: number;
  62651. readonly RGBA8_SNORM: number;
  62652. readonly R8I: number;
  62653. readonly RG8I: number;
  62654. readonly RGB8I: number;
  62655. readonly RGBA8I: number;
  62656. readonly R8UI: number;
  62657. readonly RG8UI: number;
  62658. readonly RGB8UI: number;
  62659. readonly RGBA8UI: number;
  62660. readonly R16I: number;
  62661. readonly RG16I: number;
  62662. readonly RGB16I: number;
  62663. readonly RGBA16I: number;
  62664. readonly R16UI: number;
  62665. readonly RG16UI: number;
  62666. readonly RGB16UI: number;
  62667. readonly RGBA16UI: number;
  62668. readonly R32I: number;
  62669. readonly RG32I: number;
  62670. readonly RGB32I: number;
  62671. readonly RGBA32I: number;
  62672. readonly R32UI: number;
  62673. readonly RG32UI: number;
  62674. readonly RGB32UI: number;
  62675. readonly RGBA32UI: number;
  62676. readonly RGB10_A2UI: number;
  62677. readonly R11F_G11F_B10F: number;
  62678. readonly RGB9_E5: number;
  62679. readonly RGB10_A2: number;
  62680. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62681. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62682. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62683. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62684. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62685. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62686. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
  62687. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62688. readonly TRANSFORM_FEEDBACK: number;
  62689. readonly INTERLEAVED_ATTRIBS: number;
  62690. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62691. createTransformFeedback(): WebGLTransformFeedback;
  62692. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62693. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62694. beginTransformFeedback(primitiveMode: number): void;
  62695. endTransformFeedback(): void;
  62696. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62697. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62698. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62699. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62700. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62701. }
  62702. interface ImageBitmap {
  62703. readonly width: number;
  62704. readonly height: number;
  62705. close(): void;
  62706. }
  62707. interface WebGLQuery extends WebGLObject {
  62708. }
  62709. declare var WebGLQuery: {
  62710. prototype: WebGLQuery;
  62711. new(): WebGLQuery;
  62712. };
  62713. interface WebGLSampler extends WebGLObject {
  62714. }
  62715. declare var WebGLSampler: {
  62716. prototype: WebGLSampler;
  62717. new(): WebGLSampler;
  62718. };
  62719. interface WebGLSync extends WebGLObject {
  62720. }
  62721. declare var WebGLSync: {
  62722. prototype: WebGLSync;
  62723. new(): WebGLSync;
  62724. };
  62725. interface WebGLTransformFeedback extends WebGLObject {
  62726. }
  62727. declare var WebGLTransformFeedback: {
  62728. prototype: WebGLTransformFeedback;
  62729. new(): WebGLTransformFeedback;
  62730. };
  62731. interface WebGLVertexArrayObject extends WebGLObject {
  62732. }
  62733. declare var WebGLVertexArrayObject: {
  62734. prototype: WebGLVertexArrayObject;
  62735. new(): WebGLVertexArrayObject;
  62736. };
  62737. // https://github.com/gpuweb/gpuweb/blob/767e515eba9306840ce3fdf57ef9d73ae5d24296/spec/index.bs
  62738. // except #280 setSubData (TODO)
  62739. interface GPUColorDict {
  62740. a: number;
  62741. b: number;
  62742. g: number;
  62743. r: number;
  62744. }
  62745. type GPUColor = [number, number, number, number] | GPUColorDict;
  62746. interface GPUOrigin2DDict {
  62747. x?: number;
  62748. y?: number;
  62749. }
  62750. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  62751. interface GPUOrigin3DDict {
  62752. x?: number;
  62753. y?: number;
  62754. z?: number;
  62755. }
  62756. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  62757. interface GPUExtent3DDict {
  62758. width: number;
  62759. height: number;
  62760. depth: number;
  62761. }
  62762. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  62763. type GPUBindingResource =
  62764. | GPUSampler
  62765. | GPUTextureView
  62766. | GPUBufferBinding;
  62767. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  62768. type GPUBindingType =
  62769. | "uniform-buffer"
  62770. | "storage-buffer"
  62771. | "readonly-storage-buffer"
  62772. | "sampler"
  62773. | "sampled-texture"
  62774. | "storage-texture";
  62775. type GPUBlendFactor =
  62776. | "zero"
  62777. | "one"
  62778. | "src-color"
  62779. | "one-minus-src-color"
  62780. | "src-alpha"
  62781. | "one-minus-src-alpha"
  62782. | "dst-color"
  62783. | "one-minus-dst-color"
  62784. | "dst-alpha"
  62785. | "one-minus-dst-alpha"
  62786. | "src-alpha-saturated"
  62787. | "blend-color"
  62788. | "one-minus-blend-color";
  62789. type GPUBlendOperation =
  62790. | "add"
  62791. | "subtract"
  62792. | "reverse-subtract"
  62793. | "min"
  62794. | "max";
  62795. type GPUCompareFunction =
  62796. | "never"
  62797. | "less"
  62798. | "equal"
  62799. | "lessEqual"
  62800. | "greater"
  62801. | "notEqual"
  62802. | "greaterEqual"
  62803. | "always";
  62804. type GPUCullMode = "none" | "front" | "back";
  62805. type GPUFilterMode = "nearest" | "linear";
  62806. type GPUFrontFace = "ccw" | "cw";
  62807. type GPUIndexFormat = "uint16" | "uint32";
  62808. type GPUInputStepMode = "vertex" | "instance";
  62809. type GPULoadOp = "load";
  62810. type GPUPrimitiveTopology =
  62811. | "point-list"
  62812. | "line-list"
  62813. | "line-strip"
  62814. | "triangle-list"
  62815. | "triangle-strip";
  62816. type GPUStencilOperation =
  62817. | "keep"
  62818. | "zero"
  62819. | "replace"
  62820. | "invert"
  62821. | "increment-clamp"
  62822. | "decrement-clamp"
  62823. | "increment-wrap"
  62824. | "decrement-wrap";
  62825. type GPUStoreOp = "store" | "clear";
  62826. type GPUTextureDimension = "1d" | "2d" | "3d";
  62827. type GPUTextureFormat =
  62828. | "r8unorm"
  62829. | "r8snorm"
  62830. | "r8uint"
  62831. | "r8sint"
  62832. | "r16uint"
  62833. | "r16sint"
  62834. | "r16float"
  62835. | "rg8unorm"
  62836. | "rg8snorm"
  62837. | "rg8uint"
  62838. | "rg8sint"
  62839. | "r32uint"
  62840. | "r32sint"
  62841. | "r32float"
  62842. | "rg16uint"
  62843. | "rg16sint"
  62844. | "rg16float"
  62845. | "rgba8unorm"
  62846. | "rgba8unorm-srgb"
  62847. | "rgba8snorm"
  62848. | "rgba8uint"
  62849. | "rgba8sint"
  62850. | "bgra8unorm"
  62851. | "bgra8unorm-srgb"
  62852. | "rgb10a2unorm"
  62853. | "rg11b10float"
  62854. | "rg32uint"
  62855. | "rg32sint"
  62856. | "rg32float"
  62857. | "rgba16uint"
  62858. | "rgba16sint"
  62859. | "rgba16float"
  62860. | "rgba32uint"
  62861. | "rgba32sint"
  62862. | "rgba32float"
  62863. | "depth32float"
  62864. | "depth24plus"
  62865. | "depth24plus-stencil8";
  62866. type GPUTextureComponentType = "float" | "sint" | "uint";
  62867. type GPUTextureViewDimension =
  62868. | "1d"
  62869. | "2d"
  62870. | "2d-array"
  62871. | "cube"
  62872. | "cube-array"
  62873. | "3d";
  62874. type GPUVertexFormat =
  62875. | "uchar2"
  62876. | "uchar4"
  62877. | "char2"
  62878. | "char4"
  62879. | "uchar2norm"
  62880. | "uchar4norm"
  62881. | "char2norm"
  62882. | "char4norm"
  62883. | "ushort2"
  62884. | "ushort4"
  62885. | "short2"
  62886. | "short4"
  62887. | "ushort2norm"
  62888. | "ushort4norm"
  62889. | "short2norm"
  62890. | "short4norm"
  62891. | "half2"
  62892. | "half4"
  62893. | "float"
  62894. | "float2"
  62895. | "float3"
  62896. | "float4"
  62897. | "uint"
  62898. | "uint2"
  62899. | "uint3"
  62900. | "uint4"
  62901. | "int"
  62902. | "int2"
  62903. | "int3"
  62904. | "int4";
  62905. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  62906. type GPUBufferUsageFlags = number;
  62907. // enum GPUBufferUsage {
  62908. // NONE = 0x0000,
  62909. // MAP_READ = 0x0001,
  62910. // MAP_WRITE = 0x0002,
  62911. // COPY_SRC = 0x0004,
  62912. // COPY_DST = 0x0008,
  62913. // INDEX = 0x0010,
  62914. // VERTEX = 0x0020,
  62915. // UNIFORM = 0x0040,
  62916. // STORAGE = 0x0080
  62917. // }
  62918. type GPUColorWriteFlags = number;
  62919. // enum GPUColorWrite {
  62920. // NONE = 0x0,
  62921. // RED = 0x1,
  62922. // GREEN = 0x2,
  62923. // BLUE = 0x4,
  62924. // ALPHA = 0x8,
  62925. // ALL = 0xf
  62926. // }
  62927. type GPUShaderStageFlags = number;
  62928. // enum GPUShaderStage {
  62929. // NONE = 0x0,
  62930. // VERTEX = 0x1,
  62931. // FRAGMENT = 0x2,
  62932. // COMPUTE = 0x4
  62933. // }
  62934. type GPUTextureUsageFlags = number;
  62935. // enum GPUTextureUsage {
  62936. // NONE = 0x00,
  62937. // COPY_SRC = 0x01,
  62938. // COPY_DST = 0x02,
  62939. // SAMPLED = 0x04,
  62940. // STORAGE = 0x08,
  62941. // OUTPUT_ATTACHMENT = 0x10
  62942. // }
  62943. interface GPUBindGroupBinding {
  62944. binding: number;
  62945. resource: GPUBindingResource;
  62946. }
  62947. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  62948. layout: GPUBindGroupLayout;
  62949. bindings: GPUBindGroupBinding[];
  62950. }
  62951. interface GPUBindGroupLayoutBinding {
  62952. binding: number;
  62953. visibility: GPUShaderStageFlags;
  62954. type: GPUBindingType;
  62955. textureDimension?: GPUTextureViewDimension;
  62956. textureComponentType?: GPUTextureComponentType;
  62957. multisampled?: boolean;
  62958. dynamic?: boolean;
  62959. }
  62960. interface GPUBindGroupLayoutDescriptor
  62961. extends GPUObjectDescriptorBase {
  62962. bindings?: GPUBindGroupLayoutBinding[];
  62963. }
  62964. interface GPUBlendDescriptor {
  62965. dstFactor?: GPUBlendFactor;
  62966. operation?: GPUBlendOperation;
  62967. srcFactor?: GPUBlendFactor;
  62968. }
  62969. interface GPUColorStateDescriptor {
  62970. format: GPUTextureFormat;
  62971. alphaBlend?: GPUBlendDescriptor;
  62972. colorBlend?: GPUBlendDescriptor;
  62973. writeMask?: GPUColorWriteFlags;
  62974. }
  62975. interface GPUBufferBinding {
  62976. buffer: GPUBuffer;
  62977. offset?: number;
  62978. size?: number;
  62979. }
  62980. interface GPUBufferCopyView {
  62981. buffer: GPUBuffer;
  62982. offset?: number;
  62983. rowPitch: number;
  62984. imageHeight: number;
  62985. }
  62986. interface GPUTextureCopyView {
  62987. texture: GPUTexture;
  62988. mipLevel?: number;
  62989. arrayLayer?: number;
  62990. origin?: GPUOrigin3D;
  62991. }
  62992. interface GPUImageBitmapCopyView {
  62993. imageBitmap: ImageBitmap;
  62994. origin?: GPUOrigin2D;
  62995. }
  62996. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  62997. size: number;
  62998. usage: GPUBufferUsageFlags;
  62999. }
  63000. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  63001. label?: string;
  63002. }
  63003. interface GPUComputePipelineDescriptor
  63004. extends GPUPipelineDescriptorBase {
  63005. computeStage: GPUProgrammableStageDescriptor;
  63006. }
  63007. interface GPUDepthStencilStateDescriptor {
  63008. format: GPUTextureFormat;
  63009. depthWriteEnabled?: boolean;
  63010. depthCompare?: GPUCompareFunction;
  63011. stencilFront: GPUStencilStateFaceDescriptor;
  63012. stencilBack: GPUStencilStateFaceDescriptor;
  63013. stencilReadMask?: number;
  63014. stencilWriteMask?: number;
  63015. }
  63016. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  63017. extensions?: GPUExtensions;
  63018. limits?: GPULimits;
  63019. }
  63020. interface GPUExtensions {
  63021. anisotropicFiltering?: boolean;
  63022. }
  63023. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  63024. initialValue?: number;
  63025. label?: string;
  63026. signalQueue?: GPUQueue;
  63027. }
  63028. interface GPUVertexAttributeDescriptor {
  63029. offset?: number;
  63030. format: GPUVertexFormat;
  63031. shaderLocation: number;
  63032. }
  63033. interface GPUVertexBufferDescriptor {
  63034. stride: number;
  63035. stepMode?: GPUInputStepMode;
  63036. attributeSet: GPUVertexAttributeDescriptor[];
  63037. }
  63038. interface GPUVertexInputDescriptor {
  63039. indexFormat?: GPUIndexFormat;
  63040. vertexBuffers: GPUVertexBufferDescriptor[];
  63041. }
  63042. interface GPULimits {
  63043. maxBindGroups?: number;
  63044. }
  63045. interface GPUPipelineDescriptorBase {
  63046. label?: string;
  63047. layout: GPUPipelineLayout;
  63048. }
  63049. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  63050. bindGroupLayouts: GPUBindGroupLayout[];
  63051. }
  63052. interface GPUProgrammableStageDescriptor {
  63053. module: GPUShaderModule;
  63054. entryPoint: string;
  63055. }
  63056. interface GPURasterizationStateDescriptor {
  63057. frontFace?: GPUFrontFace;
  63058. cullMode?: GPUCullMode;
  63059. depthBias?: number;
  63060. depthBiasSlopeScale?: number;
  63061. depthBiasClamp?: number;
  63062. }
  63063. interface GPURenderPassColorAttachmentDescriptor {
  63064. attachment: GPUTextureView;
  63065. resolveTarget?: GPUTextureView;
  63066. loadValue: GPULoadOp | GPUColor;
  63067. storeOp: GPUStoreOp;
  63068. }
  63069. interface GPURenderPassDepthStencilAttachmentDescriptor {
  63070. attachment: GPUTextureView;
  63071. depthLoadValue: GPULoadOp | number;
  63072. depthStoreOp: GPUStoreOp;
  63073. stencilLoadValue: GPULoadOp | number;
  63074. stencilStoreOp: GPUStoreOp;
  63075. }
  63076. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  63077. colorAttachments: GPURenderPassColorAttachmentDescriptor[];
  63078. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  63079. }
  63080. interface GPURenderPipelineStageDescriptor {
  63081. vertexStage: GPUProgrammableStageDescriptor;
  63082. fragmentStage?: GPUProgrammableStageDescriptor;
  63083. }
  63084. interface GPURenderPipelineDescriptor
  63085. extends GPUPipelineDescriptorBase, GPUPipelineDescriptorBase {
  63086. primitiveTopology: GPUPrimitiveTopology;
  63087. rasterizationState?: GPURasterizationStateDescriptor;
  63088. colorStates: GPUColorStateDescriptor[];
  63089. depthStencilState?: GPUDepthStencilStateDescriptor;
  63090. vertexInput: GPUVertexInputDescriptor;
  63091. sampleCount?: number;
  63092. sampleMask?: number;
  63093. alphaToCoverageEnabled?: boolean;
  63094. }
  63095. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  63096. compare?: GPUCompareFunction;
  63097. lodMaxClamp?: number;
  63098. lodMinClamp?: number;
  63099. magFilter?: GPUFilterMode;
  63100. maxAnisotropy?: number;
  63101. minFilter?: GPUFilterMode;
  63102. mipmapFilter?: GPUFilterMode;
  63103. addressModeU?: GPUAddressMode;
  63104. addressModeV?: GPUAddressMode;
  63105. addressModeW?: GPUAddressMode;
  63106. }
  63107. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  63108. code: Uint32Array | string;
  63109. label?: string;
  63110. }
  63111. interface GPUStencilStateFaceDescriptor {
  63112. compare?: GPUCompareFunction;
  63113. depthFailOp?: GPUStencilOperation;
  63114. passOp?: GPUStencilOperation;
  63115. failOp?: GPUStencilOperation;
  63116. }
  63117. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  63118. device: GPUDevice;
  63119. format: GPUTextureFormat;
  63120. usage?: GPUTextureUsageFlags;
  63121. }
  63122. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  63123. size: GPUExtent3D;
  63124. arrayLayerCount?: number;
  63125. mipLevelCount?: number;
  63126. sampleCount?: number;
  63127. dimension?: GPUTextureDimension;
  63128. format: GPUTextureFormat;
  63129. usage: GPUTextureUsageFlags;
  63130. }
  63131. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  63132. format?: GPUTextureFormat;
  63133. dimension?: GPUTextureViewDimension;
  63134. aspect?: GPUTextureAspect;
  63135. baseArrayLayer?: number;
  63136. baseMipLevel?: number;
  63137. arrayLayerCount?: number;
  63138. mipLevelCount?: number;
  63139. }
  63140. interface GPUAdapter extends GPUObjectBase {
  63141. readonly extensions: GPUExtensions;
  63142. readonly name: string;
  63143. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice>;
  63144. }
  63145. interface GPUBindGroup extends GPUObjectBase {}
  63146. interface GPUBindGroupLayout extends GPUObjectBase {}
  63147. interface GPUBuffer extends GPUObjectBase {
  63148. //readonly mapping: ArrayBuffer | null;
  63149. destroy(): void;
  63150. unmap(): void;
  63151. mapWriteAsync(): Promise<ArrayBuffer>;
  63152. mapReadAsync(): Promise<ArrayBuffer>;
  63153. // TODO: Remove setSubData (#280)
  63154. setSubData(
  63155. offset: number,
  63156. src: ArrayBufferView,
  63157. srcOffset?: number,
  63158. byteLength?: number
  63159. ): void;
  63160. }
  63161. interface GPUCommandBuffer extends GPUObjectBase {}
  63162. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase {}
  63163. interface GPUCommandEncoder extends GPUObjectBase {
  63164. beginComputePass(
  63165. descriptor?: GPUComputePassDescriptor
  63166. ): GPUComputePassEncoder;
  63167. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  63168. copyBufferToBuffer(
  63169. source: GPUBuffer,
  63170. sourceOffset: number,
  63171. destination: GPUBuffer,
  63172. destinationOffset: number,
  63173. size: number
  63174. ): void;
  63175. copyBufferToTexture(
  63176. source: GPUBufferCopyView,
  63177. destination: GPUTextureCopyView,
  63178. copySize: GPUExtent3D
  63179. ): void;
  63180. copyTextureToBuffer(
  63181. source: GPUTextureCopyView,
  63182. destination: GPUBufferCopyView,
  63183. copySize: GPUExtent3D
  63184. ): void;
  63185. copyTextureToTexture(
  63186. source: GPUTextureCopyView,
  63187. destination: GPUTextureCopyView,
  63188. copySize: GPUExtent3D
  63189. ): void;
  63190. copyImageBitmapToTexture(
  63191. source: GPUImageBitmapCopyView,
  63192. destination: GPUTextureCopyView,
  63193. copySize: GPUExtent3D
  63194. ): void;
  63195. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  63196. popDebugGroup(): void;
  63197. pushDebugGroup(groupLabel: string): void;
  63198. insertDebugMarker(markerLabel: string): void;
  63199. }
  63200. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase {}
  63201. interface GPUComputePassEncoder extends GPUProgrammablePassEncoder {
  63202. setPipeline(pipeline: GPUComputePipeline): void;
  63203. dispatch(x: number, y?: number, z?: number): void;
  63204. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  63205. endPass(): void;
  63206. }
  63207. interface GPUComputePipeline extends GPUObjectBase {}
  63208. interface GPUObjectBase {
  63209. label: string | undefined;
  63210. }
  63211. interface GPUObjectDescriptorBase {
  63212. label?: string;
  63213. }
  63214. // SwapChain / CanvasContext
  63215. interface GPUCanvasContext {
  63216. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  63217. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  63218. }
  63219. interface GPUDevice extends GPUObjectBase {
  63220. readonly adapter: GPUAdapter;
  63221. readonly extensions: GPUExtensions;
  63222. readonly limits: GPULimits;
  63223. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  63224. createBindGroupLayout(
  63225. descriptor: GPUBindGroupLayoutDescriptor
  63226. ): GPUBindGroupLayout;
  63227. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  63228. createBufferMapped(
  63229. descriptor: GPUBufferDescriptor
  63230. ): [GPUBuffer, ArrayBuffer];
  63231. createBufferMappedAsync(
  63232. descriptor: GPUBufferDescriptor
  63233. ): Promise<[GPUBuffer, ArrayBuffer]>;
  63234. createComputePipeline(
  63235. descriptor: GPUComputePipelineDescriptor
  63236. ): GPUComputePipeline;
  63237. createPipelineLayout(
  63238. descriptor: GPUPipelineLayoutDescriptor
  63239. ): GPUPipelineLayout;
  63240. createRenderPipeline(
  63241. descriptor: GPURenderPipelineDescriptor
  63242. ): GPURenderPipeline;
  63243. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  63244. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  63245. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  63246. createCommandEncoder(
  63247. descriptor?: GPUCommandEncoderDescriptor
  63248. ): GPUCommandEncoder;
  63249. createRenderBundleEncoder(
  63250. descriptor: GPURenderBundleEncoderDescriptor
  63251. ): GPURenderBundleEncoder;
  63252. getQueue(): GPUQueue;
  63253. readonly lost: Promise<GPUDeviceLostInfo>;
  63254. }
  63255. interface GPUFence extends GPUObjectBase {
  63256. getCompletedValue(): number;
  63257. onCompletion(completionValue: number): Promise<void>;
  63258. }
  63259. interface GPUPipelineLayout extends GPUObjectBase {}
  63260. interface GPUProgrammablePassEncoder extends GPUObjectBase {
  63261. setBindGroup(index: number, bindGroup: GPUBindGroup): void;
  63262. popDebugGroup(): void;
  63263. pushDebugGroup(groupLabel: string): void;
  63264. insertDebugMarker(markerLabel: string): void;
  63265. }
  63266. interface GPUQueue extends GPUObjectBase {
  63267. signal(fence: GPUFence, signalValue: number): void;
  63268. submit(buffers: GPUCommandBuffer[]): void;
  63269. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  63270. }
  63271. interface GPURenderEncoderBase extends GPUProgrammablePassEncoder {
  63272. setPipeline(pipeline: GPURenderPipeline): void;
  63273. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  63274. setVertexBuffers(
  63275. startSlot: number,
  63276. buffers: GPUBuffer[],
  63277. offsets: number[]
  63278. ): void;
  63279. draw(
  63280. vertexCount: number,
  63281. instanceCount: number,
  63282. firstVertex: number,
  63283. firstInstance: number
  63284. ): void;
  63285. drawIndexed(
  63286. indexCount: number,
  63287. instanceCount: number,
  63288. firstIndex: number,
  63289. baseVertex: number,
  63290. firstInstance: number
  63291. ): void;
  63292. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  63293. drawIndexedIndirect(
  63294. indirectBuffer: GPUBuffer,
  63295. indirectOffset: number
  63296. ): void;
  63297. }
  63298. interface GPURenderPassEncoder extends GPURenderEncoderBase {
  63299. setViewport(
  63300. x: number,
  63301. y: number,
  63302. width: number,
  63303. height: number,
  63304. minDepth: number,
  63305. maxDepth: number
  63306. ): void;
  63307. setScissorRect(x: number, y: number, width: number, height: number): void;
  63308. setBlendColor(color: GPUColor): void;
  63309. setStencilReference(reference: number): void;
  63310. executeBundles(bundles: GPURenderBundle[]): void;
  63311. endPass(): void;
  63312. }
  63313. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase {}
  63314. interface GPURenderBundle extends GPUObjectBase {}
  63315. interface GPURenderBundleEncoder extends GPURenderEncoderBase {}
  63316. interface GPURenderBundleEncoderDescriptor
  63317. extends GPUObjectDescriptorBase {
  63318. colorFormats: GPUTextureFormat[];
  63319. depthStencilFormat?: GPUTextureFormat;
  63320. sampleCount?: number;
  63321. }
  63322. interface GPURenderPipeline extends GPUObjectBase {}
  63323. interface GPUSampler extends GPUObjectBase {}
  63324. interface GPUShaderModule extends GPUObjectBase {}
  63325. interface GPUSwapChain extends GPUObjectBase {
  63326. getCurrentTexture(): GPUTexture;
  63327. }
  63328. interface GPUTexture extends GPUObjectBase {
  63329. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  63330. destroy(): void;
  63331. }
  63332. interface GPUTextureView extends GPUObjectBase {}
  63333. type GPUPowerPreference = "low-power" | "high-performance";
  63334. interface GPURequestAdapterOptions {
  63335. powerPreference?: GPUPowerPreference;
  63336. }
  63337. interface GPU {
  63338. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter>;
  63339. }
  63340. // ****************************************************************************
  63341. // ERROR SCOPES
  63342. // ****************************************************************************
  63343. type GPUErrorFilter = "none" | "out-of-memory" | "validation";
  63344. declare class GPUOutOfMemoryError {
  63345. constructor();
  63346. }
  63347. declare class GPUValidationError {
  63348. constructor(message: string);
  63349. readonly message: string;
  63350. }
  63351. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  63352. interface GPUDevice {
  63353. pushErrorScope(filter: GPUErrorFilter): void;
  63354. popErrorScope(): Promise<GPUError | null>;
  63355. }
  63356. // ****************************************************************************
  63357. // TELEMETRY
  63358. // ****************************************************************************
  63359. interface GPUUncapturedErrorEvent extends Event {
  63360. readonly error: GPUError;
  63361. }
  63362. interface GPUUncapturedErrorEventInit extends EventInit {
  63363. error: GPUError;
  63364. }
  63365. interface GPUDevice extends EventTarget {
  63366. onuncapturederror: Event | undefined;
  63367. }
  63368. interface GPUDeviceLostInfo {
  63369. readonly message: string;
  63370. }
  63371. interface GPU {
  63372. // May reject with DOMException // TODO: DOMException("OperationError")?
  63373. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter>;
  63374. }
  63375. interface Navigator {
  63376. readonly gpu: GPU | undefined;
  63377. }
  63378. // Type definitions for WebVR API
  63379. // Project: https://w3c.github.io/webvr/
  63380. // Definitions by: six a <https://github.com/lostfictions>
  63381. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63382. interface VRDisplay extends EventTarget {
  63383. /**
  63384. * Dictionary of capabilities describing the VRDisplay.
  63385. */
  63386. readonly capabilities: VRDisplayCapabilities;
  63387. /**
  63388. * z-depth defining the far plane of the eye view frustum
  63389. * enables mapping of values in the render target depth
  63390. * attachment to scene coordinates. Initially set to 10000.0.
  63391. */
  63392. depthFar: number;
  63393. /**
  63394. * z-depth defining the near plane of the eye view frustum
  63395. * enables mapping of values in the render target depth
  63396. * attachment to scene coordinates. Initially set to 0.01.
  63397. */
  63398. depthNear: number;
  63399. /**
  63400. * An identifier for this distinct VRDisplay. Used as an
  63401. * association point in the Gamepad API.
  63402. */
  63403. readonly displayId: number;
  63404. /**
  63405. * A display name, a user-readable name identifying it.
  63406. */
  63407. readonly displayName: string;
  63408. readonly isConnected: boolean;
  63409. readonly isPresenting: boolean;
  63410. /**
  63411. * If this VRDisplay supports room-scale experiences, the optional
  63412. * stage attribute contains details on the room-scale parameters.
  63413. */
  63414. readonly stageParameters: VRStageParameters | null;
  63415. /**
  63416. * Passing the value returned by `requestAnimationFrame` to
  63417. * `cancelAnimationFrame` will unregister the callback.
  63418. * @param handle Define the hanle of the request to cancel
  63419. */
  63420. cancelAnimationFrame(handle: number): void;
  63421. /**
  63422. * Stops presenting to the VRDisplay.
  63423. * @returns a promise to know when it stopped
  63424. */
  63425. exitPresent(): Promise<void>;
  63426. /**
  63427. * Return the current VREyeParameters for the given eye.
  63428. * @param whichEye Define the eye we want the parameter for
  63429. * @returns the eye parameters
  63430. */
  63431. getEyeParameters(whichEye: string): VREyeParameters;
  63432. /**
  63433. * Populates the passed VRFrameData with the information required to render
  63434. * the current frame.
  63435. * @param frameData Define the data structure to populate
  63436. * @returns true if ok otherwise false
  63437. */
  63438. getFrameData(frameData: VRFrameData): boolean;
  63439. /**
  63440. * Get the layers currently being presented.
  63441. * @returns the list of VR layers
  63442. */
  63443. getLayers(): VRLayer[];
  63444. /**
  63445. * Return a VRPose containing the future predicted pose of the VRDisplay
  63446. * when the current frame will be presented. The value returned will not
  63447. * change until JavaScript has returned control to the browser.
  63448. *
  63449. * The VRPose will contain the position, orientation, velocity,
  63450. * and acceleration of each of these properties.
  63451. * @returns the pose object
  63452. */
  63453. getPose(): VRPose;
  63454. /**
  63455. * Return the current instantaneous pose of the VRDisplay, with no
  63456. * prediction applied.
  63457. * @returns the current instantaneous pose
  63458. */
  63459. getImmediatePose(): VRPose;
  63460. /**
  63461. * The callback passed to `requestAnimationFrame` will be called
  63462. * any time a new frame should be rendered. When the VRDisplay is
  63463. * presenting the callback will be called at the native refresh
  63464. * rate of the HMD. When not presenting this function acts
  63465. * identically to how window.requestAnimationFrame acts. Content should
  63466. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63467. * asynchronously from other displays and at differing refresh rates.
  63468. * @param callback Define the eaction to run next frame
  63469. * @returns the request handle it
  63470. */
  63471. requestAnimationFrame(callback: FrameRequestCallback): number;
  63472. /**
  63473. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63474. * Repeat calls while already presenting will update the VRLayers being displayed.
  63475. * @param layers Define the list of layer to present
  63476. * @returns a promise to know when the request has been fulfilled
  63477. */
  63478. requestPresent(layers: VRLayer[]): Promise<void>;
  63479. /**
  63480. * Reset the pose for this display, treating its current position and
  63481. * orientation as the "origin/zero" values. VRPose.position,
  63482. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63483. * updated when calling resetPose(). This should be called in only
  63484. * sitting-space experiences.
  63485. */
  63486. resetPose(): void;
  63487. /**
  63488. * The VRLayer provided to the VRDisplay will be captured and presented
  63489. * in the HMD. Calling this function has the same effect on the source
  63490. * canvas as any other operation that uses its source image, and canvases
  63491. * created without preserveDrawingBuffer set to true will be cleared.
  63492. * @param pose Define the pose to submit
  63493. */
  63494. submitFrame(pose?: VRPose): void;
  63495. }
  63496. declare var VRDisplay: {
  63497. prototype: VRDisplay;
  63498. new(): VRDisplay;
  63499. };
  63500. interface VRLayer {
  63501. leftBounds?: number[] | Float32Array | null;
  63502. rightBounds?: number[] | Float32Array | null;
  63503. source?: HTMLCanvasElement | null;
  63504. }
  63505. interface VRDisplayCapabilities {
  63506. readonly canPresent: boolean;
  63507. readonly hasExternalDisplay: boolean;
  63508. readonly hasOrientation: boolean;
  63509. readonly hasPosition: boolean;
  63510. readonly maxLayers: number;
  63511. }
  63512. interface VREyeParameters {
  63513. /** @deprecated */
  63514. readonly fieldOfView: VRFieldOfView;
  63515. readonly offset: Float32Array;
  63516. readonly renderHeight: number;
  63517. readonly renderWidth: number;
  63518. }
  63519. interface VRFieldOfView {
  63520. readonly downDegrees: number;
  63521. readonly leftDegrees: number;
  63522. readonly rightDegrees: number;
  63523. readonly upDegrees: number;
  63524. }
  63525. interface VRFrameData {
  63526. readonly leftProjectionMatrix: Float32Array;
  63527. readonly leftViewMatrix: Float32Array;
  63528. readonly pose: VRPose;
  63529. readonly rightProjectionMatrix: Float32Array;
  63530. readonly rightViewMatrix: Float32Array;
  63531. readonly timestamp: number;
  63532. }
  63533. interface VRPose {
  63534. readonly angularAcceleration: Float32Array | null;
  63535. readonly angularVelocity: Float32Array | null;
  63536. readonly linearAcceleration: Float32Array | null;
  63537. readonly linearVelocity: Float32Array | null;
  63538. readonly orientation: Float32Array | null;
  63539. readonly position: Float32Array | null;
  63540. readonly timestamp: number;
  63541. }
  63542. interface VRStageParameters {
  63543. sittingToStandingTransform?: Float32Array;
  63544. sizeX?: number;
  63545. sizeY?: number;
  63546. }
  63547. interface Navigator {
  63548. getVRDisplays(): Promise<VRDisplay[]>;
  63549. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63550. }
  63551. interface Window {
  63552. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63553. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63554. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63555. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63556. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63557. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63558. }
  63559. interface Gamepad {
  63560. readonly displayId: number;
  63561. }
  63562. type XRSessionMode =
  63563. | "inline"
  63564. | "immersive-vr"
  63565. | "immersive-ar";
  63566. type XRReferenceSpaceType =
  63567. | "viewer"
  63568. | "local"
  63569. | "local-floor"
  63570. | "bounded-floor"
  63571. | "unbounded";
  63572. type XREnvironmentBlendMode =
  63573. | "opaque"
  63574. | "additive"
  63575. | "alpha-blend";
  63576. type XRVisibilityState =
  63577. | "visible"
  63578. | "visible-blurred"
  63579. | "hidden";
  63580. type XRHandedness =
  63581. | "none"
  63582. | "left"
  63583. | "right";
  63584. type XRTargetRayMode =
  63585. | "gaze"
  63586. | "tracked-pointer"
  63587. | "screen";
  63588. type XREye =
  63589. | "none"
  63590. | "left"
  63591. | "right";
  63592. interface XRSpace extends EventTarget {
  63593. }
  63594. interface XRRenderState {
  63595. depthNear?: number;
  63596. depthFar?: number;
  63597. inlineVerticalFieldOfView?: number;
  63598. baseLayer?: XRWebGLLayer;
  63599. }
  63600. interface XRInputSource {
  63601. handedness: XRHandedness;
  63602. targetRayMode: XRTargetRayMode;
  63603. targetRaySpace: XRSpace;
  63604. gripSpace: XRSpace | undefined;
  63605. gamepad: Gamepad | undefined;
  63606. profiles: Array<string>;
  63607. }
  63608. interface XRSession {
  63609. addEventListener: Function;
  63610. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63611. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63612. requestAnimationFrame: Function;
  63613. end(): Promise<void>;
  63614. renderState: XRRenderState;
  63615. inputSources: Array<XRInputSource>;
  63616. }
  63617. interface XRReferenceSpace extends XRSpace {
  63618. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63619. onreset: any;
  63620. }
  63621. interface XRFrame {
  63622. session: XRSession;
  63623. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63624. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63625. }
  63626. interface XRViewerPose extends XRPose {
  63627. views: Array<XRView>;
  63628. }
  63629. interface XRPose {
  63630. transform: XRRigidTransform;
  63631. emulatedPosition: boolean;
  63632. }
  63633. declare var XRWebGLLayer: {
  63634. prototype: XRWebGLLayer;
  63635. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63636. };
  63637. interface XRWebGLLayer {
  63638. framebuffer: WebGLFramebuffer;
  63639. framebufferWidth: number;
  63640. framebufferHeight: number;
  63641. getViewport: Function;
  63642. }
  63643. interface XRRigidTransform {
  63644. position: DOMPointReadOnly;
  63645. orientation: DOMPointReadOnly;
  63646. matrix: Float32Array;
  63647. inverse: XRRigidTransform;
  63648. }
  63649. interface XRView {
  63650. eye: XREye;
  63651. projectionMatrix: Float32Array;
  63652. transform: XRRigidTransform;
  63653. }
  63654. interface XRInputSourceChangeEvent {
  63655. session: XRSession;
  63656. removed: Array<XRInputSource>;
  63657. added: Array<XRInputSource>;
  63658. }
  63659. declare module BABYLON.GUI {
  63660. /**
  63661. * Class used to specific a value and its associated unit
  63662. */
  63663. export class ValueAndUnit {
  63664. /** defines the unit to store */
  63665. unit: number;
  63666. /** defines a boolean indicating if the value can be negative */
  63667. negativeValueAllowed: boolean;
  63668. private _value;
  63669. private _originalUnit;
  63670. /**
  63671. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63672. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63673. */
  63674. ignoreAdaptiveScaling: boolean;
  63675. /**
  63676. * Creates a new ValueAndUnit
  63677. * @param value defines the value to store
  63678. * @param unit defines the unit to store
  63679. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63680. */
  63681. constructor(value: number,
  63682. /** defines the unit to store */
  63683. unit?: number,
  63684. /** defines a boolean indicating if the value can be negative */
  63685. negativeValueAllowed?: boolean);
  63686. /** Gets a boolean indicating if the value is a percentage */
  63687. readonly isPercentage: boolean;
  63688. /** Gets a boolean indicating if the value is store as pixel */
  63689. readonly isPixel: boolean;
  63690. /** Gets direct internal value */
  63691. readonly internalValue: number;
  63692. /**
  63693. * Gets value as pixel
  63694. * @param host defines the root host
  63695. * @param refValue defines the reference value for percentages
  63696. * @returns the value as pixel
  63697. */
  63698. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63699. /**
  63700. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63701. * @param value defines the value to store
  63702. * @param unit defines the unit to store
  63703. * @returns the current ValueAndUnit
  63704. */
  63705. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63706. /**
  63707. * Gets the value accordingly to its unit
  63708. * @param host defines the root host
  63709. * @returns the value
  63710. */
  63711. getValue(host: AdvancedDynamicTexture): number;
  63712. /**
  63713. * Gets a string representation of the value
  63714. * @param host defines the root host
  63715. * @param decimals defines an optional number of decimals to display
  63716. * @returns a string
  63717. */
  63718. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63719. /**
  63720. * Store a value parsed from a string
  63721. * @param source defines the source string
  63722. * @returns true if the value was successfully parsed
  63723. */
  63724. fromString(source: string | number): boolean;
  63725. private static _Regex;
  63726. private static _UNITMODE_PERCENTAGE;
  63727. private static _UNITMODE_PIXEL;
  63728. /** UNITMODE_PERCENTAGE */
  63729. static readonly UNITMODE_PERCENTAGE: number;
  63730. /** UNITMODE_PIXEL */
  63731. static readonly UNITMODE_PIXEL: number;
  63732. }
  63733. }
  63734. declare module BABYLON.GUI {
  63735. /**
  63736. * Define a style used by control to automatically setup properties based on a template.
  63737. * Only support font related properties so far
  63738. */
  63739. export class Style implements BABYLON.IDisposable {
  63740. private _fontFamily;
  63741. private _fontStyle;
  63742. private _fontWeight;
  63743. /** @hidden */ private _host: AdvancedDynamicTexture;
  63744. /** @hidden */ private _fontSize: ValueAndUnit;
  63745. /**
  63746. * BABYLON.Observable raised when the style values are changed
  63747. */
  63748. onChangedObservable: BABYLON.Observable<Style>;
  63749. /**
  63750. * Creates a new style object
  63751. * @param host defines the AdvancedDynamicTexture which hosts this style
  63752. */
  63753. constructor(host: AdvancedDynamicTexture);
  63754. /**
  63755. * Gets or sets the font size
  63756. */
  63757. fontSize: string | number;
  63758. /**
  63759. * Gets or sets the font family
  63760. */
  63761. fontFamily: string;
  63762. /**
  63763. * Gets or sets the font style
  63764. */
  63765. fontStyle: string;
  63766. /** Gets or sets font weight */
  63767. fontWeight: string;
  63768. /** Dispose all associated resources */
  63769. dispose(): void;
  63770. }
  63771. }
  63772. declare module BABYLON.GUI {
  63773. /**
  63774. * Class used to transport BABYLON.Vector2 information for pointer events
  63775. */
  63776. export class Vector2WithInfo extends BABYLON.Vector2 {
  63777. /** defines the current mouse button index */
  63778. buttonIndex: number;
  63779. /**
  63780. * Creates a new Vector2WithInfo
  63781. * @param source defines the vector2 data to transport
  63782. * @param buttonIndex defines the current mouse button index
  63783. */
  63784. constructor(source: BABYLON.Vector2,
  63785. /** defines the current mouse button index */
  63786. buttonIndex?: number);
  63787. }
  63788. /** Class used to provide 2D matrix features */
  63789. export class Matrix2D {
  63790. /** Gets the internal array of 6 floats used to store matrix data */
  63791. m: Float32Array;
  63792. /**
  63793. * Creates a new matrix
  63794. * @param m00 defines value for (0, 0)
  63795. * @param m01 defines value for (0, 1)
  63796. * @param m10 defines value for (1, 0)
  63797. * @param m11 defines value for (1, 1)
  63798. * @param m20 defines value for (2, 0)
  63799. * @param m21 defines value for (2, 1)
  63800. */
  63801. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63802. /**
  63803. * Fills the matrix from direct values
  63804. * @param m00 defines value for (0, 0)
  63805. * @param m01 defines value for (0, 1)
  63806. * @param m10 defines value for (1, 0)
  63807. * @param m11 defines value for (1, 1)
  63808. * @param m20 defines value for (2, 0)
  63809. * @param m21 defines value for (2, 1)
  63810. * @returns the current modified matrix
  63811. */
  63812. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63813. /**
  63814. * Gets matrix determinant
  63815. * @returns the determinant
  63816. */
  63817. determinant(): number;
  63818. /**
  63819. * Inverses the matrix and stores it in a target matrix
  63820. * @param result defines the target matrix
  63821. * @returns the current matrix
  63822. */
  63823. invertToRef(result: Matrix2D): Matrix2D;
  63824. /**
  63825. * Multiplies the current matrix with another one
  63826. * @param other defines the second operand
  63827. * @param result defines the target matrix
  63828. * @returns the current matrix
  63829. */
  63830. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63831. /**
  63832. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63833. * @param x defines the x coordinate to transform
  63834. * @param y defines the x coordinate to transform
  63835. * @param result defines the target vector2
  63836. * @returns the current matrix
  63837. */
  63838. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63839. /**
  63840. * Creates an identity matrix
  63841. * @returns a new matrix
  63842. */
  63843. static Identity(): Matrix2D;
  63844. /**
  63845. * Creates a translation matrix and stores it in a target matrix
  63846. * @param x defines the x coordinate of the translation
  63847. * @param y defines the y coordinate of the translation
  63848. * @param result defines the target matrix
  63849. */
  63850. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63851. /**
  63852. * Creates a scaling matrix and stores it in a target matrix
  63853. * @param x defines the x coordinate of the scaling
  63854. * @param y defines the y coordinate of the scaling
  63855. * @param result defines the target matrix
  63856. */
  63857. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63858. /**
  63859. * Creates a rotation matrix and stores it in a target matrix
  63860. * @param angle defines the rotation angle
  63861. * @param result defines the target matrix
  63862. */
  63863. static RotationToRef(angle: number, result: Matrix2D): void;
  63864. private static _TempPreTranslationMatrix;
  63865. private static _TempPostTranslationMatrix;
  63866. private static _TempRotationMatrix;
  63867. private static _TempScalingMatrix;
  63868. private static _TempCompose0;
  63869. private static _TempCompose1;
  63870. private static _TempCompose2;
  63871. /**
  63872. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63873. * @param tx defines the x coordinate of the translation
  63874. * @param ty defines the y coordinate of the translation
  63875. * @param angle defines the rotation angle
  63876. * @param scaleX defines the x coordinate of the scaling
  63877. * @param scaleY defines the y coordinate of the scaling
  63878. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63879. * @param result defines the target matrix
  63880. */
  63881. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63882. }
  63883. }
  63884. declare module BABYLON.GUI {
  63885. /**
  63886. * Class used to store 2D control sizes
  63887. */
  63888. export class Measure {
  63889. /** defines left coordinate */
  63890. left: number;
  63891. /** defines top coordinate */
  63892. top: number;
  63893. /** defines width dimension */
  63894. width: number;
  63895. /** defines height dimension */
  63896. height: number;
  63897. /**
  63898. * Creates a new measure
  63899. * @param left defines left coordinate
  63900. * @param top defines top coordinate
  63901. * @param width defines width dimension
  63902. * @param height defines height dimension
  63903. */
  63904. constructor(
  63905. /** defines left coordinate */
  63906. left: number,
  63907. /** defines top coordinate */
  63908. top: number,
  63909. /** defines width dimension */
  63910. width: number,
  63911. /** defines height dimension */
  63912. height: number);
  63913. /**
  63914. * Copy from another measure
  63915. * @param other defines the other measure to copy from
  63916. */
  63917. copyFrom(other: Measure): void;
  63918. /**
  63919. * Copy from a group of 4 floats
  63920. * @param left defines left coordinate
  63921. * @param top defines top coordinate
  63922. * @param width defines width dimension
  63923. * @param height defines height dimension
  63924. */
  63925. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63926. /**
  63927. * Computes the axis aligned bounding box measure for two given measures
  63928. * @param a Input measure
  63929. * @param b Input measure
  63930. * @param result the resulting bounding measure
  63931. */
  63932. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63933. /**
  63934. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63935. * @param transform the matrix to transform the measure before computing the AABB
  63936. * @param result the resulting AABB
  63937. */
  63938. transformToRef(transform: Matrix2D, result: Measure): void;
  63939. /**
  63940. * Check equality between this measure and another one
  63941. * @param other defines the other measures
  63942. * @returns true if both measures are equals
  63943. */
  63944. isEqualsTo(other: Measure): boolean;
  63945. /**
  63946. * Creates an empty measure
  63947. * @returns a new measure
  63948. */
  63949. static Empty(): Measure;
  63950. }
  63951. }
  63952. declare module BABYLON.GUI {
  63953. /**
  63954. * Interface used to define a control that can receive focus
  63955. */
  63956. export interface IFocusableControl {
  63957. /**
  63958. * Function called when the control receives the focus
  63959. */
  63960. onFocus(): void;
  63961. /**
  63962. * Function called when the control loses the focus
  63963. */
  63964. onBlur(): void;
  63965. /**
  63966. * Function called to let the control handle keyboard events
  63967. * @param evt defines the current keyboard event
  63968. */
  63969. processKeyboard(evt: KeyboardEvent): void;
  63970. /**
  63971. * Function called to get the list of controls that should not steal the focus from this control
  63972. * @returns an array of controls
  63973. */
  63974. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63975. }
  63976. /**
  63977. * Class used to create texture to support 2D GUI elements
  63978. * @see http://doc.babylonjs.com/how_to/gui
  63979. */
  63980. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63981. private _isDirty;
  63982. private _renderObserver;
  63983. private _resizeObserver;
  63984. private _preKeyboardObserver;
  63985. private _pointerMoveObserver;
  63986. private _pointerObserver;
  63987. private _canvasPointerOutObserver;
  63988. private _background;
  63989. /** @hidden */ private _rootContainer: Container;
  63990. /** @hidden */ private _lastPickedControl: Control;
  63991. /** @hidden */ private _lastControlOver: {
  63992. [pointerId: number]: Control;
  63993. };
  63994. /** @hidden */ private _lastControlDown: {
  63995. [pointerId: number]: Control;
  63996. };
  63997. /** @hidden */ private _capturingControl: {
  63998. [pointerId: number]: Control;
  63999. };
  64000. /** @hidden */ private _shouldBlockPointer: boolean;
  64001. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  64002. /** @hidden */ private _linkedControls: Control[];
  64003. private _isFullscreen;
  64004. private _fullscreenViewport;
  64005. private _idealWidth;
  64006. private _idealHeight;
  64007. private _useSmallestIdeal;
  64008. private _renderAtIdealSize;
  64009. private _focusedControl;
  64010. private _blockNextFocusCheck;
  64011. private _renderScale;
  64012. private _rootCanvas;
  64013. private _cursorChanged;
  64014. /**
  64015. * Define type to string to ensure compatibility across browsers
  64016. * Safari doesn't support DataTransfer constructor
  64017. */
  64018. private _clipboardData;
  64019. /**
  64020. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  64021. */
  64022. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  64023. /**
  64024. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  64025. */
  64026. onControlPickedObservable: BABYLON.Observable<Control>;
  64027. /**
  64028. * BABYLON.Observable event triggered before layout is evaluated
  64029. */
  64030. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64031. /**
  64032. * BABYLON.Observable event triggered after the layout was evaluated
  64033. */
  64034. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64035. /**
  64036. * BABYLON.Observable event triggered before the texture is rendered
  64037. */
  64038. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64039. /**
  64040. * BABYLON.Observable event triggered after the texture was rendered
  64041. */
  64042. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  64043. /**
  64044. * Gets or sets a boolean defining if alpha is stored as premultiplied
  64045. */
  64046. premulAlpha: boolean;
  64047. /**
  64048. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  64049. * Useful when you want more antialiasing
  64050. */
  64051. renderScale: number;
  64052. /** Gets or sets the background color */
  64053. background: string;
  64054. /**
  64055. * Gets or sets the ideal width used to design controls.
  64056. * The GUI will then rescale everything accordingly
  64057. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64058. */
  64059. idealWidth: number;
  64060. /**
  64061. * Gets or sets the ideal height used to design controls.
  64062. * The GUI will then rescale everything accordingly
  64063. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64064. */
  64065. idealHeight: number;
  64066. /**
  64067. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  64068. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64069. */
  64070. useSmallestIdeal: boolean;
  64071. /**
  64072. * Gets or sets a boolean indicating if adaptive scaling must be used
  64073. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  64074. */
  64075. renderAtIdealSize: boolean;
  64076. /**
  64077. * Gets the underlying layer used to render the texture when in fullscreen mode
  64078. */
  64079. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  64080. /**
  64081. * Gets the root container control
  64082. */
  64083. readonly rootContainer: Container;
  64084. /**
  64085. * Returns an array containing the root container.
  64086. * This is mostly used to let the Inspector introspects the ADT
  64087. * @returns an array containing the rootContainer
  64088. */
  64089. getChildren(): Array<Container>;
  64090. /**
  64091. * Will return all controls that are inside this texture
  64092. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  64093. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  64094. * @return all child controls
  64095. */
  64096. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64097. /**
  64098. * Gets or sets the current focused control
  64099. */
  64100. focusedControl: BABYLON.Nullable<IFocusableControl>;
  64101. /**
  64102. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  64103. */
  64104. isForeground: boolean;
  64105. /**
  64106. * Gets or set information about clipboardData
  64107. */
  64108. clipboardData: string;
  64109. /**
  64110. * Creates a new AdvancedDynamicTexture
  64111. * @param name defines the name of the texture
  64112. * @param width defines the width of the texture
  64113. * @param height defines the height of the texture
  64114. * @param scene defines the hosting scene
  64115. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  64116. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  64117. */
  64118. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  64119. /**
  64120. * Get the current class name of the texture useful for serialization or dynamic coding.
  64121. * @returns "AdvancedDynamicTexture"
  64122. */
  64123. getClassName(): string;
  64124. /**
  64125. * Function used to execute a function on all controls
  64126. * @param func defines the function to execute
  64127. * @param container defines the container where controls belong. If null the root container will be used
  64128. */
  64129. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  64130. private _useInvalidateRectOptimization;
  64131. /**
  64132. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  64133. */
  64134. useInvalidateRectOptimization: boolean;
  64135. private _invalidatedRectangle;
  64136. /**
  64137. * Invalidates a rectangle area on the gui texture
  64138. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  64139. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  64140. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  64141. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  64142. */
  64143. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  64144. /**
  64145. * Marks the texture as dirty forcing a complete update
  64146. */
  64147. markAsDirty(): void;
  64148. /**
  64149. * Helper function used to create a new style
  64150. * @returns a new style
  64151. * @see http://doc.babylonjs.com/how_to/gui#styles
  64152. */
  64153. createStyle(): Style;
  64154. /**
  64155. * Adds a new control to the root container
  64156. * @param control defines the control to add
  64157. * @returns the current texture
  64158. */
  64159. addControl(control: Control): AdvancedDynamicTexture;
  64160. /**
  64161. * Removes a control from the root container
  64162. * @param control defines the control to remove
  64163. * @returns the current texture
  64164. */
  64165. removeControl(control: Control): AdvancedDynamicTexture;
  64166. /**
  64167. * Release all resources
  64168. */
  64169. dispose(): void;
  64170. private _onResize;
  64171. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  64172. /**
  64173. * Get screen coordinates for a vector3
  64174. * @param position defines the position to project
  64175. * @param worldMatrix defines the world matrix to use
  64176. * @returns the projected position
  64177. */
  64178. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  64179. private _checkUpdate;
  64180. private _clearMeasure;
  64181. private _render;
  64182. /** @hidden */ private _changeCursor(cursor: string): void;
  64183. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  64184. private _doPicking;
  64185. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  64186. [pointerId: number]: Control;
  64187. }, control: Control): void;
  64188. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  64189. /** Attach to all scene events required to support pointer events */
  64190. attach(): void;
  64191. /** @hidden */
  64192. private onClipboardCopy;
  64193. /** @hidden */
  64194. private onClipboardCut;
  64195. /** @hidden */
  64196. private onClipboardPaste;
  64197. /**
  64198. * Register the clipboard Events onto the canvas
  64199. */
  64200. registerClipboardEvents(): void;
  64201. /**
  64202. * Unregister the clipboard Events from the canvas
  64203. */
  64204. unRegisterClipboardEvents(): void;
  64205. /**
  64206. * Connect the texture to a hosting mesh to enable interactions
  64207. * @param mesh defines the mesh to attach to
  64208. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  64209. */
  64210. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  64211. /**
  64212. * Move the focus to a specific control
  64213. * @param control defines the control which will receive the focus
  64214. */
  64215. moveFocusToControl(control: IFocusableControl): void;
  64216. private _manageFocus;
  64217. private _attachToOnPointerOut;
  64218. /**
  64219. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  64220. * @param mesh defines the mesh which will receive the texture
  64221. * @param width defines the texture width (1024 by default)
  64222. * @param height defines the texture height (1024 by default)
  64223. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  64224. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  64225. * @returns a new AdvancedDynamicTexture
  64226. */
  64227. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  64228. /**
  64229. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  64230. * In this mode the texture will rely on a layer for its rendering.
  64231. * This allows it to be treated like any other layer.
  64232. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  64233. * LayerMask is set through advancedTexture.layer.layerMask
  64234. * @param name defines name for the texture
  64235. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  64236. * @param scene defines the hsoting scene
  64237. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  64238. * @returns a new AdvancedDynamicTexture
  64239. */
  64240. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  64241. }
  64242. }
  64243. declare module BABYLON.GUI {
  64244. /**
  64245. * Root class used for all 2D controls
  64246. * @see http://doc.babylonjs.com/how_to/gui#controls
  64247. */
  64248. export class Control {
  64249. /** defines the name of the control */
  64250. name?: string | undefined;
  64251. /**
  64252. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  64253. */
  64254. static AllowAlphaInheritance: boolean;
  64255. private _alpha;
  64256. private _alphaSet;
  64257. private _zIndex;
  64258. /** @hidden */ private _host: AdvancedDynamicTexture;
  64259. /** Gets or sets the control parent */
  64260. parent: BABYLON.Nullable<Container>;
  64261. /** @hidden */ private _currentMeasure: Measure;
  64262. private _fontFamily;
  64263. private _fontStyle;
  64264. private _fontWeight;
  64265. private _fontSize;
  64266. private _font;
  64267. /** @hidden */ private _width: ValueAndUnit;
  64268. /** @hidden */ private _height: ValueAndUnit;
  64269. /** @hidden */
  64270. protected _fontOffset: {
  64271. ascent: number;
  64272. height: number;
  64273. descent: number;
  64274. };
  64275. private _color;
  64276. private _style;
  64277. private _styleObserver;
  64278. /** @hidden */
  64279. protected _horizontalAlignment: number;
  64280. /** @hidden */
  64281. protected _verticalAlignment: number;
  64282. /** @hidden */
  64283. protected _isDirty: boolean;
  64284. /** @hidden */
  64285. protected _wasDirty: boolean;
  64286. /** @hidden */ private _tempParentMeasure: Measure;
  64287. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64288. /** @hidden */
  64289. protected _cachedParentMeasure: Measure;
  64290. private _paddingLeft;
  64291. private _paddingRight;
  64292. private _paddingTop;
  64293. private _paddingBottom;
  64294. /** @hidden */ private _left: ValueAndUnit;
  64295. /** @hidden */ private _top: ValueAndUnit;
  64296. private _scaleX;
  64297. private _scaleY;
  64298. private _rotation;
  64299. private _transformCenterX;
  64300. private _transformCenterY;
  64301. /** @hidden */ private _transformMatrix: Matrix2D;
  64302. /** @hidden */
  64303. protected _invertTransformMatrix: Matrix2D;
  64304. /** @hidden */
  64305. protected _transformedPosition: BABYLON.Vector2;
  64306. private _isMatrixDirty;
  64307. private _cachedOffsetX;
  64308. private _cachedOffsetY;
  64309. private _isVisible;
  64310. private _isHighlighted;
  64311. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64312. private _fontSet;
  64313. private _dummyVector2;
  64314. private _downCount;
  64315. private _enterCount;
  64316. private _doNotRender;
  64317. private _downPointerIds;
  64318. protected _isEnabled: boolean;
  64319. protected _disabledColor: string;
  64320. /** @hidden */
  64321. protected _rebuildLayout: boolean;
  64322. /** @hidden */ private _isClipped: boolean;
  64323. /** @hidden */ private _tag: any;
  64324. /**
  64325. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  64326. */
  64327. uniqueId: number;
  64328. /**
  64329. * Gets or sets an object used to store user defined information for the node
  64330. */
  64331. metadata: any;
  64332. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64333. isHitTestVisible: boolean;
  64334. /** Gets or sets a boolean indicating if the control can block pointer events */
  64335. isPointerBlocker: boolean;
  64336. /** Gets or sets a boolean indicating if the control can be focusable */
  64337. isFocusInvisible: boolean;
  64338. /**
  64339. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64340. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  64341. */
  64342. clipChildren: boolean;
  64343. /**
  64344. * Gets or sets a boolean indicating that control content must be clipped
  64345. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  64346. */
  64347. clipContent: boolean;
  64348. /**
  64349. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64350. */
  64351. useBitmapCache: boolean;
  64352. private _cacheData;
  64353. private _shadowOffsetX;
  64354. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64355. shadowOffsetX: number;
  64356. private _shadowOffsetY;
  64357. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64358. shadowOffsetY: number;
  64359. private _shadowBlur;
  64360. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64361. shadowBlur: number;
  64362. private _shadowColor;
  64363. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64364. shadowColor: string;
  64365. /** Gets or sets the cursor to use when the control is hovered */
  64366. hoverCursor: string;
  64367. /** @hidden */
  64368. protected _linkOffsetX: ValueAndUnit;
  64369. /** @hidden */
  64370. protected _linkOffsetY: ValueAndUnit;
  64371. /** Gets the control type name */
  64372. readonly typeName: string;
  64373. /**
  64374. * Get the current class name of the control.
  64375. * @returns current class name
  64376. */
  64377. getClassName(): string;
  64378. /**
  64379. * An event triggered when the pointer move over the control.
  64380. */
  64381. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64382. /**
  64383. * An event triggered when the pointer move out of the control.
  64384. */
  64385. onPointerOutObservable: BABYLON.Observable<Control>;
  64386. /**
  64387. * An event triggered when the pointer taps the control
  64388. */
  64389. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64390. /**
  64391. * An event triggered when pointer up
  64392. */
  64393. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64394. /**
  64395. * An event triggered when a control is clicked on
  64396. */
  64397. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64398. /**
  64399. * An event triggered when pointer enters the control
  64400. */
  64401. onPointerEnterObservable: BABYLON.Observable<Control>;
  64402. /**
  64403. * An event triggered when the control is marked as dirty
  64404. */
  64405. onDirtyObservable: BABYLON.Observable<Control>;
  64406. /**
  64407. * An event triggered before drawing the control
  64408. */
  64409. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64410. /**
  64411. * An event triggered after the control was drawn
  64412. */
  64413. onAfterDrawObservable: BABYLON.Observable<Control>;
  64414. /**
  64415. * Get the hosting AdvancedDynamicTexture
  64416. */
  64417. readonly host: AdvancedDynamicTexture;
  64418. /** Gets or set information about font offsets (used to render and align text) */
  64419. fontOffset: {
  64420. ascent: number;
  64421. height: number;
  64422. descent: number;
  64423. };
  64424. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64425. alpha: number;
  64426. /**
  64427. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64428. */
  64429. isHighlighted: boolean;
  64430. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64431. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64432. */
  64433. scaleX: number;
  64434. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64435. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64436. */
  64437. scaleY: number;
  64438. /** Gets or sets the rotation angle (0 by default)
  64439. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64440. */
  64441. rotation: number;
  64442. /** Gets or sets the transformation center on Y axis (0 by default)
  64443. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64444. */
  64445. transformCenterY: number;
  64446. /** Gets or sets the transformation center on X axis (0 by default)
  64447. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64448. */
  64449. transformCenterX: number;
  64450. /**
  64451. * Gets or sets the horizontal alignment
  64452. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64453. */
  64454. horizontalAlignment: number;
  64455. /**
  64456. * Gets or sets the vertical alignment
  64457. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64458. */
  64459. verticalAlignment: number;
  64460. /**
  64461. * Gets or sets control width
  64462. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64463. */
  64464. width: string | number;
  64465. /**
  64466. * Gets or sets the control width in pixel
  64467. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64468. */
  64469. widthInPixels: number;
  64470. /**
  64471. * Gets or sets control height
  64472. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64473. */
  64474. height: string | number;
  64475. /**
  64476. * Gets or sets control height in pixel
  64477. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64478. */
  64479. heightInPixels: number;
  64480. /** Gets or set font family */
  64481. fontFamily: string;
  64482. /** Gets or sets font style */
  64483. fontStyle: string;
  64484. /** Gets or sets font weight */
  64485. fontWeight: string;
  64486. /**
  64487. * Gets or sets style
  64488. * @see http://doc.babylonjs.com/how_to/gui#styles
  64489. */
  64490. style: BABYLON.Nullable<Style>;
  64491. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  64492. /** Gets or sets font size in pixels */
  64493. fontSizeInPixels: number;
  64494. /** Gets or sets font size */
  64495. fontSize: string | number;
  64496. /** Gets or sets foreground color */
  64497. color: string;
  64498. /** Gets or sets z index which is used to reorder controls on the z axis */
  64499. zIndex: number;
  64500. /** Gets or sets a boolean indicating if the control can be rendered */
  64501. notRenderable: boolean;
  64502. /** Gets or sets a boolean indicating if the control is visible */
  64503. isVisible: boolean;
  64504. /** Gets a boolean indicating that the control needs to update its rendering */
  64505. readonly isDirty: boolean;
  64506. /**
  64507. * Gets the current linked mesh (or null if none)
  64508. */
  64509. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64510. /**
  64511. * Gets or sets a value indicating the padding to use on the left of the control
  64512. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64513. */
  64514. paddingLeft: string | number;
  64515. /**
  64516. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64517. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64518. */
  64519. paddingLeftInPixels: number;
  64520. /**
  64521. * Gets or sets a value indicating the padding to use on the right of the control
  64522. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64523. */
  64524. paddingRight: string | number;
  64525. /**
  64526. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64527. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64528. */
  64529. paddingRightInPixels: number;
  64530. /**
  64531. * Gets or sets a value indicating the padding to use on the top of the control
  64532. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64533. */
  64534. paddingTop: string | number;
  64535. /**
  64536. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64537. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64538. */
  64539. paddingTopInPixels: number;
  64540. /**
  64541. * Gets or sets a value indicating the padding to use on the bottom of the control
  64542. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64543. */
  64544. paddingBottom: string | number;
  64545. /**
  64546. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64547. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64548. */
  64549. paddingBottomInPixels: number;
  64550. /**
  64551. * Gets or sets a value indicating the left coordinate of the control
  64552. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64553. */
  64554. left: string | number;
  64555. /**
  64556. * Gets or sets a value indicating the left coordinate in pixels of the control
  64557. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64558. */
  64559. leftInPixels: number;
  64560. /**
  64561. * Gets or sets a value indicating the top coordinate of the control
  64562. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64563. */
  64564. top: string | number;
  64565. /**
  64566. * Gets or sets a value indicating the top coordinate in pixels of the control
  64567. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64568. */
  64569. topInPixels: number;
  64570. /**
  64571. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64572. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64573. */
  64574. linkOffsetX: string | number;
  64575. /**
  64576. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64577. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64578. */
  64579. linkOffsetXInPixels: number;
  64580. /**
  64581. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64582. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64583. */
  64584. linkOffsetY: string | number;
  64585. /**
  64586. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64587. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64588. */
  64589. linkOffsetYInPixels: number;
  64590. /** Gets the center coordinate on X axis */
  64591. readonly centerX: number;
  64592. /** Gets the center coordinate on Y axis */
  64593. readonly centerY: number;
  64594. /** Gets or sets if control is Enabled*/
  64595. isEnabled: boolean;
  64596. /** Gets or sets background color of control if it's disabled*/
  64597. disabledColor: string;
  64598. /**
  64599. * Creates a new control
  64600. * @param name defines the name of the control
  64601. */
  64602. constructor(
  64603. /** defines the name of the control */
  64604. name?: string | undefined);
  64605. /** @hidden */
  64606. protected _getTypeName(): string;
  64607. /**
  64608. * Gets the first ascendant in the hierarchy of the given type
  64609. * @param className defines the required type
  64610. * @returns the ascendant or null if not found
  64611. */
  64612. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64613. /** @hidden */ private _resetFontCache(): void;
  64614. /**
  64615. * Determines if a container is an ascendant of the current control
  64616. * @param container defines the container to look for
  64617. * @returns true if the container is one of the ascendant of the control
  64618. */
  64619. isAscendant(container: Control): boolean;
  64620. /**
  64621. * Gets coordinates in local control space
  64622. * @param globalCoordinates defines the coordinates to transform
  64623. * @returns the new coordinates in local space
  64624. */
  64625. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64626. /**
  64627. * Gets coordinates in local control space
  64628. * @param globalCoordinates defines the coordinates to transform
  64629. * @param result defines the target vector2 where to store the result
  64630. * @returns the current control
  64631. */
  64632. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64633. /**
  64634. * Gets coordinates in parent local control space
  64635. * @param globalCoordinates defines the coordinates to transform
  64636. * @returns the new coordinates in parent local space
  64637. */
  64638. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64639. /**
  64640. * Move the current control to a vector3 position projected onto the screen.
  64641. * @param position defines the target position
  64642. * @param scene defines the hosting scene
  64643. */
  64644. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64645. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64646. /**
  64647. * Will return all controls that have this control as ascendant
  64648. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  64649. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  64650. * @return all child controls
  64651. */
  64652. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64653. /**
  64654. * Link current control with a target mesh
  64655. * @param mesh defines the mesh to link with
  64656. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64657. */
  64658. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64659. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64660. /** @hidden */ private _offsetLeft(offset: number): void;
  64661. /** @hidden */ private _offsetTop(offset: number): void;
  64662. /** @hidden */ private _markMatrixAsDirty(): void;
  64663. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  64664. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  64665. /** @hidden */
  64666. protected invalidateRect(): void;
  64667. /** @hidden */ private _markAsDirty(force?: boolean): void;
  64668. /** @hidden */ private _markAllAsDirty(): void;
  64669. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64670. /** @hidden */
  64671. protected _transform(context?: CanvasRenderingContext2D): void;
  64672. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  64673. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64674. /** @hidden */
  64675. protected _applyStates(context: CanvasRenderingContext2D): void;
  64676. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64677. /** @hidden */
  64678. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64679. protected _evaluateClippingState(parentMeasure: Measure): void;
  64680. /** @hidden */ private _measure(): void;
  64681. /** @hidden */
  64682. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64683. /** @hidden */
  64684. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64685. /** @hidden */
  64686. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64687. /** @hidden */
  64688. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64689. private static _ClipMeasure;
  64690. private _tmpMeasureA;
  64691. private _clip;
  64692. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64693. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64694. /**
  64695. * Tests if a given coordinates belong to the current control
  64696. * @param x defines x coordinate to test
  64697. * @param y defines y coordinate to test
  64698. * @returns true if the coordinates are inside the control
  64699. */
  64700. contains(x: number, y: number): boolean;
  64701. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64702. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64703. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  64704. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  64705. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64706. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64707. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64708. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64709. private _prepareFont;
  64710. /** Releases associated resources */
  64711. dispose(): void;
  64712. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64713. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64714. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64715. private static _VERTICAL_ALIGNMENT_TOP;
  64716. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64717. private static _VERTICAL_ALIGNMENT_CENTER;
  64718. /** HORIZONTAL_ALIGNMENT_LEFT */
  64719. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64720. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64721. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64722. /** HORIZONTAL_ALIGNMENT_CENTER */
  64723. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64724. /** VERTICAL_ALIGNMENT_TOP */
  64725. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64726. /** VERTICAL_ALIGNMENT_BOTTOM */
  64727. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64728. /** VERTICAL_ALIGNMENT_CENTER */
  64729. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64730. private static _FontHeightSizes;
  64731. /** @hidden */ private static _GetFontOffset(font: string): {
  64732. ascent: number;
  64733. height: number;
  64734. descent: number;
  64735. };
  64736. /**
  64737. * Creates a stack panel that can be used to render headers
  64738. * @param control defines the control to associate with the header
  64739. * @param text defines the text of the header
  64740. * @param size defines the size of the header
  64741. * @param options defines options used to configure the header
  64742. * @returns a new StackPanel
  64743. * @ignore
  64744. * @hidden
  64745. */
  64746. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64747. isHorizontal: boolean;
  64748. controlFirst: boolean;
  64749. }) => any;
  64750. /** @hidden */
  64751. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64752. }
  64753. }
  64754. declare module BABYLON.GUI {
  64755. /**
  64756. * Root class for 2D containers
  64757. * @see http://doc.babylonjs.com/how_to/gui#containers
  64758. */
  64759. export class Container extends Control {
  64760. name?: string | undefined;
  64761. /** @hidden */
  64762. protected _children: Control[];
  64763. /** @hidden */
  64764. protected _measureForChildren: Measure;
  64765. /** @hidden */
  64766. protected _background: string;
  64767. /** @hidden */
  64768. protected _adaptWidthToChildren: boolean;
  64769. /** @hidden */
  64770. protected _adaptHeightToChildren: boolean;
  64771. /**
  64772. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64773. */
  64774. logLayoutCycleErrors: boolean;
  64775. /**
  64776. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64777. */
  64778. maxLayoutCycle: number;
  64779. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64780. adaptHeightToChildren: boolean;
  64781. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64782. adaptWidthToChildren: boolean;
  64783. /** Gets or sets background color */
  64784. background: string;
  64785. /** Gets the list of children */
  64786. readonly children: Control[];
  64787. /**
  64788. * Creates a new Container
  64789. * @param name defines the name of the container
  64790. */
  64791. constructor(name?: string | undefined);
  64792. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  64793. /**
  64794. * Gets a child using its name
  64795. * @param name defines the child name to look for
  64796. * @returns the child control if found
  64797. */
  64798. getChildByName(name: string): BABYLON.Nullable<Control>;
  64799. /**
  64800. * Gets a child using its type and its name
  64801. * @param name defines the child name to look for
  64802. * @param type defines the child type to look for
  64803. * @returns the child control if found
  64804. */
  64805. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64806. /**
  64807. * Search for a specific control in children
  64808. * @param control defines the control to look for
  64809. * @returns true if the control is in child list
  64810. */
  64811. containsControl(control: Control): boolean;
  64812. /**
  64813. * Adds a new control to the current container
  64814. * @param control defines the control to add
  64815. * @returns the current container
  64816. */
  64817. addControl(control: BABYLON.Nullable<Control>): Container;
  64818. /**
  64819. * Removes all controls from the current container
  64820. * @returns the current container
  64821. */
  64822. clearControls(): Container;
  64823. /**
  64824. * Removes a control from the current container
  64825. * @param control defines the control to remove
  64826. * @returns the current container
  64827. */
  64828. removeControl(control: Control): Container;
  64829. /** @hidden */ private _reOrderControl(control: Control): void;
  64830. /** @hidden */ private _offsetLeft(offset: number): void;
  64831. /** @hidden */ private _offsetTop(offset: number): void;
  64832. /** @hidden */ private _markAllAsDirty(): void;
  64833. /** @hidden */
  64834. protected _localDraw(context: CanvasRenderingContext2D): void;
  64835. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64836. /** @hidden */
  64837. protected _beforeLayout(): void;
  64838. /** @hidden */
  64839. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64840. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64841. protected _postMeasure(): void;
  64842. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64843. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64844. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64845. /** @hidden */
  64846. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64847. /** Releases associated resources */
  64848. dispose(): void;
  64849. }
  64850. }
  64851. declare module BABYLON.GUI {
  64852. /** Class used to create rectangle container */
  64853. export class Rectangle extends Container {
  64854. name?: string | undefined;
  64855. private _thickness;
  64856. private _cornerRadius;
  64857. /** Gets or sets border thickness */
  64858. thickness: number;
  64859. /** Gets or sets the corner radius angle */
  64860. cornerRadius: number;
  64861. /**
  64862. * Creates a new Rectangle
  64863. * @param name defines the control name
  64864. */
  64865. constructor(name?: string | undefined);
  64866. protected _getTypeName(): string;
  64867. protected _localDraw(context: CanvasRenderingContext2D): void;
  64868. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64869. private _drawRoundedRect;
  64870. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64871. }
  64872. }
  64873. declare module BABYLON.GUI {
  64874. /**
  64875. * Enum that determines the text-wrapping mode to use.
  64876. */
  64877. export enum TextWrapping {
  64878. /**
  64879. * Clip the text when it's larger than Control.width; this is the default mode.
  64880. */
  64881. Clip = 0,
  64882. /**
  64883. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64884. */
  64885. WordWrap = 1,
  64886. /**
  64887. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64888. */
  64889. Ellipsis = 2
  64890. }
  64891. /**
  64892. * Class used to create text block control
  64893. */
  64894. export class TextBlock extends Control {
  64895. /**
  64896. * Defines the name of the control
  64897. */
  64898. name?: string | undefined;
  64899. private _text;
  64900. private _textWrapping;
  64901. private _textHorizontalAlignment;
  64902. private _textVerticalAlignment;
  64903. private _lines;
  64904. private _resizeToFit;
  64905. private _lineSpacing;
  64906. private _outlineWidth;
  64907. private _outlineColor;
  64908. /**
  64909. * An event triggered after the text is changed
  64910. */
  64911. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64912. /**
  64913. * An event triggered after the text was broken up into lines
  64914. */
  64915. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64916. /**
  64917. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64918. */
  64919. readonly lines: any[];
  64920. /**
  64921. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64922. */
  64923. /**
  64924. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64925. */
  64926. resizeToFit: boolean;
  64927. /**
  64928. * Gets or sets a boolean indicating if text must be wrapped
  64929. */
  64930. /**
  64931. * Gets or sets a boolean indicating if text must be wrapped
  64932. */
  64933. textWrapping: TextWrapping | boolean;
  64934. /**
  64935. * Gets or sets text to display
  64936. */
  64937. /**
  64938. * Gets or sets text to display
  64939. */
  64940. text: string;
  64941. /**
  64942. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64943. */
  64944. /**
  64945. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64946. */
  64947. textHorizontalAlignment: number;
  64948. /**
  64949. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64950. */
  64951. /**
  64952. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64953. */
  64954. textVerticalAlignment: number;
  64955. /**
  64956. * Gets or sets line spacing value
  64957. */
  64958. /**
  64959. * Gets or sets line spacing value
  64960. */
  64961. lineSpacing: string | number;
  64962. /**
  64963. * Gets or sets outlineWidth of the text to display
  64964. */
  64965. /**
  64966. * Gets or sets outlineWidth of the text to display
  64967. */
  64968. outlineWidth: number;
  64969. /**
  64970. * Gets or sets outlineColor of the text to display
  64971. */
  64972. /**
  64973. * Gets or sets outlineColor of the text to display
  64974. */
  64975. outlineColor: string;
  64976. /**
  64977. * Creates a new TextBlock object
  64978. * @param name defines the name of the control
  64979. * @param text defines the text to display (emptry string by default)
  64980. */
  64981. constructor(
  64982. /**
  64983. * Defines the name of the control
  64984. */
  64985. name?: string | undefined, text?: string);
  64986. protected _getTypeName(): string;
  64987. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64988. private _drawText;
  64989. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64990. protected _applyStates(context: CanvasRenderingContext2D): void;
  64991. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64992. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64993. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64994. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64995. protected _renderLines(context: CanvasRenderingContext2D): void;
  64996. /**
  64997. * Given a width constraint applied on the text block, find the expected height
  64998. * @returns expected height
  64999. */
  65000. computeExpectedHeight(): number;
  65001. dispose(): void;
  65002. }
  65003. }
  65004. declare module BABYLON.GUI {
  65005. /**
  65006. * Class used to create 2D images
  65007. */
  65008. export class Image extends Control {
  65009. name?: string | undefined;
  65010. private static _WorkingCanvas;
  65011. private _domImage;
  65012. private _imageWidth;
  65013. private _imageHeight;
  65014. private _loaded;
  65015. private _stretch;
  65016. private _source;
  65017. private _autoScale;
  65018. private _sourceLeft;
  65019. private _sourceTop;
  65020. private _sourceWidth;
  65021. private _sourceHeight;
  65022. private _cellWidth;
  65023. private _cellHeight;
  65024. private _cellId;
  65025. private _populateNinePatchSlicesFromImage;
  65026. private _sliceLeft;
  65027. private _sliceRight;
  65028. private _sliceTop;
  65029. private _sliceBottom;
  65030. private _detectPointerOnOpaqueOnly;
  65031. /**
  65032. * BABYLON.Observable notified when the content is loaded
  65033. */
  65034. onImageLoadedObservable: BABYLON.Observable<Image>;
  65035. /**
  65036. * Gets a boolean indicating that the content is loaded
  65037. */
  65038. readonly isLoaded: boolean;
  65039. /**
  65040. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  65041. */
  65042. populateNinePatchSlicesFromImage: boolean;
  65043. /**
  65044. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  65045. * Beware using this as this will comsume more memory as the image has to be stored twice
  65046. */
  65047. detectPointerOnOpaqueOnly: boolean;
  65048. /**
  65049. * Gets or sets the left value for slicing (9-patch)
  65050. */
  65051. sliceLeft: number;
  65052. /**
  65053. * Gets or sets the right value for slicing (9-patch)
  65054. */
  65055. sliceRight: number;
  65056. /**
  65057. * Gets or sets the top value for slicing (9-patch)
  65058. */
  65059. sliceTop: number;
  65060. /**
  65061. * Gets or sets the bottom value for slicing (9-patch)
  65062. */
  65063. sliceBottom: number;
  65064. /**
  65065. * Gets or sets the left coordinate in the source image
  65066. */
  65067. sourceLeft: number;
  65068. /**
  65069. * Gets or sets the top coordinate in the source image
  65070. */
  65071. sourceTop: number;
  65072. /**
  65073. * Gets or sets the width to capture in the source image
  65074. */
  65075. sourceWidth: number;
  65076. /**
  65077. * Gets or sets the height to capture in the source image
  65078. */
  65079. sourceHeight: number;
  65080. /**
  65081. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  65082. * @see http://doc.babylonjs.com/how_to/gui#image
  65083. */
  65084. autoScale: boolean;
  65085. /** Gets or sets the streching mode used by the image */
  65086. stretch: number;
  65087. /**
  65088. * Gets or sets the internal DOM image used to render the control
  65089. */
  65090. domImage: HTMLImageElement;
  65091. private _onImageLoaded;
  65092. private _extractNinePatchSliceDataFromImage;
  65093. /**
  65094. * Gets or sets image source url
  65095. */
  65096. source: BABYLON.Nullable<string>;
  65097. /**
  65098. * Gets or sets the cell width to use when animation sheet is enabled
  65099. * @see http://doc.babylonjs.com/how_to/gui#image
  65100. */
  65101. cellWidth: number;
  65102. /**
  65103. * Gets or sets the cell height to use when animation sheet is enabled
  65104. * @see http://doc.babylonjs.com/how_to/gui#image
  65105. */
  65106. cellHeight: number;
  65107. /**
  65108. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  65109. * @see http://doc.babylonjs.com/how_to/gui#image
  65110. */
  65111. cellId: number;
  65112. /**
  65113. * Creates a new Image
  65114. * @param name defines the control name
  65115. * @param url defines the image url
  65116. */
  65117. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  65118. /**
  65119. * Tests if a given coordinates belong to the current control
  65120. * @param x defines x coordinate to test
  65121. * @param y defines y coordinate to test
  65122. * @returns true if the coordinates are inside the control
  65123. */
  65124. contains(x: number, y: number): boolean;
  65125. protected _getTypeName(): string;
  65126. /** Force the control to synchronize with its content */
  65127. synchronizeSizeWithContent(): void;
  65128. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65129. private _prepareWorkingCanvasForOpaqueDetection;
  65130. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  65131. private _renderCornerPatch;
  65132. private _renderNinePatch;
  65133. dispose(): void;
  65134. /** STRETCH_NONE */
  65135. static readonly STRETCH_NONE: number;
  65136. /** STRETCH_FILL */
  65137. static readonly STRETCH_FILL: number;
  65138. /** STRETCH_UNIFORM */
  65139. static readonly STRETCH_UNIFORM: number;
  65140. /** STRETCH_EXTEND */
  65141. static readonly STRETCH_EXTEND: number;
  65142. /** NINE_PATCH */
  65143. static readonly STRETCH_NINE_PATCH: number;
  65144. }
  65145. }
  65146. declare module BABYLON.GUI {
  65147. /**
  65148. * Class used to create 2D buttons
  65149. */
  65150. export class Button extends Rectangle {
  65151. name?: string | undefined;
  65152. /**
  65153. * Function called to generate a pointer enter animation
  65154. */
  65155. pointerEnterAnimation: () => void;
  65156. /**
  65157. * Function called to generate a pointer out animation
  65158. */
  65159. pointerOutAnimation: () => void;
  65160. /**
  65161. * Function called to generate a pointer down animation
  65162. */
  65163. pointerDownAnimation: () => void;
  65164. /**
  65165. * Function called to generate a pointer up animation
  65166. */
  65167. pointerUpAnimation: () => void;
  65168. /**
  65169. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  65170. */
  65171. delegatePickingToChildren: boolean;
  65172. private _image;
  65173. /**
  65174. * Returns the image part of the button (if any)
  65175. */
  65176. readonly image: BABYLON.Nullable<Image>;
  65177. private _textBlock;
  65178. /**
  65179. * Returns the image part of the button (if any)
  65180. */
  65181. readonly textBlock: BABYLON.Nullable<TextBlock>;
  65182. /**
  65183. * Creates a new Button
  65184. * @param name defines the name of the button
  65185. */
  65186. constructor(name?: string | undefined);
  65187. protected _getTypeName(): string;
  65188. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  65189. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  65190. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  65191. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65192. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65193. /**
  65194. * Creates a new button made with an image and a text
  65195. * @param name defines the name of the button
  65196. * @param text defines the text of the button
  65197. * @param imageUrl defines the url of the image
  65198. * @returns a new Button
  65199. */
  65200. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  65201. /**
  65202. * Creates a new button made with an image
  65203. * @param name defines the name of the button
  65204. * @param imageUrl defines the url of the image
  65205. * @returns a new Button
  65206. */
  65207. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  65208. /**
  65209. * Creates a new button made with a text
  65210. * @param name defines the name of the button
  65211. * @param text defines the text of the button
  65212. * @returns a new Button
  65213. */
  65214. static CreateSimpleButton(name: string, text: string): Button;
  65215. /**
  65216. * Creates a new button made with an image and a centered text
  65217. * @param name defines the name of the button
  65218. * @param text defines the text of the button
  65219. * @param imageUrl defines the url of the image
  65220. * @returns a new Button
  65221. */
  65222. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65223. }
  65224. }
  65225. declare module BABYLON.GUI {
  65226. /**
  65227. * Class used to create a 2D stack panel container
  65228. */
  65229. export class StackPanel extends Container {
  65230. name?: string | undefined;
  65231. private _isVertical;
  65232. private _manualWidth;
  65233. private _manualHeight;
  65234. private _doNotTrackManualChanges;
  65235. /**
  65236. * Gets or sets a boolean indicating that layou warnings should be ignored
  65237. */
  65238. ignoreLayoutWarnings: boolean;
  65239. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65240. isVertical: boolean;
  65241. /**
  65242. * Gets or sets panel width.
  65243. * This value should not be set when in horizontal mode as it will be computed automatically
  65244. */
  65245. width: string | number;
  65246. /**
  65247. * Gets or sets panel height.
  65248. * This value should not be set when in vertical mode as it will be computed automatically
  65249. */
  65250. height: string | number;
  65251. /**
  65252. * Creates a new StackPanel
  65253. * @param name defines control name
  65254. */
  65255. constructor(name?: string | undefined);
  65256. protected _getTypeName(): string;
  65257. /** @hidden */
  65258. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65259. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65260. protected _postMeasure(): void;
  65261. }
  65262. }
  65263. declare module BABYLON.GUI {
  65264. /**
  65265. * Class used to represent a 2D checkbox
  65266. */
  65267. export class Checkbox extends Control {
  65268. name?: string | undefined;
  65269. private _isChecked;
  65270. private _background;
  65271. private _checkSizeRatio;
  65272. private _thickness;
  65273. /** Gets or sets border thickness */
  65274. thickness: number;
  65275. /**
  65276. * BABYLON.Observable raised when isChecked property changes
  65277. */
  65278. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65279. /** Gets or sets a value indicating the ratio between overall size and check size */
  65280. checkSizeRatio: number;
  65281. /** Gets or sets background color */
  65282. background: string;
  65283. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65284. isChecked: boolean;
  65285. /**
  65286. * Creates a new CheckBox
  65287. * @param name defines the control name
  65288. */
  65289. constructor(name?: string | undefined);
  65290. protected _getTypeName(): string;
  65291. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65292. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65293. /**
  65294. * Utility function to easily create a checkbox with a header
  65295. * @param title defines the label to use for the header
  65296. * @param onValueChanged defines the callback to call when value changes
  65297. * @returns a StackPanel containing the checkbox and a textBlock
  65298. */
  65299. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65300. }
  65301. }
  65302. declare module BABYLON.GUI {
  65303. /**
  65304. * Class used to store key control properties
  65305. */
  65306. export class KeyPropertySet {
  65307. /** Width */
  65308. width?: string;
  65309. /** Height */
  65310. height?: string;
  65311. /** Left padding */
  65312. paddingLeft?: string;
  65313. /** Right padding */
  65314. paddingRight?: string;
  65315. /** Top padding */
  65316. paddingTop?: string;
  65317. /** Bottom padding */
  65318. paddingBottom?: string;
  65319. /** Foreground color */
  65320. color?: string;
  65321. /** Background color */
  65322. background?: string;
  65323. }
  65324. /**
  65325. * Class used to create virtual keyboard
  65326. */
  65327. export class VirtualKeyboard extends StackPanel {
  65328. /** BABYLON.Observable raised when a key is pressed */
  65329. onKeyPressObservable: BABYLON.Observable<string>;
  65330. /** Gets or sets default key button width */
  65331. defaultButtonWidth: string;
  65332. /** Gets or sets default key button height */
  65333. defaultButtonHeight: string;
  65334. /** Gets or sets default key button left padding */
  65335. defaultButtonPaddingLeft: string;
  65336. /** Gets or sets default key button right padding */
  65337. defaultButtonPaddingRight: string;
  65338. /** Gets or sets default key button top padding */
  65339. defaultButtonPaddingTop: string;
  65340. /** Gets or sets default key button bottom padding */
  65341. defaultButtonPaddingBottom: string;
  65342. /** Gets or sets default key button foreground color */
  65343. defaultButtonColor: string;
  65344. /** Gets or sets default key button background color */
  65345. defaultButtonBackground: string;
  65346. /** Gets or sets shift button foreground color */
  65347. shiftButtonColor: string;
  65348. /** Gets or sets shift button thickness*/
  65349. selectedShiftThickness: number;
  65350. /** Gets shift key state */
  65351. shiftState: number;
  65352. protected _getTypeName(): string;
  65353. private _createKey;
  65354. /**
  65355. * Adds a new row of keys
  65356. * @param keys defines the list of keys to add
  65357. * @param propertySets defines the associated property sets
  65358. */
  65359. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65360. /**
  65361. * Set the shift key to a specific state
  65362. * @param shiftState defines the new shift state
  65363. */
  65364. applyShiftState(shiftState: number): void;
  65365. private _currentlyConnectedInputText;
  65366. private _connectedInputTexts;
  65367. private _onKeyPressObserver;
  65368. /** Gets the input text control currently attached to the keyboard */
  65369. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65370. /**
  65371. * Connects the keyboard with an input text control
  65372. *
  65373. * @param input defines the target control
  65374. */
  65375. connect(input: InputText): void;
  65376. /**
  65377. * Disconnects the keyboard from connected InputText controls
  65378. *
  65379. * @param input optionally defines a target control, otherwise all are disconnected
  65380. */
  65381. disconnect(input?: InputText): void;
  65382. private _removeConnectedInputObservables;
  65383. /**
  65384. * Release all resources
  65385. */
  65386. dispose(): void;
  65387. /**
  65388. * Creates a new keyboard using a default layout
  65389. *
  65390. * @param name defines control name
  65391. * @returns a new VirtualKeyboard
  65392. */
  65393. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65394. }
  65395. }
  65396. declare module BABYLON.GUI {
  65397. /**
  65398. * Class used to create input text control
  65399. */
  65400. export class InputText extends Control implements IFocusableControl {
  65401. name?: string | undefined;
  65402. private _text;
  65403. private _placeholderText;
  65404. private _background;
  65405. private _focusedBackground;
  65406. private _focusedColor;
  65407. private _placeholderColor;
  65408. private _thickness;
  65409. private _margin;
  65410. private _autoStretchWidth;
  65411. private _maxWidth;
  65412. private _isFocused;
  65413. private _blinkTimeout;
  65414. private _blinkIsEven;
  65415. private _cursorOffset;
  65416. private _scrollLeft;
  65417. private _textWidth;
  65418. private _clickedCoordinate;
  65419. private _deadKey;
  65420. private _addKey;
  65421. private _currentKey;
  65422. private _isTextHighlightOn;
  65423. private _textHighlightColor;
  65424. private _highligherOpacity;
  65425. private _highlightedText;
  65426. private _startHighlightIndex;
  65427. private _endHighlightIndex;
  65428. private _cursorIndex;
  65429. private _onFocusSelectAll;
  65430. private _isPointerDown;
  65431. private _onClipboardObserver;
  65432. private _onPointerDblTapObserver;
  65433. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65434. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65435. promptMessage: string;
  65436. /** Force disable prompt on mobile device */
  65437. disableMobilePrompt: boolean;
  65438. /** BABYLON.Observable raised when the text changes */
  65439. onTextChangedObservable: BABYLON.Observable<InputText>;
  65440. /** BABYLON.Observable raised just before an entered character is to be added */
  65441. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65442. /** BABYLON.Observable raised when the control gets the focus */
  65443. onFocusObservable: BABYLON.Observable<InputText>;
  65444. /** BABYLON.Observable raised when the control loses the focus */
  65445. onBlurObservable: BABYLON.Observable<InputText>;
  65446. /**Observable raised when the text is highlighted */
  65447. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65448. /**Observable raised when copy event is triggered */
  65449. onTextCopyObservable: BABYLON.Observable<InputText>;
  65450. /** BABYLON.Observable raised when cut event is triggered */
  65451. onTextCutObservable: BABYLON.Observable<InputText>;
  65452. /** BABYLON.Observable raised when paste event is triggered */
  65453. onTextPasteObservable: BABYLON.Observable<InputText>;
  65454. /** BABYLON.Observable raised when a key event was processed */
  65455. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65456. /** Gets or sets the maximum width allowed by the control */
  65457. maxWidth: string | number;
  65458. /** Gets the maximum width allowed by the control in pixels */
  65459. readonly maxWidthInPixels: number;
  65460. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65461. highligherOpacity: number;
  65462. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65463. onFocusSelectAll: boolean;
  65464. /** Gets or sets the text hightlight color */
  65465. textHighlightColor: string;
  65466. /** Gets or sets control margin */
  65467. margin: string;
  65468. /** Gets control margin in pixels */
  65469. readonly marginInPixels: number;
  65470. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65471. autoStretchWidth: boolean;
  65472. /** Gets or sets border thickness */
  65473. thickness: number;
  65474. /** Gets or sets the background color when focused */
  65475. focusedBackground: string;
  65476. /** Gets or sets the background color when focused */
  65477. focusedColor: string;
  65478. /** Gets or sets the background color */
  65479. background: string;
  65480. /** Gets or sets the placeholder color */
  65481. placeholderColor: string;
  65482. /** Gets or sets the text displayed when the control is empty */
  65483. placeholderText: string;
  65484. /** Gets or sets the dead key flag */
  65485. deadKey: boolean;
  65486. /** Gets or sets the highlight text */
  65487. highlightedText: string;
  65488. /** Gets or sets if the current key should be added */
  65489. addKey: boolean;
  65490. /** Gets or sets the value of the current key being entered */
  65491. currentKey: string;
  65492. /** Gets or sets the text displayed in the control */
  65493. text: string;
  65494. /** Gets or sets control width */
  65495. width: string | number;
  65496. /**
  65497. * Creates a new InputText
  65498. * @param name defines the control name
  65499. * @param text defines the text of the control
  65500. */
  65501. constructor(name?: string | undefined, text?: string);
  65502. /** @hidden */
  65503. onBlur(): void;
  65504. /** @hidden */
  65505. onFocus(): void;
  65506. protected _getTypeName(): string;
  65507. /**
  65508. * Function called to get the list of controls that should not steal the focus from this control
  65509. * @returns an array of controls
  65510. */
  65511. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65512. /** @hidden */
  65513. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65514. /** @hidden */
  65515. private _updateValueFromCursorIndex;
  65516. /** @hidden */
  65517. private _processDblClick;
  65518. /** @hidden */
  65519. private _selectAllText;
  65520. /**
  65521. * Handles the keyboard event
  65522. * @param evt Defines the KeyboardEvent
  65523. */
  65524. processKeyboard(evt: KeyboardEvent): void;
  65525. /** @hidden */
  65526. private _onCopyText;
  65527. /** @hidden */
  65528. private _onCutText;
  65529. /** @hidden */
  65530. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65531. protected _beforeRenderText(text: string): string;
  65532. dispose(): void;
  65533. }
  65534. }
  65535. declare module BABYLON.GUI {
  65536. /**
  65537. * Class used to create a 2D grid container
  65538. */
  65539. export class Grid extends Container {
  65540. name?: string | undefined;
  65541. private _rowDefinitions;
  65542. private _columnDefinitions;
  65543. private _cells;
  65544. private _childControls;
  65545. /**
  65546. * Gets the number of columns
  65547. */
  65548. readonly columnCount: number;
  65549. /**
  65550. * Gets the number of rows
  65551. */
  65552. readonly rowCount: number;
  65553. /** Gets the list of children */
  65554. readonly children: Control[];
  65555. /** Gets the list of cells (e.g. the containers) */
  65556. readonly cells: {
  65557. [key: string]: Container;
  65558. };
  65559. /**
  65560. * Gets the definition of a specific row
  65561. * @param index defines the index of the row
  65562. * @returns the row definition
  65563. */
  65564. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65565. /**
  65566. * Gets the definition of a specific column
  65567. * @param index defines the index of the column
  65568. * @returns the column definition
  65569. */
  65570. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65571. /**
  65572. * Adds a new row to the grid
  65573. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65574. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65575. * @returns the current grid
  65576. */
  65577. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65578. /**
  65579. * Adds a new column to the grid
  65580. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65581. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65582. * @returns the current grid
  65583. */
  65584. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65585. /**
  65586. * Update a row definition
  65587. * @param index defines the index of the row to update
  65588. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65589. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65590. * @returns the current grid
  65591. */
  65592. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65593. /**
  65594. * Update a column definition
  65595. * @param index defines the index of the column to update
  65596. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65597. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65598. * @returns the current grid
  65599. */
  65600. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65601. /**
  65602. * Gets the list of children stored in a specific cell
  65603. * @param row defines the row to check
  65604. * @param column defines the column to check
  65605. * @returns the list of controls
  65606. */
  65607. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65608. /**
  65609. * Gets a string representing the child cell info (row x column)
  65610. * @param child defines the control to get info from
  65611. * @returns a string containing the child cell info (row x column)
  65612. */
  65613. getChildCellInfo(child: Control): string;
  65614. private _removeCell;
  65615. private _offsetCell;
  65616. /**
  65617. * Remove a column definition at specified index
  65618. * @param index defines the index of the column to remove
  65619. * @returns the current grid
  65620. */
  65621. removeColumnDefinition(index: number): Grid;
  65622. /**
  65623. * Remove a row definition at specified index
  65624. * @param index defines the index of the row to remove
  65625. * @returns the current grid
  65626. */
  65627. removeRowDefinition(index: number): Grid;
  65628. /**
  65629. * Adds a new control to the current grid
  65630. * @param control defines the control to add
  65631. * @param row defines the row where to add the control (0 by default)
  65632. * @param column defines the column where to add the control (0 by default)
  65633. * @returns the current grid
  65634. */
  65635. addControl(control: Control, row?: number, column?: number): Grid;
  65636. /**
  65637. * Removes a control from the current container
  65638. * @param control defines the control to remove
  65639. * @returns the current container
  65640. */
  65641. removeControl(control: Control): Container;
  65642. /**
  65643. * Creates a new Grid
  65644. * @param name defines control name
  65645. */
  65646. constructor(name?: string | undefined);
  65647. protected _getTypeName(): string;
  65648. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65649. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65650. /** Releases associated resources */
  65651. dispose(): void;
  65652. }
  65653. }
  65654. declare module BABYLON.GUI {
  65655. /** Class used to create color pickers */
  65656. export class ColorPicker extends Control {
  65657. name?: string | undefined;
  65658. private static _Epsilon;
  65659. private _colorWheelCanvas;
  65660. private _value;
  65661. private _tmpColor;
  65662. private _pointerStartedOnSquare;
  65663. private _pointerStartedOnWheel;
  65664. private _squareLeft;
  65665. private _squareTop;
  65666. private _squareSize;
  65667. private _h;
  65668. private _s;
  65669. private _v;
  65670. private _lastPointerDownID;
  65671. /**
  65672. * BABYLON.Observable raised when the value changes
  65673. */
  65674. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65675. /** Gets or sets the color of the color picker */
  65676. value: BABYLON.Color3;
  65677. /**
  65678. * Gets or sets control width
  65679. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65680. */
  65681. width: string | number;
  65682. /**
  65683. * Gets or sets control height
  65684. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65685. */
  65686. /** Gets or sets control height */
  65687. height: string | number;
  65688. /** Gets or sets control size */
  65689. size: string | number;
  65690. /**
  65691. * Creates a new ColorPicker
  65692. * @param name defines the control name
  65693. */
  65694. constructor(name?: string | undefined);
  65695. protected _getTypeName(): string;
  65696. /** @hidden */
  65697. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65698. private _updateSquareProps;
  65699. private _drawGradientSquare;
  65700. private _drawCircle;
  65701. private _createColorWheelCanvas;
  65702. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  65703. private _pointerIsDown;
  65704. private _updateValueFromPointer;
  65705. private _isPointOnSquare;
  65706. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65707. /**
  65708. * This function expands the color picker by creating a color picker dialog with manual
  65709. * color value input and the ability to save colors into an array to be used later in
  65710. * subsequent launches of the dialogue.
  65711. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65712. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  65713. * @returns picked color as a hex string and the saved colors array as hex strings.
  65714. */
  65715. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65716. pickerWidth?: string;
  65717. pickerHeight?: string;
  65718. headerHeight?: string;
  65719. lastColor?: string;
  65720. swatchLimit?: number;
  65721. numSwatchesPerLine?: number;
  65722. savedColors?: Array<string>;
  65723. }): Promise<{
  65724. savedColors?: string[];
  65725. pickedColor: string;
  65726. }>;
  65727. }
  65728. }
  65729. declare module BABYLON.GUI {
  65730. /** Class used to create 2D ellipse containers */
  65731. export class Ellipse extends Container {
  65732. name?: string | undefined;
  65733. private _thickness;
  65734. /** Gets or sets border thickness */
  65735. thickness: number;
  65736. /**
  65737. * Creates a new Ellipse
  65738. * @param name defines the control name
  65739. */
  65740. constructor(name?: string | undefined);
  65741. protected _getTypeName(): string;
  65742. protected _localDraw(context: CanvasRenderingContext2D): void;
  65743. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65744. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65745. }
  65746. }
  65747. declare module BABYLON.GUI {
  65748. /**
  65749. * Class used to create a password control
  65750. */
  65751. export class InputPassword extends InputText {
  65752. protected _beforeRenderText(text: string): string;
  65753. }
  65754. }
  65755. declare module BABYLON.GUI {
  65756. /** Class used to render 2D lines */
  65757. export class Line extends Control {
  65758. name?: string | undefined;
  65759. private _lineWidth;
  65760. private _x1;
  65761. private _y1;
  65762. private _x2;
  65763. private _y2;
  65764. private _dash;
  65765. private _connectedControl;
  65766. private _connectedControlDirtyObserver;
  65767. /** Gets or sets the dash pattern */
  65768. dash: Array<number>;
  65769. /** Gets or sets the control connected with the line end */
  65770. connectedControl: Control;
  65771. /** Gets or sets start coordinates on X axis */
  65772. x1: string | number;
  65773. /** Gets or sets start coordinates on Y axis */
  65774. y1: string | number;
  65775. /** Gets or sets end coordinates on X axis */
  65776. x2: string | number;
  65777. /** Gets or sets end coordinates on Y axis */
  65778. y2: string | number;
  65779. /** Gets or sets line width */
  65780. lineWidth: number;
  65781. /** Gets or sets horizontal alignment */
  65782. horizontalAlignment: number;
  65783. /** Gets or sets vertical alignment */
  65784. verticalAlignment: number;
  65785. private readonly _effectiveX2;
  65786. private readonly _effectiveY2;
  65787. /**
  65788. * Creates a new Line
  65789. * @param name defines the control name
  65790. */
  65791. constructor(name?: string | undefined);
  65792. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  65793. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65794. /**
  65795. * Move one end of the line given 3D cartesian coordinates.
  65796. * @param position Targeted world position
  65797. * @param scene BABYLON.Scene
  65798. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65799. */
  65800. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65801. /**
  65802. * Move one end of the line to a position in screen absolute space.
  65803. * @param projectedPosition Position in screen absolute space (X, Y)
  65804. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65805. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65806. }
  65807. }
  65808. declare module BABYLON.GUI {
  65809. /**
  65810. * Class used to store a point for a MultiLine object.
  65811. * The point can be pure 2D coordinates, a mesh or a control
  65812. */
  65813. export class MultiLinePoint {
  65814. private _multiLine;
  65815. private _x;
  65816. private _y;
  65817. private _control;
  65818. private _mesh;
  65819. private _controlObserver;
  65820. private _meshObserver;
  65821. /** @hidden */ private _point: BABYLON.Vector2;
  65822. /**
  65823. * Creates a new MultiLinePoint
  65824. * @param multiLine defines the source MultiLine object
  65825. */
  65826. constructor(multiLine: MultiLine);
  65827. /** Gets or sets x coordinate */
  65828. x: string | number;
  65829. /** Gets or sets y coordinate */
  65830. y: string | number;
  65831. /** Gets or sets the control associated with this point */
  65832. control: BABYLON.Nullable<Control>;
  65833. /** Gets or sets the mesh associated with this point */
  65834. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65835. /** Resets links */
  65836. resetLinks(): void;
  65837. /**
  65838. * Gets a translation vector
  65839. * @returns the translation vector
  65840. */
  65841. translate(): BABYLON.Vector2;
  65842. private _translatePoint;
  65843. /** Release associated resources */
  65844. dispose(): void;
  65845. }
  65846. }
  65847. declare module BABYLON.GUI {
  65848. /**
  65849. * Class used to create multi line control
  65850. */
  65851. export class MultiLine extends Control {
  65852. name?: string | undefined;
  65853. private _lineWidth;
  65854. private _dash;
  65855. private _points;
  65856. private _minX;
  65857. private _minY;
  65858. private _maxX;
  65859. private _maxY;
  65860. /**
  65861. * Creates a new MultiLine
  65862. * @param name defines the control name
  65863. */
  65864. constructor(name?: string | undefined);
  65865. /** Gets or sets dash pattern */
  65866. dash: Array<number>;
  65867. /**
  65868. * Gets point stored at specified index
  65869. * @param index defines the index to look for
  65870. * @returns the requested point if found
  65871. */
  65872. getAt(index: number): MultiLinePoint;
  65873. /** Function called when a point is updated */
  65874. onPointUpdate: () => void;
  65875. /**
  65876. * Adds new points to the point collection
  65877. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65878. * @returns the list of created MultiLinePoint
  65879. */
  65880. add(...items: (AbstractMesh | Control | {
  65881. x: string | number;
  65882. y: string | number;
  65883. })[]): MultiLinePoint[];
  65884. /**
  65885. * Adds a new point to the point collection
  65886. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65887. * @returns the created MultiLinePoint
  65888. */
  65889. push(item?: (AbstractMesh | Control | {
  65890. x: string | number;
  65891. y: string | number;
  65892. })): MultiLinePoint;
  65893. /**
  65894. * Remove a specific value or point from the active point collection
  65895. * @param value defines the value or point to remove
  65896. */
  65897. remove(value: number | MultiLinePoint): void;
  65898. /**
  65899. * Resets this object to initial state (no point)
  65900. */
  65901. reset(): void;
  65902. /**
  65903. * Resets all links
  65904. */
  65905. resetLinks(): void;
  65906. /** Gets or sets line width */
  65907. lineWidth: number;
  65908. horizontalAlignment: number;
  65909. verticalAlignment: number;
  65910. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65911. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  65912. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65913. dispose(): void;
  65914. }
  65915. }
  65916. declare module BABYLON.GUI {
  65917. /**
  65918. * Class used to create radio button controls
  65919. */
  65920. export class RadioButton extends Control {
  65921. name?: string | undefined;
  65922. private _isChecked;
  65923. private _background;
  65924. private _checkSizeRatio;
  65925. private _thickness;
  65926. /** Gets or sets border thickness */
  65927. thickness: number;
  65928. /** Gets or sets group name */
  65929. group: string;
  65930. /** BABYLON.Observable raised when isChecked is changed */
  65931. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65932. /** Gets or sets a value indicating the ratio between overall size and check size */
  65933. checkSizeRatio: number;
  65934. /** Gets or sets background color */
  65935. background: string;
  65936. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65937. isChecked: boolean;
  65938. /**
  65939. * Creates a new RadioButton
  65940. * @param name defines the control name
  65941. */
  65942. constructor(name?: string | undefined);
  65943. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65944. /**
  65945. * Utility function to easily create a radio button with a header
  65946. * @param title defines the label to use for the header
  65947. * @param group defines the group to use for the radio button
  65948. * @param isChecked defines the initial state of the radio button
  65949. * @param onValueChanged defines the callback to call when value changes
  65950. * @returns a StackPanel containing the radio button and a textBlock
  65951. */
  65952. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65953. }
  65954. }
  65955. declare module BABYLON.GUI {
  65956. /**
  65957. * Class used to create slider controls
  65958. */
  65959. export class BaseSlider extends Control {
  65960. name?: string | undefined;
  65961. protected _thumbWidth: ValueAndUnit;
  65962. private _minimum;
  65963. private _maximum;
  65964. private _value;
  65965. private _isVertical;
  65966. protected _barOffset: ValueAndUnit;
  65967. private _isThumbClamped;
  65968. protected _displayThumb: boolean;
  65969. private _step;
  65970. private _lastPointerDownID;
  65971. protected _effectiveBarOffset: number;
  65972. protected _renderLeft: number;
  65973. protected _renderTop: number;
  65974. protected _renderWidth: number;
  65975. protected _renderHeight: number;
  65976. protected _backgroundBoxLength: number;
  65977. protected _backgroundBoxThickness: number;
  65978. protected _effectiveThumbThickness: number;
  65979. /** BABYLON.Observable raised when the sldier value changes */
  65980. onValueChangedObservable: BABYLON.Observable<number>;
  65981. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65982. displayThumb: boolean;
  65983. /** Gets or sets a step to apply to values (0 by default) */
  65984. step: number;
  65985. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65986. barOffset: string | number;
  65987. /** Gets main bar offset in pixels*/
  65988. readonly barOffsetInPixels: number;
  65989. /** Gets or sets thumb width */
  65990. thumbWidth: string | number;
  65991. /** Gets thumb width in pixels */
  65992. readonly thumbWidthInPixels: number;
  65993. /** Gets or sets minimum value */
  65994. minimum: number;
  65995. /** Gets or sets maximum value */
  65996. maximum: number;
  65997. /** Gets or sets current value */
  65998. value: number;
  65999. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  66000. isVertical: boolean;
  66001. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  66002. isThumbClamped: boolean;
  66003. /**
  66004. * Creates a new BaseSlider
  66005. * @param name defines the control name
  66006. */
  66007. constructor(name?: string | undefined);
  66008. protected _getTypeName(): string;
  66009. protected _getThumbPosition(): number;
  66010. protected _getThumbThickness(type: string): number;
  66011. protected _prepareRenderingData(type: string): void;
  66012. private _pointerIsDown;
  66013. /** @hidden */
  66014. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66015. }
  66016. }
  66017. declare module BABYLON.GUI {
  66018. /**
  66019. * Class used to create slider controls
  66020. */
  66021. export class Slider extends BaseSlider {
  66022. name?: string | undefined;
  66023. private _background;
  66024. private _borderColor;
  66025. private _isThumbCircle;
  66026. protected _displayValueBar: boolean;
  66027. /** Gets or sets a boolean indicating if the value bar must be rendered */
  66028. displayValueBar: boolean;
  66029. /** Gets or sets border color */
  66030. borderColor: string;
  66031. /** Gets or sets background color */
  66032. background: string;
  66033. /** Gets or sets a boolean indicating if the thumb should be round or square */
  66034. isThumbCircle: boolean;
  66035. /**
  66036. * Creates a new Slider
  66037. * @param name defines the control name
  66038. */
  66039. constructor(name?: string | undefined);
  66040. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66041. }
  66042. }
  66043. declare module BABYLON.GUI {
  66044. /** Class used to create a RadioGroup
  66045. * which contains groups of radio buttons
  66046. */
  66047. export class SelectorGroup {
  66048. /** name of SelectorGroup */
  66049. name: string;
  66050. private _groupPanel;
  66051. private _selectors;
  66052. private _groupHeader;
  66053. /**
  66054. * Creates a new SelectorGroup
  66055. * @param name of group, used as a group heading
  66056. */
  66057. constructor(
  66058. /** name of SelectorGroup */
  66059. name: string);
  66060. /** Gets the groupPanel of the SelectorGroup */
  66061. readonly groupPanel: StackPanel;
  66062. /** Gets the selectors array */
  66063. readonly selectors: StackPanel[];
  66064. /** Gets and sets the group header */
  66065. header: string;
  66066. /** @hidden */
  66067. private _addGroupHeader;
  66068. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  66069. /** Removes the selector at the given position
  66070. * @param selectorNb the position of the selector within the group
  66071. */
  66072. removeSelector(selectorNb: number): void;
  66073. }
  66074. /** Class used to create a CheckboxGroup
  66075. * which contains groups of checkbox buttons
  66076. */
  66077. export class CheckboxGroup extends SelectorGroup {
  66078. /** Adds a checkbox as a control
  66079. * @param text is the label for the selector
  66080. * @param func is the function called when the Selector is checked
  66081. * @param checked is true when Selector is checked
  66082. */
  66083. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  66084. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66085. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66086. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66087. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66088. }
  66089. /** Class used to create a RadioGroup
  66090. * which contains groups of radio buttons
  66091. */
  66092. export class RadioGroup extends SelectorGroup {
  66093. private _selectNb;
  66094. /** Adds a radio button as a control
  66095. * @param label is the label for the selector
  66096. * @param func is the function called when the Selector is checked
  66097. * @param checked is true when Selector is checked
  66098. */
  66099. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  66100. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66101. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66102. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66103. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66104. }
  66105. /** Class used to create a SliderGroup
  66106. * which contains groups of slider buttons
  66107. */
  66108. export class SliderGroup extends SelectorGroup {
  66109. /**
  66110. * Adds a slider to the SelectorGroup
  66111. * @param label is the label for the SliderBar
  66112. * @param func is the function called when the Slider moves
  66113. * @param unit is a string describing the units used, eg degrees or metres
  66114. * @param min is the minimum value for the Slider
  66115. * @param max is the maximum value for the Slider
  66116. * @param value is the start value for the Slider between min and max
  66117. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  66118. */
  66119. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  66120. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  66121. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  66122. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  66123. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  66124. }
  66125. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  66126. * @see http://doc.babylonjs.com/how_to/selector
  66127. */
  66128. export class SelectionPanel extends Rectangle {
  66129. /** name of SelectionPanel */
  66130. name: string;
  66131. /** an array of SelectionGroups */
  66132. groups: SelectorGroup[];
  66133. private _panel;
  66134. private _buttonColor;
  66135. private _buttonBackground;
  66136. private _headerColor;
  66137. private _barColor;
  66138. private _barHeight;
  66139. private _spacerHeight;
  66140. private _labelColor;
  66141. private _groups;
  66142. private _bars;
  66143. /**
  66144. * Creates a new SelectionPanel
  66145. * @param name of SelectionPanel
  66146. * @param groups is an array of SelectionGroups
  66147. */
  66148. constructor(
  66149. /** name of SelectionPanel */
  66150. name: string,
  66151. /** an array of SelectionGroups */
  66152. groups?: SelectorGroup[]);
  66153. protected _getTypeName(): string;
  66154. /** Gets or sets the headerColor */
  66155. headerColor: string;
  66156. private _setHeaderColor;
  66157. /** Gets or sets the button color */
  66158. buttonColor: string;
  66159. private _setbuttonColor;
  66160. /** Gets or sets the label color */
  66161. labelColor: string;
  66162. private _setLabelColor;
  66163. /** Gets or sets the button background */
  66164. buttonBackground: string;
  66165. private _setButtonBackground;
  66166. /** Gets or sets the color of separator bar */
  66167. barColor: string;
  66168. private _setBarColor;
  66169. /** Gets or sets the height of separator bar */
  66170. barHeight: string;
  66171. private _setBarHeight;
  66172. /** Gets or sets the height of spacers*/
  66173. spacerHeight: string;
  66174. private _setSpacerHeight;
  66175. /** Adds a bar between groups */
  66176. private _addSpacer;
  66177. /** Add a group to the selection panel
  66178. * @param group is the selector group to add
  66179. */
  66180. addGroup(group: SelectorGroup): void;
  66181. /** Remove the group from the given position
  66182. * @param groupNb is the position of the group in the list
  66183. */
  66184. removeGroup(groupNb: number): void;
  66185. /** Change a group header label
  66186. * @param label is the new group header label
  66187. * @param groupNb is the number of the group to relabel
  66188. * */
  66189. setHeaderName(label: string, groupNb: number): void;
  66190. /** Change selector label to the one given
  66191. * @param label is the new selector label
  66192. * @param groupNb is the number of the groupcontaining the selector
  66193. * @param selectorNb is the number of the selector within a group to relabel
  66194. * */
  66195. relabel(label: string, groupNb: number, selectorNb: number): void;
  66196. /** For a given group position remove the selector at the given position
  66197. * @param groupNb is the number of the group to remove the selector from
  66198. * @param selectorNb is the number of the selector within the group
  66199. */
  66200. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66201. /** For a given group position of correct type add a checkbox button
  66202. * @param groupNb is the number of the group to remove the selector from
  66203. * @param label is the label for the selector
  66204. * @param func is the function called when the Selector is checked
  66205. * @param checked is true when Selector is checked
  66206. */
  66207. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66208. /** For a given group position of correct type add a radio button
  66209. * @param groupNb is the number of the group to remove the selector from
  66210. * @param label is the label for the selector
  66211. * @param func is the function called when the Selector is checked
  66212. * @param checked is true when Selector is checked
  66213. */
  66214. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66215. /**
  66216. * For a given slider group add a slider
  66217. * @param groupNb is the number of the group to add the slider to
  66218. * @param label is the label for the Slider
  66219. * @param func is the function called when the Slider moves
  66220. * @param unit is a string describing the units used, eg degrees or metres
  66221. * @param min is the minimum value for the Slider
  66222. * @param max is the maximum value for the Slider
  66223. * @param value is the start value for the Slider between min and max
  66224. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66225. */
  66226. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66227. }
  66228. }
  66229. declare module BABYLON.GUI {
  66230. /**
  66231. * Class used to hold a the container for ScrollViewer
  66232. * @hidden
  66233. */
  66234. export class _ScrollViewerWindow extends Container {
  66235. parentClientWidth: number;
  66236. parentClientHeight: number;
  66237. /**
  66238. * Creates a new ScrollViewerWindow
  66239. * @param name of ScrollViewerWindow
  66240. */
  66241. constructor(name?: string);
  66242. protected _getTypeName(): string;
  66243. /** @hidden */
  66244. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66245. protected _postMeasure(): void;
  66246. }
  66247. }
  66248. declare module BABYLON.GUI {
  66249. /**
  66250. * Class used to create slider controls
  66251. */
  66252. export class ScrollBar extends BaseSlider {
  66253. name?: string | undefined;
  66254. private _background;
  66255. private _borderColor;
  66256. private _thumbMeasure;
  66257. /** Gets or sets border color */
  66258. borderColor: string;
  66259. /** Gets or sets background color */
  66260. background: string;
  66261. /**
  66262. * Creates a new Slider
  66263. * @param name defines the control name
  66264. */
  66265. constructor(name?: string | undefined);
  66266. protected _getTypeName(): string;
  66267. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  66268. private _first;
  66269. private _originX;
  66270. private _originY;
  66271. /** @hidden */
  66272. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66273. }
  66274. }
  66275. declare module BABYLON.GUI {
  66276. /**
  66277. * Class used to hold a viewer window and sliders in a grid
  66278. */
  66279. export class ScrollViewer extends Rectangle {
  66280. private _grid;
  66281. private _horizontalBarSpace;
  66282. private _verticalBarSpace;
  66283. private _dragSpace;
  66284. private _horizontalBar;
  66285. private _verticalBar;
  66286. private _barColor;
  66287. private _barBackground;
  66288. private _barSize;
  66289. private _endLeft;
  66290. private _endTop;
  66291. private _window;
  66292. private _pointerIsOver;
  66293. private _wheelPrecision;
  66294. private _onPointerObserver;
  66295. private _clientWidth;
  66296. private _clientHeight;
  66297. /**
  66298. * Gets the horizontal scrollbar
  66299. */
  66300. readonly horizontalBar: ScrollBar;
  66301. /**
  66302. * Gets the vertical scrollbar
  66303. */
  66304. readonly verticalBar: ScrollBar;
  66305. /**
  66306. * Adds a new control to the current container
  66307. * @param control defines the control to add
  66308. * @returns the current container
  66309. */
  66310. addControl(control: BABYLON.Nullable<Control>): Container;
  66311. /**
  66312. * Removes a control from the current container
  66313. * @param control defines the control to remove
  66314. * @returns the current container
  66315. */
  66316. removeControl(control: Control): Container;
  66317. /** Gets the list of children */
  66318. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  66319. /**
  66320. * Creates a new ScrollViewer
  66321. * @param name of ScrollViewer
  66322. */
  66323. constructor(name?: string);
  66324. /** Reset the scroll viewer window to initial size */
  66325. resetWindow(): void;
  66326. protected _getTypeName(): string;
  66327. private _buildClientSizes;
  66328. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66329. protected _postMeasure(): void;
  66330. /**
  66331. * Gets or sets the mouse wheel precision
  66332. * from 0 to 1 with a default value of 0.05
  66333. * */
  66334. wheelPrecision: number;
  66335. /** Gets or sets the bar color */
  66336. barColor: string;
  66337. /** Gets or sets the size of the bar */
  66338. barSize: number;
  66339. /** Gets or sets the bar background */
  66340. barBackground: string;
  66341. /** @hidden */
  66342. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  66343. /** @hidden */
  66344. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66345. /** Releases associated resources */
  66346. dispose(): void;
  66347. }
  66348. }
  66349. declare module BABYLON.GUI {
  66350. /** Class used to render a grid */
  66351. export class DisplayGrid extends Control {
  66352. name?: string | undefined;
  66353. private _cellWidth;
  66354. private _cellHeight;
  66355. private _minorLineTickness;
  66356. private _minorLineColor;
  66357. private _majorLineTickness;
  66358. private _majorLineColor;
  66359. private _majorLineFrequency;
  66360. private _background;
  66361. private _displayMajorLines;
  66362. private _displayMinorLines;
  66363. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66364. displayMinorLines: boolean;
  66365. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66366. displayMajorLines: boolean;
  66367. /** Gets or sets background color (Black by default) */
  66368. background: string;
  66369. /** Gets or sets the width of each cell (20 by default) */
  66370. cellWidth: number;
  66371. /** Gets or sets the height of each cell (20 by default) */
  66372. cellHeight: number;
  66373. /** Gets or sets the tickness of minor lines (1 by default) */
  66374. minorLineTickness: number;
  66375. /** Gets or sets the color of minor lines (DarkGray by default) */
  66376. minorLineColor: string;
  66377. /** Gets or sets the tickness of major lines (2 by default) */
  66378. majorLineTickness: number;
  66379. /** Gets or sets the color of major lines (White by default) */
  66380. majorLineColor: string;
  66381. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66382. majorLineFrequency: number;
  66383. /**
  66384. * Creates a new GridDisplayRectangle
  66385. * @param name defines the control name
  66386. */
  66387. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  66388. protected _getTypeName(): string;
  66389. }
  66390. }
  66391. declare module BABYLON.GUI {
  66392. /**
  66393. * Class used to create slider controls based on images
  66394. */
  66395. export class ImageBasedSlider extends BaseSlider {
  66396. name?: string | undefined;
  66397. private _backgroundImage;
  66398. private _thumbImage;
  66399. private _valueBarImage;
  66400. private _tempMeasure;
  66401. displayThumb: boolean;
  66402. /**
  66403. * Gets or sets the image used to render the background
  66404. */
  66405. backgroundImage: Image;
  66406. /**
  66407. * Gets or sets the image used to render the value bar
  66408. */
  66409. valueBarImage: Image;
  66410. /**
  66411. * Gets or sets the image used to render the thumb
  66412. */
  66413. thumbImage: Image;
  66414. /**
  66415. * Creates a new ImageBasedSlider
  66416. * @param name defines the control name
  66417. */
  66418. constructor(name?: string | undefined);
  66419. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  66420. }
  66421. }
  66422. declare module BABYLON.GUI {
  66423. /**
  66424. * Forcing an export so that this code will execute
  66425. * @hidden
  66426. */
  66427. const name = "Statics";
  66428. }
  66429. declare module BABYLON.GUI {
  66430. /**
  66431. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66432. */
  66433. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66434. /**
  66435. * Define the instrumented AdvancedDynamicTexture.
  66436. */
  66437. texture: AdvancedDynamicTexture;
  66438. private _captureRenderTime;
  66439. private _renderTime;
  66440. private _captureLayoutTime;
  66441. private _layoutTime;
  66442. private _onBeginRenderObserver;
  66443. private _onEndRenderObserver;
  66444. private _onBeginLayoutObserver;
  66445. private _onEndLayoutObserver;
  66446. /**
  66447. * Gets the perf counter used to capture render time
  66448. */
  66449. readonly renderTimeCounter: BABYLON.PerfCounter;
  66450. /**
  66451. * Gets the perf counter used to capture layout time
  66452. */
  66453. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66454. /**
  66455. * Enable or disable the render time capture
  66456. */
  66457. captureRenderTime: boolean;
  66458. /**
  66459. * Enable or disable the layout time capture
  66460. */
  66461. captureLayoutTime: boolean;
  66462. /**
  66463. * Instantiates a new advanced dynamic texture instrumentation.
  66464. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66465. * @param texture Defines the AdvancedDynamicTexture to instrument
  66466. */
  66467. constructor(
  66468. /**
  66469. * Define the instrumented AdvancedDynamicTexture.
  66470. */
  66471. texture: AdvancedDynamicTexture);
  66472. /**
  66473. * Dispose and release associated resources.
  66474. */
  66475. dispose(): void;
  66476. }
  66477. }
  66478. declare module BABYLON.GUI {
  66479. /**
  66480. * Class used to create containers for controls
  66481. */
  66482. export class Container3D extends Control3D {
  66483. private _blockLayout;
  66484. /**
  66485. * Gets the list of child controls
  66486. */
  66487. protected _children: Control3D[];
  66488. /**
  66489. * Gets the list of child controls
  66490. */
  66491. readonly children: Array<Control3D>;
  66492. /**
  66493. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66494. * This is helpful to optimize layout operation when adding multiple children in a row
  66495. */
  66496. blockLayout: boolean;
  66497. /**
  66498. * Creates a new container
  66499. * @param name defines the container name
  66500. */
  66501. constructor(name?: string);
  66502. /**
  66503. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66504. * @returns the current container
  66505. */
  66506. updateLayout(): Container3D;
  66507. /**
  66508. * Gets a boolean indicating if the given control is in the children of this control
  66509. * @param control defines the control to check
  66510. * @returns true if the control is in the child list
  66511. */
  66512. containsControl(control: Control3D): boolean;
  66513. /**
  66514. * Adds a control to the children of this control
  66515. * @param control defines the control to add
  66516. * @returns the current container
  66517. */
  66518. addControl(control: Control3D): Container3D;
  66519. /**
  66520. * This function will be called everytime a new control is added
  66521. */
  66522. protected _arrangeChildren(): void;
  66523. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66524. /**
  66525. * Removes a control from the children of this control
  66526. * @param control defines the control to remove
  66527. * @returns the current container
  66528. */
  66529. removeControl(control: Control3D): Container3D;
  66530. protected _getTypeName(): string;
  66531. /**
  66532. * Releases all associated resources
  66533. */
  66534. dispose(): void;
  66535. /** Control rotation will remain unchanged */
  66536. static readonly UNSET_ORIENTATION: number;
  66537. /** Control will rotate to make it look at sphere central axis */
  66538. static readonly FACEORIGIN_ORIENTATION: number;
  66539. /** Control will rotate to make it look back at sphere central axis */
  66540. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66541. /** Control will rotate to look at z axis (0, 0, 1) */
  66542. static readonly FACEFORWARD_ORIENTATION: number;
  66543. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66544. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66545. }
  66546. }
  66547. declare module BABYLON.GUI {
  66548. /**
  66549. * Class used to manage 3D user interface
  66550. * @see http://doc.babylonjs.com/how_to/gui3d
  66551. */
  66552. export class GUI3DManager implements BABYLON.IDisposable {
  66553. private _scene;
  66554. private _sceneDisposeObserver;
  66555. private _utilityLayer;
  66556. private _rootContainer;
  66557. private _pointerObserver;
  66558. private _pointerOutObserver;
  66559. /** @hidden */ private _lastPickedControl: Control3D;
  66560. /** @hidden */ private _lastControlOver: {
  66561. [pointerId: number]: Control3D;
  66562. };
  66563. /** @hidden */ private _lastControlDown: {
  66564. [pointerId: number]: Control3D;
  66565. };
  66566. /**
  66567. * BABYLON.Observable raised when the point picked by the pointer events changed
  66568. */
  66569. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66570. /** @hidden */ private _sharedMaterials: {
  66571. [key: string]: BABYLON.Material;
  66572. };
  66573. /** Gets the hosting scene */
  66574. readonly scene: BABYLON.Scene;
  66575. /** Gets associated utility layer */
  66576. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66577. /**
  66578. * Creates a new GUI3DManager
  66579. * @param scene
  66580. */
  66581. constructor(scene?: BABYLON.Scene);
  66582. private _handlePointerOut;
  66583. private _doPicking;
  66584. /**
  66585. * Gets the root container
  66586. */
  66587. readonly rootContainer: Container3D;
  66588. /**
  66589. * Gets a boolean indicating if the given control is in the root child list
  66590. * @param control defines the control to check
  66591. * @returns true if the control is in the root child list
  66592. */
  66593. containsControl(control: Control3D): boolean;
  66594. /**
  66595. * Adds a control to the root child list
  66596. * @param control defines the control to add
  66597. * @returns the current manager
  66598. */
  66599. addControl(control: Control3D): GUI3DManager;
  66600. /**
  66601. * Removes a control from the root child list
  66602. * @param control defines the control to remove
  66603. * @returns the current container
  66604. */
  66605. removeControl(control: Control3D): GUI3DManager;
  66606. /**
  66607. * Releases all associated resources
  66608. */
  66609. dispose(): void;
  66610. }
  66611. }
  66612. declare module BABYLON.GUI {
  66613. /**
  66614. * Class used to transport BABYLON.Vector3 information for pointer events
  66615. */
  66616. export class Vector3WithInfo extends BABYLON.Vector3 {
  66617. /** defines the current mouse button index */
  66618. buttonIndex: number;
  66619. /**
  66620. * Creates a new Vector3WithInfo
  66621. * @param source defines the vector3 data to transport
  66622. * @param buttonIndex defines the current mouse button index
  66623. */
  66624. constructor(source: BABYLON.Vector3,
  66625. /** defines the current mouse button index */
  66626. buttonIndex?: number);
  66627. }
  66628. }
  66629. declare module BABYLON.GUI {
  66630. /**
  66631. * Class used as base class for controls
  66632. */
  66633. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66634. /** Defines the control name */
  66635. name?: string | undefined;
  66636. /** @hidden */ private _host: GUI3DManager;
  66637. private _node;
  66638. private _downCount;
  66639. private _enterCount;
  66640. private _downPointerIds;
  66641. private _isVisible;
  66642. /** Gets or sets the control position in world space */
  66643. position: BABYLON.Vector3;
  66644. /** Gets or sets the control scaling in world space */
  66645. scaling: BABYLON.Vector3;
  66646. /** Callback used to start pointer enter animation */
  66647. pointerEnterAnimation: () => void;
  66648. /** Callback used to start pointer out animation */
  66649. pointerOutAnimation: () => void;
  66650. /** Callback used to start pointer down animation */
  66651. pointerDownAnimation: () => void;
  66652. /** Callback used to start pointer up animation */
  66653. pointerUpAnimation: () => void;
  66654. /**
  66655. * An event triggered when the pointer move over the control
  66656. */
  66657. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66658. /**
  66659. * An event triggered when the pointer move out of the control
  66660. */
  66661. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66662. /**
  66663. * An event triggered when the pointer taps the control
  66664. */
  66665. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66666. /**
  66667. * An event triggered when pointer is up
  66668. */
  66669. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66670. /**
  66671. * An event triggered when a control is clicked on (with a mouse)
  66672. */
  66673. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66674. /**
  66675. * An event triggered when pointer enters the control
  66676. */
  66677. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66678. /**
  66679. * Gets or sets the parent container
  66680. */
  66681. parent: BABYLON.Nullable<Container3D>;
  66682. private _behaviors;
  66683. /**
  66684. * Gets the list of attached behaviors
  66685. * @see http://doc.babylonjs.com/features/behaviour
  66686. */
  66687. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66688. /**
  66689. * Attach a behavior to the control
  66690. * @see http://doc.babylonjs.com/features/behaviour
  66691. * @param behavior defines the behavior to attach
  66692. * @returns the current control
  66693. */
  66694. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66695. /**
  66696. * Remove an attached behavior
  66697. * @see http://doc.babylonjs.com/features/behaviour
  66698. * @param behavior defines the behavior to attach
  66699. * @returns the current control
  66700. */
  66701. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66702. /**
  66703. * Gets an attached behavior by name
  66704. * @param name defines the name of the behavior to look for
  66705. * @see http://doc.babylonjs.com/features/behaviour
  66706. * @returns null if behavior was not found else the requested behavior
  66707. */
  66708. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66709. /** Gets or sets a boolean indicating if the control is visible */
  66710. isVisible: boolean;
  66711. /**
  66712. * Creates a new control
  66713. * @param name defines the control name
  66714. */
  66715. constructor(
  66716. /** Defines the control name */
  66717. name?: string | undefined);
  66718. /**
  66719. * Gets a string representing the class name
  66720. */
  66721. readonly typeName: string;
  66722. /**
  66723. * Get the current class name of the control.
  66724. * @returns current class name
  66725. */
  66726. getClassName(): string;
  66727. protected _getTypeName(): string;
  66728. /**
  66729. * Gets the transform node used by this control
  66730. */
  66731. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66732. /**
  66733. * Gets the mesh used to render this control
  66734. */
  66735. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66736. /**
  66737. * Link the control as child of the given node
  66738. * @param node defines the node to link to. Use null to unlink the control
  66739. * @returns the current control
  66740. */
  66741. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66742. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  66743. /**
  66744. * Node creation.
  66745. * Can be overriden by children
  66746. * @param scene defines the scene where the node must be attached
  66747. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66748. */
  66749. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66750. /**
  66751. * Affect a material to the given mesh
  66752. * @param mesh defines the mesh which will represent the control
  66753. */
  66754. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66755. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66756. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  66757. /** @hidden */ private _onPointerOut(target: Control3D): void;
  66758. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66759. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66760. /** @hidden */
  66761. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66762. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66763. /** @hidden */ private _disposeNode(): void;
  66764. /**
  66765. * Releases all associated resources
  66766. */
  66767. dispose(): void;
  66768. }
  66769. }
  66770. declare module BABYLON.GUI {
  66771. /**
  66772. * Class used as a root to all buttons
  66773. */
  66774. export class AbstractButton3D extends Control3D {
  66775. /**
  66776. * Creates a new button
  66777. * @param name defines the control name
  66778. */
  66779. constructor(name?: string);
  66780. protected _getTypeName(): string;
  66781. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66782. }
  66783. }
  66784. declare module BABYLON.GUI {
  66785. /**
  66786. * Class used to create a button in 3D
  66787. */
  66788. export class Button3D extends AbstractButton3D {
  66789. /** @hidden */
  66790. protected _currentMaterial: BABYLON.Material;
  66791. private _facadeTexture;
  66792. private _content;
  66793. private _contentResolution;
  66794. private _contentScaleRatio;
  66795. /**
  66796. * Gets or sets the texture resolution used to render content (512 by default)
  66797. */
  66798. contentResolution: BABYLON.int;
  66799. /**
  66800. * Gets or sets the texture scale ratio used to render content (2 by default)
  66801. */
  66802. contentScaleRatio: number;
  66803. protected _disposeFacadeTexture(): void;
  66804. protected _resetContent(): void;
  66805. /**
  66806. * Creates a new button
  66807. * @param name defines the control name
  66808. */
  66809. constructor(name?: string);
  66810. /**
  66811. * Gets or sets the GUI 2D content used to display the button's facade
  66812. */
  66813. content: Control;
  66814. /**
  66815. * Apply the facade texture (created from the content property).
  66816. * This function can be overloaded by child classes
  66817. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66818. */
  66819. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66820. protected _getTypeName(): string;
  66821. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66822. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66823. /**
  66824. * Releases all associated resources
  66825. */
  66826. dispose(): void;
  66827. }
  66828. }
  66829. declare module BABYLON.GUI {
  66830. /**
  66831. * Abstract class used to create a container panel deployed on the surface of a volume
  66832. */
  66833. export abstract class VolumeBasedPanel extends Container3D {
  66834. private _columns;
  66835. private _rows;
  66836. private _rowThenColum;
  66837. private _orientation;
  66838. protected _cellWidth: number;
  66839. protected _cellHeight: number;
  66840. /**
  66841. * Gets or sets the distance between elements
  66842. */
  66843. margin: number;
  66844. /**
  66845. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66846. * | Value | Type | Description |
  66847. * | ----- | ----------------------------------- | ----------- |
  66848. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66849. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66850. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66851. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66852. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66853. */
  66854. orientation: number;
  66855. /**
  66856. * Gets or sets the number of columns requested (10 by default).
  66857. * The panel will automatically compute the number of rows based on number of child controls.
  66858. */
  66859. columns: BABYLON.int;
  66860. /**
  66861. * Gets or sets a the number of rows requested.
  66862. * The panel will automatically compute the number of columns based on number of child controls.
  66863. */
  66864. rows: BABYLON.int;
  66865. /**
  66866. * Creates new VolumeBasedPanel
  66867. */
  66868. constructor();
  66869. protected _arrangeChildren(): void;
  66870. /** Child classes must implement this function to provide correct control positioning */
  66871. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66872. /** Child classes can implement this function to provide additional processing */
  66873. protected _finalProcessing(): void;
  66874. }
  66875. }
  66876. declare module BABYLON.GUI {
  66877. /**
  66878. * Class used to create a container panel deployed on the surface of a cylinder
  66879. */
  66880. export class CylinderPanel extends VolumeBasedPanel {
  66881. private _radius;
  66882. /**
  66883. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66884. */
  66885. radius: BABYLON.float;
  66886. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66887. private _cylindricalMapping;
  66888. }
  66889. }
  66890. declare module BABYLON.GUI {
  66891. /** @hidden */
  66892. export var fluentVertexShader: {
  66893. name: string;
  66894. shader: string;
  66895. };
  66896. }
  66897. declare module BABYLON.GUI {
  66898. /** @hidden */
  66899. export var fluentPixelShader: {
  66900. name: string;
  66901. shader: string;
  66902. };
  66903. }
  66904. declare module BABYLON.GUI {
  66905. /** @hidden */
  66906. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66907. INNERGLOW: boolean;
  66908. BORDER: boolean;
  66909. HOVERLIGHT: boolean;
  66910. TEXTURE: boolean;
  66911. constructor();
  66912. }
  66913. /**
  66914. * Class used to render controls with fluent desgin
  66915. */
  66916. export class FluentMaterial extends BABYLON.PushMaterial {
  66917. /**
  66918. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66919. */
  66920. innerGlowColorIntensity: number;
  66921. /**
  66922. * Gets or sets the inner glow color (white by default)
  66923. */
  66924. innerGlowColor: BABYLON.Color3;
  66925. /**
  66926. * Gets or sets alpha value (default is 1.0)
  66927. */
  66928. alpha: number;
  66929. /**
  66930. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66931. */
  66932. albedoColor: BABYLON.Color3;
  66933. /**
  66934. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66935. */
  66936. renderBorders: boolean;
  66937. /**
  66938. * Gets or sets border width (default is 0.5)
  66939. */
  66940. borderWidth: number;
  66941. /**
  66942. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66943. */
  66944. edgeSmoothingValue: number;
  66945. /**
  66946. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66947. */
  66948. borderMinValue: number;
  66949. /**
  66950. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66951. */
  66952. renderHoverLight: boolean;
  66953. /**
  66954. * Gets or sets the radius used to render the hover light (default is 1.0)
  66955. */
  66956. hoverRadius: number;
  66957. /**
  66958. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66959. */
  66960. hoverColor: BABYLON.Color4;
  66961. /**
  66962. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66963. */
  66964. hoverPosition: BABYLON.Vector3;
  66965. private _albedoTexture;
  66966. /** Gets or sets the texture to use for albedo color */
  66967. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66968. /**
  66969. * Creates a new Fluent material
  66970. * @param name defines the name of the material
  66971. * @param scene defines the hosting scene
  66972. */
  66973. constructor(name: string, scene: BABYLON.Scene);
  66974. needAlphaBlending(): boolean;
  66975. needAlphaTesting(): boolean;
  66976. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66977. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66978. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66979. getActiveTextures(): BABYLON.BaseTexture[];
  66980. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66981. dispose(forceDisposeEffect?: boolean): void;
  66982. clone(name: string): FluentMaterial;
  66983. serialize(): any;
  66984. getClassName(): string;
  66985. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66986. }
  66987. }
  66988. declare module BABYLON.GUI {
  66989. /**
  66990. * Class used to create a holographic button in 3D
  66991. */
  66992. export class HolographicButton extends Button3D {
  66993. private _backPlate;
  66994. private _textPlate;
  66995. private _frontPlate;
  66996. private _text;
  66997. private _imageUrl;
  66998. private _shareMaterials;
  66999. private _frontMaterial;
  67000. private _backMaterial;
  67001. private _plateMaterial;
  67002. private _pickedPointObserver;
  67003. private _tooltipFade;
  67004. private _tooltipTextBlock;
  67005. private _tooltipTexture;
  67006. private _tooltipMesh;
  67007. private _tooltipHoverObserver;
  67008. private _tooltipOutObserver;
  67009. private _disposeTooltip;
  67010. /**
  67011. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  67012. */
  67013. tooltipText: BABYLON.Nullable<string>;
  67014. /**
  67015. * Gets or sets text for the button
  67016. */
  67017. text: string;
  67018. /**
  67019. * Gets or sets the image url for the button
  67020. */
  67021. imageUrl: string;
  67022. /**
  67023. * Gets the back material used by this button
  67024. */
  67025. readonly backMaterial: FluentMaterial;
  67026. /**
  67027. * Gets the front material used by this button
  67028. */
  67029. readonly frontMaterial: FluentMaterial;
  67030. /**
  67031. * Gets the plate material used by this button
  67032. */
  67033. readonly plateMaterial: BABYLON.StandardMaterial;
  67034. /**
  67035. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  67036. */
  67037. readonly shareMaterials: boolean;
  67038. /**
  67039. * Creates a new button
  67040. * @param name defines the control name
  67041. */
  67042. constructor(name?: string, shareMaterials?: boolean);
  67043. protected _getTypeName(): string;
  67044. private _rebuildContent;
  67045. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67046. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  67047. private _createBackMaterial;
  67048. private _createFrontMaterial;
  67049. private _createPlateMaterial;
  67050. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  67051. /**
  67052. * Releases all associated resources
  67053. */
  67054. dispose(): void;
  67055. }
  67056. }
  67057. declare module BABYLON.GUI {
  67058. /**
  67059. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  67060. */
  67061. export class MeshButton3D extends Button3D {
  67062. /** @hidden */
  67063. protected _currentMesh: BABYLON.Mesh;
  67064. /**
  67065. * Creates a new 3D button based on a mesh
  67066. * @param mesh mesh to become a 3D button
  67067. * @param name defines the control name
  67068. */
  67069. constructor(mesh: BABYLON.Mesh, name?: string);
  67070. protected _getTypeName(): string;
  67071. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  67072. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  67073. }
  67074. }
  67075. declare module BABYLON.GUI {
  67076. /**
  67077. * Class used to create a container panel deployed on the surface of a plane
  67078. */
  67079. export class PlanePanel extends VolumeBasedPanel {
  67080. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67081. }
  67082. }
  67083. declare module BABYLON.GUI {
  67084. /**
  67085. * Class used to create a container panel where items get randomized planar mapping
  67086. */
  67087. export class ScatterPanel extends VolumeBasedPanel {
  67088. private _iteration;
  67089. /**
  67090. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  67091. */
  67092. iteration: BABYLON.float;
  67093. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67094. private _scatterMapping;
  67095. protected _finalProcessing(): void;
  67096. }
  67097. }
  67098. declare module BABYLON.GUI {
  67099. /**
  67100. * Class used to create a container panel deployed on the surface of a sphere
  67101. */
  67102. export class SpherePanel extends VolumeBasedPanel {
  67103. private _radius;
  67104. /**
  67105. * Gets or sets the radius of the sphere where to project controls (5 by default)
  67106. */
  67107. radius: BABYLON.float;
  67108. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  67109. private _sphericalMapping;
  67110. }
  67111. }
  67112. declare module BABYLON.GUI {
  67113. /**
  67114. * Class used to create a stack panel in 3D on XY plane
  67115. */
  67116. export class StackPanel3D extends Container3D {
  67117. private _isVertical;
  67118. /**
  67119. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67120. */
  67121. isVertical: boolean;
  67122. /**
  67123. * Gets or sets the distance between elements
  67124. */
  67125. margin: number;
  67126. /**
  67127. * Creates new StackPanel
  67128. * @param isVertical
  67129. */
  67130. constructor(isVertical?: boolean);
  67131. protected _arrangeChildren(): void;
  67132. }
  67133. }
  67134. declare module BABYLON {
  67135. /**
  67136. * Mode that determines the coordinate system to use.
  67137. */
  67138. export enum GLTFLoaderCoordinateSystemMode {
  67139. /**
  67140. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67141. */
  67142. AUTO = 0,
  67143. /**
  67144. * Sets the useRightHandedSystem flag on the scene.
  67145. */
  67146. FORCE_RIGHT_HANDED = 1
  67147. }
  67148. /**
  67149. * Mode that determines what animations will start.
  67150. */
  67151. export enum GLTFLoaderAnimationStartMode {
  67152. /**
  67153. * No animation will start.
  67154. */
  67155. NONE = 0,
  67156. /**
  67157. * The first animation will start.
  67158. */
  67159. FIRST = 1,
  67160. /**
  67161. * All animations will start.
  67162. */
  67163. ALL = 2
  67164. }
  67165. /**
  67166. * Interface that contains the data for the glTF asset.
  67167. */
  67168. export interface IGLTFLoaderData {
  67169. /**
  67170. * Object that represents the glTF JSON.
  67171. */
  67172. json: Object;
  67173. /**
  67174. * The BIN chunk of a binary glTF.
  67175. */
  67176. bin: Nullable<ArrayBufferView>;
  67177. }
  67178. /**
  67179. * Interface for extending the loader.
  67180. */
  67181. export interface IGLTFLoaderExtension {
  67182. /**
  67183. * The name of this extension.
  67184. */
  67185. readonly name: string;
  67186. /**
  67187. * Defines whether this extension is enabled.
  67188. */
  67189. enabled: boolean;
  67190. }
  67191. /**
  67192. * Loader state.
  67193. */
  67194. export enum GLTFLoaderState {
  67195. /**
  67196. * The asset is loading.
  67197. */
  67198. LOADING = 0,
  67199. /**
  67200. * The asset is ready for rendering.
  67201. */
  67202. READY = 1,
  67203. /**
  67204. * The asset is completely loaded.
  67205. */
  67206. COMPLETE = 2
  67207. }
  67208. /** @hidden */
  67209. export interface IGLTFLoader extends IDisposable {
  67210. readonly state: Nullable<GLTFLoaderState>;
  67211. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67212. meshes: AbstractMesh[];
  67213. particleSystems: IParticleSystem[];
  67214. skeletons: Skeleton[];
  67215. animationGroups: AnimationGroup[];
  67216. }>;
  67217. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67218. }
  67219. /**
  67220. * File loader for loading glTF files into a scene.
  67221. */
  67222. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67223. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67224. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67225. /**
  67226. * Raised when the asset has been parsed
  67227. */
  67228. onParsedObservable: Observable<IGLTFLoaderData>;
  67229. private _onParsedObserver;
  67230. /**
  67231. * Raised when the asset has been parsed
  67232. */
  67233. onParsed: (loaderData: IGLTFLoaderData) => void;
  67234. /**
  67235. * 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.
  67236. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67237. * Defaults to true.
  67238. * @hidden
  67239. */
  67240. static IncrementalLoading: boolean;
  67241. /**
  67242. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67243. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67244. * @hidden
  67245. */
  67246. static HomogeneousCoordinates: boolean;
  67247. /**
  67248. * The coordinate system mode. Defaults to AUTO.
  67249. */
  67250. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67251. /**
  67252. * The animation start mode. Defaults to FIRST.
  67253. */
  67254. animationStartMode: GLTFLoaderAnimationStartMode;
  67255. /**
  67256. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67257. */
  67258. compileMaterials: boolean;
  67259. /**
  67260. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67261. */
  67262. useClipPlane: boolean;
  67263. /**
  67264. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67265. */
  67266. compileShadowGenerators: boolean;
  67267. /**
  67268. * Defines if the Alpha blended materials are only applied as coverage.
  67269. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67270. * If true, no extra effects are applied to transparent pixels.
  67271. */
  67272. transparencyAsCoverage: boolean;
  67273. /**
  67274. * Function called before loading a url referenced by the asset.
  67275. */
  67276. preprocessUrlAsync: (url: string) => Promise<string>;
  67277. /**
  67278. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67279. */
  67280. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67281. private _onMeshLoadedObserver;
  67282. /**
  67283. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67284. */
  67285. onMeshLoaded: (mesh: AbstractMesh) => void;
  67286. /**
  67287. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67288. */
  67289. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67290. private _onTextureLoadedObserver;
  67291. /**
  67292. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67293. */
  67294. onTextureLoaded: (texture: BaseTexture) => void;
  67295. /**
  67296. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67297. */
  67298. readonly onMaterialLoadedObservable: Observable<Material>;
  67299. private _onMaterialLoadedObserver;
  67300. /**
  67301. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67302. */
  67303. onMaterialLoaded: (material: Material) => void;
  67304. /**
  67305. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67306. */
  67307. readonly onCameraLoadedObservable: Observable<Camera>;
  67308. private _onCameraLoadedObserver;
  67309. /**
  67310. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67311. */
  67312. onCameraLoaded: (camera: Camera) => void;
  67313. /**
  67314. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67315. * For assets with LODs, raised when all of the LODs are complete.
  67316. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67317. */
  67318. readonly onCompleteObservable: Observable<void>;
  67319. private _onCompleteObserver;
  67320. /**
  67321. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67322. * For assets with LODs, raised when all of the LODs are complete.
  67323. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67324. */
  67325. onComplete: () => void;
  67326. /**
  67327. * Observable raised when an error occurs.
  67328. */
  67329. readonly onErrorObservable: Observable<any>;
  67330. private _onErrorObserver;
  67331. /**
  67332. * Callback raised when an error occurs.
  67333. */
  67334. onError: (reason: any) => void;
  67335. /**
  67336. * Observable raised after the loader is disposed.
  67337. */
  67338. readonly onDisposeObservable: Observable<void>;
  67339. private _onDisposeObserver;
  67340. /**
  67341. * Callback raised after the loader is disposed.
  67342. */
  67343. onDispose: () => void;
  67344. /**
  67345. * Observable raised after a loader extension is created.
  67346. * Set additional options for a loader extension in this event.
  67347. */
  67348. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67349. private _onExtensionLoadedObserver;
  67350. /**
  67351. * Callback raised after a loader extension is created.
  67352. */
  67353. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67354. /**
  67355. * Defines if the loader logging is enabled.
  67356. */
  67357. loggingEnabled: boolean;
  67358. /**
  67359. * Defines if the loader should capture performance counters.
  67360. */
  67361. capturePerformanceCounters: boolean;
  67362. /**
  67363. * Defines if the loader should validate the asset.
  67364. */
  67365. validate: boolean;
  67366. /**
  67367. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67368. */
  67369. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67370. private _onValidatedObserver;
  67371. /**
  67372. * Callback raised after a loader extension is created.
  67373. */
  67374. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67375. private _loader;
  67376. /**
  67377. * Name of the loader ("gltf")
  67378. */
  67379. name: string;
  67380. /**
  67381. * Supported file extensions of the loader (.gltf, .glb)
  67382. */
  67383. extensions: ISceneLoaderPluginExtensions;
  67384. /**
  67385. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67386. */
  67387. dispose(): void;
  67388. /** @hidden */ private _clear(): void;
  67389. /**
  67390. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67391. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67392. * @param scene the scene the meshes should be added to
  67393. * @param data the glTF data to load
  67394. * @param rootUrl root url to load from
  67395. * @param onProgress event that fires when loading progress has occured
  67396. * @param fileName Defines the name of the file to load
  67397. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67398. */
  67399. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67400. meshes: AbstractMesh[];
  67401. particleSystems: IParticleSystem[];
  67402. skeletons: Skeleton[];
  67403. animationGroups: AnimationGroup[];
  67404. }>;
  67405. /**
  67406. * Imports all objects from the loaded glTF data and adds them to the scene
  67407. * @param scene the scene the objects should be added to
  67408. * @param data the glTF data to load
  67409. * @param rootUrl root url to load from
  67410. * @param onProgress event that fires when loading progress has occured
  67411. * @param fileName Defines the name of the file to load
  67412. * @returns a promise which completes when objects have been loaded to the scene
  67413. */
  67414. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67415. /**
  67416. * Load into an asset container.
  67417. * @param scene The scene to load into
  67418. * @param data The data to import
  67419. * @param rootUrl The root url for scene and resources
  67420. * @param onProgress The callback when the load progresses
  67421. * @param fileName Defines the name of the file to load
  67422. * @returns The loaded asset container
  67423. */
  67424. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67425. /**
  67426. * If the data string can be loaded directly.
  67427. * @param data string contianing the file data
  67428. * @returns if the data can be loaded directly
  67429. */
  67430. canDirectLoad(data: string): boolean;
  67431. /**
  67432. * Rewrites a url by combining a root url and response url.
  67433. */
  67434. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67435. /**
  67436. * Instantiates a glTF file loader plugin.
  67437. * @returns the created plugin
  67438. */
  67439. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67440. /**
  67441. * The loader state or null if the loader is not active.
  67442. */
  67443. readonly loaderState: Nullable<GLTFLoaderState>;
  67444. /**
  67445. * Returns a promise that resolves when the asset is completely loaded.
  67446. * @returns a promise that resolves when the asset is completely loaded.
  67447. */
  67448. whenCompleteAsync(): Promise<void>;
  67449. private _parseAsync;
  67450. private _validateAsync;
  67451. private _getLoader;
  67452. private _unpackBinary;
  67453. private _unpackBinaryV1;
  67454. private _unpackBinaryV2;
  67455. private static _parseVersion;
  67456. private static _compareVersion;
  67457. private static _decodeBufferToText;
  67458. private static readonly _logSpaces;
  67459. private _logIndentLevel;
  67460. private _loggingEnabled;
  67461. /** @hidden */ private _log: (message: string) => void;
  67462. /** @hidden */ private _logOpen(message: string): void;
  67463. /** @hidden */ private _logClose(): void;
  67464. private _logEnabled;
  67465. private _logDisabled;
  67466. private _capturePerformanceCounters;
  67467. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  67468. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  67469. private _startPerformanceCounterEnabled;
  67470. private _startPerformanceCounterDisabled;
  67471. private _endPerformanceCounterEnabled;
  67472. private _endPerformanceCounterDisabled;
  67473. }
  67474. }
  67475. declare module BABYLON.GLTF1 {
  67476. /**
  67477. * Enums
  67478. * @hidden
  67479. */
  67480. export enum EComponentType {
  67481. BYTE = 5120,
  67482. UNSIGNED_BYTE = 5121,
  67483. SHORT = 5122,
  67484. UNSIGNED_SHORT = 5123,
  67485. FLOAT = 5126
  67486. }
  67487. /** @hidden */
  67488. export enum EShaderType {
  67489. FRAGMENT = 35632,
  67490. VERTEX = 35633
  67491. }
  67492. /** @hidden */
  67493. export enum EParameterType {
  67494. BYTE = 5120,
  67495. UNSIGNED_BYTE = 5121,
  67496. SHORT = 5122,
  67497. UNSIGNED_SHORT = 5123,
  67498. INT = 5124,
  67499. UNSIGNED_INT = 5125,
  67500. FLOAT = 5126,
  67501. FLOAT_VEC2 = 35664,
  67502. FLOAT_VEC3 = 35665,
  67503. FLOAT_VEC4 = 35666,
  67504. INT_VEC2 = 35667,
  67505. INT_VEC3 = 35668,
  67506. INT_VEC4 = 35669,
  67507. BOOL = 35670,
  67508. BOOL_VEC2 = 35671,
  67509. BOOL_VEC3 = 35672,
  67510. BOOL_VEC4 = 35673,
  67511. FLOAT_MAT2 = 35674,
  67512. FLOAT_MAT3 = 35675,
  67513. FLOAT_MAT4 = 35676,
  67514. SAMPLER_2D = 35678
  67515. }
  67516. /** @hidden */
  67517. export enum ETextureWrapMode {
  67518. CLAMP_TO_EDGE = 33071,
  67519. MIRRORED_REPEAT = 33648,
  67520. REPEAT = 10497
  67521. }
  67522. /** @hidden */
  67523. export enum ETextureFilterType {
  67524. NEAREST = 9728,
  67525. LINEAR = 9728,
  67526. NEAREST_MIPMAP_NEAREST = 9984,
  67527. LINEAR_MIPMAP_NEAREST = 9985,
  67528. NEAREST_MIPMAP_LINEAR = 9986,
  67529. LINEAR_MIPMAP_LINEAR = 9987
  67530. }
  67531. /** @hidden */
  67532. export enum ETextureFormat {
  67533. ALPHA = 6406,
  67534. RGB = 6407,
  67535. RGBA = 6408,
  67536. LUMINANCE = 6409,
  67537. LUMINANCE_ALPHA = 6410
  67538. }
  67539. /** @hidden */
  67540. export enum ECullingType {
  67541. FRONT = 1028,
  67542. BACK = 1029,
  67543. FRONT_AND_BACK = 1032
  67544. }
  67545. /** @hidden */
  67546. export enum EBlendingFunction {
  67547. ZERO = 0,
  67548. ONE = 1,
  67549. SRC_COLOR = 768,
  67550. ONE_MINUS_SRC_COLOR = 769,
  67551. DST_COLOR = 774,
  67552. ONE_MINUS_DST_COLOR = 775,
  67553. SRC_ALPHA = 770,
  67554. ONE_MINUS_SRC_ALPHA = 771,
  67555. DST_ALPHA = 772,
  67556. ONE_MINUS_DST_ALPHA = 773,
  67557. CONSTANT_COLOR = 32769,
  67558. ONE_MINUS_CONSTANT_COLOR = 32770,
  67559. CONSTANT_ALPHA = 32771,
  67560. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67561. SRC_ALPHA_SATURATE = 776
  67562. }
  67563. /** @hidden */
  67564. export interface IGLTFProperty {
  67565. extensions?: {
  67566. [key: string]: any;
  67567. };
  67568. extras?: Object;
  67569. }
  67570. /** @hidden */
  67571. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67572. name?: string;
  67573. }
  67574. /** @hidden */
  67575. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67576. bufferView: string;
  67577. byteOffset: number;
  67578. byteStride: number;
  67579. count: number;
  67580. type: string;
  67581. componentType: EComponentType;
  67582. max?: number[];
  67583. min?: number[];
  67584. name?: string;
  67585. }
  67586. /** @hidden */
  67587. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67588. buffer: string;
  67589. byteOffset: number;
  67590. byteLength: number;
  67591. byteStride: number;
  67592. target?: number;
  67593. }
  67594. /** @hidden */
  67595. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67596. uri: string;
  67597. byteLength?: number;
  67598. type?: string;
  67599. }
  67600. /** @hidden */
  67601. export interface IGLTFShader extends IGLTFChildRootProperty {
  67602. uri: string;
  67603. type: EShaderType;
  67604. }
  67605. /** @hidden */
  67606. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67607. attributes: string[];
  67608. fragmentShader: string;
  67609. vertexShader: string;
  67610. }
  67611. /** @hidden */
  67612. export interface IGLTFTechniqueParameter {
  67613. type: number;
  67614. count?: number;
  67615. semantic?: string;
  67616. node?: string;
  67617. value?: number | boolean | string | Array<any>;
  67618. source?: string;
  67619. babylonValue?: any;
  67620. }
  67621. /** @hidden */
  67622. export interface IGLTFTechniqueCommonProfile {
  67623. lightingModel: string;
  67624. texcoordBindings: Object;
  67625. parameters?: Array<any>;
  67626. }
  67627. /** @hidden */
  67628. export interface IGLTFTechniqueStatesFunctions {
  67629. blendColor?: number[];
  67630. blendEquationSeparate?: number[];
  67631. blendFuncSeparate?: number[];
  67632. colorMask: boolean[];
  67633. cullFace: number[];
  67634. }
  67635. /** @hidden */
  67636. export interface IGLTFTechniqueStates {
  67637. enable: number[];
  67638. functions: IGLTFTechniqueStatesFunctions;
  67639. }
  67640. /** @hidden */
  67641. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67642. parameters: {
  67643. [key: string]: IGLTFTechniqueParameter;
  67644. };
  67645. program: string;
  67646. attributes: {
  67647. [key: string]: string;
  67648. };
  67649. uniforms: {
  67650. [key: string]: string;
  67651. };
  67652. states: IGLTFTechniqueStates;
  67653. }
  67654. /** @hidden */
  67655. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67656. technique?: string;
  67657. values: string[];
  67658. }
  67659. /** @hidden */
  67660. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67661. attributes: {
  67662. [key: string]: string;
  67663. };
  67664. indices: string;
  67665. material: string;
  67666. mode?: number;
  67667. }
  67668. /** @hidden */
  67669. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67670. primitives: IGLTFMeshPrimitive[];
  67671. }
  67672. /** @hidden */
  67673. export interface IGLTFImage extends IGLTFChildRootProperty {
  67674. uri: string;
  67675. }
  67676. /** @hidden */
  67677. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67678. magFilter?: number;
  67679. minFilter?: number;
  67680. wrapS?: number;
  67681. wrapT?: number;
  67682. }
  67683. /** @hidden */
  67684. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67685. sampler: string;
  67686. source: string;
  67687. format?: ETextureFormat;
  67688. internalFormat?: ETextureFormat;
  67689. target?: number;
  67690. type?: number;
  67691. babylonTexture?: Texture;
  67692. }
  67693. /** @hidden */
  67694. export interface IGLTFAmbienLight {
  67695. color?: number[];
  67696. }
  67697. /** @hidden */
  67698. export interface IGLTFDirectionalLight {
  67699. color?: number[];
  67700. }
  67701. /** @hidden */
  67702. export interface IGLTFPointLight {
  67703. color?: number[];
  67704. constantAttenuation?: number;
  67705. linearAttenuation?: number;
  67706. quadraticAttenuation?: number;
  67707. }
  67708. /** @hidden */
  67709. export interface IGLTFSpotLight {
  67710. color?: number[];
  67711. constantAttenuation?: number;
  67712. fallOfAngle?: number;
  67713. fallOffExponent?: number;
  67714. linearAttenuation?: number;
  67715. quadraticAttenuation?: number;
  67716. }
  67717. /** @hidden */
  67718. export interface IGLTFLight extends IGLTFChildRootProperty {
  67719. type: string;
  67720. }
  67721. /** @hidden */
  67722. export interface IGLTFCameraOrthographic {
  67723. xmag: number;
  67724. ymag: number;
  67725. zfar: number;
  67726. znear: number;
  67727. }
  67728. /** @hidden */
  67729. export interface IGLTFCameraPerspective {
  67730. aspectRatio: number;
  67731. yfov: number;
  67732. zfar: number;
  67733. znear: number;
  67734. }
  67735. /** @hidden */
  67736. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67737. type: string;
  67738. }
  67739. /** @hidden */
  67740. export interface IGLTFAnimationChannelTarget {
  67741. id: string;
  67742. path: string;
  67743. }
  67744. /** @hidden */
  67745. export interface IGLTFAnimationChannel {
  67746. sampler: string;
  67747. target: IGLTFAnimationChannelTarget;
  67748. }
  67749. /** @hidden */
  67750. export interface IGLTFAnimationSampler {
  67751. input: string;
  67752. output: string;
  67753. interpolation?: string;
  67754. }
  67755. /** @hidden */
  67756. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67757. channels?: IGLTFAnimationChannel[];
  67758. parameters?: {
  67759. [key: string]: string;
  67760. };
  67761. samplers?: {
  67762. [key: string]: IGLTFAnimationSampler;
  67763. };
  67764. }
  67765. /** @hidden */
  67766. export interface IGLTFNodeInstanceSkin {
  67767. skeletons: string[];
  67768. skin: string;
  67769. meshes: string[];
  67770. }
  67771. /** @hidden */
  67772. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67773. bindShapeMatrix: number[];
  67774. inverseBindMatrices: string;
  67775. jointNames: string[];
  67776. babylonSkeleton?: Skeleton;
  67777. }
  67778. /** @hidden */
  67779. export interface IGLTFNode extends IGLTFChildRootProperty {
  67780. camera?: string;
  67781. children: string[];
  67782. skin?: string;
  67783. jointName?: string;
  67784. light?: string;
  67785. matrix: number[];
  67786. mesh?: string;
  67787. meshes?: string[];
  67788. rotation?: number[];
  67789. scale?: number[];
  67790. translation?: number[];
  67791. babylonNode?: Node;
  67792. }
  67793. /** @hidden */
  67794. export interface IGLTFScene extends IGLTFChildRootProperty {
  67795. nodes: string[];
  67796. }
  67797. /** @hidden */
  67798. export interface IGLTFRuntime {
  67799. extensions: {
  67800. [key: string]: any;
  67801. };
  67802. accessors: {
  67803. [key: string]: IGLTFAccessor;
  67804. };
  67805. buffers: {
  67806. [key: string]: IGLTFBuffer;
  67807. };
  67808. bufferViews: {
  67809. [key: string]: IGLTFBufferView;
  67810. };
  67811. meshes: {
  67812. [key: string]: IGLTFMesh;
  67813. };
  67814. lights: {
  67815. [key: string]: IGLTFLight;
  67816. };
  67817. cameras: {
  67818. [key: string]: IGLTFCamera;
  67819. };
  67820. nodes: {
  67821. [key: string]: IGLTFNode;
  67822. };
  67823. images: {
  67824. [key: string]: IGLTFImage;
  67825. };
  67826. textures: {
  67827. [key: string]: IGLTFTexture;
  67828. };
  67829. shaders: {
  67830. [key: string]: IGLTFShader;
  67831. };
  67832. programs: {
  67833. [key: string]: IGLTFProgram;
  67834. };
  67835. samplers: {
  67836. [key: string]: IGLTFSampler;
  67837. };
  67838. techniques: {
  67839. [key: string]: IGLTFTechnique;
  67840. };
  67841. materials: {
  67842. [key: string]: IGLTFMaterial;
  67843. };
  67844. animations: {
  67845. [key: string]: IGLTFAnimation;
  67846. };
  67847. skins: {
  67848. [key: string]: IGLTFSkins;
  67849. };
  67850. currentScene?: Object;
  67851. scenes: {
  67852. [key: string]: IGLTFScene;
  67853. };
  67854. extensionsUsed: string[];
  67855. extensionsRequired?: string[];
  67856. buffersCount: number;
  67857. shaderscount: number;
  67858. scene: Scene;
  67859. rootUrl: string;
  67860. loadedBufferCount: number;
  67861. loadedBufferViews: {
  67862. [name: string]: ArrayBufferView;
  67863. };
  67864. loadedShaderCount: number;
  67865. importOnlyMeshes: boolean;
  67866. importMeshesNames?: string[];
  67867. dummyNodes: Node[];
  67868. }
  67869. /** @hidden */
  67870. export interface INodeToRoot {
  67871. bone: Bone;
  67872. node: IGLTFNode;
  67873. id: string;
  67874. }
  67875. /** @hidden */
  67876. export interface IJointNode {
  67877. node: IGLTFNode;
  67878. id: string;
  67879. }
  67880. }
  67881. declare module BABYLON.GLTF1 {
  67882. /**
  67883. * Utils functions for GLTF
  67884. * @hidden
  67885. */
  67886. export class GLTFUtils {
  67887. /**
  67888. * Sets the given "parameter" matrix
  67889. * @param scene: the Scene object
  67890. * @param source: the source node where to pick the matrix
  67891. * @param parameter: the GLTF technique parameter
  67892. * @param uniformName: the name of the shader's uniform
  67893. * @param shaderMaterial: the shader material
  67894. */
  67895. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67896. /**
  67897. * Sets the given "parameter" matrix
  67898. * @param shaderMaterial: the shader material
  67899. * @param uniform: the name of the shader's uniform
  67900. * @param value: the value of the uniform
  67901. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67902. */
  67903. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67904. /**
  67905. * Returns the wrap mode of the texture
  67906. * @param mode: the mode value
  67907. */
  67908. static GetWrapMode(mode: number): number;
  67909. /**
  67910. * Returns the byte stride giving an accessor
  67911. * @param accessor: the GLTF accessor objet
  67912. */
  67913. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67914. /**
  67915. * Returns the texture filter mode giving a mode value
  67916. * @param mode: the filter mode value
  67917. */
  67918. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67919. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67920. /**
  67921. * Returns a buffer from its accessor
  67922. * @param gltfRuntime: the GLTF runtime
  67923. * @param accessor: the GLTF accessor
  67924. */
  67925. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67926. /**
  67927. * Decodes a buffer view into a string
  67928. * @param view: the buffer view
  67929. */
  67930. static DecodeBufferToText(view: ArrayBufferView): string;
  67931. /**
  67932. * Returns the default material of gltf. Related to
  67933. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67934. * @param scene: the Babylon.js scene
  67935. */
  67936. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67937. private static _DefaultMaterial;
  67938. }
  67939. }
  67940. declare module BABYLON.GLTF1 {
  67941. /**
  67942. * Implementation of the base glTF spec
  67943. * @hidden
  67944. */
  67945. export class GLTFLoaderBase {
  67946. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67947. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67948. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67949. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67950. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67951. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67952. }
  67953. /**
  67954. * glTF V1 Loader
  67955. * @hidden
  67956. */
  67957. export class GLTFLoader implements IGLTFLoader {
  67958. static Extensions: {
  67959. [name: string]: GLTFLoaderExtension;
  67960. };
  67961. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67962. state: Nullable<GLTFLoaderState>;
  67963. dispose(): void;
  67964. private _importMeshAsync;
  67965. /**
  67966. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67967. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67968. * @param scene the scene the meshes should be added to
  67969. * @param data gltf data containing information of the meshes in a loaded file
  67970. * @param rootUrl root url to load from
  67971. * @param onProgress event that fires when loading progress has occured
  67972. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67973. */
  67974. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67975. meshes: AbstractMesh[];
  67976. particleSystems: IParticleSystem[];
  67977. skeletons: Skeleton[];
  67978. animationGroups: AnimationGroup[];
  67979. }>;
  67980. private _loadAsync;
  67981. /**
  67982. * Imports all objects from a loaded gltf file and adds them to the scene
  67983. * @param scene the scene the objects should be added to
  67984. * @param data gltf data containing information of the meshes in a loaded file
  67985. * @param rootUrl root url to load from
  67986. * @param onProgress event that fires when loading progress has occured
  67987. * @returns a promise which completes when objects have been loaded to the scene
  67988. */
  67989. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67990. private _loadShadersAsync;
  67991. private _loadBuffersAsync;
  67992. private _createNodes;
  67993. }
  67994. /** @hidden */
  67995. export abstract class GLTFLoaderExtension {
  67996. private _name;
  67997. constructor(name: string);
  67998. readonly name: string;
  67999. /**
  68000. * Defines an override for loading the runtime
  68001. * Return true to stop further extensions from loading the runtime
  68002. */
  68003. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  68004. /**
  68005. * Defines an onverride for creating gltf runtime
  68006. * Return true to stop further extensions from creating the runtime
  68007. */
  68008. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  68009. /**
  68010. * Defines an override for loading buffers
  68011. * Return true to stop further extensions from loading this buffer
  68012. */
  68013. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  68014. /**
  68015. * Defines an override for loading texture buffers
  68016. * Return true to stop further extensions from loading this texture data
  68017. */
  68018. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68019. /**
  68020. * Defines an override for creating textures
  68021. * Return true to stop further extensions from loading this texture
  68022. */
  68023. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  68024. /**
  68025. * Defines an override for loading shader strings
  68026. * Return true to stop further extensions from loading this shader data
  68027. */
  68028. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68029. /**
  68030. * Defines an override for loading materials
  68031. * Return true to stop further extensions from loading this material
  68032. */
  68033. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68034. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  68035. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  68036. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  68037. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  68038. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  68039. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  68040. private static LoadTextureBufferAsync;
  68041. private static CreateTextureAsync;
  68042. private static ApplyExtensions;
  68043. }
  68044. }
  68045. declare module BABYLON.GLTF1 {
  68046. /** @hidden */
  68047. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  68048. private _bin;
  68049. constructor();
  68050. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  68051. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68052. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  68053. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  68054. }
  68055. }
  68056. declare module BABYLON.GLTF1 {
  68057. /** @hidden */
  68058. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  68059. constructor();
  68060. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  68061. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  68062. private _loadTexture;
  68063. }
  68064. }
  68065. declare module BABYLON.GLTF2.Loader {
  68066. /**
  68067. * Loader interface with an index field.
  68068. */
  68069. export interface IArrayItem {
  68070. /**
  68071. * The index of this item in the array.
  68072. */
  68073. index: number;
  68074. }
  68075. /**
  68076. * Loader interface with additional members.
  68077. */
  68078. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  68079. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68080. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  68081. }
  68082. /**
  68083. * Loader interface with additional members.
  68084. */
  68085. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  68086. }
  68087. /** @hidden */
  68088. export interface _IAnimationSamplerData {
  68089. input: Float32Array;
  68090. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  68091. output: Float32Array;
  68092. }
  68093. /**
  68094. * Loader interface with additional members.
  68095. */
  68096. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  68097. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  68098. }
  68099. /**
  68100. * Loader interface with additional members.
  68101. */
  68102. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68103. channels: IAnimationChannel[];
  68104. samplers: IAnimationSampler[];
  68105. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  68106. }
  68107. /**
  68108. * Loader interface with additional members.
  68109. */
  68110. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68111. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68112. }
  68113. /**
  68114. * Loader interface with additional members.
  68115. */
  68116. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68117. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68118. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  68119. }
  68120. /**
  68121. * Loader interface with additional members.
  68122. */
  68123. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68124. }
  68125. /**
  68126. * Loader interface with additional members.
  68127. */
  68128. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68129. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  68130. }
  68131. /**
  68132. * Loader interface with additional members.
  68133. */
  68134. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68135. }
  68136. /**
  68137. * Loader interface with additional members.
  68138. */
  68139. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68140. }
  68141. /**
  68142. * Loader interface with additional members.
  68143. */
  68144. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68145. baseColorTexture?: ITextureInfo;
  68146. metallicRoughnessTexture?: ITextureInfo;
  68147. }
  68148. /**
  68149. * Loader interface with additional members.
  68150. */
  68151. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68152. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68153. normalTexture?: IMaterialNormalTextureInfo;
  68154. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68155. emissiveTexture?: ITextureInfo;
  68156. /** @hidden */ private _data?: {
  68157. [babylonDrawMode: number]: {
  68158. babylonMaterial: Material;
  68159. babylonMeshes: AbstractMesh[];
  68160. promise: Promise<void>;
  68161. };
  68162. };
  68163. }
  68164. /**
  68165. * Loader interface with additional members.
  68166. */
  68167. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68168. primitives: IMeshPrimitive[];
  68169. }
  68170. /**
  68171. * Loader interface with additional members.
  68172. */
  68173. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68174. /** @hidden */ private _instanceData?: {
  68175. babylonSourceMesh: Mesh;
  68176. promise: Promise<any>;
  68177. };
  68178. }
  68179. /**
  68180. * Loader interface with additional members.
  68181. */
  68182. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68183. /**
  68184. * The parent glTF node.
  68185. */
  68186. parent?: INode;
  68187. /** @hidden */ private _babylonTransformNode?: TransformNode;
  68188. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  68189. /** @hidden */ private _babylonBones?: Bone[];
  68190. /** @hidden */ private _numMorphTargets?: number;
  68191. }
  68192. /** @hidden */
  68193. export interface _ISamplerData {
  68194. noMipMaps: boolean;
  68195. samplingMode: number;
  68196. wrapU: number;
  68197. wrapV: number;
  68198. }
  68199. /**
  68200. * Loader interface with additional members.
  68201. */
  68202. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68203. /** @hidden */ private _data?: _ISamplerData;
  68204. }
  68205. /**
  68206. * Loader interface with additional members.
  68207. */
  68208. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68209. }
  68210. /**
  68211. * Loader interface with additional members.
  68212. */
  68213. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68214. /** @hidden */ private _data?: {
  68215. babylonSkeleton: Skeleton;
  68216. promise: Promise<void>;
  68217. };
  68218. }
  68219. /**
  68220. * Loader interface with additional members.
  68221. */
  68222. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68223. }
  68224. /**
  68225. * Loader interface with additional members.
  68226. */
  68227. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68228. }
  68229. /**
  68230. * Loader interface with additional members.
  68231. */
  68232. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68233. accessors?: IAccessor[];
  68234. animations?: IAnimation[];
  68235. buffers?: IBuffer[];
  68236. bufferViews?: IBufferView[];
  68237. cameras?: ICamera[];
  68238. images?: IImage[];
  68239. materials?: IMaterial[];
  68240. meshes?: IMesh[];
  68241. nodes?: INode[];
  68242. samplers?: ISampler[];
  68243. scenes?: IScene[];
  68244. skins?: ISkin[];
  68245. textures?: ITexture[];
  68246. }
  68247. }
  68248. declare module BABYLON.GLTF2 {
  68249. /**
  68250. * Interface for a glTF loader extension.
  68251. */
  68252. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68253. /**
  68254. * Called after the loader state changes to LOADING.
  68255. */
  68256. onLoading?(): void;
  68257. /**
  68258. * Called after the loader state changes to READY.
  68259. */
  68260. onReady?(): void;
  68261. /**
  68262. * Define this method to modify the default behavior when loading scenes.
  68263. * @param context The context when loading the asset
  68264. * @param scene The glTF scene property
  68265. * @returns A promise that resolves when the load is complete or null if not handled
  68266. */
  68267. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68268. /**
  68269. * Define this method to modify the default behavior when loading nodes.
  68270. * @param context The context when loading the asset
  68271. * @param node The glTF node property
  68272. * @param assign A function called synchronously after parsing the glTF properties
  68273. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68274. */
  68275. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68276. /**
  68277. * Define this method to modify the default behavior when loading cameras.
  68278. * @param context The context when loading the asset
  68279. * @param camera The glTF camera property
  68280. * @param assign A function called synchronously after parsing the glTF properties
  68281. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68282. */
  68283. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68284. /**
  68285. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68286. * @param context The context when loading the asset
  68287. * @param primitive The glTF mesh primitive property
  68288. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68289. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68290. /**
  68291. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68292. * @param context The context when loading the asset
  68293. * @param name The mesh name when loading the asset
  68294. * @param node The glTF node when loading the asset
  68295. * @param mesh The glTF mesh when loading the asset
  68296. * @param primitive The glTF mesh primitive property
  68297. * @param assign A function called synchronously after parsing the glTF properties
  68298. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68299. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68300. /**
  68301. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68302. * @param context The context when loading the asset
  68303. * @param material The glTF material property
  68304. * @param assign A function called synchronously after parsing the glTF properties
  68305. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68306. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68307. /**
  68308. * Define this method to modify the default behavior when creating materials.
  68309. * @param context The context when loading the asset
  68310. * @param material The glTF material property
  68311. * @param babylonDrawMode The draw mode for the Babylon material
  68312. * @returns The Babylon material or null if not handled
  68313. */
  68314. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68315. /**
  68316. * Define this method to modify the default behavior when loading material properties.
  68317. * @param context The context when loading the asset
  68318. * @param material The glTF material property
  68319. * @param babylonMaterial The Babylon material
  68320. * @returns A promise that resolves when the load is complete or null if not handled
  68321. */
  68322. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68323. /**
  68324. * Define this method to modify the default behavior when loading texture infos.
  68325. * @param context The context when loading the asset
  68326. * @param textureInfo The glTF texture info property
  68327. * @param assign A function called synchronously after parsing the glTF properties
  68328. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68329. */
  68330. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68331. /**
  68332. * Define this method to modify the default behavior when loading animations.
  68333. * @param context The context when loading the asset
  68334. * @param animation The glTF animation property
  68335. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68336. */
  68337. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68338. /**
  68339. * @hidden Define this method to modify the default behavior when loading skins.
  68340. * @param context The context when loading the asset
  68341. * @param node The glTF node property
  68342. * @param skin The glTF skin property
  68343. * @returns A promise that resolves when the load is complete or null if not handled
  68344. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68345. /**
  68346. * @hidden Define this method to modify the default behavior when loading uris.
  68347. * @param context The context when loading the asset
  68348. * @param property The glTF property associated with the uri
  68349. * @param uri The uri to load
  68350. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68351. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68352. }
  68353. }
  68354. declare module BABYLON.GLTF2 {
  68355. /**
  68356. * Helper class for working with arrays when loading the glTF asset
  68357. */
  68358. export class ArrayItem {
  68359. /**
  68360. * Gets an item from the given array.
  68361. * @param context The context when loading the asset
  68362. * @param array The array to get the item from
  68363. * @param index The index to the array
  68364. * @returns The array item
  68365. */
  68366. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68367. /**
  68368. * Assign an `index` field to each item of the given array.
  68369. * @param array The array of items
  68370. */
  68371. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68372. }
  68373. /**
  68374. * The glTF 2.0 loader
  68375. */
  68376. export class GLTFLoader implements IGLTFLoader {
  68377. /** @hidden */ private _completePromises: Promise<any>[];
  68378. private _disposed;
  68379. private _parent;
  68380. private _state;
  68381. private _extensions;
  68382. private _rootUrl;
  68383. private _fileName;
  68384. private _uniqueRootUrl;
  68385. private _gltf;
  68386. private _babylonScene;
  68387. private _rootBabylonMesh;
  68388. private _defaultBabylonMaterialData;
  68389. private _progressCallback?;
  68390. private _requests;
  68391. private static readonly _DefaultSampler;
  68392. private static _ExtensionNames;
  68393. private static _ExtensionFactories;
  68394. /**
  68395. * Registers a loader extension.
  68396. * @param name The name of the loader extension.
  68397. * @param factory The factory function that creates the loader extension.
  68398. */
  68399. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68400. /**
  68401. * Unregisters a loader extension.
  68402. * @param name The name of the loader extenion.
  68403. * @returns A boolean indicating whether the extension has been unregistered
  68404. */
  68405. static UnregisterExtension(name: string): boolean;
  68406. /**
  68407. * Gets the loader state.
  68408. */
  68409. readonly state: Nullable<GLTFLoaderState>;
  68410. /**
  68411. * The glTF object parsed from the JSON.
  68412. */
  68413. readonly gltf: IGLTF;
  68414. /**
  68415. * The Babylon scene when loading the asset.
  68416. */
  68417. readonly babylonScene: Scene;
  68418. /**
  68419. * The root Babylon mesh when loading the asset.
  68420. */
  68421. readonly rootBabylonMesh: Mesh;
  68422. /** @hidden */
  68423. constructor(parent: GLTFFileLoader);
  68424. /** @hidden */
  68425. dispose(): void;
  68426. /** @hidden */
  68427. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68428. meshes: AbstractMesh[];
  68429. particleSystems: IParticleSystem[];
  68430. skeletons: Skeleton[];
  68431. animationGroups: AnimationGroup[];
  68432. }>;
  68433. /** @hidden */
  68434. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68435. private _loadAsync;
  68436. private _loadData;
  68437. private _setupData;
  68438. private _loadExtensions;
  68439. private _checkExtensions;
  68440. private _setState;
  68441. private _createRootNode;
  68442. /**
  68443. * Loads a glTF scene.
  68444. * @param context The context when loading the asset
  68445. * @param scene The glTF scene property
  68446. * @returns A promise that resolves when the load is complete
  68447. */
  68448. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68449. private _forEachPrimitive;
  68450. private _getMeshes;
  68451. private _getSkeletons;
  68452. private _getAnimationGroups;
  68453. private _startAnimations;
  68454. /**
  68455. * Loads a glTF node.
  68456. * @param context The context when loading the asset
  68457. * @param node The glTF node property
  68458. * @param assign A function called synchronously after parsing the glTF properties
  68459. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68460. */
  68461. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68462. private _loadMeshAsync;
  68463. /**
  68464. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68465. * @param context The context when loading the asset
  68466. * @param name The mesh name when loading the asset
  68467. * @param node The glTF node when loading the asset
  68468. * @param mesh The glTF mesh when loading the asset
  68469. * @param primitive The glTF mesh primitive property
  68470. * @param assign A function called synchronously after parsing the glTF properties
  68471. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68472. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68473. private _loadVertexDataAsync;
  68474. private _createMorphTargets;
  68475. private _loadMorphTargetsAsync;
  68476. private _loadMorphTargetVertexDataAsync;
  68477. private static _LoadTransform;
  68478. private _loadSkinAsync;
  68479. private _loadBones;
  68480. private _loadBone;
  68481. private _loadSkinInverseBindMatricesDataAsync;
  68482. private _updateBoneMatrices;
  68483. private _getNodeMatrix;
  68484. /**
  68485. * Loads a glTF camera.
  68486. * @param context The context when loading the asset
  68487. * @param camera The glTF camera property
  68488. * @param assign A function called synchronously after parsing the glTF properties
  68489. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68490. */
  68491. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68492. private _loadAnimationsAsync;
  68493. /**
  68494. * Loads a glTF animation.
  68495. * @param context The context when loading the asset
  68496. * @param animation The glTF animation property
  68497. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68498. */
  68499. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68500. /**
  68501. * @hidden Loads a glTF animation channel.
  68502. * @param context The context when loading the asset
  68503. * @param animationContext The context of the animation when loading the asset
  68504. * @param animation The glTF animation property
  68505. * @param channel The glTF animation channel property
  68506. * @param babylonAnimationGroup The babylon animation group property
  68507. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68508. * @returns A void promise when the channel load is complete
  68509. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68510. private _loadAnimationSamplerAsync;
  68511. private _loadBufferAsync;
  68512. /**
  68513. * Loads a glTF buffer view.
  68514. * @param context The context when loading the asset
  68515. * @param bufferView The glTF buffer view property
  68516. * @returns A promise that resolves with the loaded data when the load is complete
  68517. */
  68518. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68519. private _loadAccessorAsync;
  68520. private _loadFloatAccessorAsync;
  68521. private _loadIndicesAccessorAsync;
  68522. private _loadVertexBufferViewAsync;
  68523. private _loadVertexAccessorAsync;
  68524. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68525. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68526. private _createDefaultMaterial;
  68527. /**
  68528. * Creates a Babylon material from a glTF material.
  68529. * @param context The context when loading the asset
  68530. * @param material The glTF material property
  68531. * @param babylonDrawMode The draw mode for the Babylon material
  68532. * @returns The Babylon material
  68533. */
  68534. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68535. /**
  68536. * Loads properties from a glTF material into a Babylon material.
  68537. * @param context The context when loading the asset
  68538. * @param material The glTF material property
  68539. * @param babylonMaterial The Babylon material
  68540. * @returns A promise that resolves when the load is complete
  68541. */
  68542. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68543. /**
  68544. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68545. * @param context The context when loading the asset
  68546. * @param material The glTF material property
  68547. * @param babylonMaterial The Babylon material
  68548. * @returns A promise that resolves when the load is complete
  68549. */
  68550. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68551. /**
  68552. * Loads the alpha properties from a glTF material into a Babylon material.
  68553. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68554. * @param context The context when loading the asset
  68555. * @param material The glTF material property
  68556. * @param babylonMaterial The Babylon material
  68557. */
  68558. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68559. /**
  68560. * Loads a glTF texture info.
  68561. * @param context The context when loading the asset
  68562. * @param textureInfo The glTF texture info property
  68563. * @param assign A function called synchronously after parsing the glTF properties
  68564. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68565. */
  68566. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68567. private _loadTextureAsync;
  68568. private _loadSampler;
  68569. /**
  68570. * Loads a glTF image.
  68571. * @param context The context when loading the asset
  68572. * @param image The glTF image property
  68573. * @returns A promise that resolves with the loaded data when the load is complete
  68574. */
  68575. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68576. /**
  68577. * Loads a glTF uri.
  68578. * @param context The context when loading the asset
  68579. * @param property The glTF property associated with the uri
  68580. * @param uri The base64 or relative uri
  68581. * @returns A promise that resolves with the loaded data when the load is complete
  68582. */
  68583. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68584. private _onProgress;
  68585. /**
  68586. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68587. * @param babylonObject the Babylon object with metadata
  68588. * @param pointer the JSON pointer
  68589. */
  68590. static AddPointerMetadata(babylonObject: {
  68591. metadata: any;
  68592. }, pointer: string): void;
  68593. private static _GetTextureWrapMode;
  68594. private static _GetTextureSamplingMode;
  68595. private static _GetTypedArrayConstructor;
  68596. private static _GetTypedArray;
  68597. private static _GetNumComponents;
  68598. private static _ValidateUri;
  68599. private static _GetDrawMode;
  68600. private _compileMaterialsAsync;
  68601. private _compileShadowGeneratorsAsync;
  68602. private _forEachExtensions;
  68603. private _applyExtensions;
  68604. private _extensionsOnLoading;
  68605. private _extensionsOnReady;
  68606. private _extensionsLoadSceneAsync;
  68607. private _extensionsLoadNodeAsync;
  68608. private _extensionsLoadCameraAsync;
  68609. private _extensionsLoadVertexDataAsync;
  68610. private _extensionsLoadMeshPrimitiveAsync;
  68611. private _extensionsLoadMaterialAsync;
  68612. private _extensionsCreateMaterial;
  68613. private _extensionsLoadMaterialPropertiesAsync;
  68614. private _extensionsLoadTextureInfoAsync;
  68615. private _extensionsLoadAnimationAsync;
  68616. private _extensionsLoadSkinAsync;
  68617. private _extensionsLoadUriAsync;
  68618. /**
  68619. * Helper method called by a loader extension to load an glTF extension.
  68620. * @param context The context when loading the asset
  68621. * @param property The glTF property to load the extension from
  68622. * @param extensionName The name of the extension to load
  68623. * @param actionAsync The action to run
  68624. * @returns The promise returned by actionAsync or null if the extension does not exist
  68625. */
  68626. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68627. /**
  68628. * Helper method called by a loader extension to load a glTF extra.
  68629. * @param context The context when loading the asset
  68630. * @param property The glTF property to load the extra from
  68631. * @param extensionName The name of the extension to load
  68632. * @param actionAsync The action to run
  68633. * @returns The promise returned by actionAsync or null if the extra does not exist
  68634. */
  68635. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68636. /**
  68637. * Increments the indentation level and logs a message.
  68638. * @param message The message to log
  68639. */
  68640. logOpen(message: string): void;
  68641. /**
  68642. * Decrements the indentation level.
  68643. */
  68644. logClose(): void;
  68645. /**
  68646. * Logs a message
  68647. * @param message The message to log
  68648. */
  68649. log(message: string): void;
  68650. /**
  68651. * Starts a performance counter.
  68652. * @param counterName The name of the performance counter
  68653. */
  68654. startPerformanceCounter(counterName: string): void;
  68655. /**
  68656. * Ends a performance counter.
  68657. * @param counterName The name of the performance counter
  68658. */
  68659. endPerformanceCounter(counterName: string): void;
  68660. }
  68661. }
  68662. declare module BABYLON.GLTF2.Loader.Extensions {
  68663. /**
  68664. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68665. */
  68666. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68667. /** The name of this extension. */
  68668. readonly name: string;
  68669. /** Defines whether this extension is enabled. */
  68670. enabled: boolean;
  68671. private _loader;
  68672. private _lights?;
  68673. /** @hidden */
  68674. constructor(loader: GLTFLoader);
  68675. /** @hidden */
  68676. dispose(): void;
  68677. /** @hidden */
  68678. onLoading(): void;
  68679. /** @hidden */
  68680. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68681. private _loadLightAsync;
  68682. }
  68683. }
  68684. declare module BABYLON.GLTF2.Loader.Extensions {
  68685. /**
  68686. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68687. */
  68688. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68689. /** The name of this extension. */
  68690. readonly name: string;
  68691. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68692. dracoCompression?: DracoCompression;
  68693. /** Defines whether this extension is enabled. */
  68694. enabled: boolean;
  68695. private _loader;
  68696. /** @hidden */
  68697. constructor(loader: GLTFLoader);
  68698. /** @hidden */
  68699. dispose(): void;
  68700. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68701. }
  68702. }
  68703. declare module BABYLON.GLTF2.Loader.Extensions {
  68704. /**
  68705. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68706. */
  68707. export class KHR_lights implements IGLTFLoaderExtension {
  68708. /** The name of this extension. */
  68709. readonly name: string;
  68710. /** Defines whether this extension is enabled. */
  68711. enabled: boolean;
  68712. private _loader;
  68713. private _lights?;
  68714. /** @hidden */
  68715. constructor(loader: GLTFLoader);
  68716. /** @hidden */
  68717. dispose(): void;
  68718. /** @hidden */
  68719. onLoading(): void;
  68720. /** @hidden */
  68721. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68722. }
  68723. }
  68724. declare module BABYLON.GLTF2.Loader.Extensions {
  68725. /**
  68726. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68727. */
  68728. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68729. /** The name of this extension. */
  68730. readonly name: string;
  68731. /** Defines whether this extension is enabled. */
  68732. enabled: boolean;
  68733. private _loader;
  68734. /** @hidden */
  68735. constructor(loader: GLTFLoader);
  68736. /** @hidden */
  68737. dispose(): void;
  68738. /** @hidden */
  68739. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68740. private _loadSpecularGlossinessPropertiesAsync;
  68741. }
  68742. }
  68743. declare module BABYLON.GLTF2.Loader.Extensions {
  68744. /**
  68745. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68746. */
  68747. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68748. /** The name of this extension. */
  68749. readonly name: string;
  68750. /** Defines whether this extension is enabled. */
  68751. enabled: boolean;
  68752. private _loader;
  68753. /** @hidden */
  68754. constructor(loader: GLTFLoader);
  68755. /** @hidden */
  68756. dispose(): void;
  68757. /** @hidden */
  68758. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68759. private _loadUnlitPropertiesAsync;
  68760. }
  68761. }
  68762. declare module BABYLON.GLTF2.Loader.Extensions {
  68763. /**
  68764. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68765. */
  68766. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68767. /** The name of this extension. */
  68768. readonly name: string;
  68769. /** Defines whether this extension is enabled. */
  68770. enabled: boolean;
  68771. private _loader;
  68772. /** @hidden */
  68773. constructor(loader: GLTFLoader);
  68774. /** @hidden */
  68775. dispose(): void;
  68776. /** @hidden */
  68777. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68778. }
  68779. }
  68780. declare module BABYLON.GLTF2.Loader.Extensions {
  68781. /**
  68782. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68783. */
  68784. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68785. /** The name of this extension. */
  68786. readonly name: string;
  68787. /** Defines whether this extension is enabled. */
  68788. enabled: boolean;
  68789. private _loader;
  68790. private _clips;
  68791. private _emitters;
  68792. /** @hidden */
  68793. constructor(loader: GLTFLoader);
  68794. /** @hidden */
  68795. dispose(): void;
  68796. /** @hidden */
  68797. onLoading(): void;
  68798. /** @hidden */
  68799. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68800. /** @hidden */
  68801. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68802. /** @hidden */
  68803. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68804. private _loadClipAsync;
  68805. private _loadEmitterAsync;
  68806. private _getEventAction;
  68807. private _loadAnimationEventAsync;
  68808. }
  68809. }
  68810. declare module BABYLON.GLTF2.Loader.Extensions {
  68811. /**
  68812. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68813. */
  68814. export class MSFT_lod implements IGLTFLoaderExtension {
  68815. /** The name of this extension. */
  68816. readonly name: string;
  68817. /** Defines whether this extension is enabled. */
  68818. enabled: boolean;
  68819. /**
  68820. * Maximum number of LODs to load, starting from the lowest LOD.
  68821. */
  68822. maxLODsToLoad: number;
  68823. /**
  68824. * Observable raised when all node LODs of one level are loaded.
  68825. * The event data is the index of the loaded LOD starting from zero.
  68826. * Dispose the loader to cancel the loading of the next level of LODs.
  68827. */
  68828. onNodeLODsLoadedObservable: Observable<number>;
  68829. /**
  68830. * Observable raised when all material LODs of one level are loaded.
  68831. * The event data is the index of the loaded LOD starting from zero.
  68832. * Dispose the loader to cancel the loading of the next level of LODs.
  68833. */
  68834. onMaterialLODsLoadedObservable: Observable<number>;
  68835. private _loader;
  68836. private _nodeIndexLOD;
  68837. private _nodeSignalLODs;
  68838. private _nodePromiseLODs;
  68839. private _materialIndexLOD;
  68840. private _materialSignalLODs;
  68841. private _materialPromiseLODs;
  68842. /** @hidden */
  68843. constructor(loader: GLTFLoader);
  68844. /** @hidden */
  68845. dispose(): void;
  68846. /** @hidden */
  68847. onReady(): void;
  68848. /** @hidden */
  68849. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68850. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68851. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68852. /**
  68853. * Gets an array of LOD properties from lowest to highest.
  68854. */
  68855. private _getLODs;
  68856. private _disposeUnusedMaterials;
  68857. }
  68858. }
  68859. declare module BABYLON.GLTF2.Loader.Extensions {
  68860. /** @hidden */
  68861. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68862. readonly name: string;
  68863. enabled: boolean;
  68864. private _loader;
  68865. constructor(loader: GLTFLoader);
  68866. dispose(): void;
  68867. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68868. }
  68869. }
  68870. declare module BABYLON.GLTF2.Loader.Extensions {
  68871. /** @hidden */
  68872. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68873. readonly name: string;
  68874. enabled: boolean;
  68875. private _loader;
  68876. constructor(loader: GLTFLoader);
  68877. dispose(): void;
  68878. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68879. }
  68880. }
  68881. declare module BABYLON.GLTF2.Loader.Extensions {
  68882. /**
  68883. * Store glTF extras (if present) in BJS objects' metadata
  68884. */
  68885. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68886. /** The name of this extension. */
  68887. readonly name: string;
  68888. /** Defines whether this extension is enabled. */
  68889. enabled: boolean;
  68890. private _loader;
  68891. private _assignExtras;
  68892. /** @hidden */
  68893. constructor(loader: GLTFLoader);
  68894. /** @hidden */
  68895. dispose(): void;
  68896. /** @hidden */
  68897. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68898. /** @hidden */
  68899. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68900. /** @hidden */
  68901. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68902. }
  68903. }
  68904. declare module BABYLON {
  68905. /**
  68906. * Class reading and parsing the MTL file bundled with the obj file.
  68907. */
  68908. export class MTLFileLoader {
  68909. /**
  68910. * All material loaded from the mtl will be set here
  68911. */
  68912. materials: StandardMaterial[];
  68913. /**
  68914. * This function will read the mtl file and create each material described inside
  68915. * This function could be improve by adding :
  68916. * -some component missing (Ni, Tf...)
  68917. * -including the specific options available
  68918. *
  68919. * @param scene defines the scene the material will be created in
  68920. * @param data defines the mtl data to parse
  68921. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68922. */
  68923. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68924. /**
  68925. * Gets the texture for the material.
  68926. *
  68927. * If the material is imported from input file,
  68928. * We sanitize the url to ensure it takes the textre from aside the material.
  68929. *
  68930. * @param rootUrl The root url to load from
  68931. * @param value The value stored in the mtl
  68932. * @return The Texture
  68933. */
  68934. private static _getTexture;
  68935. }
  68936. /**
  68937. * Options for loading OBJ/MTL files
  68938. */
  68939. type MeshLoadOptions = {
  68940. /**
  68941. * Defines if UVs are optimized by default during load.
  68942. */
  68943. OptimizeWithUV: boolean;
  68944. /**
  68945. * Defines custom scaling of UV coordinates of loaded meshes.
  68946. */
  68947. UVScaling: Vector2;
  68948. /**
  68949. * Invert model on y-axis (does a model scaling inversion)
  68950. */
  68951. InvertY: boolean;
  68952. /**
  68953. * Invert Y-Axis of referenced textures on load
  68954. */
  68955. InvertTextureY: boolean;
  68956. /**
  68957. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68958. */
  68959. ImportVertexColors: boolean;
  68960. /**
  68961. * Compute the normals for the model, even if normals are present in the file.
  68962. */
  68963. ComputeNormals: boolean;
  68964. /**
  68965. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68966. */
  68967. SkipMaterials: boolean;
  68968. /**
  68969. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68970. */
  68971. MaterialLoadingFailsSilently: boolean;
  68972. };
  68973. /**
  68974. * OBJ file type loader.
  68975. * This is a babylon scene loader plugin.
  68976. */
  68977. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68978. /**
  68979. * Defines if UVs are optimized by default during load.
  68980. */
  68981. static OPTIMIZE_WITH_UV: boolean;
  68982. /**
  68983. * Invert model on y-axis (does a model scaling inversion)
  68984. */
  68985. static INVERT_Y: boolean;
  68986. /**
  68987. * Invert Y-Axis of referenced textures on load
  68988. */
  68989. static INVERT_TEXTURE_Y: boolean;
  68990. /**
  68991. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68992. */
  68993. static IMPORT_VERTEX_COLORS: boolean;
  68994. /**
  68995. * Compute the normals for the model, even if normals are present in the file.
  68996. */
  68997. static COMPUTE_NORMALS: boolean;
  68998. /**
  68999. * Defines custom scaling of UV coordinates of loaded meshes.
  69000. */
  69001. static UV_SCALING: Vector2;
  69002. /**
  69003. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  69004. */
  69005. static SKIP_MATERIALS: boolean;
  69006. /**
  69007. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  69008. *
  69009. * Defaults to true for backwards compatibility.
  69010. */
  69011. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  69012. /**
  69013. * Defines the name of the plugin.
  69014. */
  69015. name: string;
  69016. /**
  69017. * Defines the extension the plugin is able to load.
  69018. */
  69019. extensions: string;
  69020. /** @hidden */
  69021. obj: RegExp;
  69022. /** @hidden */
  69023. group: RegExp;
  69024. /** @hidden */
  69025. mtllib: RegExp;
  69026. /** @hidden */
  69027. usemtl: RegExp;
  69028. /** @hidden */
  69029. smooth: RegExp;
  69030. /** @hidden */
  69031. vertexPattern: RegExp;
  69032. /** @hidden */
  69033. normalPattern: RegExp;
  69034. /** @hidden */
  69035. uvPattern: RegExp;
  69036. /** @hidden */
  69037. facePattern1: RegExp;
  69038. /** @hidden */
  69039. facePattern2: RegExp;
  69040. /** @hidden */
  69041. facePattern3: RegExp;
  69042. /** @hidden */
  69043. facePattern4: RegExp;
  69044. /** @hidden */
  69045. facePattern5: RegExp;
  69046. private _meshLoadOptions;
  69047. /**
  69048. * Creates loader for .OBJ files
  69049. *
  69050. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  69051. */
  69052. constructor(meshLoadOptions?: MeshLoadOptions);
  69053. private static readonly currentMeshLoadOptions;
  69054. /**
  69055. * Calls synchronously the MTL file attached to this obj.
  69056. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69057. * Without this function materials are not displayed in the first frame (but displayed after).
  69058. * In consequence it is impossible to get material information in your HTML file
  69059. *
  69060. * @param url The URL of the MTL file
  69061. * @param rootUrl
  69062. * @param onSuccess Callback function to be called when the MTL file is loaded
  69063. * @private
  69064. */
  69065. private _loadMTL;
  69066. /**
  69067. * Instantiates a OBJ file loader plugin.
  69068. * @returns the created plugin
  69069. */
  69070. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  69071. /**
  69072. * If the data string can be loaded directly.
  69073. *
  69074. * @param data string containing the file data
  69075. * @returns if the data can be loaded directly
  69076. */
  69077. canDirectLoad(data: string): boolean;
  69078. /**
  69079. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69080. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69081. * @param scene the scene the meshes should be added to
  69082. * @param data the OBJ data to load
  69083. * @param rootUrl root url to load from
  69084. * @param onProgress event that fires when loading progress has occured
  69085. * @param fileName Defines the name of the file to load
  69086. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69087. */
  69088. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69089. meshes: AbstractMesh[];
  69090. particleSystems: IParticleSystem[];
  69091. skeletons: Skeleton[];
  69092. animationGroups: AnimationGroup[];
  69093. }>;
  69094. /**
  69095. * Imports all objects from the loaded OBJ data and adds them to the scene
  69096. * @param scene the scene the objects should be added to
  69097. * @param data the OBJ data to load
  69098. * @param rootUrl root url to load from
  69099. * @param onProgress event that fires when loading progress has occured
  69100. * @param fileName Defines the name of the file to load
  69101. * @returns a promise which completes when objects have been loaded to the scene
  69102. */
  69103. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69104. /**
  69105. * Load into an asset container.
  69106. * @param scene The scene to load into
  69107. * @param data The data to import
  69108. * @param rootUrl The root url for scene and resources
  69109. * @param onProgress The callback when the load progresses
  69110. * @param fileName Defines the name of the file to load
  69111. * @returns The loaded asset container
  69112. */
  69113. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69114. /**
  69115. * Read the OBJ file and create an Array of meshes.
  69116. * Each mesh contains all information given by the OBJ and the MTL file.
  69117. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69118. *
  69119. * @param meshesNames
  69120. * @param scene Scene The scene where are displayed the data
  69121. * @param data String The content of the obj file
  69122. * @param rootUrl String The path to the folder
  69123. * @returns Array<AbstractMesh>
  69124. * @private
  69125. */
  69126. private _parseSolid;
  69127. }
  69128. }
  69129. declare module BABYLON {
  69130. /**
  69131. * STL file type loader.
  69132. * This is a babylon scene loader plugin.
  69133. */
  69134. export class STLFileLoader implements ISceneLoaderPlugin {
  69135. /** @hidden */
  69136. solidPattern: RegExp;
  69137. /** @hidden */
  69138. facetsPattern: RegExp;
  69139. /** @hidden */
  69140. normalPattern: RegExp;
  69141. /** @hidden */
  69142. vertexPattern: RegExp;
  69143. /**
  69144. * Defines the name of the plugin.
  69145. */
  69146. name: string;
  69147. /**
  69148. * Defines the extensions the stl loader is able to load.
  69149. * force data to come in as an ArrayBuffer
  69150. * we'll convert to string if it looks like it's an ASCII .stl
  69151. */
  69152. extensions: ISceneLoaderPluginExtensions;
  69153. /**
  69154. * Import meshes into a scene.
  69155. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69156. * @param scene The scene to import into
  69157. * @param data The data to import
  69158. * @param rootUrl The root url for scene and resources
  69159. * @param meshes The meshes array to import into
  69160. * @param particleSystems The particle systems array to import into
  69161. * @param skeletons The skeletons array to import into
  69162. * @param onError The callback when import fails
  69163. * @returns True if successful or false otherwise
  69164. */
  69165. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69166. /**
  69167. * Load into a scene.
  69168. * @param scene The scene to load into
  69169. * @param data The data to import
  69170. * @param rootUrl The root url for scene and resources
  69171. * @param onError The callback when import fails
  69172. * @returns true if successful or false otherwise
  69173. */
  69174. load(scene: Scene, data: any, rootUrl: string): boolean;
  69175. /**
  69176. * Load into an asset container.
  69177. * @param scene The scene to load into
  69178. * @param data The data to import
  69179. * @param rootUrl The root url for scene and resources
  69180. * @param onError The callback when import fails
  69181. * @returns The loaded asset container
  69182. */
  69183. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69184. private _isBinary;
  69185. private _parseBinary;
  69186. private _parseASCII;
  69187. }
  69188. }
  69189. declare module BABYLON {
  69190. /**
  69191. * Class for generating OBJ data from a Babylon scene.
  69192. */
  69193. export class OBJExport {
  69194. /**
  69195. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69196. * @param mesh defines the list of meshes to serialize
  69197. * @param materials defines if materials should be exported
  69198. * @param matlibname defines the name of the associated mtl file
  69199. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69200. * @returns the OBJ content
  69201. */
  69202. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69203. /**
  69204. * Exports the material(s) of a mesh in .MTL file format (text)
  69205. * @param mesh defines the mesh to extract the material from
  69206. * @returns the mtl content
  69207. */
  69208. static MTL(mesh: Mesh): string;
  69209. }
  69210. }
  69211. declare module BABYLON {
  69212. /** @hidden */
  69213. export var __IGLTFExporterExtension: number;
  69214. /**
  69215. * Interface for extending the exporter
  69216. * @hidden
  69217. */
  69218. export interface IGLTFExporterExtension {
  69219. /**
  69220. * The name of this extension
  69221. */
  69222. readonly name: string;
  69223. /**
  69224. * Defines whether this extension is enabled
  69225. */
  69226. enabled: boolean;
  69227. /**
  69228. * Defines whether this extension is required
  69229. */
  69230. required: boolean;
  69231. }
  69232. }
  69233. declare module BABYLON.GLTF2.Exporter {
  69234. /** @hidden */
  69235. export var __IGLTFExporterExtensionV2: number;
  69236. /**
  69237. * Interface for a glTF exporter extension
  69238. * @hidden
  69239. */
  69240. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69241. /**
  69242. * Define this method to modify the default behavior before exporting a texture
  69243. * @param context The context when loading the asset
  69244. * @param babylonTexture The glTF texture info property
  69245. * @param mimeType The mime-type of the generated image
  69246. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69247. */
  69248. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69249. /**
  69250. * Define this method to modify the default behavior when exporting texture info
  69251. * @param context The context when loading the asset
  69252. * @param meshPrimitive glTF mesh primitive
  69253. * @param babylonSubMesh Babylon submesh
  69254. * @param binaryWriter glTF serializer binary writer instance
  69255. * @returns nullable IMeshPrimitive promise
  69256. */
  69257. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69258. /**
  69259. * Define this method to modify the default behavior when exporting a node
  69260. * @param context The context when exporting the node
  69261. * @param node glTF node
  69262. * @param babylonNode BabylonJS node
  69263. * @returns nullable INode promise
  69264. */
  69265. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69266. /**
  69267. * Called after the exporter state changes to EXPORTING
  69268. */
  69269. onExporting?(): void;
  69270. }
  69271. }
  69272. declare module BABYLON.GLTF2.Exporter {
  69273. /**
  69274. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69275. * @hidden
  69276. */
  69277. export class _GLTFMaterialExporter {
  69278. /**
  69279. * Represents the dielectric specular values for R, G and B
  69280. */
  69281. private static readonly _DielectricSpecular;
  69282. /**
  69283. * Allows the maximum specular power to be defined for material calculations
  69284. */
  69285. private static readonly _MaxSpecularPower;
  69286. /**
  69287. * Mapping to store textures
  69288. */
  69289. private _textureMap;
  69290. /**
  69291. * Numeric tolerance value
  69292. */
  69293. private static readonly _Epsilon;
  69294. /**
  69295. * Reference to the glTF Exporter
  69296. */
  69297. private _exporter;
  69298. constructor(exporter: _Exporter);
  69299. /**
  69300. * Specifies if two colors are approximately equal in value
  69301. * @param color1 first color to compare to
  69302. * @param color2 second color to compare to
  69303. * @param epsilon threshold value
  69304. */
  69305. private static FuzzyEquals;
  69306. /**
  69307. * Gets the materials from a Babylon scene and converts them to glTF materials
  69308. * @param scene babylonjs scene
  69309. * @param mimeType texture mime type
  69310. * @param images array of images
  69311. * @param textures array of textures
  69312. * @param materials array of materials
  69313. * @param imageData mapping of texture names to base64 textures
  69314. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69315. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69316. /**
  69317. * Makes a copy of the glTF material without the texture parameters
  69318. * @param originalMaterial original glTF material
  69319. * @returns glTF material without texture parameters
  69320. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69321. /**
  69322. * Specifies if the material has any texture parameters present
  69323. * @param material glTF Material
  69324. * @returns boolean specifying if texture parameters are present
  69325. */ private _hasTexturesPresent(material: IMaterial): boolean;
  69326. /**
  69327. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69328. * @param babylonStandardMaterial
  69329. * @returns glTF Metallic Roughness Material representation
  69330. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69331. /**
  69332. * Computes the metallic factor
  69333. * @param diffuse diffused value
  69334. * @param specular specular value
  69335. * @param oneMinusSpecularStrength one minus the specular strength
  69336. * @returns metallic value
  69337. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69338. /**
  69339. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69340. * @param glTFMaterial glTF material
  69341. * @param babylonMaterial Babylon material
  69342. */
  69343. private static _SetAlphaMode;
  69344. /**
  69345. * Converts a Babylon Standard Material to a glTF Material
  69346. * @param babylonStandardMaterial BJS Standard Material
  69347. * @param mimeType mime type to use for the textures
  69348. * @param images array of glTF image interfaces
  69349. * @param textures array of glTF texture interfaces
  69350. * @param materials array of glTF material interfaces
  69351. * @param imageData map of image file name to data
  69352. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69353. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69354. /**
  69355. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69356. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69357. * @param mimeType mime type to use for the textures
  69358. * @param images array of glTF image interfaces
  69359. * @param textures array of glTF texture interfaces
  69360. * @param materials array of glTF material interfaces
  69361. * @param imageData map of image file name to data
  69362. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69363. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69364. /**
  69365. * Converts an image typed array buffer to a base64 image
  69366. * @param buffer typed array buffer
  69367. * @param width width of the image
  69368. * @param height height of the image
  69369. * @param mimeType mimetype of the image
  69370. * @returns base64 image string
  69371. */
  69372. private _createBase64FromCanvasAsync;
  69373. /**
  69374. * Generates a white texture based on the specified width and height
  69375. * @param width width of the texture in pixels
  69376. * @param height height of the texture in pixels
  69377. * @param scene babylonjs scene
  69378. * @returns white texture
  69379. */
  69380. private _createWhiteTexture;
  69381. /**
  69382. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  69383. * @param texture1 first texture to resize
  69384. * @param texture2 second texture to resize
  69385. * @param scene babylonjs scene
  69386. * @returns resized textures or null
  69387. */
  69388. private _resizeTexturesToSameDimensions;
  69389. /**
  69390. * Converts an array of pixels to a Float32Array
  69391. * Throws an error if the pixel format is not supported
  69392. * @param pixels - array buffer containing pixel values
  69393. * @returns Float32 of pixels
  69394. */
  69395. private _convertPixelArrayToFloat32;
  69396. /**
  69397. * Convert Specular Glossiness Textures to Metallic Roughness
  69398. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69399. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69400. * @param diffuseTexture texture used to store diffuse information
  69401. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69402. * @param factors specular glossiness material factors
  69403. * @param mimeType the mime type to use for the texture
  69404. * @returns pbr metallic roughness interface or null
  69405. */
  69406. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69407. /**
  69408. * Converts specular glossiness material properties to metallic roughness
  69409. * @param specularGlossiness interface with specular glossiness material properties
  69410. * @returns interface with metallic roughness material properties
  69411. */
  69412. private _convertSpecularGlossinessToMetallicRoughness;
  69413. /**
  69414. * Calculates the surface reflectance, independent of lighting conditions
  69415. * @param color Color source to calculate brightness from
  69416. * @returns number representing the perceived brightness, or zero if color is undefined
  69417. */
  69418. private _getPerceivedBrightness;
  69419. /**
  69420. * Returns the maximum color component value
  69421. * @param color
  69422. * @returns maximum color component value, or zero if color is null or undefined
  69423. */
  69424. private _getMaxComponent;
  69425. /**
  69426. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69427. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69428. * @param mimeType mime type to use for the textures
  69429. * @param images array of glTF image interfaces
  69430. * @param textures array of glTF texture interfaces
  69431. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69432. * @param imageData map of image file name to data
  69433. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69434. * @returns glTF PBR Metallic Roughness factors
  69435. */
  69436. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69437. private _getGLTFTextureSampler;
  69438. private _getGLTFTextureWrapMode;
  69439. private _getGLTFTextureWrapModesSampler;
  69440. /**
  69441. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69442. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69443. * @param mimeType mime type to use for the textures
  69444. * @param images array of glTF image interfaces
  69445. * @param textures array of glTF texture interfaces
  69446. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69447. * @param imageData map of image file name to data
  69448. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69449. * @returns glTF PBR Metallic Roughness factors
  69450. */
  69451. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69452. /**
  69453. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69454. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69455. * @param mimeType mime type to use for the textures
  69456. * @param images array of glTF image interfaces
  69457. * @param textures array of glTF texture interfaces
  69458. * @param materials array of glTF material interfaces
  69459. * @param imageData map of image file name to data
  69460. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69461. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69462. private setMetallicRoughnessPbrMaterial;
  69463. private getPixelsFromTexture;
  69464. /**
  69465. * Extracts a texture from a Babylon texture into file data and glTF data
  69466. * @param babylonTexture Babylon texture to extract
  69467. * @param mimeType Mime Type of the babylonTexture
  69468. * @return glTF texture info, or null if the texture format is not supported
  69469. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69470. /**
  69471. * Builds a texture from base64 string
  69472. * @param base64Texture base64 texture string
  69473. * @param baseTextureName Name to use for the texture
  69474. * @param mimeType image mime type for the texture
  69475. * @param images array of images
  69476. * @param textures array of textures
  69477. * @param imageData map of image data
  69478. * @returns glTF texture info, or null if the texture format is not supported
  69479. */
  69480. private _getTextureInfoFromBase64;
  69481. }
  69482. }
  69483. declare module BABYLON {
  69484. /**
  69485. * Class for holding and downloading glTF file data
  69486. */
  69487. export class GLTFData {
  69488. /**
  69489. * Object which contains the file name as the key and its data as the value
  69490. */
  69491. glTFFiles: {
  69492. [fileName: string]: string | Blob;
  69493. };
  69494. /**
  69495. * Initializes the glTF file object
  69496. */
  69497. constructor();
  69498. /**
  69499. * Downloads the glTF data as files based on their names and data
  69500. */
  69501. downloadFiles(): void;
  69502. }
  69503. }
  69504. declare module BABYLON {
  69505. /**
  69506. * Holds a collection of exporter options and parameters
  69507. */
  69508. export interface IExportOptions {
  69509. /**
  69510. * Function which indicates whether a babylon node should be exported or not
  69511. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69512. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69513. */
  69514. shouldExportNode?(node: Node): boolean;
  69515. /**
  69516. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69517. * @param metadata source metadata to read from
  69518. * @returns the data to store to glTF node extras
  69519. */
  69520. metadataSelector?(metadata: any): any;
  69521. /**
  69522. * The sample rate to bake animation curves
  69523. */
  69524. animationSampleRate?: number;
  69525. /**
  69526. * Begin serialization without waiting for the scene to be ready
  69527. */
  69528. exportWithoutWaitingForScene?: boolean;
  69529. }
  69530. /**
  69531. * Class for generating glTF data from a Babylon scene.
  69532. */
  69533. export class GLTF2Export {
  69534. /**
  69535. * Exports the geometry of the scene to .gltf file format asynchronously
  69536. * @param scene Babylon scene with scene hierarchy information
  69537. * @param filePrefix File prefix to use when generating the glTF file
  69538. * @param options Exporter options
  69539. * @returns Returns an object with a .gltf file and associates texture names
  69540. * as keys and their data and paths as values
  69541. */
  69542. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69543. private static _PreExportAsync;
  69544. private static _PostExportAsync;
  69545. /**
  69546. * Exports the geometry of the scene to .glb file format asychronously
  69547. * @param scene Babylon scene with scene hierarchy information
  69548. * @param filePrefix File prefix to use when generating glb file
  69549. * @param options Exporter options
  69550. * @returns Returns an object with a .glb filename as key and data as value
  69551. */
  69552. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69553. }
  69554. }
  69555. declare module BABYLON.GLTF2.Exporter {
  69556. /**
  69557. * @hidden
  69558. */
  69559. export class _GLTFUtilities {
  69560. /**
  69561. * Creates a buffer view based on the supplied arguments
  69562. * @param bufferIndex index value of the specified buffer
  69563. * @param byteOffset byte offset value
  69564. * @param byteLength byte length of the bufferView
  69565. * @param byteStride byte distance between conequential elements
  69566. * @param name name of the buffer view
  69567. * @returns bufferView for glTF
  69568. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69569. /**
  69570. * Creates an accessor based on the supplied arguments
  69571. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69572. * @param name The name of the accessor
  69573. * @param type The type of the accessor
  69574. * @param componentType The datatype of components in the attribute
  69575. * @param count The number of attributes referenced by this accessor
  69576. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69577. * @param min Minimum value of each component in this attribute
  69578. * @param max Maximum value of each component in this attribute
  69579. * @returns accessor for glTF
  69580. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69581. /**
  69582. * Calculates the minimum and maximum values of an array of position floats
  69583. * @param positions Positions array of a mesh
  69584. * @param vertexStart Starting vertex offset to calculate min and max values
  69585. * @param vertexCount Number of vertices to check for min and max values
  69586. * @returns min number array and max number array
  69587. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69588. min: number[];
  69589. max: number[];
  69590. };
  69591. /**
  69592. * Converts a new right-handed Vector3
  69593. * @param vector vector3 array
  69594. * @returns right-handed Vector3
  69595. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69596. /**
  69597. * Converts a Vector3 to right-handed
  69598. * @param vector Vector3 to convert to right-handed
  69599. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69600. /**
  69601. * Converts a three element number array to right-handed
  69602. * @param vector number array to convert to right-handed
  69603. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69604. /**
  69605. * Converts a new right-handed Vector3
  69606. * @param vector vector3 array
  69607. * @returns right-handed Vector3
  69608. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69609. /**
  69610. * Converts a Vector3 to right-handed
  69611. * @param vector Vector3 to convert to right-handed
  69612. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69613. /**
  69614. * Converts a three element number array to right-handed
  69615. * @param vector number array to convert to right-handed
  69616. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69617. /**
  69618. * Converts a Vector4 to right-handed
  69619. * @param vector Vector4 to convert to right-handed
  69620. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69621. /**
  69622. * Converts a Vector4 to right-handed
  69623. * @param vector Vector4 to convert to right-handed
  69624. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  69625. /**
  69626. * Converts a Quaternion to right-handed
  69627. * @param quaternion Source quaternion to convert to right-handed
  69628. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69629. /**
  69630. * Converts a Quaternion to right-handed
  69631. * @param quaternion Source quaternion to convert to right-handed
  69632. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  69633. }
  69634. }
  69635. declare module BABYLON.GLTF2.Exporter {
  69636. /**
  69637. * Converts Babylon Scene into glTF 2.0.
  69638. * @hidden
  69639. */
  69640. export class _Exporter {
  69641. /**
  69642. * Stores the glTF to export
  69643. */ private _glTF: IGLTF;
  69644. /**
  69645. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69646. */ private _bufferViews: IBufferView[];
  69647. /**
  69648. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69649. */ private _accessors: IAccessor[];
  69650. /**
  69651. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69652. */
  69653. private _nodes;
  69654. /**
  69655. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69656. */
  69657. private _scenes;
  69658. /**
  69659. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69660. */
  69661. private _meshes;
  69662. /**
  69663. * Stores all the generated material information, which represents the appearance of each primitive
  69664. */ private _materials: IMaterial[]; private _materialMap: {
  69665. [materialID: number]: number;
  69666. };
  69667. /**
  69668. * Stores all the generated texture information, which is referenced by glTF materials
  69669. */ private _textures: ITexture[];
  69670. /**
  69671. * Stores all the generated image information, which is referenced by glTF textures
  69672. */ private _images: IImage[];
  69673. /**
  69674. * Stores all the texture samplers
  69675. */ private _samplers: ISampler[];
  69676. /**
  69677. * Stores all the generated animation samplers, which is referenced by glTF animations
  69678. */
  69679. /**
  69680. * Stores the animations for glTF models
  69681. */
  69682. private _animations;
  69683. /**
  69684. * Stores the total amount of bytes stored in the glTF buffer
  69685. */
  69686. private _totalByteLength;
  69687. /**
  69688. * Stores a reference to the Babylon scene containing the source geometry and material information
  69689. */ private _babylonScene: Scene;
  69690. /**
  69691. * Stores a map of the image data, where the key is the file name and the value
  69692. * is the image data
  69693. */ private _imageData: {
  69694. [fileName: string]: {
  69695. data: Uint8Array;
  69696. mimeType: ImageMimeType;
  69697. };
  69698. };
  69699. /**
  69700. * Stores a map of the unique id of a node to its index in the node array
  69701. */
  69702. private _nodeMap;
  69703. /**
  69704. * Specifies if the Babylon scene should be converted to right-handed on export
  69705. */ private _convertToRightHandedSystem: boolean;
  69706. /**
  69707. * Baked animation sample rate
  69708. */
  69709. private _animationSampleRate;
  69710. private _options;
  69711. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  69712. private _extensions;
  69713. private static _ExtensionNames;
  69714. private static _ExtensionFactories;
  69715. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69716. private _forEachExtensions;
  69717. private _extensionsOnExporting;
  69718. /**
  69719. * Load glTF serializer extensions
  69720. */
  69721. private _loadExtensions;
  69722. /**
  69723. * Creates a glTF Exporter instance, which can accept optional exporter options
  69724. * @param babylonScene Babylon scene object
  69725. * @param options Options to modify the behavior of the exporter
  69726. */
  69727. constructor(babylonScene: Scene, options?: IExportOptions);
  69728. /**
  69729. * Registers a glTF exporter extension
  69730. * @param name Name of the extension to export
  69731. * @param factory The factory function that creates the exporter extension
  69732. */
  69733. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69734. /**
  69735. * Un-registers an exporter extension
  69736. * @param name The name fo the exporter extension
  69737. * @returns A boolean indicating whether the extension has been un-registered
  69738. */
  69739. static UnregisterExtension(name: string): boolean;
  69740. /**
  69741. * Lazy load a local engine with premultiplied alpha set to false
  69742. */ private _getLocalEngine(): Engine;
  69743. private reorderIndicesBasedOnPrimitiveMode;
  69744. /**
  69745. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69746. * clock-wise during export to glTF
  69747. * @param submesh BabylonJS submesh
  69748. * @param primitiveMode Primitive mode of the mesh
  69749. * @param sideOrientation the winding order of the submesh
  69750. * @param vertexBufferKind The type of vertex attribute
  69751. * @param meshAttributeArray The vertex attribute data
  69752. * @param byteOffset The offset to the binary data
  69753. * @param binaryWriter The binary data for the glTF file
  69754. */
  69755. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69756. /**
  69757. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69758. * clock-wise during export to glTF
  69759. * @param submesh BabylonJS submesh
  69760. * @param primitiveMode Primitive mode of the mesh
  69761. * @param sideOrientation the winding order of the submesh
  69762. * @param vertexBufferKind The type of vertex attribute
  69763. * @param meshAttributeArray The vertex attribute data
  69764. * @param byteOffset The offset to the binary data
  69765. * @param binaryWriter The binary data for the glTF file
  69766. */
  69767. private reorderTriangleFillMode;
  69768. /**
  69769. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69770. * clock-wise during export to glTF
  69771. * @param submesh BabylonJS submesh
  69772. * @param primitiveMode Primitive mode of the mesh
  69773. * @param sideOrientation the winding order of the submesh
  69774. * @param vertexBufferKind The type of vertex attribute
  69775. * @param meshAttributeArray The vertex attribute data
  69776. * @param byteOffset The offset to the binary data
  69777. * @param binaryWriter The binary data for the glTF file
  69778. */
  69779. private reorderTriangleStripDrawMode;
  69780. /**
  69781. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69782. * clock-wise during export to glTF
  69783. * @param submesh BabylonJS submesh
  69784. * @param primitiveMode Primitive mode of the mesh
  69785. * @param sideOrientation the winding order of the submesh
  69786. * @param vertexBufferKind The type of vertex attribute
  69787. * @param meshAttributeArray The vertex attribute data
  69788. * @param byteOffset The offset to the binary data
  69789. * @param binaryWriter The binary data for the glTF file
  69790. */
  69791. private reorderTriangleFanMode;
  69792. /**
  69793. * Writes the vertex attribute data to binary
  69794. * @param vertices The vertices to write to the binary writer
  69795. * @param byteOffset The offset into the binary writer to overwrite binary data
  69796. * @param vertexAttributeKind The vertex attribute type
  69797. * @param meshAttributeArray The vertex attribute data
  69798. * @param binaryWriter The writer containing the binary data
  69799. */
  69800. private writeVertexAttributeData;
  69801. /**
  69802. * Writes mesh attribute data to a data buffer
  69803. * Returns the bytelength of the data
  69804. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69805. * @param meshAttributeArray Array containing the attribute data
  69806. * @param binaryWriter The buffer to write the binary data to
  69807. * @param indices Used to specify the order of the vertex data
  69808. */
  69809. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69810. /**
  69811. * Generates glTF json data
  69812. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69813. * @param glTFPrefix Text to use when prefixing a glTF file
  69814. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69815. * @returns json data as string
  69816. */
  69817. private generateJSON;
  69818. /**
  69819. * Generates data for .gltf and .bin files based on the glTF prefix string
  69820. * @param glTFPrefix Text to use when prefixing a glTF file
  69821. * @returns GLTFData with glTF file data
  69822. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69823. /**
  69824. * Creates a binary buffer for glTF
  69825. * @returns array buffer for binary data
  69826. */
  69827. private _generateBinaryAsync;
  69828. /**
  69829. * Pads the number to a multiple of 4
  69830. * @param num number to pad
  69831. * @returns padded number
  69832. */
  69833. private _getPadding;
  69834. /**
  69835. * Generates a glb file from the json and binary data
  69836. * Returns an object with the glb file name as the key and data as the value
  69837. * @param glTFPrefix
  69838. * @returns object with glb filename as key and data as value
  69839. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69840. /**
  69841. * Sets the TRS for each node
  69842. * @param node glTF Node for storing the transformation data
  69843. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69844. */
  69845. private setNodeTransformation;
  69846. private getVertexBufferFromMesh;
  69847. /**
  69848. * Creates a bufferview based on the vertices type for the Babylon mesh
  69849. * @param kind Indicates the type of vertices data
  69850. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69851. * @param binaryWriter The buffer to write the bufferview data to
  69852. */
  69853. private createBufferViewKind;
  69854. /**
  69855. * The primitive mode of the Babylon mesh
  69856. * @param babylonMesh The BabylonJS mesh
  69857. */
  69858. private getMeshPrimitiveMode;
  69859. /**
  69860. * Sets the primitive mode of the glTF mesh primitive
  69861. * @param meshPrimitive glTF mesh primitive
  69862. * @param primitiveMode The primitive mode
  69863. */
  69864. private setPrimitiveMode;
  69865. /**
  69866. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69867. * @param meshPrimitive glTF mesh primitive
  69868. * @param attributeKind vertex attribute
  69869. * @returns boolean specifying if uv coordinates are present
  69870. */
  69871. private setAttributeKind;
  69872. /**
  69873. * Sets data for the primitive attributes of each submesh
  69874. * @param mesh glTF Mesh object to store the primitive attribute information
  69875. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69876. * @param binaryWriter Buffer to write the attribute data to
  69877. */
  69878. private setPrimitiveAttributesAsync;
  69879. /**
  69880. * Creates a glTF scene based on the array of meshes
  69881. * Returns the the total byte offset
  69882. * @param babylonScene Babylon scene to get the mesh data from
  69883. * @param binaryWriter Buffer to write binary data to
  69884. */
  69885. private createSceneAsync;
  69886. /**
  69887. * Creates a mapping of Node unique id to node index and handles animations
  69888. * @param babylonScene Babylon Scene
  69889. * @param nodes Babylon transform nodes
  69890. * @param binaryWriter Buffer to write binary data to
  69891. * @returns Node mapping of unique id to index
  69892. */
  69893. private createNodeMapAndAnimationsAsync;
  69894. /**
  69895. * Creates a glTF node from a Babylon mesh
  69896. * @param babylonMesh Source Babylon mesh
  69897. * @param binaryWriter Buffer for storing geometry data
  69898. * @returns glTF node
  69899. */
  69900. private createNodeAsync;
  69901. }
  69902. /**
  69903. * @hidden
  69904. *
  69905. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69906. */
  69907. export class _BinaryWriter {
  69908. /**
  69909. * Array buffer which stores all binary data
  69910. */
  69911. private _arrayBuffer;
  69912. /**
  69913. * View of the array buffer
  69914. */
  69915. private _dataView;
  69916. /**
  69917. * byte offset of data in array buffer
  69918. */
  69919. private _byteOffset;
  69920. /**
  69921. * Initialize binary writer with an initial byte length
  69922. * @param byteLength Initial byte length of the array buffer
  69923. */
  69924. constructor(byteLength: number);
  69925. /**
  69926. * Resize the array buffer to the specified byte length
  69927. * @param byteLength
  69928. */
  69929. private resizeBuffer;
  69930. /**
  69931. * Get an array buffer with the length of the byte offset
  69932. * @returns ArrayBuffer resized to the byte offset
  69933. */
  69934. getArrayBuffer(): ArrayBuffer;
  69935. /**
  69936. * Get the byte offset of the array buffer
  69937. * @returns byte offset
  69938. */
  69939. getByteOffset(): number;
  69940. /**
  69941. * Stores an UInt8 in the array buffer
  69942. * @param entry
  69943. * @param byteOffset If defined, specifies where to set the value as an offset.
  69944. */
  69945. setUInt8(entry: number, byteOffset?: number): void;
  69946. /**
  69947. * Gets an UInt32 in the array buffer
  69948. * @param entry
  69949. * @param byteOffset If defined, specifies where to set the value as an offset.
  69950. */
  69951. getUInt32(byteOffset: number): number;
  69952. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69953. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69954. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69955. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69956. /**
  69957. * Stores a Float32 in the array buffer
  69958. * @param entry
  69959. */
  69960. setFloat32(entry: number, byteOffset?: number): void;
  69961. /**
  69962. * Stores an UInt32 in the array buffer
  69963. * @param entry
  69964. * @param byteOffset If defined, specifies where to set the value as an offset.
  69965. */
  69966. setUInt32(entry: number, byteOffset?: number): void;
  69967. }
  69968. }
  69969. declare module BABYLON.GLTF2.Exporter {
  69970. /**
  69971. * @hidden
  69972. * Interface to store animation data.
  69973. */
  69974. export interface _IAnimationData {
  69975. /**
  69976. * Keyframe data.
  69977. */
  69978. inputs: number[];
  69979. /**
  69980. * Value data.
  69981. */
  69982. outputs: number[][];
  69983. /**
  69984. * Animation interpolation data.
  69985. */
  69986. samplerInterpolation: AnimationSamplerInterpolation;
  69987. /**
  69988. * Minimum keyframe value.
  69989. */
  69990. inputsMin: number;
  69991. /**
  69992. * Maximum keyframe value.
  69993. */
  69994. inputsMax: number;
  69995. }
  69996. /**
  69997. * @hidden
  69998. */
  69999. export interface _IAnimationInfo {
  70000. /**
  70001. * The target channel for the animation
  70002. */
  70003. animationChannelTargetPath: AnimationChannelTargetPath;
  70004. /**
  70005. * The glTF accessor type for the data.
  70006. */
  70007. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  70008. /**
  70009. * Specifies if quaternions should be used.
  70010. */
  70011. useQuaternion: boolean;
  70012. }
  70013. /**
  70014. * @hidden
  70015. * Utility class for generating glTF animation data from BabylonJS.
  70016. */
  70017. export class _GLTFAnimation {
  70018. /**
  70019. * @ignore
  70020. *
  70021. * Creates glTF channel animation from BabylonJS animation.
  70022. * @param babylonTransformNode - BabylonJS mesh.
  70023. * @param animation - animation.
  70024. * @param animationChannelTargetPath - The target animation channel.
  70025. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  70026. * @param useQuaternion - Specifies if quaternions are used.
  70027. * @returns nullable IAnimationData
  70028. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  70029. private static _DeduceAnimationInfo;
  70030. /**
  70031. * @ignore
  70032. * Create node animations from the transform node animations
  70033. * @param babylonNode
  70034. * @param runtimeGLTFAnimation
  70035. * @param idleGLTFAnimations
  70036. * @param nodeMap
  70037. * @param nodes
  70038. * @param binaryWriter
  70039. * @param bufferViews
  70040. * @param accessors
  70041. * @param convertToRightHandedSystem
  70042. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70043. [key: number]: number;
  70044. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70045. /**
  70046. * @ignore
  70047. * Create node animations from the animation groups
  70048. * @param babylonScene
  70049. * @param glTFAnimations
  70050. * @param nodeMap
  70051. * @param nodes
  70052. * @param binaryWriter
  70053. * @param bufferViews
  70054. * @param accessors
  70055. * @param convertToRightHandedSystem
  70056. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70057. [key: number]: number;
  70058. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70059. private static AddAnimation;
  70060. /**
  70061. * Create a baked animation
  70062. * @param babylonTransformNode BabylonJS mesh
  70063. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70064. * @param animationChannelTargetPath animation target channel
  70065. * @param minFrame minimum animation frame
  70066. * @param maxFrame maximum animation frame
  70067. * @param fps frames per second of the animation
  70068. * @param inputs input key frames of the animation
  70069. * @param outputs output key frame data of the animation
  70070. * @param convertToRightHandedSystem converts the values to right-handed
  70071. * @param useQuaternion specifies if quaternions should be used
  70072. */
  70073. private static _CreateBakedAnimation;
  70074. private static _ConvertFactorToVector3OrQuaternion;
  70075. private static _SetInterpolatedValue;
  70076. /**
  70077. * Creates linear animation from the animation key frames
  70078. * @param babylonTransformNode BabylonJS mesh
  70079. * @param animation BabylonJS animation
  70080. * @param animationChannelTargetPath The target animation channel
  70081. * @param frameDelta The difference between the last and first frame of the animation
  70082. * @param inputs Array to store the key frame times
  70083. * @param outputs Array to store the key frame data
  70084. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70085. * @param useQuaternion Specifies if quaternions are used in the animation
  70086. */
  70087. private static _CreateLinearOrStepAnimation;
  70088. /**
  70089. * Creates cubic spline animation from the animation key frames
  70090. * @param babylonTransformNode BabylonJS mesh
  70091. * @param animation BabylonJS animation
  70092. * @param animationChannelTargetPath The target animation channel
  70093. * @param frameDelta The difference between the last and first frame of the animation
  70094. * @param inputs Array to store the key frame times
  70095. * @param outputs Array to store the key frame data
  70096. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70097. * @param useQuaternion Specifies if quaternions are used in the animation
  70098. */
  70099. private static _CreateCubicSplineAnimation;
  70100. private static _GetBasePositionRotationOrScale;
  70101. /**
  70102. * Adds a key frame value
  70103. * @param keyFrame
  70104. * @param animation
  70105. * @param outputs
  70106. * @param animationChannelTargetPath
  70107. * @param basePositionRotationOrScale
  70108. * @param convertToRightHandedSystem
  70109. * @param useQuaternion
  70110. */
  70111. private static _AddKeyframeValue;
  70112. /**
  70113. * Determine the interpolation based on the key frames
  70114. * @param keyFrames
  70115. * @param animationChannelTargetPath
  70116. * @param useQuaternion
  70117. */
  70118. private static _DeduceInterpolation;
  70119. /**
  70120. * Adds an input tangent or output tangent to the output data
  70121. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70122. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70123. * @param outputs The animation data by keyframe
  70124. * @param animationChannelTargetPath The target animation channel
  70125. * @param interpolation The interpolation type
  70126. * @param keyFrame The key frame with the animation data
  70127. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70128. * @param useQuaternion Specifies if quaternions are used
  70129. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70130. */
  70131. private static AddSplineTangent;
  70132. /**
  70133. * Get the minimum and maximum key frames' frame values
  70134. * @param keyFrames animation key frames
  70135. * @returns the minimum and maximum key frame value
  70136. */
  70137. private static calculateMinMaxKeyFrames;
  70138. }
  70139. }
  70140. declare module BABYLON.GLTF2.Exporter {
  70141. /** @hidden */
  70142. export var textureTransformPixelShader: {
  70143. name: string;
  70144. shader: string;
  70145. };
  70146. }
  70147. declare module BABYLON.GLTF2.Exporter.Extensions {
  70148. /**
  70149. * @hidden
  70150. */
  70151. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70152. /** Name of this extension */
  70153. readonly name: string;
  70154. /** Defines whether this extension is enabled */
  70155. enabled: boolean;
  70156. /** Defines whether this extension is required */
  70157. required: boolean;
  70158. /** Reference to the glTF exporter */
  70159. private _exporter;
  70160. constructor(exporter: _Exporter);
  70161. dispose(): void;
  70162. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70163. /**
  70164. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70165. * @param babylonTexture
  70166. * @param offset
  70167. * @param rotation
  70168. * @param scale
  70169. * @param scene
  70170. */
  70171. private _textureTransformTextureAsync;
  70172. }
  70173. }
  70174. declare module BABYLON.GLTF2.Exporter.Extensions {
  70175. /**
  70176. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70177. */
  70178. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70179. /** The name of this extension. */
  70180. readonly name: string;
  70181. /** Defines whether this extension is enabled. */
  70182. enabled: boolean;
  70183. /** Defines whether this extension is required */
  70184. required: boolean;
  70185. /** Reference to the glTF exporter */
  70186. private _exporter;
  70187. private _lights;
  70188. /** @hidden */
  70189. constructor(exporter: _Exporter);
  70190. /** @hidden */
  70191. dispose(): void;
  70192. /** @hidden */
  70193. onExporting(): void;
  70194. /**
  70195. * Define this method to modify the default behavior when exporting a node
  70196. * @param context The context when exporting the node
  70197. * @param node glTF node
  70198. * @param babylonNode BabylonJS node
  70199. * @returns nullable INode promise
  70200. */
  70201. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70202. }
  70203. }
  70204. declare module BABYLON {
  70205. /**
  70206. * Class for generating STL data from a Babylon scene.
  70207. */
  70208. export class STLExport {
  70209. /**
  70210. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70211. * @param meshes list defines the mesh to serialize
  70212. * @param download triggers the automatic download of the file.
  70213. * @param fileName changes the downloads fileName.
  70214. * @param binary changes the STL to a binary type.
  70215. * @param isLittleEndian toggle for binary type exporter.
  70216. * @returns the STL as UTF8 string
  70217. */
  70218. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70219. }
  70220. }
  70221. /**
  70222. * @ignoreChildren
  70223. * @ignore
  70224. */
  70225. declare module "babylonjs-gltf2interface" {
  70226. export = BABYLON.GLTF2;
  70227. }
  70228. /**
  70229. * Module for glTF 2.0 Interface
  70230. * @ignoreChildren
  70231. * @ignore
  70232. */
  70233. declare module BABYLON.GLTF2 {
  70234. /**
  70235. * The datatype of the components in the attribute
  70236. */
  70237. const enum AccessorComponentType {
  70238. /**
  70239. * Byte
  70240. */
  70241. BYTE = 5120,
  70242. /**
  70243. * Unsigned Byte
  70244. */
  70245. UNSIGNED_BYTE = 5121,
  70246. /**
  70247. * Short
  70248. */
  70249. SHORT = 5122,
  70250. /**
  70251. * Unsigned Short
  70252. */
  70253. UNSIGNED_SHORT = 5123,
  70254. /**
  70255. * Unsigned Int
  70256. */
  70257. UNSIGNED_INT = 5125,
  70258. /**
  70259. * Float
  70260. */
  70261. FLOAT = 5126,
  70262. }
  70263. /**
  70264. * Specifies if the attirbute is a scalar, vector, or matrix
  70265. */
  70266. const enum AccessorType {
  70267. /**
  70268. * Scalar
  70269. */
  70270. SCALAR = "SCALAR",
  70271. /**
  70272. * Vector2
  70273. */
  70274. VEC2 = "VEC2",
  70275. /**
  70276. * Vector3
  70277. */
  70278. VEC3 = "VEC3",
  70279. /**
  70280. * Vector4
  70281. */
  70282. VEC4 = "VEC4",
  70283. /**
  70284. * Matrix2x2
  70285. */
  70286. MAT2 = "MAT2",
  70287. /**
  70288. * Matrix3x3
  70289. */
  70290. MAT3 = "MAT3",
  70291. /**
  70292. * Matrix4x4
  70293. */
  70294. MAT4 = "MAT4",
  70295. }
  70296. /**
  70297. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70298. */
  70299. const enum AnimationChannelTargetPath {
  70300. /**
  70301. * Translation
  70302. */
  70303. TRANSLATION = "translation",
  70304. /**
  70305. * Rotation
  70306. */
  70307. ROTATION = "rotation",
  70308. /**
  70309. * Scale
  70310. */
  70311. SCALE = "scale",
  70312. /**
  70313. * Weights
  70314. */
  70315. WEIGHTS = "weights",
  70316. }
  70317. /**
  70318. * Interpolation algorithm
  70319. */
  70320. const enum AnimationSamplerInterpolation {
  70321. /**
  70322. * The animated values are linearly interpolated between keyframes
  70323. */
  70324. LINEAR = "LINEAR",
  70325. /**
  70326. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70327. */
  70328. STEP = "STEP",
  70329. /**
  70330. * The animation's interpolation is computed using a cubic spline with specified tangents
  70331. */
  70332. CUBICSPLINE = "CUBICSPLINE",
  70333. }
  70334. /**
  70335. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70336. */
  70337. const enum CameraType {
  70338. /**
  70339. * A perspective camera containing properties to create a perspective projection matrix
  70340. */
  70341. PERSPECTIVE = "perspective",
  70342. /**
  70343. * An orthographic camera containing properties to create an orthographic projection matrix
  70344. */
  70345. ORTHOGRAPHIC = "orthographic",
  70346. }
  70347. /**
  70348. * The mime-type of the image
  70349. */
  70350. const enum ImageMimeType {
  70351. /**
  70352. * JPEG Mime-type
  70353. */
  70354. JPEG = "image/jpeg",
  70355. /**
  70356. * PNG Mime-type
  70357. */
  70358. PNG = "image/png",
  70359. }
  70360. /**
  70361. * The alpha rendering mode of the material
  70362. */
  70363. const enum MaterialAlphaMode {
  70364. /**
  70365. * The alpha value is ignored and the rendered output is fully opaque
  70366. */
  70367. OPAQUE = "OPAQUE",
  70368. /**
  70369. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70370. */
  70371. MASK = "MASK",
  70372. /**
  70373. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  70374. */
  70375. BLEND = "BLEND",
  70376. }
  70377. /**
  70378. * The type of the primitives to render
  70379. */
  70380. const enum MeshPrimitiveMode {
  70381. /**
  70382. * Points
  70383. */
  70384. POINTS = 0,
  70385. /**
  70386. * Lines
  70387. */
  70388. LINES = 1,
  70389. /**
  70390. * Line Loop
  70391. */
  70392. LINE_LOOP = 2,
  70393. /**
  70394. * Line Strip
  70395. */
  70396. LINE_STRIP = 3,
  70397. /**
  70398. * Triangles
  70399. */
  70400. TRIANGLES = 4,
  70401. /**
  70402. * Triangle Strip
  70403. */
  70404. TRIANGLE_STRIP = 5,
  70405. /**
  70406. * Triangle Fan
  70407. */
  70408. TRIANGLE_FAN = 6,
  70409. }
  70410. /**
  70411. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70412. */
  70413. const enum TextureMagFilter {
  70414. /**
  70415. * Nearest
  70416. */
  70417. NEAREST = 9728,
  70418. /**
  70419. * Linear
  70420. */
  70421. LINEAR = 9729,
  70422. }
  70423. /**
  70424. * Minification filter. All valid values correspond to WebGL enums
  70425. */
  70426. const enum TextureMinFilter {
  70427. /**
  70428. * Nearest
  70429. */
  70430. NEAREST = 9728,
  70431. /**
  70432. * Linear
  70433. */
  70434. LINEAR = 9729,
  70435. /**
  70436. * Nearest Mip-Map Nearest
  70437. */
  70438. NEAREST_MIPMAP_NEAREST = 9984,
  70439. /**
  70440. * Linear Mipmap Nearest
  70441. */
  70442. LINEAR_MIPMAP_NEAREST = 9985,
  70443. /**
  70444. * Nearest Mipmap Linear
  70445. */
  70446. NEAREST_MIPMAP_LINEAR = 9986,
  70447. /**
  70448. * Linear Mipmap Linear
  70449. */
  70450. LINEAR_MIPMAP_LINEAR = 9987,
  70451. }
  70452. /**
  70453. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70454. */
  70455. const enum TextureWrapMode {
  70456. /**
  70457. * Clamp to Edge
  70458. */
  70459. CLAMP_TO_EDGE = 33071,
  70460. /**
  70461. * Mirrored Repeat
  70462. */
  70463. MIRRORED_REPEAT = 33648,
  70464. /**
  70465. * Repeat
  70466. */
  70467. REPEAT = 10497,
  70468. }
  70469. /**
  70470. * glTF Property
  70471. */
  70472. interface IProperty {
  70473. /**
  70474. * Dictionary object with extension-specific objects
  70475. */
  70476. extensions?: {
  70477. [key: string]: any;
  70478. };
  70479. /**
  70480. * Application-Specific data
  70481. */
  70482. extras?: any;
  70483. }
  70484. /**
  70485. * glTF Child of Root Property
  70486. */
  70487. interface IChildRootProperty extends IProperty {
  70488. /**
  70489. * The user-defined name of this object
  70490. */
  70491. name?: string;
  70492. }
  70493. /**
  70494. * Indices of those attributes that deviate from their initialization value
  70495. */
  70496. interface IAccessorSparseIndices extends IProperty {
  70497. /**
  70498. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70499. */
  70500. bufferView: number;
  70501. /**
  70502. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70503. */
  70504. byteOffset?: number;
  70505. /**
  70506. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70507. */
  70508. componentType: AccessorComponentType;
  70509. }
  70510. /**
  70511. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70512. */
  70513. interface IAccessorSparseValues extends IProperty {
  70514. /**
  70515. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70516. */
  70517. bufferView: number;
  70518. /**
  70519. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70520. */
  70521. byteOffset?: number;
  70522. }
  70523. /**
  70524. * Sparse storage of attributes that deviate from their initialization value
  70525. */
  70526. interface IAccessorSparse extends IProperty {
  70527. /**
  70528. * The number of attributes encoded in this sparse accessor
  70529. */
  70530. count: number;
  70531. /**
  70532. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70533. */
  70534. indices: IAccessorSparseIndices;
  70535. /**
  70536. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  70537. */
  70538. values: IAccessorSparseValues;
  70539. }
  70540. /**
  70541. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  70542. */
  70543. interface IAccessor extends IChildRootProperty {
  70544. /**
  70545. * The index of the bufferview
  70546. */
  70547. bufferView?: number;
  70548. /**
  70549. * The offset relative to the start of the bufferView in bytes
  70550. */
  70551. byteOffset?: number;
  70552. /**
  70553. * The datatype of components in the attribute
  70554. */
  70555. componentType: AccessorComponentType;
  70556. /**
  70557. * Specifies whether integer data values should be normalized
  70558. */
  70559. normalized?: boolean;
  70560. /**
  70561. * The number of attributes referenced by this accessor
  70562. */
  70563. count: number;
  70564. /**
  70565. * Specifies if the attribute is a scalar, vector, or matrix
  70566. */
  70567. type: AccessorType;
  70568. /**
  70569. * Maximum value of each component in this attribute
  70570. */
  70571. max?: number[];
  70572. /**
  70573. * Minimum value of each component in this attribute
  70574. */
  70575. min?: number[];
  70576. /**
  70577. * Sparse storage of attributes that deviate from their initialization value
  70578. */
  70579. sparse?: IAccessorSparse;
  70580. }
  70581. /**
  70582. * Targets an animation's sampler at a node's property
  70583. */
  70584. interface IAnimationChannel extends IProperty {
  70585. /**
  70586. * The index of a sampler in this animation used to compute the value for the target
  70587. */
  70588. sampler: number;
  70589. /**
  70590. * The index of the node and TRS property to target
  70591. */
  70592. target: IAnimationChannelTarget;
  70593. }
  70594. /**
  70595. * The index of the node and TRS property that an animation channel targets
  70596. */
  70597. interface IAnimationChannelTarget extends IProperty {
  70598. /**
  70599. * The index of the node to target
  70600. */
  70601. node: number;
  70602. /**
  70603. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70604. */
  70605. path: AnimationChannelTargetPath;
  70606. }
  70607. /**
  70608. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70609. */
  70610. interface IAnimationSampler extends IProperty {
  70611. /**
  70612. * The index of an accessor containing keyframe input values, e.g., time
  70613. */
  70614. input: number;
  70615. /**
  70616. * Interpolation algorithm
  70617. */
  70618. interpolation?: AnimationSamplerInterpolation;
  70619. /**
  70620. * The index of an accessor, containing keyframe output values
  70621. */
  70622. output: number;
  70623. }
  70624. /**
  70625. * A keyframe animation
  70626. */
  70627. interface IAnimation extends IChildRootProperty {
  70628. /**
  70629. * An array of channels, each of which targets an animation's sampler at a node's property
  70630. */
  70631. channels: IAnimationChannel[];
  70632. /**
  70633. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70634. */
  70635. samplers: IAnimationSampler[];
  70636. }
  70637. /**
  70638. * Metadata about the glTF asset
  70639. */
  70640. interface IAsset extends IChildRootProperty {
  70641. /**
  70642. * A copyright message suitable for display to credit the content creator
  70643. */
  70644. copyright?: string;
  70645. /**
  70646. * Tool that generated this glTF model. Useful for debugging
  70647. */
  70648. generator?: string;
  70649. /**
  70650. * The glTF version that this asset targets
  70651. */
  70652. version: string;
  70653. /**
  70654. * The minimum glTF version that this asset targets
  70655. */
  70656. minVersion?: string;
  70657. }
  70658. /**
  70659. * A buffer points to binary geometry, animation, or skins
  70660. */
  70661. interface IBuffer extends IChildRootProperty {
  70662. /**
  70663. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  70664. */
  70665. uri?: string;
  70666. /**
  70667. * The length of the buffer in bytes
  70668. */
  70669. byteLength: number;
  70670. }
  70671. /**
  70672. * A view into a buffer generally representing a subset of the buffer
  70673. */
  70674. interface IBufferView extends IChildRootProperty {
  70675. /**
  70676. * The index of the buffer
  70677. */
  70678. buffer: number;
  70679. /**
  70680. * The offset into the buffer in bytes
  70681. */
  70682. byteOffset?: number;
  70683. /**
  70684. * The lenth of the bufferView in bytes
  70685. */
  70686. byteLength: number;
  70687. /**
  70688. * The stride, in bytes
  70689. */
  70690. byteStride?: number;
  70691. }
  70692. /**
  70693. * An orthographic camera containing properties to create an orthographic projection matrix
  70694. */
  70695. interface ICameraOrthographic extends IProperty {
  70696. /**
  70697. * The floating-point horizontal magnification of the view. Must not be zero
  70698. */
  70699. xmag: number;
  70700. /**
  70701. * The floating-point vertical magnification of the view. Must not be zero
  70702. */
  70703. ymag: number;
  70704. /**
  70705. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70706. */
  70707. zfar: number;
  70708. /**
  70709. * The floating-point distance to the near clipping plane
  70710. */
  70711. znear: number;
  70712. }
  70713. /**
  70714. * A perspective camera containing properties to create a perspective projection matrix
  70715. */
  70716. interface ICameraPerspective extends IProperty {
  70717. /**
  70718. * The floating-point aspect ratio of the field of view
  70719. */
  70720. aspectRatio?: number;
  70721. /**
  70722. * The floating-point vertical field of view in radians
  70723. */
  70724. yfov: number;
  70725. /**
  70726. * The floating-point distance to the far clipping plane
  70727. */
  70728. zfar?: number;
  70729. /**
  70730. * The floating-point distance to the near clipping plane
  70731. */
  70732. znear: number;
  70733. }
  70734. /**
  70735. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70736. */
  70737. interface ICamera extends IChildRootProperty {
  70738. /**
  70739. * An orthographic camera containing properties to create an orthographic projection matrix
  70740. */
  70741. orthographic?: ICameraOrthographic;
  70742. /**
  70743. * A perspective camera containing properties to create a perspective projection matrix
  70744. */
  70745. perspective?: ICameraPerspective;
  70746. /**
  70747. * Specifies if the camera uses a perspective or orthographic projection
  70748. */
  70749. type: CameraType;
  70750. }
  70751. /**
  70752. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70753. */
  70754. interface IImage extends IChildRootProperty {
  70755. /**
  70756. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  70757. */
  70758. uri?: string;
  70759. /**
  70760. * The image's MIME type
  70761. */
  70762. mimeType?: ImageMimeType;
  70763. /**
  70764. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70765. */
  70766. bufferView?: number;
  70767. }
  70768. /**
  70769. * Material Normal Texture Info
  70770. */
  70771. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70772. /**
  70773. * The scalar multiplier applied to each normal vector of the normal texture
  70774. */
  70775. scale?: number;
  70776. }
  70777. /**
  70778. * Material Occlusion Texture Info
  70779. */
  70780. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70781. /**
  70782. * A scalar multiplier controlling the amount of occlusion applied
  70783. */
  70784. strength?: number;
  70785. }
  70786. /**
  70787. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70788. */
  70789. interface IMaterialPbrMetallicRoughness {
  70790. /**
  70791. * The material's base color factor
  70792. */
  70793. baseColorFactor?: number[];
  70794. /**
  70795. * The base color texture
  70796. */
  70797. baseColorTexture?: ITextureInfo;
  70798. /**
  70799. * The metalness of the material
  70800. */
  70801. metallicFactor?: number;
  70802. /**
  70803. * The roughness of the material
  70804. */
  70805. roughnessFactor?: number;
  70806. /**
  70807. * The metallic-roughness texture
  70808. */
  70809. metallicRoughnessTexture?: ITextureInfo;
  70810. }
  70811. /**
  70812. * The material appearance of a primitive
  70813. */
  70814. interface IMaterial extends IChildRootProperty {
  70815. /**
  70816. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  70817. */
  70818. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70819. /**
  70820. * The normal map texture
  70821. */
  70822. normalTexture?: IMaterialNormalTextureInfo;
  70823. /**
  70824. * The occlusion map texture
  70825. */
  70826. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70827. /**
  70828. * The emissive map texture
  70829. */
  70830. emissiveTexture?: ITextureInfo;
  70831. /**
  70832. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  70833. */
  70834. emissiveFactor?: number[];
  70835. /**
  70836. * The alpha rendering mode of the material
  70837. */
  70838. alphaMode?: MaterialAlphaMode;
  70839. /**
  70840. * The alpha cutoff value of the material
  70841. */
  70842. alphaCutoff?: number;
  70843. /**
  70844. * Specifies whether the material is double sided
  70845. */
  70846. doubleSided?: boolean;
  70847. }
  70848. /**
  70849. * Geometry to be rendered with the given material
  70850. */
  70851. interface IMeshPrimitive extends IProperty {
  70852. /**
  70853. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70854. */
  70855. attributes: {
  70856. [name: string]: number;
  70857. };
  70858. /**
  70859. * The index of the accessor that contains the indices
  70860. */
  70861. indices?: number;
  70862. /**
  70863. * The index of the material to apply to this primitive when rendering
  70864. */
  70865. material?: number;
  70866. /**
  70867. * The type of primitives to render. All valid values correspond to WebGL enums
  70868. */
  70869. mode?: MeshPrimitiveMode;
  70870. /**
  70871. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  70872. */
  70873. targets?: {
  70874. [name: string]: number;
  70875. }[];
  70876. }
  70877. /**
  70878. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70879. */
  70880. interface IMesh extends IChildRootProperty {
  70881. /**
  70882. * An array of primitives, each defining geometry to be rendered with a material
  70883. */
  70884. primitives: IMeshPrimitive[];
  70885. /**
  70886. * Array of weights to be applied to the Morph Targets
  70887. */
  70888. weights?: number[];
  70889. }
  70890. /**
  70891. * A node in the node hierarchy
  70892. */
  70893. interface INode extends IChildRootProperty {
  70894. /**
  70895. * The index of the camera referenced by this node
  70896. */
  70897. camera?: number;
  70898. /**
  70899. * The indices of this node's children
  70900. */
  70901. children?: number[];
  70902. /**
  70903. * The index of the skin referenced by this node
  70904. */
  70905. skin?: number;
  70906. /**
  70907. * A floating-point 4x4 transformation matrix stored in column-major order
  70908. */
  70909. matrix?: number[];
  70910. /**
  70911. * The index of the mesh in this node
  70912. */
  70913. mesh?: number;
  70914. /**
  70915. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70916. */
  70917. rotation?: number[];
  70918. /**
  70919. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70920. */
  70921. scale?: number[];
  70922. /**
  70923. * The node's translation along the x, y, and z axes
  70924. */
  70925. translation?: number[];
  70926. /**
  70927. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70928. */
  70929. weights?: number[];
  70930. }
  70931. /**
  70932. * Texture sampler properties for filtering and wrapping modes
  70933. */
  70934. interface ISampler extends IChildRootProperty {
  70935. /**
  70936. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70937. */
  70938. magFilter?: TextureMagFilter;
  70939. /**
  70940. * Minification filter. All valid values correspond to WebGL enums
  70941. */
  70942. minFilter?: TextureMinFilter;
  70943. /**
  70944. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70945. */
  70946. wrapS?: TextureWrapMode;
  70947. /**
  70948. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70949. */
  70950. wrapT?: TextureWrapMode;
  70951. }
  70952. /**
  70953. * The root nodes of a scene
  70954. */
  70955. interface IScene extends IChildRootProperty {
  70956. /**
  70957. * The indices of each root node
  70958. */
  70959. nodes: number[];
  70960. }
  70961. /**
  70962. * Joints and matrices defining a skin
  70963. */
  70964. interface ISkin extends IChildRootProperty {
  70965. /**
  70966. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  70967. */
  70968. inverseBindMatrices?: number;
  70969. /**
  70970. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70971. */
  70972. skeleton?: number;
  70973. /**
  70974. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  70975. */
  70976. joints: number[];
  70977. }
  70978. /**
  70979. * A texture and its sampler
  70980. */
  70981. interface ITexture extends IChildRootProperty {
  70982. /**
  70983. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70984. */
  70985. sampler?: number;
  70986. /**
  70987. * The index of the image used by this texture
  70988. */
  70989. source: number;
  70990. }
  70991. /**
  70992. * Reference to a texture
  70993. */
  70994. interface ITextureInfo extends IProperty {
  70995. /**
  70996. * The index of the texture
  70997. */
  70998. index: number;
  70999. /**
  71000. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  71001. */
  71002. texCoord?: number;
  71003. }
  71004. /**
  71005. * The root object for a glTF asset
  71006. */
  71007. interface IGLTF extends IProperty {
  71008. /**
  71009. * An array of accessors. An accessor is a typed view into a bufferView
  71010. */
  71011. accessors?: IAccessor[];
  71012. /**
  71013. * An array of keyframe animations
  71014. */
  71015. animations?: IAnimation[];
  71016. /**
  71017. * Metadata about the glTF asset
  71018. */
  71019. asset: IAsset;
  71020. /**
  71021. * An array of buffers. A buffer points to binary geometry, animation, or skins
  71022. */
  71023. buffers?: IBuffer[];
  71024. /**
  71025. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  71026. */
  71027. bufferViews?: IBufferView[];
  71028. /**
  71029. * An array of cameras
  71030. */
  71031. cameras?: ICamera[];
  71032. /**
  71033. * Names of glTF extensions used somewhere in this asset
  71034. */
  71035. extensionsUsed?: string[];
  71036. /**
  71037. * Names of glTF extensions required to properly load this asset
  71038. */
  71039. extensionsRequired?: string[];
  71040. /**
  71041. * An array of images. An image defines data used to create a texture
  71042. */
  71043. images?: IImage[];
  71044. /**
  71045. * An array of materials. A material defines the appearance of a primitive
  71046. */
  71047. materials?: IMaterial[];
  71048. /**
  71049. * An array of meshes. A mesh is a set of primitives to be rendered
  71050. */
  71051. meshes?: IMesh[];
  71052. /**
  71053. * An array of nodes
  71054. */
  71055. nodes?: INode[];
  71056. /**
  71057. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71058. */
  71059. samplers?: ISampler[];
  71060. /**
  71061. * The index of the default scene
  71062. */
  71063. scene?: number;
  71064. /**
  71065. * An array of scenes
  71066. */
  71067. scenes?: IScene[];
  71068. /**
  71069. * An array of skins. A skin is defined by joints and matrices
  71070. */
  71071. skins?: ISkin[];
  71072. /**
  71073. * An array of textures
  71074. */
  71075. textures?: ITexture[];
  71076. }
  71077. /**
  71078. * The glTF validation results
  71079. */
  71080. interface IGLTFValidationResults {
  71081. info: {
  71082. generator: string;
  71083. hasAnimations: boolean;
  71084. hasDefaultScene: boolean;
  71085. hasMaterials: boolean;
  71086. hasMorphTargets: boolean;
  71087. hasSkins: boolean;
  71088. hasTextures: boolean;
  71089. maxAttributesUsed: number;
  71090. primitivesCount: number
  71091. };
  71092. issues: {
  71093. messages: Array<string>;
  71094. numErrors: number;
  71095. numHints: number;
  71096. numInfos: number;
  71097. numWarnings: number;
  71098. truncated: boolean
  71099. };
  71100. mimeType: string;
  71101. uri: string;
  71102. validatedAt: string;
  71103. validatorVersion: string;
  71104. }
  71105. /**
  71106. * The glTF validation options
  71107. */
  71108. interface IGLTFValidationOptions {
  71109. uri?: string;
  71110. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71111. validateAccessorData?: boolean;
  71112. maxIssues?: number;
  71113. ignoredIssues?: Array<string>;
  71114. severityOverrides?: Object;
  71115. }
  71116. /**
  71117. * The glTF validator object
  71118. */
  71119. interface IGLTFValidator {
  71120. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71121. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71122. }
  71123. }
  71124. declare module BABYLON {
  71125. /** @hidden */
  71126. export var cellPixelShader: {
  71127. name: string;
  71128. shader: string;
  71129. };
  71130. }
  71131. declare module BABYLON {
  71132. /** @hidden */
  71133. export var cellVertexShader: {
  71134. name: string;
  71135. shader: string;
  71136. };
  71137. }
  71138. declare module BABYLON {
  71139. export class CellMaterial extends BABYLON.PushMaterial {
  71140. private _diffuseTexture;
  71141. diffuseTexture: BABYLON.BaseTexture;
  71142. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  71143. computeHighLevel: boolean;
  71144. private _disableLighting;
  71145. disableLighting: boolean;
  71146. private _maxSimultaneousLights;
  71147. maxSimultaneousLights: number;
  71148. private _renderId;
  71149. constructor(name: string, scene: BABYLON.Scene);
  71150. needAlphaBlending(): boolean;
  71151. needAlphaTesting(): boolean;
  71152. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71153. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71154. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71155. getAnimatables(): BABYLON.IAnimatable[];
  71156. getActiveTextures(): BABYLON.BaseTexture[];
  71157. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71158. dispose(forceDisposeEffect?: boolean): void;
  71159. getClassName(): string;
  71160. clone(name: string): CellMaterial;
  71161. serialize(): any;
  71162. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71163. }
  71164. }
  71165. declare module BABYLON {
  71166. export class CustomShaderStructure {
  71167. FragmentStore: string;
  71168. VertexStore: string;
  71169. constructor();
  71170. }
  71171. export class ShaderSpecialParts {
  71172. constructor();
  71173. Fragment_Begin: string;
  71174. Fragment_Definitions: string;
  71175. Fragment_MainBegin: string;
  71176. Fragment_Custom_Diffuse: string;
  71177. Fragment_Before_Lights: string;
  71178. Fragment_Before_Fog: string;
  71179. Fragment_Custom_Alpha: string;
  71180. Fragment_Before_FragColor: string;
  71181. Vertex_Begin: string;
  71182. Vertex_Definitions: string;
  71183. Vertex_MainBegin: string;
  71184. Vertex_Before_PositionUpdated: string;
  71185. Vertex_Before_NormalUpdated: string;
  71186. Vertex_MainEnd: string;
  71187. }
  71188. export class CustomMaterial extends BABYLON.StandardMaterial {
  71189. static ShaderIndexer: number;
  71190. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71191. FragmentShader: string;
  71192. VertexShader: string;
  71193. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71194. ReviewUniform(name: string, arr: string[]): string[];
  71195. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71196. constructor(name: string, scene: BABYLON.Scene);
  71197. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71198. Fragment_Begin(shaderPart: string): CustomMaterial;
  71199. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71200. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71201. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71202. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71203. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71204. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71205. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71206. Vertex_Begin(shaderPart: string): CustomMaterial;
  71207. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71208. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71209. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71210. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71211. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71212. }
  71213. }
  71214. declare module BABYLON {
  71215. export class ShaderAlebdoParts {
  71216. constructor();
  71217. Fragment_Begin: string;
  71218. Fragment_Definitions: string;
  71219. Fragment_MainBegin: string;
  71220. Fragment_Custom_Albedo: string;
  71221. Fragment_Before_Lights: string;
  71222. Fragment_Custom_MetallicRoughness: string;
  71223. Fragment_Custom_MicroSurface: string;
  71224. Fragment_Before_Fog: string;
  71225. Fragment_Custom_Alpha: string;
  71226. Fragment_Before_FragColor: string;
  71227. Vertex_Begin: string;
  71228. Vertex_Definitions: string;
  71229. Vertex_MainBegin: string;
  71230. Vertex_Before_PositionUpdated: string;
  71231. Vertex_Before_NormalUpdated: string;
  71232. Vertex_MainEnd: string;
  71233. }
  71234. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71235. static ShaderIndexer: number;
  71236. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  71237. FragmentShader: string;
  71238. VertexShader: string;
  71239. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71240. ReviewUniform(name: string, arr: string[]): string[];
  71241. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71242. constructor(name: string, scene: BABYLON.Scene);
  71243. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71244. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71245. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71246. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71247. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71248. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71249. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71250. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71251. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71252. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71253. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71254. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71255. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71256. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71257. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71258. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71259. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71260. }
  71261. }
  71262. declare module BABYLON {
  71263. /** @hidden */
  71264. export var firePixelShader: {
  71265. name: string;
  71266. shader: string;
  71267. };
  71268. }
  71269. declare module BABYLON {
  71270. /** @hidden */
  71271. export var fireVertexShader: {
  71272. name: string;
  71273. shader: string;
  71274. };
  71275. }
  71276. declare module BABYLON {
  71277. export class FireMaterial extends BABYLON.PushMaterial {
  71278. private _diffuseTexture;
  71279. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71280. private _distortionTexture;
  71281. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71282. private _opacityTexture;
  71283. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71284. diffuseColor: BABYLON.Color3;
  71285. speed: number;
  71286. private _scaledDiffuse;
  71287. private _renderId;
  71288. private _lastTime;
  71289. constructor(name: string, scene: BABYLON.Scene);
  71290. needAlphaBlending(): boolean;
  71291. needAlphaTesting(): boolean;
  71292. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71293. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71294. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71295. getAnimatables(): BABYLON.IAnimatable[];
  71296. getActiveTextures(): BABYLON.BaseTexture[];
  71297. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71298. getClassName(): string;
  71299. dispose(forceDisposeEffect?: boolean): void;
  71300. clone(name: string): FireMaterial;
  71301. serialize(): any;
  71302. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71303. }
  71304. }
  71305. declare module BABYLON {
  71306. /** @hidden */
  71307. export var furPixelShader: {
  71308. name: string;
  71309. shader: string;
  71310. };
  71311. }
  71312. declare module BABYLON {
  71313. /** @hidden */
  71314. export var furVertexShader: {
  71315. name: string;
  71316. shader: string;
  71317. };
  71318. }
  71319. declare module BABYLON {
  71320. export class FurMaterial extends BABYLON.PushMaterial {
  71321. private _diffuseTexture;
  71322. diffuseTexture: BABYLON.BaseTexture;
  71323. private _heightTexture;
  71324. heightTexture: BABYLON.BaseTexture;
  71325. diffuseColor: BABYLON.Color3;
  71326. furLength: number;
  71327. furAngle: number;
  71328. furColor: BABYLON.Color3;
  71329. furOffset: number;
  71330. furSpacing: number;
  71331. furGravity: BABYLON.Vector3;
  71332. furSpeed: number;
  71333. furDensity: number;
  71334. furOcclusion: number;
  71335. furTexture: BABYLON.DynamicTexture;
  71336. private _disableLighting;
  71337. disableLighting: boolean;
  71338. private _maxSimultaneousLights;
  71339. maxSimultaneousLights: number;
  71340. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  71341. private _renderId;
  71342. private _furTime;
  71343. constructor(name: string, scene: BABYLON.Scene);
  71344. furTime: number;
  71345. needAlphaBlending(): boolean;
  71346. needAlphaTesting(): boolean;
  71347. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71348. updateFur(): void;
  71349. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71350. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71351. getAnimatables(): BABYLON.IAnimatable[];
  71352. getActiveTextures(): BABYLON.BaseTexture[];
  71353. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71354. dispose(forceDisposeEffect?: boolean): void;
  71355. clone(name: string): FurMaterial;
  71356. serialize(): any;
  71357. getClassName(): string;
  71358. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71359. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71360. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71361. }
  71362. }
  71363. declare module BABYLON {
  71364. /** @hidden */
  71365. export var gradientPixelShader: {
  71366. name: string;
  71367. shader: string;
  71368. };
  71369. }
  71370. declare module BABYLON {
  71371. /** @hidden */
  71372. export var gradientVertexShader: {
  71373. name: string;
  71374. shader: string;
  71375. };
  71376. }
  71377. declare module BABYLON {
  71378. export class GradientMaterial extends BABYLON.PushMaterial {
  71379. private _maxSimultaneousLights;
  71380. maxSimultaneousLights: number;
  71381. topColor: BABYLON.Color3;
  71382. topColorAlpha: number;
  71383. bottomColor: BABYLON.Color3;
  71384. bottomColorAlpha: number;
  71385. offset: number;
  71386. scale: number;
  71387. smoothness: number;
  71388. private _disableLighting;
  71389. disableLighting: boolean;
  71390. private _renderId;
  71391. constructor(name: string, scene: BABYLON.Scene);
  71392. needAlphaBlending(): boolean;
  71393. needAlphaTesting(): boolean;
  71394. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71395. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71396. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71397. getAnimatables(): BABYLON.IAnimatable[];
  71398. dispose(forceDisposeEffect?: boolean): void;
  71399. clone(name: string): GradientMaterial;
  71400. serialize(): any;
  71401. getClassName(): string;
  71402. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71403. }
  71404. }
  71405. declare module BABYLON {
  71406. /** @hidden */
  71407. export var gridPixelShader: {
  71408. name: string;
  71409. shader: string;
  71410. };
  71411. }
  71412. declare module BABYLON {
  71413. /** @hidden */
  71414. export var gridVertexShader: {
  71415. name: string;
  71416. shader: string;
  71417. };
  71418. }
  71419. declare module BABYLON {
  71420. /**
  71421. * The grid materials allows you to wrap any shape with a grid.
  71422. * Colors are customizable.
  71423. */
  71424. export class GridMaterial extends BABYLON.PushMaterial {
  71425. /**
  71426. * Main color of the grid (e.g. between lines)
  71427. */
  71428. mainColor: BABYLON.Color3;
  71429. /**
  71430. * Color of the grid lines.
  71431. */
  71432. lineColor: BABYLON.Color3;
  71433. /**
  71434. * The scale of the grid compared to unit.
  71435. */
  71436. gridRatio: number;
  71437. /**
  71438. * Allows setting an offset for the grid lines.
  71439. */
  71440. gridOffset: BABYLON.Vector3;
  71441. /**
  71442. * The frequency of thicker lines.
  71443. */
  71444. majorUnitFrequency: number;
  71445. /**
  71446. * The visibility of minor units in the grid.
  71447. */
  71448. minorUnitVisibility: number;
  71449. /**
  71450. * The grid opacity outside of the lines.
  71451. */
  71452. opacity: number;
  71453. /**
  71454. * Determine RBG output is premultiplied by alpha value.
  71455. */
  71456. preMultiplyAlpha: boolean;
  71457. private _opacityTexture;
  71458. opacityTexture: BABYLON.BaseTexture;
  71459. private _gridControl;
  71460. private _renderId;
  71461. /**
  71462. * constructor
  71463. * @param name The name given to the material in order to identify it afterwards.
  71464. * @param scene The scene the material is used in.
  71465. */
  71466. constructor(name: string, scene: BABYLON.Scene);
  71467. /**
  71468. * Returns wehter or not the grid requires alpha blending.
  71469. */
  71470. needAlphaBlending(): boolean;
  71471. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71472. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71473. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71474. /**
  71475. * Dispose the material and its associated resources.
  71476. * @param forceDisposeEffect will also dispose the used effect when true
  71477. */
  71478. dispose(forceDisposeEffect?: boolean): void;
  71479. clone(name: string): GridMaterial;
  71480. serialize(): any;
  71481. getClassName(): string;
  71482. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71483. }
  71484. }
  71485. declare module BABYLON {
  71486. /** @hidden */
  71487. export var lavaPixelShader: {
  71488. name: string;
  71489. shader: string;
  71490. };
  71491. }
  71492. declare module BABYLON {
  71493. /** @hidden */
  71494. export var lavaVertexShader: {
  71495. name: string;
  71496. shader: string;
  71497. };
  71498. }
  71499. declare module BABYLON {
  71500. export class LavaMaterial extends BABYLON.PushMaterial {
  71501. private _diffuseTexture;
  71502. diffuseTexture: BABYLON.BaseTexture;
  71503. noiseTexture: BABYLON.BaseTexture;
  71504. fogColor: BABYLON.Color3;
  71505. speed: number;
  71506. movingSpeed: number;
  71507. lowFrequencySpeed: number;
  71508. fogDensity: number;
  71509. private _lastTime;
  71510. diffuseColor: BABYLON.Color3;
  71511. private _disableLighting;
  71512. disableLighting: boolean;
  71513. private _unlit;
  71514. unlit: boolean;
  71515. private _maxSimultaneousLights;
  71516. maxSimultaneousLights: number;
  71517. private _scaledDiffuse;
  71518. private _renderId;
  71519. constructor(name: string, scene: BABYLON.Scene);
  71520. needAlphaBlending(): boolean;
  71521. needAlphaTesting(): boolean;
  71522. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71523. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71524. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71525. getAnimatables(): BABYLON.IAnimatable[];
  71526. getActiveTextures(): BABYLON.BaseTexture[];
  71527. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71528. dispose(forceDisposeEffect?: boolean): void;
  71529. clone(name: string): LavaMaterial;
  71530. serialize(): any;
  71531. getClassName(): string;
  71532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71533. }
  71534. }
  71535. declare module BABYLON {
  71536. /** @hidden */
  71537. export var mixPixelShader: {
  71538. name: string;
  71539. shader: string;
  71540. };
  71541. }
  71542. declare module BABYLON {
  71543. /** @hidden */
  71544. export var mixVertexShader: {
  71545. name: string;
  71546. shader: string;
  71547. };
  71548. }
  71549. declare module BABYLON {
  71550. export class MixMaterial extends BABYLON.PushMaterial {
  71551. /**
  71552. * Mix textures
  71553. */
  71554. private _mixTexture1;
  71555. mixTexture1: BABYLON.BaseTexture;
  71556. private _mixTexture2;
  71557. mixTexture2: BABYLON.BaseTexture;
  71558. /**
  71559. * Diffuse textures
  71560. */
  71561. private _diffuseTexture1;
  71562. diffuseTexture1: BABYLON.Texture;
  71563. private _diffuseTexture2;
  71564. diffuseTexture2: BABYLON.Texture;
  71565. private _diffuseTexture3;
  71566. diffuseTexture3: BABYLON.Texture;
  71567. private _diffuseTexture4;
  71568. diffuseTexture4: BABYLON.Texture;
  71569. private _diffuseTexture5;
  71570. diffuseTexture5: BABYLON.Texture;
  71571. private _diffuseTexture6;
  71572. diffuseTexture6: BABYLON.Texture;
  71573. private _diffuseTexture7;
  71574. diffuseTexture7: BABYLON.Texture;
  71575. private _diffuseTexture8;
  71576. diffuseTexture8: BABYLON.Texture;
  71577. /**
  71578. * Uniforms
  71579. */
  71580. diffuseColor: BABYLON.Color3;
  71581. specularColor: BABYLON.Color3;
  71582. specularPower: number;
  71583. private _disableLighting;
  71584. disableLighting: boolean;
  71585. private _maxSimultaneousLights;
  71586. maxSimultaneousLights: number;
  71587. private _renderId;
  71588. constructor(name: string, scene: BABYLON.Scene);
  71589. needAlphaBlending(): boolean;
  71590. needAlphaTesting(): boolean;
  71591. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71592. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71593. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71594. getAnimatables(): BABYLON.IAnimatable[];
  71595. getActiveTextures(): BABYLON.BaseTexture[];
  71596. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71597. dispose(forceDisposeEffect?: boolean): void;
  71598. clone(name: string): MixMaterial;
  71599. serialize(): any;
  71600. getClassName(): string;
  71601. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71602. }
  71603. }
  71604. declare module BABYLON {
  71605. /** @hidden */
  71606. export var normalPixelShader: {
  71607. name: string;
  71608. shader: string;
  71609. };
  71610. }
  71611. declare module BABYLON {
  71612. /** @hidden */
  71613. export var normalVertexShader: {
  71614. name: string;
  71615. shader: string;
  71616. };
  71617. }
  71618. declare module BABYLON {
  71619. export class NormalMaterial extends BABYLON.PushMaterial {
  71620. private _diffuseTexture;
  71621. diffuseTexture: BABYLON.BaseTexture;
  71622. diffuseColor: BABYLON.Color3;
  71623. private _disableLighting;
  71624. disableLighting: boolean;
  71625. private _maxSimultaneousLights;
  71626. maxSimultaneousLights: number;
  71627. private _renderId;
  71628. constructor(name: string, scene: BABYLON.Scene);
  71629. needAlphaBlending(): boolean;
  71630. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71631. needAlphaTesting(): boolean;
  71632. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71633. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71634. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71635. getAnimatables(): BABYLON.IAnimatable[];
  71636. getActiveTextures(): BABYLON.BaseTexture[];
  71637. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71638. dispose(forceDisposeEffect?: boolean): void;
  71639. clone(name: string): NormalMaterial;
  71640. serialize(): any;
  71641. getClassName(): string;
  71642. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71643. }
  71644. }
  71645. declare module BABYLON {
  71646. /** @hidden */
  71647. export var shadowOnlyPixelShader: {
  71648. name: string;
  71649. shader: string;
  71650. };
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export var shadowOnlyVertexShader: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module BABYLON {
  71660. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71661. private _renderId;
  71662. private _activeLight;
  71663. constructor(name: string, scene: BABYLON.Scene);
  71664. shadowColor: BABYLON.Color3;
  71665. needAlphaBlending(): boolean;
  71666. needAlphaTesting(): boolean;
  71667. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71668. activeLight: BABYLON.IShadowLight;
  71669. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71670. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71671. clone(name: string): ShadowOnlyMaterial;
  71672. serialize(): any;
  71673. getClassName(): string;
  71674. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71675. }
  71676. }
  71677. declare module BABYLON {
  71678. /** @hidden */
  71679. export var simplePixelShader: {
  71680. name: string;
  71681. shader: string;
  71682. };
  71683. }
  71684. declare module BABYLON {
  71685. /** @hidden */
  71686. export var simpleVertexShader: {
  71687. name: string;
  71688. shader: string;
  71689. };
  71690. }
  71691. declare module BABYLON {
  71692. export class SimpleMaterial extends BABYLON.PushMaterial {
  71693. private _diffuseTexture;
  71694. diffuseTexture: BABYLON.BaseTexture;
  71695. diffuseColor: BABYLON.Color3;
  71696. private _disableLighting;
  71697. disableLighting: boolean;
  71698. private _maxSimultaneousLights;
  71699. maxSimultaneousLights: number;
  71700. private _renderId;
  71701. constructor(name: string, scene: BABYLON.Scene);
  71702. needAlphaBlending(): boolean;
  71703. needAlphaTesting(): boolean;
  71704. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71705. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71706. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71707. getAnimatables(): BABYLON.IAnimatable[];
  71708. getActiveTextures(): BABYLON.BaseTexture[];
  71709. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71710. dispose(forceDisposeEffect?: boolean): void;
  71711. clone(name: string): SimpleMaterial;
  71712. serialize(): any;
  71713. getClassName(): string;
  71714. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71715. }
  71716. }
  71717. declare module BABYLON {
  71718. /** @hidden */
  71719. export var skyPixelShader: {
  71720. name: string;
  71721. shader: string;
  71722. };
  71723. }
  71724. declare module BABYLON {
  71725. /** @hidden */
  71726. export var skyVertexShader: {
  71727. name: string;
  71728. shader: string;
  71729. };
  71730. }
  71731. declare module BABYLON {
  71732. /**
  71733. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71734. * @see https://doc.babylonjs.com/extensions/sky
  71735. */
  71736. export class SkyMaterial extends BABYLON.PushMaterial {
  71737. /**
  71738. * Defines the overall luminance of sky in interval ]0, 1[.
  71739. */
  71740. luminance: number;
  71741. /**
  71742. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71743. */
  71744. turbidity: number;
  71745. /**
  71746. * Defines the sky appearance (light intensity).
  71747. */
  71748. rayleigh: number;
  71749. /**
  71750. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71751. */
  71752. mieCoefficient: number;
  71753. /**
  71754. * Defines the amount of haze particles following the Mie scattering theory.
  71755. */
  71756. mieDirectionalG: number;
  71757. /**
  71758. * Defines the distance of the sun according to the active scene camera.
  71759. */
  71760. distance: number;
  71761. /**
  71762. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71763. * "inclined".
  71764. */
  71765. inclination: number;
  71766. /**
  71767. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71768. * an object direction and a reference direction.
  71769. */
  71770. azimuth: number;
  71771. /**
  71772. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71773. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71774. */
  71775. sunPosition: BABYLON.Vector3;
  71776. /**
  71777. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71778. * .sunPosition property.
  71779. */
  71780. useSunPosition: boolean;
  71781. /**
  71782. * Defines an offset vector used to get a horizon offset.
  71783. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71784. */
  71785. cameraOffset: BABYLON.Vector3;
  71786. private _cameraPosition;
  71787. private _renderId;
  71788. /**
  71789. * Instantiates a new sky material.
  71790. * This material allows to create dynamic and texture free
  71791. * effects for skyboxes by taking care of the atmosphere state.
  71792. * @see https://doc.babylonjs.com/extensions/sky
  71793. * @param name Define the name of the material in the scene
  71794. * @param scene Define the scene the material belong to
  71795. */
  71796. constructor(name: string, scene: BABYLON.Scene);
  71797. /**
  71798. * Specifies if the material will require alpha blending
  71799. * @returns a boolean specifying if alpha blending is needed
  71800. */
  71801. needAlphaBlending(): boolean;
  71802. /**
  71803. * Specifies if this material should be rendered in alpha test mode
  71804. * @returns false as the sky material doesn't need alpha testing.
  71805. */
  71806. needAlphaTesting(): boolean;
  71807. /**
  71808. * Get the texture used for alpha test purpose.
  71809. * @returns null as the sky material has no texture.
  71810. */
  71811. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71812. /**
  71813. * Get if the submesh is ready to be used and all its information available.
  71814. * Child classes can use it to update shaders
  71815. * @param mesh defines the mesh to check
  71816. * @param subMesh defines which submesh to check
  71817. * @param useInstances specifies that instances should be used
  71818. * @returns a boolean indicating that the submesh is ready or not
  71819. */
  71820. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71821. /**
  71822. * Binds the submesh to this material by preparing the effect and shader to draw
  71823. * @param world defines the world transformation matrix
  71824. * @param mesh defines the mesh containing the submesh
  71825. * @param subMesh defines the submesh to bind the material to
  71826. */
  71827. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71828. /**
  71829. * Get the list of animatables in the material.
  71830. * @returns the list of animatables object used in the material
  71831. */
  71832. getAnimatables(): BABYLON.IAnimatable[];
  71833. /**
  71834. * Disposes the material
  71835. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71836. */
  71837. dispose(forceDisposeEffect?: boolean): void;
  71838. /**
  71839. * Makes a duplicate of the material, and gives it a new name
  71840. * @param name defines the new name for the duplicated material
  71841. * @returns the cloned material
  71842. */
  71843. clone(name: string): SkyMaterial;
  71844. /**
  71845. * Serializes this material in a JSON representation
  71846. * @returns the serialized material object
  71847. */
  71848. serialize(): any;
  71849. /**
  71850. * Gets the current class name of the material e.g. "SkyMaterial"
  71851. * Mainly use in serialization.
  71852. * @returns the class name
  71853. */
  71854. getClassName(): string;
  71855. /**
  71856. * Creates a sky material from parsed material data
  71857. * @param source defines the JSON representation of the material
  71858. * @param scene defines the hosting scene
  71859. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71860. * @returns a new sky material
  71861. */
  71862. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71863. }
  71864. }
  71865. declare module BABYLON {
  71866. /** @hidden */
  71867. export var terrainPixelShader: {
  71868. name: string;
  71869. shader: string;
  71870. };
  71871. }
  71872. declare module BABYLON {
  71873. /** @hidden */
  71874. export var terrainVertexShader: {
  71875. name: string;
  71876. shader: string;
  71877. };
  71878. }
  71879. declare module BABYLON {
  71880. export class TerrainMaterial extends BABYLON.PushMaterial {
  71881. private _mixTexture;
  71882. mixTexture: BABYLON.BaseTexture;
  71883. private _diffuseTexture1;
  71884. diffuseTexture1: BABYLON.Texture;
  71885. private _diffuseTexture2;
  71886. diffuseTexture2: BABYLON.Texture;
  71887. private _diffuseTexture3;
  71888. diffuseTexture3: BABYLON.Texture;
  71889. private _bumpTexture1;
  71890. bumpTexture1: BABYLON.Texture;
  71891. private _bumpTexture2;
  71892. bumpTexture2: BABYLON.Texture;
  71893. private _bumpTexture3;
  71894. bumpTexture3: BABYLON.Texture;
  71895. diffuseColor: BABYLON.Color3;
  71896. specularColor: BABYLON.Color3;
  71897. specularPower: number;
  71898. private _disableLighting;
  71899. disableLighting: boolean;
  71900. private _maxSimultaneousLights;
  71901. maxSimultaneousLights: number;
  71902. private _renderId;
  71903. constructor(name: string, scene: BABYLON.Scene);
  71904. needAlphaBlending(): boolean;
  71905. needAlphaTesting(): boolean;
  71906. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71907. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71908. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71909. getAnimatables(): BABYLON.IAnimatable[];
  71910. getActiveTextures(): BABYLON.BaseTexture[];
  71911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71912. dispose(forceDisposeEffect?: boolean): void;
  71913. clone(name: string): TerrainMaterial;
  71914. serialize(): any;
  71915. getClassName(): string;
  71916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71917. }
  71918. }
  71919. declare module BABYLON {
  71920. /** @hidden */
  71921. export var triplanarPixelShader: {
  71922. name: string;
  71923. shader: string;
  71924. };
  71925. }
  71926. declare module BABYLON {
  71927. /** @hidden */
  71928. export var triplanarVertexShader: {
  71929. name: string;
  71930. shader: string;
  71931. };
  71932. }
  71933. declare module BABYLON {
  71934. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71935. mixTexture: BABYLON.BaseTexture;
  71936. private _diffuseTextureX;
  71937. diffuseTextureX: BABYLON.BaseTexture;
  71938. private _diffuseTextureY;
  71939. diffuseTextureY: BABYLON.BaseTexture;
  71940. private _diffuseTextureZ;
  71941. diffuseTextureZ: BABYLON.BaseTexture;
  71942. private _normalTextureX;
  71943. normalTextureX: BABYLON.BaseTexture;
  71944. private _normalTextureY;
  71945. normalTextureY: BABYLON.BaseTexture;
  71946. private _normalTextureZ;
  71947. normalTextureZ: BABYLON.BaseTexture;
  71948. tileSize: number;
  71949. diffuseColor: BABYLON.Color3;
  71950. specularColor: BABYLON.Color3;
  71951. specularPower: number;
  71952. private _disableLighting;
  71953. disableLighting: boolean;
  71954. private _maxSimultaneousLights;
  71955. maxSimultaneousLights: number;
  71956. private _renderId;
  71957. constructor(name: string, scene: BABYLON.Scene);
  71958. needAlphaBlending(): boolean;
  71959. needAlphaTesting(): boolean;
  71960. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71961. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71962. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71963. getAnimatables(): BABYLON.IAnimatable[];
  71964. getActiveTextures(): BABYLON.BaseTexture[];
  71965. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71966. dispose(forceDisposeEffect?: boolean): void;
  71967. clone(name: string): TriPlanarMaterial;
  71968. serialize(): any;
  71969. getClassName(): string;
  71970. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71971. }
  71972. }
  71973. declare module BABYLON {
  71974. /** @hidden */
  71975. export var waterPixelShader: {
  71976. name: string;
  71977. shader: string;
  71978. };
  71979. }
  71980. declare module BABYLON {
  71981. /** @hidden */
  71982. export var waterVertexShader: {
  71983. name: string;
  71984. shader: string;
  71985. };
  71986. }
  71987. declare module BABYLON {
  71988. export class WaterMaterial extends BABYLON.PushMaterial {
  71989. renderTargetSize: BABYLON.Vector2;
  71990. private _bumpTexture;
  71991. bumpTexture: BABYLON.BaseTexture;
  71992. diffuseColor: BABYLON.Color3;
  71993. specularColor: BABYLON.Color3;
  71994. specularPower: number;
  71995. private _disableLighting;
  71996. disableLighting: boolean;
  71997. private _maxSimultaneousLights;
  71998. maxSimultaneousLights: number;
  71999. /**
  72000. * @param {number}: Represents the wind force
  72001. */
  72002. windForce: number;
  72003. /**
  72004. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  72005. */
  72006. windDirection: BABYLON.Vector2;
  72007. /**
  72008. * @param {number}: Wave height, represents the height of the waves
  72009. */
  72010. waveHeight: number;
  72011. /**
  72012. * @param {number}: Bump height, represents the bump height related to the bump map
  72013. */
  72014. bumpHeight: number;
  72015. /**
  72016. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72017. */
  72018. private _bumpSuperimpose;
  72019. bumpSuperimpose: boolean;
  72020. /**
  72021. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72022. */
  72023. private _fresnelSeparate;
  72024. fresnelSeparate: boolean;
  72025. /**
  72026. * @param {boolean}: bump Waves modify the reflection.
  72027. */
  72028. private _bumpAffectsReflection;
  72029. bumpAffectsReflection: boolean;
  72030. /**
  72031. * @param {number}: The water color blended with the refraction (near)
  72032. */
  72033. waterColor: BABYLON.Color3;
  72034. /**
  72035. * @param {number}: The blend factor related to the water color
  72036. */
  72037. colorBlendFactor: number;
  72038. /**
  72039. * @param {number}: The water color blended with the reflection (far)
  72040. */
  72041. waterColor2: BABYLON.Color3;
  72042. /**
  72043. * @param {number}: The blend factor related to the water color (reflection, far)
  72044. */
  72045. colorBlendFactor2: number;
  72046. /**
  72047. * @param {number}: Represents the maximum length of a wave
  72048. */
  72049. waveLength: number;
  72050. /**
  72051. * @param {number}: Defines the waves speed
  72052. */
  72053. waveSpeed: number;
  72054. /**
  72055. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72056. * will avoid calculating useless pixels in the pixel shader of the water material.
  72057. */
  72058. disableClipPlane: boolean;
  72059. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72060. private _mesh;
  72061. private _refractionRTT;
  72062. private _reflectionRTT;
  72063. private _reflectionTransform;
  72064. private _lastTime;
  72065. private _lastDeltaTime;
  72066. private _renderId;
  72067. private _useLogarithmicDepth;
  72068. private _waitingRenderList;
  72069. private _imageProcessingConfiguration;
  72070. private _imageProcessingObserver;
  72071. /**
  72072. * Gets a boolean indicating that current material needs to register RTT
  72073. */
  72074. readonly hasRenderTargetTextures: boolean;
  72075. /**
  72076. * Constructor
  72077. */
  72078. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72079. useLogarithmicDepth: boolean;
  72080. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72081. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72082. addToRenderList(node: any): void;
  72083. enableRenderTargets(enable: boolean): void;
  72084. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72085. readonly renderTargetsEnabled: boolean;
  72086. needAlphaBlending(): boolean;
  72087. needAlphaTesting(): boolean;
  72088. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72089. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72090. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72091. private _createRenderTargets;
  72092. getAnimatables(): BABYLON.IAnimatable[];
  72093. getActiveTextures(): BABYLON.BaseTexture[];
  72094. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72095. dispose(forceDisposeEffect?: boolean): void;
  72096. clone(name: string): WaterMaterial;
  72097. serialize(): any;
  72098. getClassName(): string;
  72099. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72100. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72101. }
  72102. }
  72103. declare module BABYLON {
  72104. /** @hidden */
  72105. export var asciiartPixelShader: {
  72106. name: string;
  72107. shader: string;
  72108. };
  72109. }
  72110. declare module BABYLON {
  72111. /**
  72112. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72113. *
  72114. * It basically takes care rendering the font front the given font size to a texture.
  72115. * This is used later on in the postprocess.
  72116. */
  72117. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72118. private _font;
  72119. private _text;
  72120. private _charSize;
  72121. /**
  72122. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72123. */
  72124. readonly charSize: number;
  72125. /**
  72126. * Create a new instance of the Ascii Art FontTexture class
  72127. * @param name the name of the texture
  72128. * @param font the font to use, use the W3C CSS notation
  72129. * @param text the caracter set to use in the rendering.
  72130. * @param scene the scene that owns the texture
  72131. */
  72132. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72133. /**
  72134. * Gets the max char width of a font.
  72135. * @param font the font to use, use the W3C CSS notation
  72136. * @return the max char width
  72137. */
  72138. private getFontWidth;
  72139. /**
  72140. * Gets the max char height of a font.
  72141. * @param font the font to use, use the W3C CSS notation
  72142. * @return the max char height
  72143. */
  72144. private getFontHeight;
  72145. /**
  72146. * Clones the current AsciiArtTexture.
  72147. * @return the clone of the texture.
  72148. */
  72149. clone(): AsciiArtFontTexture;
  72150. /**
  72151. * Parses a json object representing the texture and returns an instance of it.
  72152. * @param source the source JSON representation
  72153. * @param scene the scene to create the texture for
  72154. * @return the parsed texture
  72155. */
  72156. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72157. }
  72158. /**
  72159. * Option available in the Ascii Art Post Process.
  72160. */
  72161. export interface IAsciiArtPostProcessOptions {
  72162. /**
  72163. * The font to use following the w3c font definition.
  72164. */
  72165. font?: string;
  72166. /**
  72167. * The character set to use in the postprocess.
  72168. */
  72169. characterSet?: string;
  72170. /**
  72171. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72172. * This number is defined between 0 and 1;
  72173. */
  72174. mixToTile?: number;
  72175. /**
  72176. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72177. * This number is defined between 0 and 1;
  72178. */
  72179. mixToNormal?: number;
  72180. }
  72181. /**
  72182. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72183. *
  72184. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72185. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72186. */
  72187. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72188. /**
  72189. * The font texture used to render the char in the post process.
  72190. */
  72191. private _asciiArtFontTexture;
  72192. /**
  72193. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72194. * This number is defined between 0 and 1;
  72195. */
  72196. mixToTile: number;
  72197. /**
  72198. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72199. * This number is defined between 0 and 1;
  72200. */
  72201. mixToNormal: number;
  72202. /**
  72203. * Instantiates a new Ascii Art Post Process.
  72204. * @param name the name to give to the postprocess
  72205. * @camera the camera to apply the post process to.
  72206. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72207. */
  72208. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72209. }
  72210. }
  72211. declare module BABYLON {
  72212. /** @hidden */
  72213. export var digitalrainPixelShader: {
  72214. name: string;
  72215. shader: string;
  72216. };
  72217. }
  72218. declare module BABYLON {
  72219. /**
  72220. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72221. *
  72222. * It basically takes care rendering the font front the given font size to a texture.
  72223. * This is used later on in the postprocess.
  72224. */
  72225. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72226. private _font;
  72227. private _text;
  72228. private _charSize;
  72229. /**
  72230. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72231. */
  72232. readonly charSize: number;
  72233. /**
  72234. * Create a new instance of the Digital Rain FontTexture class
  72235. * @param name the name of the texture
  72236. * @param font the font to use, use the W3C CSS notation
  72237. * @param text the caracter set to use in the rendering.
  72238. * @param scene the scene that owns the texture
  72239. */
  72240. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72241. /**
  72242. * Gets the max char width of a font.
  72243. * @param font the font to use, use the W3C CSS notation
  72244. * @return the max char width
  72245. */
  72246. private getFontWidth;
  72247. /**
  72248. * Gets the max char height of a font.
  72249. * @param font the font to use, use the W3C CSS notation
  72250. * @return the max char height
  72251. */
  72252. private getFontHeight;
  72253. /**
  72254. * Clones the current DigitalRainFontTexture.
  72255. * @return the clone of the texture.
  72256. */
  72257. clone(): DigitalRainFontTexture;
  72258. /**
  72259. * Parses a json object representing the texture and returns an instance of it.
  72260. * @param source the source JSON representation
  72261. * @param scene the scene to create the texture for
  72262. * @return the parsed texture
  72263. */
  72264. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72265. }
  72266. /**
  72267. * Option available in the Digital Rain Post Process.
  72268. */
  72269. export interface IDigitalRainPostProcessOptions {
  72270. /**
  72271. * The font to use following the w3c font definition.
  72272. */
  72273. font?: string;
  72274. /**
  72275. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72276. * This number is defined between 0 and 1;
  72277. */
  72278. mixToTile?: number;
  72279. /**
  72280. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72281. * This number is defined between 0 and 1;
  72282. */
  72283. mixToNormal?: number;
  72284. }
  72285. /**
  72286. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72287. *
  72288. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72289. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72290. */
  72291. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72292. /**
  72293. * The font texture used to render the char in the post process.
  72294. */
  72295. private _digitalRainFontTexture;
  72296. /**
  72297. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72298. * This number is defined between 0 and 1;
  72299. */
  72300. mixToTile: number;
  72301. /**
  72302. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72303. * This number is defined between 0 and 1;
  72304. */
  72305. mixToNormal: number;
  72306. /**
  72307. * Instantiates a new Digital Rain Post Process.
  72308. * @param name the name to give to the postprocess
  72309. * @camera the camera to apply the post process to.
  72310. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72311. */
  72312. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72313. }
  72314. }
  72315. declare module BABYLON {
  72316. /** @hidden */
  72317. export var oceanPostProcessPixelShader: {
  72318. name: string;
  72319. shader: string;
  72320. };
  72321. }
  72322. declare module BABYLON {
  72323. /**
  72324. * Option available in the Ocean Post Process.
  72325. */
  72326. export interface IOceanPostProcessOptions {
  72327. /**
  72328. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72329. */
  72330. reflectionSize?: number | {
  72331. width: number;
  72332. height: number;
  72333. } | {
  72334. ratio: number;
  72335. };
  72336. /**
  72337. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72338. */
  72339. refractionSize?: number | {
  72340. width: number;
  72341. height: number;
  72342. } | {
  72343. ratio: number;
  72344. };
  72345. }
  72346. /**
  72347. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72348. *
  72349. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72350. * Example usage:
  72351. * var pp = new OceanPostProcess("myOcean", camera);
  72352. * pp.reflectionEnabled = true;
  72353. * pp.refractionEnabled = true;
  72354. */
  72355. export class OceanPostProcess extends BABYLON.PostProcess {
  72356. /**
  72357. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72358. */
  72359. /**
  72360. * Sets weither or not the real-time reflection is enabled on the ocean.
  72361. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72362. */
  72363. reflectionEnabled: boolean;
  72364. /**
  72365. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72366. */
  72367. /**
  72368. * Sets weither or not the real-time refraction is enabled on the ocean.
  72369. * Is set to true, the refraction render target texture will be used as refraction texture.
  72370. */
  72371. refractionEnabled: boolean;
  72372. /**
  72373. * Gets wether or not the post-processes is supported by the running hardware.
  72374. * This requires draw buffer supports.
  72375. */
  72376. readonly isSupported: boolean;
  72377. /**
  72378. * This is the reflection mirror texture used to display reflections on the ocean.
  72379. * By default, render list is empty.
  72380. */
  72381. reflectionTexture: BABYLON.MirrorTexture;
  72382. /**
  72383. * This is the refraction render target texture used to display refraction on the ocean.
  72384. * By default, render list is empty.
  72385. */
  72386. refractionTexture: BABYLON.RenderTargetTexture;
  72387. private _time;
  72388. private _cameraRotation;
  72389. private _cameraViewMatrix;
  72390. private _reflectionEnabled;
  72391. private _refractionEnabled;
  72392. private _geometryRenderer;
  72393. /**
  72394. * Instantiates a new Ocean Post Process.
  72395. * @param name the name to give to the postprocess.
  72396. * @camera the camera to apply the post process to.
  72397. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72398. */
  72399. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72400. /**
  72401. * Returns the appropriate defines according to the current configuration.
  72402. */
  72403. private _getDefines;
  72404. /**
  72405. * Computes the current camera rotation as the shader requires a camera rotation.
  72406. */
  72407. private _computeCameraRotation;
  72408. }
  72409. }
  72410. declare module BABYLON {
  72411. /** @hidden */
  72412. export var brickProceduralTexturePixelShader: {
  72413. name: string;
  72414. shader: string;
  72415. };
  72416. }
  72417. declare module BABYLON {
  72418. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72419. private _numberOfBricksHeight;
  72420. private _numberOfBricksWidth;
  72421. private _jointColor;
  72422. private _brickColor;
  72423. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72424. updateShaderUniforms(): void;
  72425. numberOfBricksHeight: number;
  72426. numberOfBricksWidth: number;
  72427. jointColor: BABYLON.Color3;
  72428. brickColor: BABYLON.Color3;
  72429. /**
  72430. * Serializes this brick procedural texture
  72431. * @returns a serialized brick procedural texture object
  72432. */
  72433. serialize(): any;
  72434. /**
  72435. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72436. * @param parsedTexture defines parsed texture data
  72437. * @param scene defines the current scene
  72438. * @param rootUrl defines the root URL containing brick procedural texture information
  72439. * @returns a parsed Brick Procedural BABYLON.Texture
  72440. */
  72441. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72442. }
  72443. }
  72444. declare module BABYLON {
  72445. /** @hidden */
  72446. export var cloudProceduralTexturePixelShader: {
  72447. name: string;
  72448. shader: string;
  72449. };
  72450. }
  72451. declare module BABYLON {
  72452. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72453. private _skyColor;
  72454. private _cloudColor;
  72455. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72456. updateShaderUniforms(): void;
  72457. skyColor: BABYLON.Color4;
  72458. cloudColor: BABYLON.Color4;
  72459. /**
  72460. * Serializes this cloud procedural texture
  72461. * @returns a serialized cloud procedural texture object
  72462. */
  72463. serialize(): any;
  72464. /**
  72465. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72466. * @param parsedTexture defines parsed texture data
  72467. * @param scene defines the current scene
  72468. * @param rootUrl defines the root URL containing cloud procedural texture information
  72469. * @returns a parsed Cloud Procedural BABYLON.Texture
  72470. */
  72471. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72472. }
  72473. }
  72474. declare module BABYLON {
  72475. /** @hidden */
  72476. export var fireProceduralTexturePixelShader: {
  72477. name: string;
  72478. shader: string;
  72479. };
  72480. }
  72481. declare module BABYLON {
  72482. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72483. private _time;
  72484. private _speed;
  72485. private _autoGenerateTime;
  72486. private _fireColors;
  72487. private _alphaThreshold;
  72488. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72489. updateShaderUniforms(): void;
  72490. render(useCameraPostProcess?: boolean): void;
  72491. static readonly PurpleFireColors: BABYLON.Color3[];
  72492. static readonly GreenFireColors: BABYLON.Color3[];
  72493. static readonly RedFireColors: BABYLON.Color3[];
  72494. static readonly BlueFireColors: BABYLON.Color3[];
  72495. autoGenerateTime: boolean;
  72496. fireColors: BABYLON.Color3[];
  72497. time: number;
  72498. speed: BABYLON.Vector2;
  72499. alphaThreshold: number;
  72500. /**
  72501. * Serializes this fire procedural texture
  72502. * @returns a serialized fire procedural texture object
  72503. */
  72504. serialize(): any;
  72505. /**
  72506. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72507. * @param parsedTexture defines parsed texture data
  72508. * @param scene defines the current scene
  72509. * @param rootUrl defines the root URL containing fire procedural texture information
  72510. * @returns a parsed Fire Procedural BABYLON.Texture
  72511. */
  72512. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72513. }
  72514. }
  72515. declare module BABYLON {
  72516. /** @hidden */
  72517. export var grassProceduralTexturePixelShader: {
  72518. name: string;
  72519. shader: string;
  72520. };
  72521. }
  72522. declare module BABYLON {
  72523. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72524. private _grassColors;
  72525. private _groundColor;
  72526. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72527. updateShaderUniforms(): void;
  72528. grassColors: BABYLON.Color3[];
  72529. groundColor: BABYLON.Color3;
  72530. /**
  72531. * Serializes this grass procedural texture
  72532. * @returns a serialized grass procedural texture object
  72533. */
  72534. serialize(): any;
  72535. /**
  72536. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72537. * @param parsedTexture defines parsed texture data
  72538. * @param scene defines the current scene
  72539. * @param rootUrl defines the root URL containing grass procedural texture information
  72540. * @returns a parsed Grass Procedural BABYLON.Texture
  72541. */
  72542. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72543. }
  72544. }
  72545. declare module BABYLON {
  72546. /** @hidden */
  72547. export var marbleProceduralTexturePixelShader: {
  72548. name: string;
  72549. shader: string;
  72550. };
  72551. }
  72552. declare module BABYLON {
  72553. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72554. private _numberOfTilesHeight;
  72555. private _numberOfTilesWidth;
  72556. private _amplitude;
  72557. private _jointColor;
  72558. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72559. updateShaderUniforms(): void;
  72560. numberOfTilesHeight: number;
  72561. amplitude: number;
  72562. numberOfTilesWidth: number;
  72563. jointColor: BABYLON.Color3;
  72564. /**
  72565. * Serializes this marble procedural texture
  72566. * @returns a serialized marble procedural texture object
  72567. */
  72568. serialize(): any;
  72569. /**
  72570. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72571. * @param parsedTexture defines parsed texture data
  72572. * @param scene defines the current scene
  72573. * @param rootUrl defines the root URL containing marble procedural texture information
  72574. * @returns a parsed Marble Procedural BABYLON.Texture
  72575. */
  72576. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72577. }
  72578. }
  72579. declare module BABYLON {
  72580. /** @hidden */
  72581. export var normalMapProceduralTexturePixelShader: {
  72582. name: string;
  72583. shader: string;
  72584. };
  72585. }
  72586. declare module BABYLON {
  72587. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72588. private _baseTexture;
  72589. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72590. updateShaderUniforms(): void;
  72591. render(useCameraPostProcess?: boolean): void;
  72592. resize(size: any, generateMipMaps: any): void;
  72593. baseTexture: BABYLON.Texture;
  72594. /**
  72595. * Serializes this normal map procedural texture
  72596. * @returns a serialized normal map procedural texture object
  72597. */
  72598. serialize(): any;
  72599. /**
  72600. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72601. * @param parsedTexture defines parsed texture data
  72602. * @param scene defines the current scene
  72603. * @param rootUrl defines the root URL containing normal map procedural texture information
  72604. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72605. */
  72606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72607. }
  72608. }
  72609. declare module BABYLON {
  72610. /** @hidden */
  72611. export var perlinNoiseProceduralTexturePixelShader: {
  72612. name: string;
  72613. shader: string;
  72614. };
  72615. }
  72616. declare module BABYLON {
  72617. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72618. time: number;
  72619. timeScale: number;
  72620. translationSpeed: number;
  72621. private _currentTranslation;
  72622. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72623. updateShaderUniforms(): void;
  72624. render(useCameraPostProcess?: boolean): void;
  72625. resize(size: any, generateMipMaps: any): void;
  72626. /**
  72627. * Serializes this perlin noise procedural texture
  72628. * @returns a serialized perlin noise procedural texture object
  72629. */
  72630. serialize(): any;
  72631. /**
  72632. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72633. * @param parsedTexture defines parsed texture data
  72634. * @param scene defines the current scene
  72635. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72636. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72637. */
  72638. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72639. }
  72640. }
  72641. declare module BABYLON {
  72642. /** @hidden */
  72643. export var roadProceduralTexturePixelShader: {
  72644. name: string;
  72645. shader: string;
  72646. };
  72647. }
  72648. declare module BABYLON {
  72649. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72650. private _roadColor;
  72651. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72652. updateShaderUniforms(): void;
  72653. roadColor: BABYLON.Color3;
  72654. /**
  72655. * Serializes this road procedural texture
  72656. * @returns a serialized road procedural texture object
  72657. */
  72658. serialize(): any;
  72659. /**
  72660. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72661. * @param parsedTexture defines parsed texture data
  72662. * @param scene defines the current scene
  72663. * @param rootUrl defines the root URL containing road procedural texture information
  72664. * @returns a parsed Road Procedural BABYLON.Texture
  72665. */
  72666. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72667. }
  72668. }
  72669. declare module BABYLON {
  72670. /** @hidden */
  72671. export var starfieldProceduralTexturePixelShader: {
  72672. name: string;
  72673. shader: string;
  72674. };
  72675. }
  72676. declare module BABYLON {
  72677. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72678. private _time;
  72679. private _alpha;
  72680. private _beta;
  72681. private _zoom;
  72682. private _formuparam;
  72683. private _stepsize;
  72684. private _tile;
  72685. private _brightness;
  72686. private _darkmatter;
  72687. private _distfading;
  72688. private _saturation;
  72689. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72690. updateShaderUniforms(): void;
  72691. time: number;
  72692. alpha: number;
  72693. beta: number;
  72694. formuparam: number;
  72695. stepsize: number;
  72696. zoom: number;
  72697. tile: number;
  72698. brightness: number;
  72699. darkmatter: number;
  72700. distfading: number;
  72701. saturation: number;
  72702. /**
  72703. * Serializes this starfield procedural texture
  72704. * @returns a serialized starfield procedural texture object
  72705. */
  72706. serialize(): any;
  72707. /**
  72708. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72709. * @param parsedTexture defines parsed texture data
  72710. * @param scene defines the current scene
  72711. * @param rootUrl defines the root URL containing startfield procedural texture information
  72712. * @returns a parsed Starfield Procedural BABYLON.Texture
  72713. */
  72714. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72715. }
  72716. }
  72717. declare module BABYLON {
  72718. /** @hidden */
  72719. export var woodProceduralTexturePixelShader: {
  72720. name: string;
  72721. shader: string;
  72722. };
  72723. }
  72724. declare module BABYLON {
  72725. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72726. private _ampScale;
  72727. private _woodColor;
  72728. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72729. updateShaderUniforms(): void;
  72730. ampScale: number;
  72731. woodColor: BABYLON.Color3;
  72732. /**
  72733. * Serializes this wood procedural texture
  72734. * @returns a serialized wood procedural texture object
  72735. */
  72736. serialize(): any;
  72737. /**
  72738. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72739. * @param parsedTexture defines parsed texture data
  72740. * @param scene defines the current scene
  72741. * @param rootUrl defines the root URL containing wood procedural texture information
  72742. * @returns a parsed Wood Procedural BABYLON.Texture
  72743. */
  72744. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72745. }
  72746. }